feat(tenpayv3): 新增商家转账用户免确认收款相关接口

This commit is contained in:
Fu Diwei 2025-07-13 21:17:21 +08:00
parent f3f3800547
commit 23bea47a53
18 changed files with 891 additions and 2 deletions

View File

@ -200,6 +200,12 @@
- 微信单号查询转账单:`GetFundAppMerchantTransferBillByTransferBillNumber`
- 发起转账并完成免确认收款授权:`CreateFundAppMerchantTransferBillPreTransferWithAuthorization`
- 转账(用户免确认收款):`CreateFundAppMerchantTransferBillTransfer`
- 商户单号查询免确认收款授权:`GetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumber`
- 获取电子回单
- 商户单号申请电子回单:`CreateFundAppMerchantTransferElecsignByOutBillNumber`

View File

@ -0,0 +1,72 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
{
/// <summary>
/// <para>表示 MCHTRANSFER.AUTHORIZATION.CONFIRMED 通知的数据。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014512908 ]]> <br/>
/// </para>
/// </summary>
public class MerchantTransferAuthorizationConfirmedResource : WechatTenpayEvent.Types.IDecryptedResource
{
/// <summary>
/// 获取或设置微信商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("mchid")]
[System.Text.Json.Serialization.JsonPropertyName("mchid")]
public string MerchantId { get; set; } = default!;
/// <summary>
/// 获取或设置微信 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置商户侧授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_authorization_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_authorization_no")]
public string OutAuthorizationNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信免确认收款授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorization_id")]
[System.Text.Json.Serialization.JsonPropertyName("authorization_id")]
public string AuthorizationId { get; set; } = default!;
/// <summary>
/// 获取或设置授权状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("state")]
[System.Text.Json.Serialization.JsonPropertyName("state")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置收款用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
/// <summary>
/// 获取或设置用户展示昵称。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_display_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_display_name")]
public string UserDisplayName { get; set; } = default!;
/// <summary>
/// 获取或设置用户确认授权的时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorize_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("authorize_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset AuthorizeTime { get; set; }
}
}

View File

@ -19,7 +19,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Events
public string MerchantId { get; set; } = default!;
/// <summary>
/// 获取或设置商户转账单号
/// 获取或设置商户转账单号
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]

View File

