feat(tenpayv3): 新增电子小票相关接口

This commit is contained in:
Fu Diwei
2023-08-11 20:24:56 +08:00
parent a69769648a
commit b7fec2b22c
29 changed files with 1430 additions and 38 deletions

View File

@@ -0,0 +1,119 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
public static class WechatTenpayClientExecuteMarketingShoppingReceiptExtensions
{
/// <summary>
/// <para>异步调用 [POST] /marketing/shopping-receipt/shoppingreceipts 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/partner/apis/shopping-receipt/shopping-receipts/upload-shopping-receipt.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.UploadMarketingShoppingReceiptResponse> ExecuteUploadMarketingShoppingReceiptAsync(this WechatTenpayClient client, Models.UploadMarketingShoppingReceiptRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.FileName == null)
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
if (request.FileHash == null)
request.FileHash = BitConverter.ToString(Utilities.SHA256Utility.Hash(request.FileBytes)).Replace("-", string.Empty).ToLower();
if (request.FileContentType == null)
request.FileContentType = Utilities.FileNameToContentTypeMapper.GetContentTypeForImage(request.FileName!) ?? "image/png";
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "marketing", "shopping-receipt", "shoppingreceipts");
using var httpContent = Utilities.FileHttpContentBuilder.Build(fileName: request.FileName, fileBytes: request.FileBytes, fileContentType: request.FileContentType, fileMetaJson: client.JsonSerializer.Serialize(request));
return await client.SendRequestAsync<Models.UploadMarketingShoppingReceiptResponse>(flurlReq, httpContent: httpContent, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /marketing/shopping-receipt/merchantshoppingreceiptjumpinfos 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/partner/apis/shopping-receipt/merchant-shopping-receipt-jump-infos/create-merchant-shopping-receipt-jump-info.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.SetMarketingShoppingReceiptJumpInfoResponse> ExecuteSetMarketingShoppingReceiptJumpInfoAsync(this WechatTenpayClient client, Models.SetMarketingShoppingReceiptJumpInfoRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "marketing", "shopping-receipt", "merchantshoppingreceiptjumpinfos");
return await client.SendRequestWithJsonAsync<Models.SetMarketingShoppingReceiptJumpInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#region CustomEntrance
/// <summary>
/// <para>异步调用 [POST] /marketing/shopping-receipt/customentrances 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/partner/apis/shopping-receipt/custom-entrances/create-custom-entrance.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateMarketingShoppingReceiptCustomEntranceResponse> ExecuteCreateMarketingShoppingReceiptCustomEntranceAsync(this WechatTenpayClient client, Models.CreateMarketingShoppingReceiptCustomEntranceRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "marketing", "shopping-receipt", "customentrances");
return await client.SendRequestWithJsonAsync<Models.CreateMarketingShoppingReceiptCustomEntranceResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /marketing/shopping-receipt/customentrances/{brand_id} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/partner/apis/shopping-receipt/custom-entrances/query-custom-entrance.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetMarketingShoppingReceiptCustomEntranceByBrandIdResponse> ExecuteGetMarketingShoppingReceiptCustomEntranceByBrandIdAsync(this WechatTenpayClient client, Models.GetMarketingShoppingReceiptCustomEntranceByBrandIdRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "marketing", "shopping-receipt", "customentrances", request.BrandId);
return await client.SendRequestWithJsonAsync<Models.GetMarketingShoppingReceiptCustomEntranceByBrandIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [PATCH] /marketing/shopping-receipt/customentrances/{brand_id} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/partner/apis/shopping-receipt/custom-entrances/update-custom-entrance.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ModifyMarketingShoppingReceiptCustomEntranceResponse> ExecuteModifyMarketingShoppingReceiptCustomEntranceAsync(this WechatTenpayClient client, Models.ModifyMarketingShoppingReceiptCustomEntranceRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, new HttpMethod("PATCH"), "marketing", "shopping-receipt", "customentrances", request.BrandId);
return await client.SendRequestWithJsonAsync<Models.ModifyMarketingShoppingReceiptCustomEntranceResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
public static class WechatTenpayClientExecutePayDevicesExtensions
{
#region Printers
/// <summary>
/// <para>异步调用 [POST] /pay-devices/printers/{device_id}/print-orders 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreatePayDevicePrinterPrintOrderResponse> ExecuteCreatePayDevicePrinterPrintOrderAsync(this WechatTenpayClient client, Models.CreatePayDevicePrinterPrintOrderRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "pay-devices", "printers", request.DeviceId, "print-orders");
return await client.SendRequestWithJsonAsync<Models.CreatePayDevicePrinterPrintOrderResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /pay-devices/printers/{device_id}/print-orders/{print_order_no} 接口。</para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetPayDevicePrinterPrintOrderByPrintOrderNumberResponse> ExecuteGetPayDevicePrinterPrintOrderByPrintOrderNumberAsync(this WechatTenpayClient client, Models.GetPayDevicePrinterPrintOrderByPrintOrderNumberRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "pay-devices", "printers", request.DeviceId, "print-orders", request.PrintOrderNumber);
return await client.SendRequestWithJsonAsync<Models.GetPayDevicePrinterPrintOrderByPrintOrderNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
}
}

View File

