feat(tenpayv3): 新增境外支付融合钱包订单相关接口

This commit is contained in:
Fu Diwei
2022-02-25 16:20:07 +08:00
parent efb7e948ed
commit 9118dd0fef
91 changed files with 4153 additions and 21 deletions

View File

@@ -15,6 +15,12 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <para>异步调用 [GET] /certificates 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay5_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/wechatpay/wechatpay5_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_7.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_7.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_7.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_7.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_7.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_7.shtml </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>

View File

@@ -14,6 +14,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [POST] /customs/orders 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/declarecustom/chapter3_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
@@ -36,6 +37,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [GET] /customs/orders 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/declarecustom/chapter3_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
@@ -69,6 +71,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [POST] /customs/redeclare 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/declarecustom/chapter3_4.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
@@ -91,6 +94,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [PATCH] /customs/orders 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/declarecustom/chapter3_5.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
@@ -113,6 +117,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [POST] /customs/verify-certificate 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/declarecustom/chapter3_2.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>

View File

@@ -14,6 +14,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [POST] /merchants 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/Onborading_Sub_Merchant/chapter3_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
@@ -37,6 +38,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [GET] /merchants/{sub_mchid} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/Onborading%20Sub%20Merchant/chapter3_2.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
@@ -61,6 +63,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
/// <summary>
/// <para>异步调用 [PUT] /merchants 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/Onborading_Sub_Merchant/chapter3_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>

View File