@ -188,6 +188,72 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
return await client.SendFlurlRequestAsJsonAsync<Models.GetFundAppMerchantTransferBillByTransferBillNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /fund-app/mch-transfer/transfer-bills/pre-transfer-with-authorization 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014399293 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationResponse> ExecuteCreateFundAppMerchantTransferBillPreTransferWithAuthorizationAsync(this WechatTenpayClient client, Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "fund-app", "mch-transfer", "transfer-bills", "pre-transfer-with-authorization");
return await client.SendFlurlRequestAsJsonAsync<Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /fund-app/mch-transfer/transfer-bills/transfer 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014399371 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateFundAppMerchantTransferBillTransferResponse> ExecuteCreateFundAppMerchantTransferBillTransferAsync(this WechatTenpayClient client, Models.CreateFundAppMerchantTransferBillTransferRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "fund-app", "mch-transfer", "transfer-bills", "transfer");
return await client.SendFlurlRequestAsJsonAsync<Models.CreateFundAppMerchantTransferBillTransferResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [GET] /fund-app/mch-transfer/user-confirm-authorization/out-authorization-no/{out_authorization_no} 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/merchant/4014399423 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumberResponse> ExecuteGetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumberAsync(this WechatTenpayClient client, Models.GetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumberRequest 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
.CreateFlurlRequest(request, HttpMethod.Get, "fund-app", "mch-transfer", "user-confirm-authorization", "out-authorization-no", request.OutAuthorizationNumber);
return await client.SendFlurlRequestAsJsonAsync<Models.GetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
#region MerchantTransfer/TransferToQQWalletBills

View File

@ -0,0 +1,128 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-bills/pre-transfer-with-authorization 接口的请求。</para>
/// </summary>
[WechatTenpaySensitive]
public class CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest : WechatTenpayRequest
{
public static class Types
{
public class TransferSceneReportInfo : CreateFundAppMerchantTransferBillRequest.Types.TransferSceneReportInfo
{
}
public class AuthorizationInfo
{
/// <summary>
/// 获取或设置用户展示名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_display_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_display_name")]
public string UserDisplayName { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户侧授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_authorization_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_authorization_no")]
public string OutAuthorizationNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置免确认收款授权结果通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorization_notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("authorization_notify_url")]
public string NotifyUrl { get; set; } = string.Empty;
}
}
/// <summary>
/// 获取或设置微信 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置转账金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_amount")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_amount")]
public int TransferAmount { get; set; }
/// <summary>
/// 获取或设置转账备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_remark")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_remark")]
public string TransferRemark { get; set; } = string.Empty;
/// <summary>
/// 获取或设置收款用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string? OpenId { get; set; }
/// <summary>
/// 获取或设置收款用户姓名(需使用平台公钥/证书加密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
[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? UserName { get; set; }
/// <summary>
/// 获取或设置转账场景 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_scene_id")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_scene_id")]
public string? TransferSceneId { get; set; }
/// <summary>
/// 获取或设置通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("notify_url")]
public string? NotifyUrl { get; set; }
/// <summary>
/// 获取或设置用户收款感知。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_recv_perception")]
[System.Text.Json.Serialization.JsonPropertyName("user_recv_perception")]
public string? UserReceivePerception { get; set; }
/// <summary>
/// 获取或设置转账场景报备信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_scene_report_infos")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_scene_report_infos")]
public IList<Types.TransferSceneReportInfo>? TransferSceneReportInfoList { get; set; }
/// <summary>
/// 获取或设置免确认收款授权信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorization_info")]
[System.Text.Json.Serialization.JsonPropertyName("authorization_info")]
public Types.AuthorizationInfo? AuthorizationInfo { get; set; }
/// <summary>
/// 获取或设置出资商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sponsor_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sponsor_mchid")]
public string? SponsorMerchantId { get; set; }
}
}

View File

@ -0,0 +1,61 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-bills/pre-transfer-with-authorization 接口的响应。</para>
/// </summary>
public class CreateFundAppMerchantTransferBillPreTransferWithAuthorizationResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信转账单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_bill_no")]
public string TransferBillNumber { 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("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置跳转领取页面的携带信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("package_info")]
[System.Text.Json.Serialization.JsonPropertyName("package_info")]
public string? PackageInfo { get; set; }
/// <summary>
/// 获取或设置用户展示昵称。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_display_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_display_name")]
public string? UserDisplayName { get; set; }
/// <summary>
/// 获取或设置商户侧授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_authorization_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_authorization_no")]
public string? OutAuthorizationNumber { get; set; }
}
}

View File

@ -0,0 +1,97 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-bills/transfer 接口的请求。</para>
/// </summary>
[WechatTenpaySensitive]
public class CreateFundAppMerchantTransferBillTransferRequest : WechatTenpayRequest
{
public static class Types
{
public class TransferSceneReportInfo : CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest.Types.TransferSceneReportInfo
{
}
}
/// <summary>
/// 获取或设置微信 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置转账金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_amount")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_amount")]
public int TransferAmount { get; set; }
/// <summary>
/// 获取或设置转账备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_remark")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_remark")]
public string TransferRemark { get; set; } = string.Empty;
/// <summary>
/// 获取或设置微信免确认收款授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorization_id")]
[System.Text.Json.Serialization.JsonPropertyName("authorization_id")]
public string AuthorizationId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置收款用户姓名(需使用平台公钥/证书加密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
[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? UserName { get; set; }
/// <summary>
/// 获取或设置转账场景 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_scene_id")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_scene_id")]
public string? TransferSceneId { get; set; }
/// <summary>
/// 获取或设置通知地址。
/// </summary>
[Newtonsoft.Json.JsonProperty("notify_url")]
[System.Text.Json.Serialization.JsonPropertyName("notify_url")]
public string? NotifyUrl { get; set; }
/// <summary>
/// 获取或设置用户收款感知。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_recv_perception")]
[System.Text.Json.Serialization.JsonPropertyName("user_recv_perception")]
public string? UserReceivePerception { get; set; }
/// <summary>
/// 获取或设置转账场景报备信息列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_scene_report_infos")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_scene_report_infos")]
public IList<Types.TransferSceneReportInfo>? TransferSceneReportInfoList { get; set; }
/// <summary>
/// 获取或设置出资商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sponsor_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sponsor_mchid")]
public string? SponsorMerchantId { get; set; }
}
}

View File

@ -0,0 +1,101 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /fund-app/mch-transfer/transfer-bills/transfer 接口的响应。</para>
/// </summary>
[WechatTenpaySensitive]
public class CreateFundAppMerchantTransferBillTransferResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置微信商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("mch_id")]
[System.Text.Json.Serialization.JsonPropertyName("mch_id")]
public string MerchantId { get; set; } = default!;
/// <summary>
/// 获取或设置微信 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_bill_no")]
public string OutBillNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信转账单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_bill_no")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_bill_no")]
public string TransferBillNumber { 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("transfer_amount")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_amount")]
public int TransferAmount { get; set; }
/// <summary>
/// 获取或设置转账备注。
/// </summary>
[Newtonsoft.Json.JsonProperty("transfer_remark")]
[System.Text.Json.Serialization.JsonPropertyName("transfer_remark")]
public string TransferRemark { get; set; } = default!;
/// <summary>
/// 获取或设置收款用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string? OpenId { get; set; }
/// <summary>
/// 获取或设置收款用户姓名(需使用商户私钥解密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
[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? UserName { get; set; }
/// <summary>
/// 获取或设置单据创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; }
/// <summary>
/// 获取或设置单据更新时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("update_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("update_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset UpdateTime { get; set; }
/// <summary>
/// 获取或设置失败原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_reason")]
[System.Text.Json.Serialization.JsonPropertyName("fail_reason")]
public string? FailReason { get; set; }
}
}

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /fund-app/mch-transfer/user-confirm-authorization/out-authorization-no/{out_authorization_no} 接口的请求。</para>
/// </summary>
public class GetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumberRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置商户侧授权单号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OutAuthorizationNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,90 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /fund-app/mch-transfer/user-confirm-authorization/out-authorization-no/{out_authorization_no} 接口的响应。</para>
/// </summary>
public class GetFundAppMerchantTransferUserConfirmAuthorizationByOutAuthorizationNumberResponse : WechatTenpayResponse
{
public static class Types
{
public class CloseInfo
{
/// <summary>
/// 获取或设置关闭原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("close_reason")]
[System.Text.Json.Serialization.JsonPropertyName("close_reason")]
public string CloseReason { get; set; } = default!;
/// <summary>
/// 获取或设置关闭时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("close_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("close_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset CloseTime { get; set; }
}
}
/// <summary>
/// 获取或设置微信 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置商户侧授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_authorization_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_authorization_no")]
public string OutAuthorizationNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信免确认收款授权单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorization_id")]
[System.Text.Json.Serialization.JsonPropertyName("authorization_id")]
public string AuthorizationId { get; set; } = default!;
/// <summary>
/// 获取或设置授权状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("state")]
[System.Text.Json.Serialization.JsonPropertyName("state")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置收款用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
/// <summary>
/// 获取或设置用户确认授权的时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorize_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("authorize_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset AuthorizeTime { get; set; }
/// <summary>
/// 获取或设置用户展示昵称。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_display_name")]
[System.Text.Json.Serialization.JsonPropertyName("user_display_name")]
public string UserDisplayName { get; set; } = default!;
/// <summary>
/// 获取或设置关闭信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("close_info")]
[System.Text.Json.Serialization.JsonPropertyName("close_info")]
public Types.CloseInfo? CloseInfo { get; set; }
}
}