@@ -0,0 +1,97 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /marketing/shopping-receipt/customentrances 接口的请求。</para>
/// </summary>
public class CreateMarketingShoppingReceiptCustomEntranceRequest : WechatTenpayRequest
{
public static class Types
{
public class JumpLink
{
/// <summary>
/// 获取或设置小程序 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("mini_programs_appid")]
[System.Text.Json.Serialization.JsonPropertyName("mini_programs_appid")]
public string MiniProgramAppId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置小程序页面路径。
/// </summary>
[Newtonsoft.Json.JsonProperty("mini_programs_path")]
[System.Text.Json.Serialization.JsonPropertyName("mini_programs_path")]
public string MiniProgramPagePath { get; set; } = string.Empty;
}
}
/// <summary>
/// 获取或设置自定义入口种类。
/// </summary>
[Newtonsoft.Json.JsonProperty("custom_entrance_type")]
[System.Text.Json.Serialization.JsonPropertyName("custom_entrance_type")]
public string CustomEntranceType { get; set; } = string.Empty;
/// <summary>
/// 获取或设置副标题。
/// </summary>
[Newtonsoft.Json.JsonProperty("subtitle")]
[System.Text.Json.Serialization.JsonPropertyName("subtitle")]
public string SubTitle { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商品缩略图 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("goods_thumbnail_url")]
[System.Text.Json.Serialization.JsonPropertyName("goods_thumbnail_url")]
public string? GoodsThumbnailUrl { get; set; }
/// <summary>
/// 获取或设置入口展示开始时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("start_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("start_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset StartTime { get; set; }
/// <summary>
/// 获取或设置入口展示结束时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("end_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("end_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset EndTime { get; set; }
/// <summary>
/// 获取或设置自定义入口状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("custom_entrance_state")]
[System.Text.Json.Serialization.JsonPropertyName("custom_entrance_state")]
public string CustomEntranceState { get; set; } = string.Empty;
/// <summary>
/// 获取或设置品牌 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("brand_id")]
[System.Text.Json.Serialization.JsonPropertyName("brand_id")]
public string BrandId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置请求业务单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_request_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_request_no")]
public string OutRequestNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置跳转信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("jump_link")]
[System.Text.Json.Serialization.JsonPropertyName("jump_link")]
public Types.JumpLink JumpLink { get; set; } = new Types.JumpLink();
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /marketing/shopping-receipt/customentrances 接口的响应。</para>
/// </summary>
public class CreateMarketingShoppingReceiptCustomEntranceResponse : GetMarketingShoppingReceiptCustomEntranceByBrandIdResponse
{
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /marketing/shopping-receipt/customentrances/{brand_id} 接口的请求。</para>
/// </summary>
public class GetMarketingShoppingReceiptCustomEntranceByBrandIdRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置品牌 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string BrandId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,102 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /marketing/shopping-receipt/customentrances/{brand_id} 接口的响应。</para>
/// </summary>
public class GetMarketingShoppingReceiptCustomEntranceByBrandIdResponse : WechatTenpayResponse
{
public static class Types
{
public class JumpLink : CreateMarketingShoppingReceiptCustomEntranceRequest.Types.JumpLink
{
}
}
/// <summary>
/// 获取或设置自定义入口种类。
/// </summary>
[Newtonsoft.Json.JsonProperty("custom_entrance_type")]
[System.Text.Json.Serialization.JsonPropertyName("custom_entrance_type")]
public string CustomEntranceType { get; set; } = default!;
/// <summary>
/// 获取或设置副标题。
/// </summary>
[Newtonsoft.Json.JsonProperty("subtitle")]
[System.Text.Json.Serialization.JsonPropertyName("subtitle")]
public string SubTitle { get; set; } = default!;
/// <summary>
/// 获取或设置商品缩略图 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("goods_thumbnail_url")]
[System.Text.Json.Serialization.JsonPropertyName("goods_thumbnail_url")]
public string? GoodsThumbnailUrl { get; set; }
/// <summary>
/// 获取或设置入口展示开始时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("start_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("start_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset StartTime { get; set; }
/// <summary>
/// 获取或设置入口展示结束时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("end_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("end_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset EndTime { get; set; }
/// <summary>
/// 获取或设置自定义入口状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("custom_entrance_state")]
[System.Text.Json.Serialization.JsonPropertyName("custom_entrance_state")]
public string CustomEntranceState { get; set; } = default!;
/// <summary>
/// 获取或设置品牌 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("brand_id")]
[System.Text.Json.Serialization.JsonPropertyName("brand_id")]
public string BrandId { get; set; } = default!;
/// <summary>
/// 获取或设置请求业务单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_request_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_request_no")]
public string OutRequestNumber { get; set; } = default!;
/// <summary>
/// 获取或设置跳转信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("jump_link")]
[System.Text.Json.Serialization.JsonPropertyName("jump_link")]
public Types.JumpLink JumpLink { get; set; } = default!;
/// <summary>
/// 获取或设置创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置修改时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("modify_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("modify_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset ModifyTime { get; set; }
}
}

View File

@@ -0,0 +1,84 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [PATCH] /marketing/shopping-receipt/customentrances/{brand_id} 接口的请求。</para>
/// </summary>
public class ModifyMarketingShoppingReceiptCustomEntranceRequest : WechatTenpayRequest
{
public static class Types
{
public class JumpLink : CreateMarketingShoppingReceiptCustomEntranceRequest.Types.JumpLink
{
}
}
/// <summary>
/// 获取或设置自定义入口种类。
/// </summary>
[Newtonsoft.Json.JsonProperty("custom_entrance_type")]
[System.Text.Json.Serialization.JsonPropertyName("custom_entrance_type")]
public string? CustomEntranceType { get; set; }
/// <summary>
/// 获取或设置副标题。
/// </summary>
[Newtonsoft.Json.JsonProperty("subtitle")]
[System.Text.Json.Serialization.JsonPropertyName("subtitle")]
public string? SubTitle { get; set; }
/// <summary>
/// 获取或设置商品缩略图 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("goods_thumbnail_url")]
[System.Text.Json.Serialization.JsonPropertyName("goods_thumbnail_url")]
public string? GoodsThumbnailUrl { get; set; }
/// <summary>
/// 获取或设置入口展示开始时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("start_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("start_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? StartTime { get; set; }
/// <summary>
/// 获取或设置入口展示结束时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("end_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("end_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? EndTime { get; set; }
/// <summary>
/// 获取或设置自定义入口状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("custom_entrance_state")]
[System.Text.Json.Serialization.JsonPropertyName("custom_entrance_state")]
public string? CustomEntranceState { get; set; }
/// <summary>
/// 获取或设置品牌 ID。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string BrandId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置请求业务单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_request_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_request_no")]
public string OutRequestNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置跳转信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("jump_link")]
[System.Text.Json.Serialization.JsonPropertyName("jump_link")]
public Types.JumpLink? JumpLink { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [PATCH] /marketing/shopping-receipt/customentrances/{brand_id} 接口的响应。</para>
/// </summary>
public class ModifyMarketingShoppingReceiptCustomEntranceResponse : GetMarketingShoppingReceiptCustomEntranceByBrandIdResponse
{
}
}

