feat(tenpayv3): 新增发起异常退款接口

This commit is contained in:
Fu Diwei
2024-01-03 16:35:24 +08:00
parent 57a4dd6c03
commit 32c951eab4
6 changed files with 186 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@@ -73,5 +73,25 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
return await client.SendRequestWithJsonAsync<Models.GetRefundDomesticRefundByOutRefundNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /refund/domestic/refunds/{refund_id}/apply-abnormal-refund 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/docs/merchant/apis/refund/refunds/create-abnormal-refund.html </para>
/// <para>REF: https://pay.weixin.qq.com/docs/partner/apis/refund/refunds/create-abnormal-refund.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateRefundDomesticAbnormalRefundApplyResponse> ExecuteCreateRefundDomesticAbnormalRefundApplyAsync(this WechatTenpayClient client, Models.CreateRefundDomesticAbnormalRefundApplyRequest 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, "refund", "domestic", "refunds", request.RefundId, "apply-abnormal-refund");
return await client.SendRequestWithJsonAsync<Models.CreateRefundDomesticAbnormalRefundApplyResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

@@ -0,0 +1,62 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /refund/domestic/refunds/{refund_id}/apply-abnormal-refund 接口的请求。</para>
/// </summary>
[WechatTenpaySensitive]
public class CreateRefundDomesticAbnormalRefundApplyRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置子单子商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string? SubMerchantId { get; set; }
/// <summary>
/// 获取或设置微信支付退款号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string RefundId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户退款单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_refund_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_refund_no")]
public string OutRefundNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置异常退款处理方式。
/// </summary>
[Newtonsoft.Json.JsonProperty("type")]
[System.Text.Json.Serialization.JsonPropertyName("type")]
public string Type { get; set; } = string.Empty;
/// <summary>
/// 获取或设置收款开户银行。
/// </summary>
[Newtonsoft.Json.JsonProperty("bank_type")]
[System.Text.Json.Serialization.JsonPropertyName("bank_type")]
public string? BankName { get; set; }
/// <summary>
/// 获取或设置收款银行卡号(需使用平台公钥/证书加密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("bank_account")]
[System.Text.Json.Serialization.JsonPropertyName("bank_account")]
[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? BankAccountNumber { get; set; }
/// <summary>
/// 获取或设置收款用户姓名(需使用平台公钥/证书加密)。
/// </summary>
[Newtonsoft.Json.JsonProperty("real_name")]
[System.Text.Json.Serialization.JsonPropertyName("real_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? RealName { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /refund/domestic/refunds/{refund_id}/apply-abnormal-refund 接口的响应。</para>
/// </summary>
public class CreateRefundDomesticAbnormalRefundApplyResponse : GetRefundDomesticRefundByOutRefundNumberResponse
{
}
}