View File

@ -0,0 +1,9 @@
{
"out_authorization_no": "plfk2020042013",
"appid": "102022609",
"openid": "216BE837A39456BD6729F6F47D7C0EEE",
"user_display_name": "wx_123456",
"authorization_id": "201202504101000123456789012",
"state": "TAKING_EFFECT",
"authorize_time": "2015-05-20T13:29:35.120+08:00"
}

View File

@ -0,0 +1,23 @@
{
"appid": "wxf636efh567hg4356",
"out_bill_no": "plfk2020042013",
"transfer_scene_id": "1000",
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
"transfer_amount": 400000,
"transfer_remark": "新会员开通有礼",
"notify_url": "https://www.weixin.qq.com/wxpay/pay.php",
"user_recv_perception": "现金奖励",
"transfer_scene_report_infos": [
{
"info_type": "活动名称",
"info_content": "新会员有礼"
}
],
"authorization_info": {
"user_display_name": "wx_123456",
"out_authorization_no": "plfk2020042013",
"authorization_notify_url": "https://www.weixin.qq.com/wxpay/pay.php"
},
"sponsor_mchid": "1900001109"
}

View File

@ -0,0 +1,9 @@
{
"out_bill_no": "plfk2020042013",
"transfer_bill_no": "1330000071100999991182020050700019480001",
"create_time": "2015-05-20T13:29:35.120+08:00",
"state": "ACCEPTED",
"package_info": "affffddafdfafddffda==",
"user_display_name": "wx_123456",
"out_authorization_no": "plfk2020042013"
}