View File

@@ -0,0 +1,74 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /marketing/shopping-receipt/merchantshoppingreceiptjumpinfos 接口的请求。</para>
/// </summary>
public class SetMarketingShoppingReceiptJumpInfoRequest : WechatTenpayRequest
{
public static class Types
{
public class JumpLink
{
/// <summary>
/// 获取或设置小程序 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_appid")]
[System.Text.Json.Serialization.JsonPropertyName("merchant_appid")]
public string MiniProgramAppId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置小程序页面路径。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_path")]
[System.Text.Json.Serialization.JsonPropertyName("merchant_path")]
public string MiniProgramPagePath { get; set; } = string.Empty;
}
}
/// <summary>
/// 获取或设置微信支付订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_id")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_id")]
public string TransactionId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置微信支付商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_mchid")]
public string? TransactionMerchantId { get; set; }
/// <summary>
/// 获取或设置微信支付子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_sub_mchid")]
public string? TransactionSubMerchantId { get; set; }
/// <summary>
/// 获取或设置用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置上传时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_upload_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("merchant_upload_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? UploadTime { get; set; }
/// <summary>
/// 获取或设置跳转信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("jump_info")]
[System.Text.Json.Serialization.JsonPropertyName("jump_info")]
public Types.JumpLink JumpLink { get; set; } = new Types.JumpLink();
}
}

View File

@@ -0,0 +1,92 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /marketing/shopping-receipt/merchantshoppingreceiptjumpinfos 接口的响应。</para>
/// </summary>
public class SetMarketingShoppingReceiptJumpInfoResponse : WechatTenpayResponse
{
public static class Types
{
public class MerchantJumpInfo
{
public static class Types
{
public class JumpLink : SetMarketingShoppingReceiptJumpInfoRequest.Types.JumpLink
{
}
}
/// <summary>
/// 获取或设置微信支付订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_id")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_id")]
public string TransactionId { get; set; } = default!;
/// <summary>
/// 获取或设置微信支付商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_mchid")]
public string? TransactionMerchantId { get; set; }
/// <summary>
/// 获取或设置微信支付子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_sub_mchid")]
public string? TransactionSubMerchantId { get; set; }
/// <summary>
/// 获取或设置用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
/// <summary>
/// 获取或设置上传时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_upload_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("merchant_upload_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? UploadTime { get; set; }
/// <summary>
/// 获取或设置跳转信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("jump_info")]
[System.Text.Json.Serialization.JsonPropertyName("jump_info")]
public Types.JumpLink JumpLink { get; set; } = default!;
/// <summary>
/// 获取或设置创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置修改时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("modify_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("modify_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset ModifyTime { get; set; }
}
}
/// <summary>
/// 获取或设置商家电子小票跳转信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_jump_info")]
[System.Text.Json.Serialization.JsonPropertyName("merchant_jump_info")]
public Types.MerchantJumpInfo MerchantJumpInfo { get; set; } = default!;
}
}

View File

@@ -0,0 +1,105 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /marketing/shopping-receipt/shoppingreceipts 接口的请求。</para>
/// </summary>
[WechatTenpaySensitive]
public class UploadMarketingShoppingReceiptRequest : WechatTenpayRequest
{
public static class Types
{
public class MerchantContactInformation
{
/// <summary>
/// 获取或设置售后咨询电话(需使用平台公钥/证书加密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("consultation_phone_number")]
[System.Text.Json.Serialization.JsonPropertyName("consultation_phone_number")]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)]
public string? ConsultationPhoneNumber { get; set; }
}
}
/// <summary>
/// 获取或设置文件字节数组。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public byte[] FileBytes { get; set; } = Array.Empty<byte>();
/// <summary>
/// 获取或设置文件名(必须以 jpg、png 为后缀)。如果不指定将由系统自动生成。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string? FileName { get; set; }
/// <summary>
/// 获取或设置文件摘要。如果不指定将由系统自动生成。
/// </summary>
[Newtonsoft.Json.JsonProperty("sha256")]
[System.Text.Json.Serialization.JsonPropertyName("sha256")]
public string? FileHash { get; set; }
/// <summary>
/// 获取或设置文件 Conent-Type。如果不指定将由系统自动生成。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string? FileContentType { get; set; }
/// <summary>
/// 获取或设置微信支付订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_id")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_id")]
public string TransactionId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置微信支付商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_mchid")]
public string? TransactionMerchantId { get; set; }
/// <summary>
/// 获取或设置微信支付子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_sub_mchid")]
public string? TransactionSubMerchantId { get; set; }
/// <summary>
/// 获取或设置商户订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_trade_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_trade_no")]
public string? OutTradeNumber { get; set; }
/// <summary>
/// 获取或设置用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置与商家的联系渠道信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_contact_information")]
[System.Text.Json.Serialization.JsonPropertyName("merchant_contact_information")]
public Types.MerchantContactInformation? MerchantContactInformation { get; set; }
/// <summary>
/// 获取或设置上传时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("upload_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("upload_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? UploadTime { get; set; }
}
}

View File

