feat(tenpayv3): 新增微信寄快递相关接口

This commit is contained in:
Fu Diwei 2023-04-03 19:26:23 +08:00
parent 7d019e0fb7
commit 59697b661b
6 changed files with 77 additions and 0 deletions

View File

@ -49,6 +49,7 @@
| √ | 行业方案:微信支付分停车服务 | 直连商户 & 服务商 | | | √ | 行业方案:微信支付分停车服务 | 直连商户 & 服务商 | |
| √ | 行业方案:租用充电宝隔夜归还 | 直连商户 | | | √ | 行业方案:租用充电宝隔夜归还 | 直连商户 | |
| √ | 行业方案:微信点餐订单 | 服务商 | | | √ | 行业方案:微信点餐订单 | 服务商 | |
| √ | 行业方案:微信寄快递 | 服务商 | |
| √ | 行业方案ETC 扣费 | 服务商 | | | √ | 行业方案ETC 扣费 | 服务商 | |
| √ | 营销工具:代金券 | 直连商户 & 服务商 | | | √ | 营销工具:代金券 | 直连商户 & 服务商 | |
| √ | 营销工具:商家券 | 直连商户 & 服务商 | | | √ | 营销工具:商家券 | 直连商户 & 服务商 | |

View File

@ -0,0 +1,33 @@
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"/> 提供微信寄快递相关的 API 扩展方法。
/// </summary>
public static class WechatTenpayClientExecuteExpressExtensions
{
/// <summary>
/// <para>异步调用 [POST] /express/users/{openid}/transform 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter4_9_1.shtml </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.TransformExpressUserOpenIdResponse> ExecuteTransformExpressUserOpenIdAsync(this WechatTenpayClient client, Models.TransformExpressUserOpenIdRequest 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, "express", "users", request.OpenId, "transform");
return await client.SendRequestWithJsonAsync<Models.TransformExpressUserOpenIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /express/users/{openid}/transform 接口的请求。</para>
/// </summary>
public class TransformExpressUserOpenIdRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置用户的 OpenId。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string OpenId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置目标应用的 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [POST] /express/users/{openid}/transform 接口的响应。</para>
/// </summary>
public class TransformExpressUserOpenIdResponse : WechatTenpayResponse
{
/// <summary>
/// 获取或设置转换后的用户 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("openid")]
[System.Text.Json.Serialization.JsonPropertyName("openid")]
public string OpenId { get; set; } = default!;
}
}

View File

@ -0,0 +1,3 @@
{
"appid": "wxaaaa1a123b456c7d"
}

View File

@ -0,0 +1,3 @@
{
"openid": "xac1234554567676"
}