Skip to content

Commit fbf21c2

Browse files
committed
feat(tenpayv3): 新增商户管理与交易拦截记录相关接口
1 parent 4427080 commit fbf21c2

30 files changed

Lines changed: 1125 additions & 0 deletions

File tree

docs/WechatTenpayV3/Basic_ModelDefinition.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
|| 商户管理:商户开户意愿确认 | 合作伙伴 | |
7171
|| 商户管理:商户平台处置通知 | 合作伙伴 | |
7272
|| 商户管理:不活跃商户身份核实 | 合作伙伴 | |
73+
|| 商户管理:商户管理记录 | 合作伙伴 | |
7374
|| 其他:消费卡 | 直连商户 & 合作伙伴 | |
7475
|| 其他:代扣服务切卡组件 | 直连商户 & 合作伙伴 | |
7576
|| 其他:图片上传(营销专用) | 直连商户 & 合作伙伴 | |
@@ -1524,6 +1525,24 @@
15241525

15251526
- 查询不活跃商户身份核实结果:`GetComplianceInactiveMerchantIdentityVerificationByVerificationId`
15261527

1528+
- 商户管理记录
1529+
1530+
- 分页查询子商户名下的商户管理记录:`QueryMerchantManageRecords`
1531+
1532+
- 查询子商户下指定商户管理记录:`GetMerchantManageRecord`
1533+
1534+
- 对指定商户管理记录提交资料:`CreateMerchantManageRecordSubmission`
1535+
1536+
- 上传商户提交资料文件:`UploadMerchantManageSubmissionFile`
1537+
1538+
- 分页查询子商户名下的交易拦截记录:`QueryTransactionBlockRecords`
1539+
1540+
- 查询子商户交易拦截记录详情:`GetTransactionBlockRecord`
1541+
1542+
- 发起交易拦截申诉:`CreateTransactionBlockSubmission`
1543+
1544+
- 查询交易拦截申诉详情:`GetTransactionBlockSubmission`
1545+
15271546
- 扩展工具
15281547

