feat(tenpayv3): 新增平台收付通资金出境退回相关接口

This commit is contained in:
Fu Diwei 2025-03-14 09:45:39 +08:00
parent b2c116f49f
commit 17b8478115
9 changed files with 260 additions and 4 deletions

View File

@ -998,6 +998,10 @@
- 获取购付汇账单文件下载链接:`GetFundsToOverseaBillDownloadUrl`
- 申请资金出境退回:`CreateFundsToOverseaReturnOrder`
- 查询出境退回结果:`GetFundsToOverseaReturnOrderByOutReturnNumber`
- 平台收付通(下载账单)
- 申请交易账单:`GetBillTradeBill`

View File

@ -13,7 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <para>异步调用 [GET] /funds-to-oversea/transactions/{transaction_id}/available_abroad_amounts 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/docs/partner/apis/ecommerce-funds-to-oversea/transaction-api/get-available-abroad-amount.html ]]>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4012476109 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
@ -36,7 +36,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <para>异步调用 [POST] /funds-to-oversea/orders 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/docs/partner/apis/ecommerce-funds-to-oversea/funds-to-os-order-api/create-order.html ]]>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4012476113 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
@ -58,7 +58,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <para>异步调用 [GET] /funds-to-oversea/orders/{out_order_id} 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/docs/partner/apis/ecommerce-funds-to-oversea/funds-to-os-order-api/query-order.html ]]>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4012476127 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
@ -82,7 +82,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <para>异步调用 [GET] /funds-to-oversea/bill-download-url 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/docs/partner/apis/ecommerce-funds-to-oversea/purchase-payment-bill/query-download-info.html ]]>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4012476132 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
@ -101,5 +101,51 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
return await client.SendFlurlRequestAsJsonAsync<Models.GetFundsToOverseaBillDownloadUrlResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /funds-to-oversea/return/return-orders 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4013735039 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateFundsToOverseaReturnOrderResponse> ExecuteCreateFundsToOverseaReturnOrderAsync(this WechatTenpayClient client, Models.CreateFundsToOverseaReturnOrderRequest 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, "funds-to-oversea", "return", "return-orders");
return await client.SendFlurlRequestAsJsonAsync<Models.CreateFundsToOverseaReturnOrderResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [GET] /funds-to-oversea/return/return-orders/out-return-no/{out_return_no} 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4013735052 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetFundsToOverseaReturnOrderByOutReturnNumberResponse> ExecuteGetFundsToOverseaReturnOrderByOutReturnNumberAsync(this WechatTenpayClient client, Models.GetFundsToOverseaReturnOrderByOutReturnNumberRequest 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, "funds-to-oversea", "return", "return-orders", "out-return-no", request.OutReturnNumber)
.SetQueryParam("sub_mchid", request.SubMerchantId);
return await client.SendFlurlRequestAsJsonAsync<Models.GetFundsToOverseaReturnOrderByOutReturnNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}

View File

@ -0,0 +1,50 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /funds-to-oversea/return/return-orders 接口的请求。</para>
/// </summary>
public class CreateFundsToOverseaReturnOrderRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置微信二级商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string SubMerchantId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户出境退回单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_return_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_return_no")]
public string OutReturnNumber { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户出境单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_order_id")]
[System.Text.Json.Serialization.JsonPropertyName("out_order_id")]
public string OutOrderId { 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("refund_id")]
[System.Text.Json.Serialization.JsonPropertyName("refund_id")]
public string RefundId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置退回金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("amount")]
[System.Text.Json.Serialization.JsonPropertyName("amount")]
public int Amount { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /funds-to-oversea/return/return-orders 接口的响应。</para>
/// </summary>
public class CreateFundsToOverseaReturnOrderResponse : GetFundsToOverseaReturnOrderByOutReturnNumberResponse
{
}
}

View File

@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /funds-to-oversea/return/return-orders/out-return-no/{out_return_no} 接口的请求。</para>
/// </summary>
public class GetFundsToOverseaReturnOrderByOutReturnNumberRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置微信二级商户号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string SubMerchantId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置商户出境退回单号。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OutReturnNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,91 @@
using System;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /funds-to-oversea/return/return-orders/out-return-no/{out_return_no} 接口的响应。</para>
/// </summary>
public class GetFundsToOverseaReturnOrderByOutReturnNumberResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置微信二级商户号。
/// </summary>
[Newtonsoft.Json.JsonProperty("sub_mchid")]
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
public string SubMerchantId { get; set; } = default!;
/// <summary>
/// 获取或设置商户出境退回单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_return_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_return_no")]
public string OutReturnNumber { get; set; } = default!;
/// <summary>
/// 获取或设置微信出境退回单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("return_id")]
[System.Text.Json.Serialization.JsonPropertyName("return_id")]
public string ReturnId { get; set; } = default!;
/// <summary>
/// 获取或设置商户出境单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_order_id")]
[System.Text.Json.Serialization.JsonPropertyName("out_order_id")]
public string OutOrderId { 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("refund_id")]
[System.Text.Json.Serialization.JsonPropertyName("refund_id")]
public string RefundId { get; set; } = default!;
/// <summary>
/// 获取或设置退回金额(单位:分)。
/// </summary>
[Newtonsoft.Json.JsonProperty("amount")]
[System.Text.Json.Serialization.JsonPropertyName("amount")]
public int Amount { get; set; }
/// <summary>
/// 获取或设置出境退回状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("state")]
[System.Text.Json.Serialization.JsonPropertyName("state")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置出境失败原因。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_reason")]
[System.Text.Json.Serialization.JsonPropertyName("fail_reason")]
public string? FailReason { 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("success_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.Rfc3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("success_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.Rfc3339DateTimeOffsetConverter))]
public DateTimeOffset? SuccessTime { get; set; }
}
}

View File

@ -0,0 +1,8 @@
{
"out_return_no": "R20250220103930",
"sub_mchid": "1900000109",
"out_order_id": "merchant_1123123",
"transaction_id": "420000000000000010",
"refund_id": "5017752501201407033233368018",
"amount": 100
}

View File

@ -0,0 +1,13 @@
{
"out_return_no": "R20250220103930",
"sub_mchid": "1900000109",
"return_id": "2375897293812",
"out_order_id": "merchant_1123123",
"transaction_id": "420000000000000010",
"refund_id": "5017752501201407033233368018",
"amount": 100,
"state": "PROCESSING",
"create_time": "2025-02-20T10:29:35+08:00",
"success_time": "2025-02-22T10:29:35+08:00",
"fail_reason": "RETURN_AMOUNT_NOT_ENOUGH"
}

View File

@ -0,0 +1,13 @@
{
"out_return_no": "R20250220103930",
"sub_mchid": "1900000109",
"return_id": "2375897293812",
"out_order_id": "merchant_1123123",
"transaction_id": "420000000000000010",
"refund_id": "5017752501201407033233368018",
"amount": 100,
"state": "PROCESSING",
"create_time": "2025-02-20T10:29:35+08:00",
"success_time": "2025-02-22T10:29:35+08:00",
"fail_reason": "RETURN_AMOUNT_NOT_ENOUGH"
}