using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Flurl; using Flurl.Http; namespace SKIT.FlurlHttpClient.Wechat.TenpayV3 { public static class WechatTenpayClientExecuteRefundExtensions { /// /// 异步调用 [POST] /refund/domestic/refunds 接口。 /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_14.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_26.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_1_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_2_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_3_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_4_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_5_9.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter5_1_14.shtml /// /// /// /// /// public static async Task ExecuteCreateRefundDomesticRefundAsync(this WechatTenpayClient client, Models.CreateRefundDomesticRefundRequest 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"); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /refund/domestic/refunds/{out_refund_no} 接口。 /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_15.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter6_1_27.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_1_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_2_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_3_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_4_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter3_5_10.shtml /// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter5_1_15.shtml /// /// /// /// /// public static async Task ExecuteGetRefundDomesticRefundByOutRefundNumberAsync(this WechatTenpayClient client, Models.GetRefundDomesticRefundByOutRefundNumberRequest 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, "refund", "domestic", "refunds", request.OutRefundNumber); if (request.SubMerchantId != null) flurlReq.SetQueryParam("sub_mchid", request.SubMerchantId); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } } }