Skip to content

Commit

Permalink
feat: Added an API to query orders.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo, Zony authored and Mo, Zony committed Jan 6, 2024
1 parent a5d66cf commit 02a0b29
Show file tree
Hide file tree
Showing 9 changed files with 615 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ namespace EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.JSPayment;
public class JsPaymentService : WeChatPayServiceBase
{
public const string CreateOrderUrl = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi";
public const string QueryOrderUrl = "https://api.mch.weixin.qq.com/v3/pay/transactions/id";

public const string QueryOrderByWechatNumberUrl =
"https://api.mch.weixin.qq.com/v3/pay/transactions/{transaction_id}";

public const string QueryOrderByOutTradeNumberUrl =
"https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/{out_trade_no}";

public JsPaymentService(AbpWeChatPayOptions options,
IAbpLazyServiceProvider lazyServiceProvider) : base(options,
Expand All @@ -24,8 +29,15 @@ public Task<CreateOrderResponse> CreateOrderAsync(CreateOrderRequest request)
return ApiRequester.RequestAsync<CreateOrderResponse>(HttpMethod.Post, CreateOrderUrl, request);
}

public Task QueryOrderAsync(QueryOrderRequest request)
public Task<QueryOrderResponse> QueryOrderByWechatNumberAsync(QueryOrderByWechatNumberRequest request)
{
var requestUrl = QueryOrderByWechatNumberUrl.Replace("{transaction_id}", request.TransactionId);
return ApiRequester.RequestAsync<QueryOrderResponse>(HttpMethod.Get, requestUrl, request);
}

public Task<QueryOrderResponse> QueryOrderByOutTradeNumberAsync(QueryOrderByOutTradeNumberRequest request)
{
return Task.CompletedTask;
var requestUrl = QueryOrderByOutTradeNumberUrl.Replace("{out_trade_no}", request.OutTradeNo);
return ApiRequester.RequestAsync<QueryOrderResponse>(HttpMethod.Get, requestUrl, request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

namespace EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.JSPayment.Models;

public class QueryOrderByOutTradeNumberRequest
{
/// <summary>
/// 直连商户号。
/// </summary>
/// <remarks>
/// 直连商户的商户号,由微信支付生成并下发。
/// </remarks>
/// <example>示例值: 1230000109。</example>
[JsonProperty("mchid")]
[Required]
[StringLength(32, MinimumLength = 1)]
public string MchId { get; set; }

/// <summary>
/// 商户订单号。
/// </summary>
/// <remarks>
/// 商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|*@ ,且在同一个商户号下唯一。
/// </remarks>
/// <example>示例值: 1217752501201407033233368018。</example>
[JsonProperty("out_trade_no")]
[Required]
[StringLength(32, MinimumLength = 6)]
public string OutTradeNo { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

namespace EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.JSPayment.Models;

public class QueryOrderRequest
public class QueryOrderByWechatNumberRequest
{
/// <summary>
/// 直连商户号。
Expand All @@ -11,6 +12,7 @@ public class QueryOrderRequest
/// 直连商户的商户号,由微信支付生成并下发。
/// </remarks>
/// <example>示例值: 1230000109。</example>
[JsonProperty("mchid")]
[Required]
[StringLength(32, MinimumLength = 1)]
public string MchId { get; set; }
Expand All @@ -22,6 +24,7 @@ public class QueryOrderRequest
/// 微信支付系统生成的订单号。
/// </remarks>
/// <example>示例值: 1217752501201407033233368018。</example>
[JsonProperty("transaction_id")]
[Required]
[StringLength(32, MinimumLength = 1)]
public string TransactionId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ public class CreateOrderAmountModel
public string Currency { get; set; } = "CNY";
}



public class CreateOrderDetailModel
{
/// <summary>
Expand Down

0 comments on commit 02a0b29

Please sign in to comment.