feat(work): 新增获取收款项目的商户单号相关接口

This commit is contained in:
Fu Diwei
2022-08-14 22:10:48 +08:00
parent 5dbc0a77ad
commit e20b855f5f
5 changed files with 80 additions and 0 deletions

View File

@@ -113,5 +113,27 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinExternalPayGetBillListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
#region Payment
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/externalpay/get_payment_info 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95944 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinExternalPayGetPaymentInfoResponse> ExecuteCgibinExternalPayGetPaymentInfoAsync(this WechatWorkClient client, Models.CgibinExternalPayGetPaymentInfoRequest 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, "cgi-bin", "externalpay", "get_payment_info")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinExternalPayGetPaymentInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalpay/get_payment_info 接口的请求。</para>
/// </summary>
public class CgibinExternalPayGetPaymentInfoRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置收款项目 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("payment_id")]
[System.Text.Json.Serialization.JsonPropertyName("payment_id")]
public string PaymentId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,28 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalpay/get_payment_info 接口的响应。</para>
/// </summary>
public class CgibinExternalPayGetPaymentInfoResponse : WechatWorkResponse
{
public static class Types
{
public class Bill
{
/// <summary>
/// 获取或设置商户单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("out_trade_no")]
[System.Text.Json.Serialization.JsonPropertyName("out_trade_no")]
public string OutTradeNumber { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置收款单列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("bill_list")]
[System.Text.Json.Serialization.JsonPropertyName("bill_list")]
public Types.Bill[] BillList { get; set; } = default!;
}
}

View File

@@ -0,0 +1,12 @@
{
"errcode": 0,
"errmsg": "ok",
"bill_list": [
{
"out_trade_no": "xxxx"
},
{
"out_trade_no": "yyyy"
}
]
}