@@ -0,0 +1,287 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
/// <summary>
/// 为 <see cref="WechatTenpayClient"/> 提供境外支付融合钱包For HK相关的 API 扩展方法。
/// </summary>
public static class WechatTenpayClientExecuteHKPartnerTransactionsExtensions
{
/// <summary>
/// <para>异步调用 [POST] /transactions/app 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter6_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKPartnerTransactionAppResponse> ExecuteCreateHKPartnerTransactionAppAsync(this WechatTenpayClient client, Models.CreateHKPartnerTransactionAppRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "app");
return await client.SendRequestWithJsonAsync<Models.CreateHKPartnerTransactionAppResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/mweb 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter3_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKPartnerTransactionMWebResponse> ExecuteCreateHKPartnerTransactionMWebAsync(this WechatTenpayClient client, Models.CreateHKPartnerTransactionMWebRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "mweb");
return await client.SendRequestWithJsonAsync<Models.CreateHKPartnerTransactionMWebResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/jsapi 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter5_4.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter7_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKPartnerTransactionJsapiResponse> ExecuteCreateHKPartnerTransactionJsapiAsync(this WechatTenpayClient client, Models.CreateHKPartnerTransactionJsapiRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "jsapi");
return await client.SendRequestWithJsonAsync<Models.CreateHKPartnerTransactionJsapiResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/native 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter4_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKPartnerTransactionNativeResponse> ExecuteCreateHKPartnerTransactionNativeAsync(this WechatTenpayClient client, Models.CreateHKPartnerTransactionNativeRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "native");
return await client.SendRequestWithJsonAsync<Models.CreateHKPartnerTransactionNativeResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /transactions/out-trade-no/{out_trade_no} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetHKPartnerTransactionByOutTradeNumberResponse> ExecuteGetHKPartnerTransactionByOutTradeNumberAsync(this WechatTenpayClient client, Models.GetHKPartnerTransactionByOutTradeNumberRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "transactions", "out-trade-no", request.OutTradeNumber)
.SetQueryParam("sp_mchid", request.MerchantId)
.SetQueryParam("sub_mchid", request.SubMerchantId);
return await client.SendRequestWithJsonAsync<Models.GetHKPartnerTransactionByOutTradeNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /transactions/id/{transaction_id} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetHKPartnerTransactionByIdResponse> ExecuteGetHKPartnerTransactionByIdAsync(this WechatTenpayClient client, Models.GetHKPartnerTransactionByIdRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "transactions", "id", request.TransactionId)
.SetQueryParam("sp_mchid", request.MerchantId)
.SetQueryParam("sub_mchid", request.SubMerchantId);
return await client.SendRequestWithJsonAsync<Models.GetHKPartnerTransactionByIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/out-trade-no/{out_trade_no}/close 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_6.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CloseHKPartnerTransactionResponse> ExecuteCloseHKPartnerTransactionAsync(this WechatTenpayClient client, Models.CloseHKPartnerTransactionRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "out-trade-no", request.OutTradeNumber, "close")
.SetQueryParam("sp_mchid", request.MerchantId)
.SetQueryParam("sub_mchid", request.SubMerchantId);
return await client.SendRequestWithJsonAsync<Models.CloseHKPartnerTransactionResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/out-trade-no/{out_trade_no}/reverse 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter3_4.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ReverseHKPartnerTransactionResponse> ExecuteReverseHKPartnerTransactionAsync(this WechatTenpayClient client, Models.ReverseHKPartnerTransactionRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "out-trade-no", request.OutTradeNumber, "reverse")
.SetQueryParam("sp_mchid", request.MerchantId)
.SetQueryParam("sub_mchid", request.SubMerchantId);
return await client.SendRequestWithJsonAsync<Models.ReverseHKPartnerTransactionResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /statements 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_5.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_5.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_5.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_5.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_5.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_5.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.DownloadHKStatementsResponse> ExecuteDownloadHKStatementsAsync(this WechatTenpayClient client, Models.DownloadHKStatementsRequest 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, "statements")
.SetQueryParam("date", request.DateString);
if (request.SubMerchantId != null)
flurlReq.SetQueryParam("mchid", request.SubMerchantId);
return await client.SendRequestWithJsonAsync<Models.DownloadHKStatementsResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /settle/settlements 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_12.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_12.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_12.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_12.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_12.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_12.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.QueryHKSettlementsResponse> ExecuteQueryHKSettlementsAsync(this WechatTenpayClient client, Models.QueryHKSettlementsRequest 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, "settle", "settlements")
.SetQueryParam("settle_state", request.SettleState)
.SetQueryParam("offset", request.Offset)
.SetQueryParam("limit", request.Limit);
if (request.SubMerchantId != null)
flurlReq.SetQueryParam("sub_mchid", request.SubMerchantId);
if (request.StartDateString != null)
flurlReq.SetQueryParam("settle_start_date", request.StartDateString);
if (request.EndDateString != null)
flurlReq.SetQueryParam("settle_end_date", request.EndDateString);
return await client.SendRequestWithJsonAsync<Models.QueryHKSettlementsResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

@@ -0,0 +1,217 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
/// <summary>
/// 为 <see cref="WechatTenpayClient"/> 提供境外支付融合钱包For HK相关的 API 扩展方法。
/// </summary>
public static class WechatTenpayClientExecuteHKTransactionsExtensions
{
/// <summary>
/// <para>异步调用 [POST] /transactions/app 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter6_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKTransactionAppResponse> ExecuteCreateHKTransactionAppAsync(this WechatTenpayClient client, Models.CreateHKTransactionAppRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "app");
return await client.SendRequestWithJsonAsync<Models.CreateHKTransactionAppResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/mweb 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter3_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKTransactionMWebResponse> ExecuteCreateHKTransactionMWebAsync(this WechatTenpayClient client, Models.CreateHKTransactionMWebRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "mweb");
return await client.SendRequestWithJsonAsync<Models.CreateHKTransactionMWebResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/jsapi 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter5_4.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter7_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKTransactionJsapiResponse> ExecuteCreateHKTransactionJsapiAsync(this WechatTenpayClient client, Models.CreateHKTransactionJsapiRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "jsapi");
return await client.SendRequestWithJsonAsync<Models.CreateHKTransactionJsapiResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/native 接口。</para>
/// <para>REF: https://https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter4_3.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CreateHKTransactionNativeResponse> ExecuteCreateHKTransactionNativeAsync(this WechatTenpayClient client, Models.CreateHKTransactionNativeRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "native");
return await client.SendRequestWithJsonAsync<Models.CreateHKTransactionNativeResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /transactions/out-trade-no/{out_trade_no} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetHKTransactionByOutTradeNumberResponse> ExecuteGetHKTransactionByOutTradeNumberAsync(this WechatTenpayClient client, Models.GetHKTransactionByOutTradeNumberRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "transactions", "out-trade-no", request.OutTradeNumber)
.SetQueryParam("mchid", request.MerchantId);
return await client.SendRequestWithJsonAsync<Models.GetHKTransactionByOutTradeNumberResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /transactions/id/{transaction_id} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_1.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter8_1.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.GetHKTransactionByIdResponse> ExecuteGetHKTransactionByIdAsync(this WechatTenpayClient client, Models.GetHKTransactionByIdRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, "transactions", "id", request.TransactionId)
.SetQueryParam("mchid", request.MerchantId);
return await client.SendRequestWithJsonAsync<Models.GetHKTransactionByIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/out-trade-no/{out_trade_no}/close 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/In-AppPay/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/H5Payment/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/OfficialPayMent/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/MiniProgramPay/chapter8_6.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/NativePay/chapter8_6.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CloseHKTransactionResponse> ExecuteCloseHKTransactionAsync(this WechatTenpayClient client, Models.CloseHKTransactionRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "out-trade-no", request.OutTradeNumber, "close")
.SetQueryParam("mchid", request.MerchantId);
return await client.SendRequestWithJsonAsync<Models.CloseHKTransactionResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /transactions/out-trade-no/{out_trade_no}/reverse 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay/en/fusion_wallet/QuickPay/chapter3_4.shtml </para>
/// <para><i>(请注意调用此接口需在构造 <see cref="WechatTenpayClient" /> 时指定特殊的 <see cref="WechatTenpayClientOptions.Endpoints"/>。)</i></para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ReverseHKTransactionResponse> ExecuteReverseHKTransactionAsync(this WechatTenpayClient client, Models.ReverseHKTransactionRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.MerchantId == null)
request.MerchantId = client.Credentials.MerchantId;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "transactions", "out-trade-no", request.OutTradeNumber, "reverse")
.SetQueryParam("mchid", request.MerchantId);
return await client.SendRequestWithJsonAsync<Models.ReverseHKTransactionResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

@@ -31,7 +31,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
return await client.SendRequestWithJsonAsync<Models.CreatePartnerTransferBatchResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /partner-transfer/batches/batch-id/{batch_id} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/transfer_partner/chapter3_2.shtml </para>

View File

@@ -74,7 +74,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
plainText: oldValue
);
}
else if(Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS1.Equals(attr.Algorithm))
else if (Constants.EncryptionAlgorithms.RSA_2048_ECB_PKCS1.Equals(attr.Algorithm))
{
newValue = Utilities.RSAUtility.EncryptWithECBByCertificate(
certificate: certificate,