@@ -0,0 +1,136 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /marketing/shopping-receipt/shoppingreceipts 接口的响应。</para>
/// </summary>
[WechatTenpaySensitive]
public class UploadMarketingShoppingReceiptResponse : WechatTenpayResponse
{
public static class Types
{
public class Receipt
{
public static class Types
{
public class MerchantContactInformation
{
/// <summary>
/// 获取或设置售后咨询电话(需使用商户私钥解密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("consultation_phone_number")]
[System.Text.Json.Serialization.JsonPropertyName("consultation_phone_number")]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_RSA_2048_WITH_SHA256, algorithm: Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS8_OAEP_WITH_SHA1_AND_MGF1)]
[WechatTenpaySensitiveProperty(scheme: Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, algorithm: Constants.EncryptionAlgorithms.SM2_C1C3C2_ASN1)]
public string? ConsultationPhoneNumber { get; set; }
}
}
/// <summary>
/// 获取或设置电子小票 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("receipt_id")]
[System.Text.Json.Serialization.JsonPropertyName("receipt_id")]
public string ReceiptId { get; set; } = default!;
/// <summary>
/// 获取或设置审核状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("state")]
[System.Text.Json.Serialization.JsonPropertyName("state")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置文件图片类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("image_type")]
[System.Text.Json.Serialization.JsonPropertyName("image_type")]
public string FileImageType { get; set; } = default!;
/// <summary>
/// 获取或设置文件摘要。
/// </summary>
[Newtonsoft.Json.JsonProperty("sha256")]
[System.Text.Json.Serialization.JsonPropertyName("sha256")]
public string FileHash { get; set; } = default!;
/// <summary>
/// 获取或设置微信支付订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_id")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_id")]
public string TransactionId { get; set; } = default!;
/// <summary>
/// 获取或设置微信支付商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_mchid")]
public string? TransactionMerchantId { get; set; }
/// <summary>
/// 获取或设置微信支付子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transaction_sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("transaction_sub_mchid")]
public string? TransactionSubMerchantId { get; set; }
/// <summary>
/// 获取或设置商户订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_trade_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_trade_no")]
public string? OutTradeNumber { get; set; }
/// <summary>
/// 获取或设置用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
/// <summary>
/// 获取或设置与商家的联系渠道。
/// </summary>
[Newtonsoft.Json.JsonProperty("merchant_contact_information")]
[System.Text.Json.Serialization.JsonPropertyName("merchant_contact_information")]
public Types.MerchantContactInformation? MerchantContactInformation { get; set; }
/// <summary>
/// 获取或设置上传时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("upload_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("upload_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339NullableDateTimeOffsetConverter))]
public DateTimeOffset? UploadTime { get; set; }
/// <summary>
/// 获取或设置创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置修改时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("modify_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("modify_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset ModifyTime { get; set; }
}
}
/// <summary>
/// 获取或设置电子小票信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("receipt")]
[System.Text.Json.Serialization.JsonPropertyName("receipt")]
public Types.Receipt Receipt { get; set; } = default!;
}
}

View File

@@ -0,0 +1,102 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /pay-devices/printers/{device_id}/print-orders 接口的请求。</para>
/// </summary>
public class CreatePayDevicePrinterPrintOrderRequest : WechatTenpayRequest
{
public static class Types
{
public class Variable
{
/// <summary>
/// 获取或设置键。
/// </summary>
[Newtonsoft.Json.JsonProperty("key")]
[System.Text.Json.Serialization.JsonPropertyName("key")]
public string Key { get; set; } = string.Empty;
/// <summary>
/// 获取或设置值。
/// </summary>
[Newtonsoft.Json.JsonProperty("value")]
[System.Text.Json.Serialization.JsonPropertyName("value")]
public string Value { get; set; } = string.Empty;
}
public class Table
{
public static class Types
{
public class Row
{
/// <summary>
/// 获取或设置单元格值列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("cell_list")]
[System.Text.Json.Serialization.JsonPropertyName("cell_list")]
public IList<string> CellList { get; set; } = new List<string>();
}
}
/// <summary>
/// 获取或设置键。
/// </summary>
[Newtonsoft.Json.JsonProperty("key")]
[System.Text.Json.Serialization.JsonPropertyName("key")]
public string Key { get; set; } = string.Empty;
/// <summary>
/// 获取或设置行列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("row_list")]
[System.Text.Json.Serialization.JsonPropertyName("row_list")]
public IList<Types.Row> RowList { get; set; } = new List<Types.Row>();
}
}
/// <summary>
/// 获取或设置小票机设备号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string DeviceId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置打印单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("print_order_no")]
[System.Text.Json.Serialization.JsonPropertyName("print_order_no")]
public string PrintOrderNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置模板 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("template_id")]
[System.Text.Json.Serialization.JsonPropertyName("template_id")]
public string TemplateId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("notify_url")]
public string? NotifyUrl { get; set; }
/// <summary>
/// 获取或设置变量列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("variable_list")]
[System.Text.Json.Serialization.JsonPropertyName("variable_list")]
public IList<Types.Variable>? VariableList { get; set; }
/// <summary>
/// 获取或设置表格变量列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("table_list")]
[System.Text.Json.Serialization.JsonPropertyName("table_list")]
public IList<Types.Table>? TableList { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /pay-devices/printers/{device_id}/print-orders 接口的响应。</para>
/// </summary>
public class CreatePayDevicePrinterPrintOrderResponse : WechatTenpayResponse
{
}
}

View File