View File

@ -0,0 +1,18 @@
{
"appid": "wxf636efh567hg4356",
"out_bill_no": "plfk2020042013",
"transfer_scene_id": "1000",
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
"transfer_amount": 400000,
"transfer_remark": "新会员开通有礼",
"notify_url": "https://www.weixin.qq.com/wxpay/pay.php",
"user_recv_perception": "现金奖励",
"transfer_scene_report_infos": [
{
"info_type": "活动名称",
"info_content": "新会员有礼"
}
],
"authorization_id": "201202504101000123456789012",
"sponsor_mchid": "1900001109"
}

View File

@ -0,0 +1,14 @@
{
"mch_id": "1900001109",
"out_bill_no": "plfk2020042013",
"transfer_bill_no": "1330000071100999991182020050700019480001",
"appid": "wxf636efh567hg4356",
"state": "SUCCESS",
"transfer_amount": 400000,
"transfer_remark": "新会员开通有礼",
"fail_reason": "PAYEE_ACCOUNT_ABNORMAL",
"openid": "o-MYE42l80oelYMDE34nYD456Xoy",
"user_name": "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45",
"create_time": "2015-05-20T13:29:35.120+08:00",
"update_time": "2015-05-20T13:29:35.120+08:00"
}

View File

@ -0,0 +1,13 @@
{
"out_authorization_no": "plfk2020042013",
"appid": "102022609",
"openid": "216BE837A39456BD6729F6F47D7C0EEE",
"user_display_name": "wx_123456",
"authorization_id": "201202504101000123456789012",
"state": "TAKING_EFFECT",
"authorize_time": "2015-05-20T13:29:35.120+08:00",
"close_info": {
"close_time": "2015-05-20T13:29:35.120+08:00",
"close_reason": "USER_CLOSE"
}
}

View File

