2023-04-06 11:17:35 +08:00
|
|
|
using System;
|
2022-01-25 13:24:49 +08:00
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Flurl.Http;
|
|
|
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
|
|
|
|
{
|
|
|
|
|
public static class WechatTenpayClientExecutePartnerPAPExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>异步调用 [POST] /partner-papay/contracts/{contract_id}/notify 接口。</para>
|
|
|
|
|
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter5_15.shtml </para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="client"></param>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
|
/// <returns></returns>
|
2023-04-06 11:17:35 +08:00
|
|
|
public static async Task<Models.NotifyPartnerPAPPayContractResponse> ExecuteNotifyPartnerPAPPayContractAsync(this WechatTenpayClient client, Models.NotifyPartnerPAPPayContractRequest request, CancellationToken cancellationToken = default)
|
2022-01-25 13:24:49 +08:00
|
|
|
{
|
|
|
|
|
if (client is null) throw new ArgumentNullException(nameof(client));
|
|
|
|
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
|
|
|
|
|
2024-01-29 23:12:37 +08:00
|
|
|
if (request.MerchantId is null)
|
2022-01-25 13:24:49 +08:00
|
|
|
request.MerchantId = client.Credentials.MerchantId;
|
|
|
|
|
|
|
|
|
|
IFlurlRequest flurlReq = client
|
2024-01-29 23:12:37 +08:00
|
|
|
.CreateFlurlRequest(request, HttpMethod.Post, "partner-papay", "contracts", request.ContractId, "notify");
|
2022-01-25 13:24:49 +08:00
|
|
|
|
2024-01-29 23:12:37 +08:00
|
|
|
return await client.SendFlurlRequestAsJsonAsync<Models.NotifyPartnerPAPPayContractResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
2022-01-25 13:24:49 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|