@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /pay-devices/printers/{device_id}/print-orders/{print_order_no} 接口的请求。</para>
/// </summary>
public class GetPayDevicePrinterPrintOrderByPrintOrderNumberRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置小票机设备号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string DeviceId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置打印单号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string PrintOrderNumber { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,107 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /pay-devices/printers/{device_id}/print-orders/{print_order_no} 接口的响应。</para>
/// </summary>
public class GetPayDevicePrinterPrintOrderByPrintOrderNumberResponse : WechatTenpayResponse
{
public static class Types
{
public class Variable
{
/// <summary>
/// 获取或设置键。
/// </summary>
[Newtonsoft.Json.JsonProperty("key")]
[System.Text.Json.Serialization.JsonPropertyName("key")]
public string Key { get; set; } = default!;
/// <summary>
/// 获取或设置值。
/// </summary>
[Newtonsoft.Json.JsonProperty("value")]
[System.Text.Json.Serialization.JsonPropertyName("value")]
public string Value { get; set; } = default!;
}
public class Table
{
public static class Types
{
public class Row
{
/// <summary>
/// 获取或设置单元格值列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("cell_list")]
[System.Text.Json.Serialization.JsonPropertyName("cell_list")]
public string[] CellList { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置键。
/// </summary>
[Newtonsoft.Json.JsonProperty("key")]
[System.Text.Json.Serialization.JsonPropertyName("key")]
public string Key { get; set; } = default!;
/// <summary>
/// 获取或设置行列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("row_list")]
[System.Text.Json.Serialization.JsonPropertyName("row_list")]
public Types.Row[] RowList { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置打印单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("print_order_no")]
[System.Text.Json.Serialization.JsonPropertyName("print_order_no")]
public string PrintOrderNumber { get; set; } = default!;
/// <summary>
/// 获取或设置模板 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("template_id")]
[System.Text.Json.Serialization.JsonPropertyName("template_id")]
public string TemplateId { get; set; } = default!;
/// <summary>
/// 获取或设置通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("notify_url")]
public string? NotifyUrl { get; set; }
/// <summary>
/// 获取或设置打印状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("print_state")]
[System.Text.Json.Serialization.JsonPropertyName("print_state")]
public string PrintState { get; set; } = default!;
/// <summary>
/// 获取或设置打印状态描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("print_state_description")]
[System.Text.Json.Serialization.JsonPropertyName("print_state_description")]
public string PrintStateDescription { get; set; } = default!;
/// <summary>
/// 获取或设置变量列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("variable_list")]
[System.Text.Json.Serialization.JsonPropertyName("variable_list")]
public Types.Variable[]? VariableList { get; set; }
/// <summary>
/// 获取或设置表格变量列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("table_list")]
[System.Text.Json.Serialization.JsonPropertyName("table_list")]
public Types.Table[]? TableList { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
{
"custom_entrance_type": "MERCHANT_ACTIVITY",
"subtitle": "双十一8折活动",
"goods_thumbnail_url": "https://qpic.cn/xxx",
"start_time": "2015-05-20T13:29:35+08:00",
"end_time": "2015-05-20T13:29:35+08:00",
"custom_entrance_state": "ONLINE",
"brand_id": "1014",
"out_request_no": "6122352020010133287985742",
"jump_link": {
"mini_programs_appid": "wxea9c30a90fs8d3fe",
"mini_programs_path": "/pages/bonus/bonus"
}
}

View File

@@ -0,0 +1,16 @@
{
"custom_entrance_type": "MERCHANT_ACTIVITY",
"subtitle": "双十一8折活动",
"goods_thumbnail_url": "https://qpic.cn/xxx",
"custom_entrance_state": "ONLINE",
"start_time": "2015-05-20T13:29:35+08:00",
"end_time": "2019-12-31T13:29:35.120+08:00",
"brand_id": "1014",
"create_time": "2015-05-20T13:29:35+08:00",
"modify_time": "2015-05-20T13:29:35+08:00",
"out_request_no": "100002322019090134234sfdf",
"jump_link": {
"mini_programs_appid": "wxea9c30a90fs8d3fe",
"mini_programs_path": "/pages/bonus/bonus"
}
}

View File

@@ -0,0 +1,16 @@
{
"custom_entrance_type": "MERCHANT_ACTIVITY",
"subtitle": "双十一8折活动",
"goods_thumbnail_url": "https://qpic.cn/xxx",
"custom_entrance_state": "ONLINE",
"start_time": "2015-05-20T13:29:35+08:00",
"end_time": "2019-12-31T13:29:35.120+08:00",
"brand_id": "1014",
"create_time": "2015-05-20T13:29:35+08:00",
"modify_time": "2015-05-20T13:29:35+08:00",
"out_request_no": "100002322019090134234sfdf",
"jump_link": {
"mini_programs_appid": "wxea9c30a90fs8d3fe",
"mini_programs_path": "/pages/bonus/bonus"
}
}

View File

@@ -0,0 +1,13 @@
{
"custom_entrance_type": "MERCHANT_ACTIVITY",
"subtitle": "双十一8折活动",
"goods_thumbnail_url": "https://qpic.cn/xxx",
"custom_entrance_state": "ONLINE",
"start_time": "2019-12-31T13:29:35.120+08:00",
"end_time": "2019-12-31T13:29:35.120+08:00",
"out_request_no": "100002322019090134234sfdf",
"jump_link": {
"mini_programs_appid": "wxea9c30a90fs8d3fe",
"mini_programs_path": "/pages/bonus/bonus"
}
}

View File

@@ -0,0 +1,16 @@
{
"custom_entrance_type": "MERCHANT_ACTIVITY",
"subtitle": "双十一8折活动",
"goods_thumbnail_url": "https://qpic.cn/xxx",
"custom_entrance_state": "ONLINE",
"start_time": "2015-05-20T13:29:35+08:00",
"end_time": "2019-12-31T13:29:35.120+08:00",
"brand_id": "1014",
"create_time": "2015-05-20T13:29:35+08:00",
"modify_time": "2015-05-20T13:29:35+08:00",
"out_request_no": "100002322019090134234sfdf",
"jump_link": {
"mini_programs_appid": "wxea9c30a90fs8d3fe",
"mini_programs_path": "/pages/bonus/bonus"
}
}

View File

@@ -0,0 +1,11 @@
{
"transaction_id": "4200000008202209139188072801",
"transaction_mchid": "1230000109",
"transaction_sub_mchid": "1230000109",
"openid": "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o",
"merchant_upload_time": "2021-05-20T13:29:35.120+08:00",
"jump_info": {
"merchant_appid": "example_merchant_appid",
"merchant_path": "example_merchant_path"
}
}

View File

@@ -0,0 +1,15 @@
{
"merchant_jump_info": {
"transaction_id": "4200000008202209139188072801",
"transaction_mchid": "1230000109",
"transaction_sub_mchid": "1230000109",
"openid": "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o",
"merchant_upload_time": "2021-05-20T13:29:35.120+08:00",
"jump_info": {
"merchant_appid": "example_merchant_appid",
"merchant_path": "example_merchant_path"
},
"create_time": "2015-05-20T13:29:35+08:00",
"modify_time": "2015-05-20T13:29:35+08:00"
}
}

View File

@@ -0,0 +1,11 @@
{
"merchant_contact_information": {
"consultation_phone_number": "pVd1HJ6v/69bDnuC4EL5Kz4jBHLiCa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg=="
},
"openid": "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o",
"sha256": "2969f98ef4763da62670d3aee5d456b56a8f3447c0178da21445206aa400a464",
"transaction_id": "1217752501201407033233368018",
"transaction_mchid": "1230000109",
"transaction_sub_mchid": "1230000109",
"upload_time": "2021-05-20T13:29:35.120+08:00"
}

View File

@@ -0,0 +1,18 @@
{
"receipt": {
"create_time": "2015-05-20T13:29:35+08:00",
"image_type": "PNG",
"merchant_contact_information": {
"consultation_phone_number": "pVd1HJ6v/69bDnuC4EL5Kz4jBHLiCa8MRtelw/wDa4SzfeespQO/0kjiwfqdfg=="
},
"modify_time": "2015-05-20T13:29:35+08:00",
"openid": "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o",
"receipt_id": "121630001",
"sha256": "2969f98ef4763da62670d3aee5d456b56a8f3447c0178da21445206aa400a464",
"state": "WAIT_REVIEW",
"transaction_id": "1217752501201407033233368018",
"transaction_mchid": "1230000109",
"transaction_sub_mchid": "1230000109",
"upload_time": "2021-05-20T13:29:35.120+08:00"
}
}

View File

@@ -0,0 +1,21 @@
{
"print_order_no": "wx8888888888888888",
"template_id": "pt_02583429616371386640209536",
"notify_url": "https:\/\/payapp.weixin.qq.com\/callback",
"variable_list": [
{
"key": "",
"value": ""
}
],
"table_list": [
{
"key": "",
"row_list": [
{
"cell_list": [ "string" ]
}
]
}
]
}

View File

@@ -0,0 +1,23 @@
{
"print_order_no": "wx8888888888888888",
"template_id": "pt_02583429616371386640209536",
"notify_url": "https:\/\/payapp.weixin.qq.com\/callback",
"print_state": "PRINT_STATE_SUCCESS",
"print_state_description": "打印结束",
"variable_list": [
{
"key": "",
"value": ""
}
],
"table_list": [
{
"key": "",
"row_list": [
{
"cell_list": [ "string" ]
}
]
}
]
}

View File

@@ -600,6 +600,44 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher)); AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher));
} }
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /marketing/shopping-receipt/shoppingreceipts")]
public async Task TestEncryptRequestSensitiveProperty_UploadMarketingShoppingReceiptRequest()
{
static Models.UploadMarketingShoppingReceiptRequest GenerateMockRequestModel()
{
return new Models.UploadMarketingShoppingReceiptRequest()
{
MerchantContactInformation = new Models.UploadMarketingShoppingReceiptRequest.Types.MerchantContactInformation()
{
ConsultationPhoneNumber = MOCK_PLAIN_STR
}
};
}
static void AssertMockRequestModel(Models.UploadMarketingShoppingReceiptRequest request, Func<string, string> decryptor)
{
Assert.NotEqual(MOCK_PLAIN_STR, request.MerchantContactInformation!.ConsultationPhoneNumber!);
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.MerchantContactInformation!.ConsultationPhoneNumber!));
Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true);
}
var reqA1 = GenerateMockRequestModel();
CreateMockClientUseRSA(autoEncrypt: false).EncryptRequestSensitiveProperty(reqA1);
AssertMockRequestModel(reqA1, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, cipher));
var reqA2 = GenerateMockRequestModel();
CreateMockClientUseSM2(autoEncrypt: false).EncryptRequestSensitiveProperty(reqA2);
AssertMockRequestModel(reqA2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher));
var reqB1 = GenerateMockRequestModel();
await CreateMockClientUseRSA(autoEncrypt: true).ExecuteUploadMarketingShoppingReceiptAsync(reqB1);
AssertMockRequestModel(reqB1, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, cipher));
var reqB2 = GenerateMockRequestModel();
await CreateMockClientUseSM2(autoEncrypt: true).ExecuteUploadMarketingShoppingReceiptAsync(reqB2);
AssertMockRequestModel(reqB2, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, cipher));
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /mch_operate/risk/withdrawl-apply")] [Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /mch_operate/risk/withdrawl-apply")]
public async Task TestEncryptRequestSensitiveProperty_CreateMerchantOperateRiskWithdrawlApplyRequest() public async Task TestEncryptRequestSensitiveProperty_CreateMerchantOperateRiskWithdrawlApplyRequest()
{ {

View File

@@ -52,7 +52,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetBillSubMerchantFundflowBillAsync(new Models.GetBillSubMerchantFundflowBillRequest()); ).ExecuteGetBillSubMerchantFundflowBillAsync(new Models.GetBillSubMerchantFundflowBillRequest());
@@ -60,7 +60,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetBillSubMerchantFundflowBillAsync(new Models.GetBillSubMerchantFundflowBillRequest()); ).ExecuteGetBillSubMerchantFundflowBillAsync(new Models.GetBillSubMerchantFundflowBillRequest());
@@ -178,7 +178,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetEcommerceApplymentByOutRequestNumberAsync(new Models.GetEcommerceApplymentByOutRequestNumberRequest()); ).ExecuteGetEcommerceApplymentByOutRequestNumberAsync(new Models.GetEcommerceApplymentByOutRequestNumberRequest());
@@ -186,7 +186,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetEcommerceApplymentByOutRequestNumberAsync(new Models.GetEcommerceApplymentByOutRequestNumberRequest()); ).ExecuteGetEcommerceApplymentByOutRequestNumberAsync(new Models.GetEcommerceApplymentByOutRequestNumberRequest());
@@ -226,7 +226,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetEcommerceBillFundflowBillAsync(new Models.GetEcommerceBillFundflowBillRequest()); ).ExecuteGetEcommerceBillFundflowBillAsync(new Models.GetEcommerceBillFundflowBillRequest());
@@ -234,13 +234,61 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetEcommerceBillFundflowBillAsync(new Models.GetEcommerceBillFundflowBillRequest()); ).ExecuteGetEcommerceBillFundflowBillAsync(new Models.GetEcommerceBillFundflowBillRequest());
AssertMockResponseModel(resB2); AssertMockResponseModel(resB2);
} }
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /marketing/shopping-receipt/shoppingreceipts")]
public async Task TestDecryptResponseSensitiveProperty_UploadMarketingShoppingReceiptResponse()
{
static Models.UploadMarketingShoppingReceiptResponse GenerateMockResponseModel(Func<string, string> encryptor)
{
return new Models.UploadMarketingShoppingReceiptResponse()
{
RawStatus = (int)HttpStatusCode.OK,
Receipt = new Models.UploadMarketingShoppingReceiptResponse.Types.Receipt()
{
MerchantContactInformation = new Models.UploadMarketingShoppingReceiptResponse.Types.Receipt.Types.MerchantContactInformation()
{
ConsultationPhoneNumber = encryptor.Invoke(MOCK_PLAIN_STR)
}
}
};
}
static void AssertMockResponseModel(Models.UploadMarketingShoppingReceiptResponse response)
{
Assert.Equal(MOCK_PLAIN_STR, response.Receipt.MerchantContactInformation!.ConsultationPhoneNumber!);
}
var resA1 = GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain));
CreateMockClientUseRSA(autoDecrypt: false).DecryptResponseSensitiveProperty(resA1);
AssertMockResponseModel(resA1);
var resA2 = GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain));
CreateMockClientUseSM2(autoDecrypt: false).DecryptResponseSensitiveProperty(resA2);
AssertMockResponseModel(resA2);
var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true,
mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
)
).ExecuteUploadMarketingShoppingReceiptAsync(new Models.UploadMarketingShoppingReceiptRequest());
AssertMockResponseModel(resB1);
var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true,
mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
)
).ExecuteUploadMarketingShoppingReceiptAsync(new Models.UploadMarketingShoppingReceiptRequest());
AssertMockResponseModel(resB2);
}
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /merchants/{sub_mchid}")] [Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /merchants/{sub_mchid}")]
public async Task TestDecryptResponseSensitiveProperty_GetHKSubMerchantResponse() public async Task TestDecryptResponseSensitiveProperty_GetHKSubMerchantResponse()
{ {
@@ -275,7 +323,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain, "Pkcs1Padding")) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain, "Pkcs1Padding"))
) )
).ExecuteGetHKSubMerchantAsync(new Models.GetHKSubMerchantRequest()); ).ExecuteGetHKSubMerchantAsync(new Models.GetHKSubMerchantRequest());
@@ -283,7 +331,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetHKSubMerchantAsync(new Models.GetHKSubMerchantRequest()); ).ExecuteGetHKSubMerchantAsync(new Models.GetHKSubMerchantRequest());
@@ -323,7 +371,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteQueryMerchantServiceComplaintsAsync(new Models.QueryMerchantServiceComplaintsRequest()); ).ExecuteQueryMerchantServiceComplaintsAsync(new Models.QueryMerchantServiceComplaintsRequest());
@@ -331,7 +379,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteQueryMerchantServiceComplaintsAsync(new Models.QueryMerchantServiceComplaintsRequest()); ).ExecuteQueryMerchantServiceComplaintsAsync(new Models.QueryMerchantServiceComplaintsRequest());
@@ -365,7 +413,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetMerchantServiceComplaintByComplaintIdAsync(new Models.GetMerchantServiceComplaintByComplaintIdRequest()); ).ExecuteGetMerchantServiceComplaintByComplaintIdAsync(new Models.GetMerchantServiceComplaintByComplaintIdRequest());
@@ -373,7 +421,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetMerchantServiceComplaintByComplaintIdAsync(new Models.GetMerchantServiceComplaintByComplaintIdRequest()); ).ExecuteGetMerchantServiceComplaintByComplaintIdAsync(new Models.GetMerchantServiceComplaintByComplaintIdRequest());
@@ -418,7 +466,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetNewTaxControlFapiaoApplicationByFapiaoApplyIdAsync(new Models.GetNewTaxControlFapiaoApplicationByFapiaoApplyIdRequest()); ).ExecuteGetNewTaxControlFapiaoApplicationByFapiaoApplyIdAsync(new Models.GetNewTaxControlFapiaoApplicationByFapiaoApplyIdRequest());
@@ -426,7 +474,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetNewTaxControlFapiaoApplicationByFapiaoApplyIdAsync(new Models.GetNewTaxControlFapiaoApplicationByFapiaoApplyIdRequest()); ).ExecuteGetNewTaxControlFapiaoApplicationByFapiaoApplyIdAsync(new Models.GetNewTaxControlFapiaoApplicationByFapiaoApplyIdRequest());
@@ -462,7 +510,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetNewTaxControlFapiaoUserTitleAsync(new Models.GetNewTaxControlFapiaoUserTitleRequest()); ).ExecuteGetNewTaxControlFapiaoUserTitleAsync(new Models.GetNewTaxControlFapiaoUserTitleRequest());
@@ -470,7 +518,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetNewTaxControlFapiaoUserTitleAsync(new Models.GetNewTaxControlFapiaoUserTitleRequest()); ).ExecuteGetNewTaxControlFapiaoUserTitleAsync(new Models.GetNewTaxControlFapiaoUserTitleRequest());
@@ -504,7 +552,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetPartnerTransferBatchDetailByDetailIdAsync(new Models.GetPartnerTransferBatchDetailByDetailIdRequest()); ).ExecuteGetPartnerTransferBatchDetailByDetailIdAsync(new Models.GetPartnerTransferBatchDetailByDetailIdRequest());
@@ -512,7 +560,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetPartnerTransferBatchDetailByDetailIdAsync(new Models.GetPartnerTransferBatchDetailByDetailIdRequest()); ).ExecuteGetPartnerTransferBatchDetailByDetailIdAsync(new Models.GetPartnerTransferBatchDetailByDetailIdRequest());
@@ -546,7 +594,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetPartnerTransferBatchDetailByOutDetailNumberAsync(new Models.GetPartnerTransferBatchDetailByOutDetailNumberRequest()); ).ExecuteGetPartnerTransferBatchDetailByOutDetailNumberAsync(new Models.GetPartnerTransferBatchDetailByOutDetailNumberRequest());
@@ -554,7 +602,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetPartnerTransferBatchDetailByOutDetailNumberAsync(new Models.GetPartnerTransferBatchDetailByOutDetailNumberRequest()); ).ExecuteGetPartnerTransferBatchDetailByOutDetailNumberAsync(new Models.GetPartnerTransferBatchDetailByOutDetailNumberRequest());
@@ -594,7 +642,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetPayScoreMerchantBillAsync(new Models.GetPayScoreMerchantBillRequest()); ).ExecuteGetPayScoreMerchantBillAsync(new Models.GetPayScoreMerchantBillRequest());
@@ -602,7 +650,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetPayScoreMerchantBillAsync(new Models.GetPayScoreMerchantBillRequest()); ).ExecuteGetPayScoreMerchantBillAsync(new Models.GetPayScoreMerchantBillRequest());
@@ -644,7 +692,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteQuerySmartGuidesAsync(new Models.QuerySmartGuidesRequest()); ).ExecuteQuerySmartGuidesAsync(new Models.QuerySmartGuidesRequest());
@@ -652,7 +700,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteQuerySmartGuidesAsync(new Models.QuerySmartGuidesRequest()); ).ExecuteQuerySmartGuidesAsync(new Models.QuerySmartGuidesRequest());
@@ -686,7 +734,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetTransferBatchDetailByOutDetailNumberAsync(new Models.GetTransferBatchDetailByOutDetailNumberRequest()); ).ExecuteGetTransferBatchDetailByOutDetailNumberAsync(new Models.GetTransferBatchDetailByOutDetailNumberRequest());
@@ -694,7 +742,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetTransferBatchDetailByOutDetailNumberAsync(new Models.GetTransferBatchDetailByOutDetailNumberRequest()); ).ExecuteGetTransferBatchDetailByOutDetailNumberAsync(new Models.GetTransferBatchDetailByOutDetailNumberRequest());
@@ -728,7 +776,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB1 = await CreateMockClientUseRSA( var resB1 = await CreateMockClientUseRSA(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain))
) )
).ExecuteGetTransferBatchDetailByDetailIdAsync(new Models.GetTransferBatchDetailByDetailIdRequest()); ).ExecuteGetTransferBatchDetailByDetailIdAsync(new Models.GetTransferBatchDetailByDetailIdRequest());
@@ -736,7 +784,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
var resB2 = await CreateMockClientUseSM2( var resB2 = await CreateMockClientUseSM2(
autoDecrypt: true, autoDecrypt: true,
mockResponseContent: new FlurlSystemTextJsonSerializer().Serialize( mockResponse: new FlurlSystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)) GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain))
) )
).ExecuteGetTransferBatchDetailByDetailIdAsync(new Models.GetTransferBatchDetailByDetailIdRequest()); ).ExecuteGetTransferBatchDetailByDetailIdAsync(new Models.GetTransferBatchDetailByDetailIdRequest());
@@ -763,28 +811,28 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
public class MockHttpMessageHandler : DelegatingHandler public class MockHttpMessageHandler : DelegatingHandler
{ {
private readonly string? _mockResponseContent; private readonly string? _mockResponse;
public MockHttpMessageHandler(HttpMessageHandler innerHandler, string? mockResponseContent) public MockHttpMessageHandler(HttpMessageHandler innerHandler, string? mockResponse)
: base(innerHandler) : base(innerHandler)
{ {
_mockResponseContent = mockResponseContent; _mockResponse = mockResponse;
} }
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{ {
bool hasContent = !string.IsNullOrEmpty(_mockResponseContent); bool hasContent = !string.IsNullOrEmpty(_mockResponse);
var resp = new HttpResponseMessage var resp = new HttpResponseMessage
{ {
StatusCode = hasContent ? HttpStatusCode.OK : HttpStatusCode.NoContent, StatusCode = hasContent ? HttpStatusCode.OK : HttpStatusCode.NoContent,
Content = hasContent ? new StringContent(_mockResponseContent!, Encoding.UTF8) : new ByteArrayContent(Array.Empty<byte>()), Content = hasContent ? new StringContent(_mockResponse!, Encoding.UTF8) : new ByteArrayContent(Array.Empty<byte>()),
}; };
resp.Headers.TryAddWithoutValidation("Content-Length", hasContent ? Encoding.UTF8.GetBytes(_mockResponseContent!).Length.ToString() : (0).ToString()); resp.Headers.TryAddWithoutValidation("Content-Length", hasContent ? Encoding.UTF8.GetBytes(_mockResponse!).Length.ToString() : (0).ToString());
return Task.FromResult(resp); return Task.FromResult(resp);
} }
} }
private static WechatTenpayClient CreateMockClientUseRSA(bool autoDecrypt, string? mockResponseContent = null) private static WechatTenpayClient CreateMockClientUseRSA(bool autoDecrypt, string? mockResponse = null)
{ {
var client = new WechatTenpayClient(new WechatTenpayClientOptions() var client = new WechatTenpayClient(new WechatTenpayClientOptions()
{ {
@@ -794,11 +842,11 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
MerchantV3Secret = Guid.NewGuid().ToString("N"), MerchantV3Secret = Guid.NewGuid().ToString("N"),
AutoDecryptResponseSensitiveProperty = autoDecrypt AutoDecryptResponseSensitiveProperty = autoDecrypt
}); });
client.Configure(settings => settings.FlurlHttpClientFactory = new MockHttpClientFactory(mockResponseContent)); client.Configure(settings => settings.FlurlHttpClientFactory = new MockHttpClientFactory(mockResponse));
return client; return client;
} }
private static WechatTenpayClient CreateMockClientUseSM2(bool autoDecrypt, string? mockResponseContent = null) private static WechatTenpayClient CreateMockClientUseSM2(bool autoDecrypt, string? mockResponse = null)
{ {
var client = new WechatTenpayClient(new WechatTenpayClientOptions() var client = new WechatTenpayClient(new WechatTenpayClientOptions()
{ {
@@ -809,7 +857,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
SignScheme = Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3, SignScheme = Constants.SignSchemes.WECHATPAY2_SM2_WITH_SM3,
AutoDecryptResponseSensitiveProperty = autoDecrypt AutoDecryptResponseSensitiveProperty = autoDecrypt
}); });
client.Configure(settings => settings.FlurlHttpClientFactory = new MockHttpClientFactory(mockResponseContent)); client.Configure(settings => settings.FlurlHttpClientFactory = new MockHttpClientFactory(mockResponse));
return client; return client;
} }
} }