15291548
- 电商订单实名校验
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Flurl.Http;
6+
7+
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
8+
{
9+
using SKIT.FlurlHttpClient.Primitives;
10+
11+
public static class WechatTenpayClientExecuteMerchantManageExtensions
12+
{
13+
/// <summary>
14+
/// <para>异步调用 [GET] /mch-manage/mch-manage-records/sub-mchid/{sub_mchid} 接口。</para>
15+
/// <para>
16+
/// REF: <br/>
17+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940381 ]]>
18+
/// </para>
19+
/// </summary>
20+
/// <param name="client"></param>
21+
/// <param name="request"></param>
22+
/// <param name="cancellationToken"></param>
23+
/// <returns></returns>
24+
public static async Task<Models.QueryMerchantManageRecordsResponse> ExecuteQueryMerchantManageRecordsAsync(this WechatTenpayClient client, Models.QueryMerchantManageRecordsRequest request, CancellationToken cancellationToken = default)
25+
{
26+
if (client is null) throw new ArgumentNullException(nameof(client));
27+
if (request is null) throw new ArgumentNullException(nameof(request));
28+
29+
IFlurlRequest flurlReq = client
30+
.CreateFlurlRequest(request, HttpMethod.Get, "mch-manage", "mch-manage-records", "sub-mchid", request.SubMerchantId)
31+
.SetQueryParam("manage_record_type", request.ManageRecordType)
32+
.SetQueryParam("manage_record_state", request.ManageRecordState)
33+
.SetQueryParam("limit", request.Limit)
34+
.SetQueryParam("offset", request.Offset);
35+
36+
return await client.SendFlurlRequestAsJsonAsync<Models.QueryMerchantManageRecordsResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
37+
}
38+
39+
/// <summary>
40+
/// <para>异步调用 [GET] /mch-manage/mch-manage-records/{manage_record_id} 接口。</para>
41+
/// <para>
42+
/// REF: <br/>
43+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940383 ]]>
44+
/// </para>
45+
/// </summary>
46+
/// <param name="client"></param>
47+
/// <param name="request"></param>
48+
/// <param name="cancellationToken"></param>
49+
/// <returns></returns>
50+
public static async Task<Models.GetMerchantManageRecordResponse> ExecuteGetMerchantManageRecordAsync(this WechatTenpayClient client, Models.GetMerchantManageRecordRequest request, CancellationToken cancellationToken = default)
51+
{
52+
if (client is null) throw new ArgumentNullException(nameof(client));
53+
if (request is null) throw new ArgumentNullException(nameof(request));
54+
55+
IFlurlRequest flurlReq = client
56+
.CreateFlurlRequest(request, HttpMethod.Get, "mch-manage", "mch-manage-records", request.ManageRecordId)
57+
.SetQueryParam("sub_mchid", request.SubMerchantId);
58+
59+
return await client.SendFlurlRequestAsJsonAsync<Models.GetMerchantManageRecordResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
60+
}
61+
62+
/// <summary>
63+
/// <para>异步调用 [POST] /mch-manage/mch-manage-records/{manage_record_id}/mch-manage-submissions 接口。</para>
64+
/// <para>
65+
/// REF: <br/>
66+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940417 ]]>
67+
/// </para>
68+
/// </summary>
69+
/// <param name="client"></param>
70+
/// <param name="request"></param>
71+
/// <param name="cancellationToken"></param>
72+
/// <returns></returns>
73+
public static async Task<Models.CreateMerchantManageRecordSubmissionResponse> ExecuteCreateMerchantManageRecordSubmissionAsync(this WechatTenpayClient client, Models.CreateMerchantManageRecordSubmissionRequest request, CancellationToken cancellationToken = default)
74+
{
75+
if (client is null) throw new ArgumentNullException(nameof(client));
76+
if (request is null) throw new ArgumentNullException(nameof(request));
77+
78+
IFlurlRequest flurlReq = client
79+
.CreateFlurlRequest(request, HttpMethod.Post, "mch-manage", "mch-manage-records", request.ManageRecordId, "mch-manage-submissions");
80+
81+
return await client.SendFlurlRequestAsJsonAsync<Models.CreateMerchantManageRecordSubmissionResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
82+
}
83+
84+
/// <summary>
85+
/// <para>异步调用 [POST] /mch-manage/submission-files/sub-mchid/{sub_mchid}/upload 接口。</para>
86+
/// <para>
87+
/// REF: <br/>
88+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940425 ]]>
89+
/// </para>
90+
/// </summary>
91+
/// <param name="client"></param>
92+
/// <param name="request"></param>
93+
/// <param name="cancellationToken"></param>
94+
/// <returns></returns>
95+
public static async Task<Models.UploadMerchantManageSubmissionFileResponse> ExecuteUploadMerchantManageSubmissionFileAsync(this WechatTenpayClient client, Models.UploadMerchantManageSubmissionFileRequest request, CancellationToken cancellationToken = default)
96+
{
97+
if (client is null) throw new ArgumentNullException(nameof(client));
98+
if (request is null) throw new ArgumentNullException(nameof(request));
99+
100+
if (request.FileName is null)
101+
request.FileName = Guid.NewGuid().ToString("N").ToLower();
102+
103+
if (request.FileHash is null)
104+
request.FileHash = EncodedString.ToHexString(Utilities.SHA256Utility.Hash(request.FileBytes)).Value!.ToLower();
105+
106+
if (request.FileContentType is null)
107+
request.FileContentType = MimeTypes.GetMimeMapping(request.FileName!);
108+
109+
IFlurlRequest flurlReq = client
110+
.CreateFlurlRequest(request, HttpMethod.Post, "mch-manage", "submission-files", "sub-mchid", request.SubMerchantId, "upload");
111+
112+
using var httpContent = Utilities.HttpContentBuilder.BuildWithFile(fileName: request.FileName, fileBytes: request.FileBytes, fileContentType: request.FileContentType, fileMetaJson: client.JsonSerializer.Serialize(request), formDataName: "submission_file");
113+
httpContent.Add(new StringContent(request.ItemId), "item_id");
114+
return await client.SendFlurlRequestAsync<Models.UploadMerchantManageSubmissionFileResponse>(flurlReq, httpContent: httpContent, cancellationToken: cancellationToken).ConfigureAwait(false);
115+
}
116+
}
117+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Flurl.Http;
6+
7+
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
8+
{
9+
using SKIT.FlurlHttpClient.Primitives;
10+
11+
public static class WechatTenpayClientExecuteTransactionBlockExtensions
12+
{
13+
/// <summary>
14+
/// <para>异步调用 [GET] /transaction-block/transaction-block-records/sub-mchid/{sub_mchid} 接口。</para>
15+
/// <para>
16+
/// REF: <br/>
17+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940432 ]]>
18+
/// </para>
19+
/// </summary>
20+
/// <param name="client"></param>
21+
/// <param name="request"></param>
22+
/// <param name="cancellationToken"></param>
23+
/// <returns></returns>
24+
public static async Task<Models.QueryTransactionBlockRecordsResponse> ExecuteQueryTransactionBlockRecordsAsync(this WechatTenpayClient client, Models.QueryTransactionBlockRecordsRequest request, CancellationToken cancellationToken = default)
25+
{
26+
if (client is null) throw new ArgumentNullException(nameof(client));
27+
if (request is null) throw new ArgumentNullException(nameof(request));
28+
29+
IFlurlRequest flurlReq = client
30+
.CreateFlurlRequest(request, HttpMethod.Get, "transaction-block", "transaction-block-records", "sub-mchid", request.SubMerchantId)
31+
.SetQueryParam("limit", request.Limit)
32+
.SetQueryParam("offset", request.Offset);
33+
34+
return await client.SendFlurlRequestAsJsonAsync<Models.QueryTransactionBlockRecordsResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
35+
}
36+
37+
/// <summary>
38+
/// <para>异步调用 [GET] /transaction-block/transaction-block-records/{block_record_id} 接口。</para>
39+
/// <para>
40+
/// REF: <br/>
41+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940435 ]]>
42+
/// </para>
43+
/// </summary>
44+
/// <param name="client"></param>
45+
/// <param name="request"></param>
46+
/// <param name="cancellationToken"></param>
47+
/// <returns></returns>
48+
public static async Task<Models.GetTransactionBlockRecordResponse> ExecuteGetTransactionBlockRecordAsync(this WechatTenpayClient client, Models.GetTransactionBlockRecordRequest request, CancellationToken cancellationToken = default)
49+
{
50+
if (client is null) throw new ArgumentNullException(nameof(client));
51+
if (request is null) throw new ArgumentNullException(nameof(request));
52+
53+
IFlurlRequest flurlReq = client
54+
.CreateFlurlRequest(request, HttpMethod.Get, "transaction-block", "transaction-block-records", request.BlockRecordId)
55+
.SetQueryParam("sub_mchid", request.SubMerchantId);
56+
57+
return await client.SendFlurlRequestAsJsonAsync<Models.GetTransactionBlockRecordResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
58+
}
59+
60+
/// <summary>
61+
/// <para>异步调用 [POST] /transaction-block/transaction-block-submissions/sub-mchid/{sub_mchid} 接口。</para>
62+
/// <para>
63+
/// REF: <br/>
64+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940446 ]]>
65+
/// </para>
66+
/// </summary>
67+
/// <param name="client"></param>
68+
/// <param name="request"></param>
69+
/// <param name="cancellationToken"></param>
70+
/// <returns></returns>
71+
public static async Task<Models.CreateTransactionBlockSubmissionResponse> ExecuteCreateTransactionBlockSubmissionAsync(this WechatTenpayClient client, Models.CreateTransactionBlockSubmissionRequest request, CancellationToken cancellationToken = default)
72+
{
73+
if (client is null) throw new ArgumentNullException(nameof(client));
74+
if (request is null) throw new ArgumentNullException(nameof(request));
75+
76+
IFlurlRequest flurlReq = client
77+
.CreateFlurlRequest(request, HttpMethod.Post, "transaction-block", "transaction-block-submissions", "sub-mchid", request.SubMerchantId);
78+
79+
return await client.SendFlurlRequestAsJsonAsync<Models.CreateTransactionBlockSubmissionResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
80+
}
81+
82+
/// <summary>
83+
/// <para>异步调用 [GET] /transaction-block/transaction-block-submissions/{block_submission_id} 接口。</para>
84+
/// <para>
85+
/// REF: <br/>
86+
/// <![CDATA[ https://pay.weixin.qq.com/doc/v3/partner/4014940449 ]]>
87+
/// </para>
88+
/// </summary>
89+
/// <param name="client"></param>
90+
/// <param name="request"></param>
91+
/// <param name="cancellationToken"></param>
92+
/// <returns></returns>
93+
public static async Task<Models.GetTransactionBlockSubmissionResponse> ExecuteGetTransactionBlockSubmissionAsync(this WechatTenpayClient client, Models.GetTransactionBlockSubmissionRequest request, CancellationToken cancellationToken = default)
94+
{
95+
if (client is null) throw new ArgumentNullException(nameof(client));
96+
if (request is null) throw new ArgumentNullException(nameof(request));
97+
98+
IFlurlRequest flurlReq = client
99+
.CreateFlurlRequest(request, HttpMethod.Get, "transaction-block", "transaction-block-submissions", request.BlockSubmissionId);
100+
101+
return await client.SendFlurlRequestAsJsonAsync<Models.GetTransactionBlockSubmissionResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
102+
}
103+
}
104+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /mch-manage/mch-manage-records/{manage_record_id}/mch-manage-submissions 接口的请求。</para>
5+
/// </summary>
6+
public class CreateMerchantManageRecordSubmissionRequest : WechatTenpayRequest
7+
{
8+
/// <summary>
9+
/// 获取或设置子商户号。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("sub_mchid")]
12+
[System.Text.Json.Serialization.JsonPropertyName("sub_mchid")]
13+
public string SubMerchantId { get; set; } = string.Empty;
14+
15+
/// <summary>
16+
/// 获取或设置商户管理记录 ID。
17+
/// </summary>
18+
[Newtonsoft.Json.JsonIgnore]
19+
[System.Text.Json.Serialization.JsonIgnore]
20+
public string ManageRecordId { get; set; } = string.Empty;
21+
22+
/// <summary>
23+
/// 获取或设置提交数据(JSON 格式)。
24+
/// </summary>
25+
[Newtonsoft.Json.JsonProperty("submit_data")]
26+
[System.Text.Json.Serialization.JsonPropertyName("submit_data")]
27+
public string SubmitData { get; set; } = "{}";
28+
}
29+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [POST] /mch-manage/mch-manage-records/{manage_record_id}/mch-manage-submissions 接口的响应。</para>
5+
/// </summary>
6+
public class CreateMerchantManageRecordSubmissionResponse : WechatTenpayResponse
7+
{
8+
/// <summary>
9+
/// 获取或设置商户管理提交资料记录 ID。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonProperty("manage_submission_id")]
12+
[System.Text.Json.Serialization.JsonPropertyName("manage_submission_id")]
13+
public string ManageSubmissionId { get; set; } = default!;
14+
}
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
2+
{
3+
/// <summary>
4+
/// <para>表示 [GET] /mch-manage/mch-manage-records/{manage_record_id} 接口的请求。</para>
5+
/// </summary>
6+
public class GetMerchantManageRecordRequest : WechatTenpayRequest
7+
{
8+
/// <summary>
9+
/// 获取或设置子商户号。
10+
/// </summary>
11+
[Newtonsoft.Json.JsonIgnore]
12+
[System.Text.Json.Serialization.JsonIgnore]
13+
public string SubMerchantId { get; set; } = string.Empty;
14+
15+
/// <summary>
16+
/// 获取或设置商户管理记录 ID。
17+
/// </summary>
18+
[Newtonsoft.Json.JsonIgnore]
19+
[System.Text.Json.Serialization.JsonIgnore]
20+
public string ManageRecordId { get; set; } = string.Empty;
21+
}
22+
}

0 commit comments

Comments
 (0)