@ -854,6 +854,112 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-bills/pre-transfer-with-authorization")]
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest()
{
static Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest GenerateMockRequestModel()
{
return new Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest()
{
UserName = MOCK_PLAIN_STR
};
}
static void AssertMockRequestModel(Models.CreateFundAppMerchantTransferBillPreTransferWithAuthorizationRequest request, Func<string, string> decryptor)
{
Assert.NotEqual(MOCK_PLAIN_STR, request.UserName!);
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.UserName!));
Assert.Equal(MOCK_CERT_SN, request.WechatpaySerialNumber!, ignoreCase: true);
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
{
using (var client = CreateMockClientUseRSA(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseRSA(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateFundAppMerchantTransferBillPreTransferWithAuthorizationAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
{
using (var client = CreateMockClientUseSM2(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseSM2(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateFundAppMerchantTransferBillPreTransferWithAuthorizationAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-bills/transfer")]
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferBillTransferRequest()
{
static Models.CreateFundAppMerchantTransferBillTransferRequest GenerateMockRequestModel()
{
return new Models.CreateFundAppMerchantTransferBillTransferRequest()
{
UserName = MOCK_PLAIN_STR
};
}
static void AssertMockRequestModel(Models.CreateFundAppMerchantTransferBillTransferRequest request, Func<string, string> decryptor)
{
Assert.NotEqual(MOCK_PLAIN_STR, request.UserName!);
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.UserName!));
Assert.Equal(MOCK_CERT_SN, request.WechatpaySerialNumber!, ignoreCase: true);
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
{
using (var client = CreateMockClientUseRSA(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseRSA(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateFundAppMerchantTransferBillTransferAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
{
using (var client = CreateMockClientUseSM2(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseSM2(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateFundAppMerchantTransferBillTransferAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /fund-app/mch-transfer/transfer-to-qq-wallet-bills")]
public async Task TestEncryptRequestSensitiveProperty_CreateFundAppMerchantTransferToQQWalletBillRequest()
{

View File

@ -370,6 +370,67 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([POST] /ecommerce/mch-transfer/transfer-bills/transfer")]
public async Task TestDecryptResponseSensitiveProperty_CreateFundAppMerchantTransferBillTransferResponse()
{
static Models.CreateFundAppMerchantTransferBillTransferResponse GenerateMockResponseModel(Func<string, string> encryptor)
{
return SetMockResponseRawStatusAsOk(new Models.CreateFundAppMerchantTransferBillTransferResponse()
{
UserName = encryptor.Invoke(MOCK_PLAIN_STR)
});
}
static void AssertMockResponseModel(Models.CreateFundAppMerchantTransferBillTransferResponse response)
{
Assert.Equal(MOCK_PLAIN_STR, response.UserName!);
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
{
using (var client = CreateMockClientUseRSA(autoDecrypt: false))
{
var response = GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)!);
client.DecryptResponseSensitiveProperty(response);
AssertMockResponseModel(response);
}
using (var client = CreateMockClientUseRSA(
autoDecrypt: true,
mockResponseContent: new SystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain)!)
)
))
{
var request = new Models.CreateFundAppMerchantTransferBillTransferRequest();
var response = await client.ExecuteCreateFundAppMerchantTransferBillTransferAsync(request);
AssertMockResponseModel(response);
}
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
{
using (var client = CreateMockClientUseSM2(autoDecrypt: false))
{
var response = GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)!);
client.DecryptResponseSensitiveProperty(response);
AssertMockResponseModel(response);
}
using (var client = CreateMockClientUseSM2(
autoDecrypt: true,
mockResponseContent: new SystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)!)
)
))
{
var request = new Models.CreateFundAppMerchantTransferBillTransferRequest();
var response = await client.ExecuteCreateFundAppMerchantTransferBillTransferAsync(request);
AssertMockResponseModel(response);
}
}
}
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /ecommerce/mch-transfer/transfer-bills/transfer-bill-no/{transfer_bill_no}")]
public async Task TestDecryptResponseSensitiveProperty_GetEcommerceMerchantTransferBillByTransferBillNumberResponse()
{
@ -553,7 +614,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /fund-app/mch-transfer/transfer-to-qq-wallet-bills/{out_bill_no}")]
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /fund-app/brand-redpacket/brand-merchant-out-batches/{out_batch_no}/out-details/{out_detail_no}")]
public async Task TestDecryptResponseSensitiveProperty_GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse()
{
static Models.GetFundAppBrandRedPacketBrandMerchantBatchDetailByOutDetailNumberResponse GenerateMockResponseModel(Func<string, string> encryptor)