From 6933416b615e98bbb37a077b180c50adbeb5db85 Mon Sep 17 00:00:00 2001 From: real-zony Date: Mon, 15 Jan 2024 21:15:00 +0800 Subject: [PATCH 1/5] chore: Reformatted the code. --- .../AbpWeChatPayAbstractionsModule.cs | 2 +- .../Dtos/GetJsSdkWeChatPayParametersInput.cs | 9 +++------ .../ApiRequests/IWeChatPayApiRequester.cs | 2 +- .../ApiRequests/WeChatPayApiRequestModel.cs | 4 ++-- .../PlatformCertificate/PlatformCertificateManager.cs | 2 +- .../Services/BasicPayment/Enums/PromotionTypeEnum.cs | 2 +- .../Services/BasicPayment/Enums/RefundChannelEnum.cs | 6 +++--- .../BasicPayment/Enums/RefundFundsAccountEnum.cs | 6 +++--- .../Services/BasicPayment/Enums/RefundStatusEnum.cs | 6 +++--- .../Services/BasicPayment/Enums/TradeStateEnum.cs | 4 ++-- .../BasicPayment/JSPayment/Models/CreateOrderRequest.cs | 2 +- .../Services/BasicPayment/Models/CloseOrderRequest.cs | 2 +- .../Services/BasicPayment/Models/QueryOrderResponse.cs | 4 +++- 13 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/AbpWeChatPayAbstractionsModule.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/AbpWeChatPayAbstractionsModule.cs index 5260747..daa5f0a 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/AbpWeChatPayAbstractionsModule.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/AbpWeChatPayAbstractionsModule.cs @@ -2,6 +2,6 @@ namespace EasyAbp.Abp.WeChat.Pay; -public class AbpWeChatPayAbstractionsModule : AbpModule +public class AbpWeChatPayAbstractionsModule : AbpModule { } \ No newline at end of file diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/RequestHandling/Dtos/GetJsSdkWeChatPayParametersInput.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/RequestHandling/Dtos/GetJsSdkWeChatPayParametersInput.cs index 578c009..e791dfc 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/RequestHandling/Dtos/GetJsSdkWeChatPayParametersInput.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay.Abstractions/RequestHandling/Dtos/GetJsSdkWeChatPayParametersInput.cs @@ -7,12 +7,9 @@ namespace EasyAbp.Abp.WeChat.Pay.RequestHandling.Dtos; [Serializable] public class GetJsSdkWeChatPayParametersInput { - [CanBeNull] - public string MchId { get; set; } + [CanBeNull] public string MchId { get; set; } - [Required] - public string AppId { get; set; } + [Required] public string AppId { get; set; } - [Required] - public string PrepayId { get; set; } + [Required] public string PrepayId { get; set; } } \ No newline at end of file diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/IWeChatPayApiRequester.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/IWeChatPayApiRequester.cs index f02755a..dd7a0af 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/IWeChatPayApiRequester.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/IWeChatPayApiRequester.cs @@ -12,7 +12,7 @@ public interface IWeChatPayApiRequester Task RequestAsync(HttpMethod method, string url, [CanBeNull] string body = null, [CanBeNull] string mchId = null); Task RequestAsync(HttpMethod method, string url, [CanBeNull] string body = null, [CanBeNull] string mchId = null); - + Task RequestRawAsync(HttpMethod method, string url, [CanBeNull] string body = null, [CanBeNull] string mchId = null); Task RequestAsync(HttpMethod method, string url, [NotNull] object body, [CanBeNull] string mchId = null); diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/WeChatPayApiRequestModel.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/WeChatPayApiRequestModel.cs index fe92e9a..b3b008f 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/WeChatPayApiRequestModel.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/ApiRequests/WeChatPayApiRequestModel.cs @@ -27,9 +27,9 @@ public class WeChatPayApiRequestModel RandomString = randomString; Url = url; Body = body; - + if (method != HttpMethod.Get) return; - + Body = null; if (!string.IsNullOrEmpty(body)) { diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Security/PlatformCertificate/PlatformCertificateManager.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Security/PlatformCertificate/PlatformCertificateManager.cs index 243d279..c8f8eda 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Security/PlatformCertificate/PlatformCertificateManager.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Security/PlatformCertificate/PlatformCertificateManager.cs @@ -54,7 +54,7 @@ public virtual async Task GetPlatformCertificateAsync certificate.EncryptCertificateData.Nonce, certificate.EncryptCertificateData.Ciphertext); - _certificatesCache.TryAdd(certificate.SerialNo,new Lazy(() => + _certificatesCache.TryAdd(certificate.SerialNo, new Lazy(() => new PlatformCertificateEntity(certificate.SerialNo, certificateString, certificate.EffectiveTime, certificate.ExpireTime))); } diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/PromotionTypeEnum.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/PromotionTypeEnum.cs index abead99..c95deae 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/PromotionTypeEnum.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/PromotionTypeEnum.cs @@ -9,7 +9,7 @@ public static class PromotionTypeEnum /// 代金券,需要走结算资金的充值型代金券。 /// public const string Coupon = "COUPON"; - + /// /// 优惠券,不走结算资金的免充值型优惠券。 /// diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundChannelEnum.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundChannelEnum.cs index a77def2..09b90d4 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundChannelEnum.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundChannelEnum.cs @@ -9,17 +9,17 @@ public static class RefundChannelEnum /// 原路退款。 /// public const string Original = "ORIGINAL"; - + /// /// 退回到余额。 /// public const string Balance = "BALANCE"; - + /// /// 原账户异常退到其他余额账户。 /// public const string OtherBalance = "OTHER_BALANCE"; - + /// /// 原银行卡异常退到其他银行卡。 /// diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundFundsAccountEnum.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundFundsAccountEnum.cs index 9034597..d3aaf11 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundFundsAccountEnum.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundFundsAccountEnum.cs @@ -9,7 +9,7 @@ public static class RefundFundsAccountEnum /// 可用余额账户。 /// public const string Available = "AVAILABLE"; - + /// /// 不可用余额账户。 /// @@ -24,9 +24,9 @@ public static class RefundFundsAccountEnum /// 运营账户。 /// public const string Operation = "OPERATION"; - + /// /// 基本账户。 /// - public const string Basic= "BASIC"; + public const string Basic = "BASIC"; } \ No newline at end of file diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundStatusEnum.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundStatusEnum.cs index e77920e..cb46976 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundStatusEnum.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/RefundStatusEnum.cs @@ -9,17 +9,17 @@ public static class RefundStatusEnum /// 退款成功。 /// public const string Success = "SUCCESS"; - + /// /// 退款关闭。 /// public const string Closed = "CLOSED"; - + /// /// 退款处理中。 /// public const string Processing = "PROCESSING"; - + /// /// 退款异常。 /// diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/TradeStateEnum.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/TradeStateEnum.cs index e226dfb..53f1f19 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/TradeStateEnum.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Enums/TradeStateEnum.cs @@ -9,7 +9,7 @@ public static class TradeStateEnum /// 支付成功。 /// public const string Success = "SUCCESS"; - + /// /// 转入退款。 /// @@ -19,7 +19,7 @@ public static class TradeStateEnum /// 未支付。 /// public const string NotPay = "NOTPAY"; - + /// /// 已关闭。 /// diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/JSPayment/Models/CreateOrderRequest.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/JSPayment/Models/CreateOrderRequest.cs index cc4004b..0647300 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/JSPayment/Models/CreateOrderRequest.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/JSPayment/Models/CreateOrderRequest.cs @@ -13,7 +13,7 @@ public class CreateOrderRequest : BasicPayment.Models.CreateOrderRequest [NotNull] [JsonProperty("payer")] public CreateOrderPayerModel Payer { get; set; } - + public class CreateOrderPayerModel { /// diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/CloseOrderRequest.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/CloseOrderRequest.cs index cdd970b..001a3b6 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/CloseOrderRequest.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/CloseOrderRequest.cs @@ -29,7 +29,7 @@ public class CloseOrderRequest /// 示例值: 1217752501201407033233368018 /// [Required] - [StringLength(32,MinimumLength = 6)] + [StringLength(32, MinimumLength = 6)] [JsonProperty("out_trade_no")] [JsonIgnore] public string OutTradeNo { get; set; } diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/QueryOrderResponse.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/QueryOrderResponse.cs index 62e0a92..ad68ddb 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/QueryOrderResponse.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/Models/QueryOrderResponse.cs @@ -418,7 +418,9 @@ public class QueryOrderPromotionDetailGoodsDetail /// /// 示例值: 1 /// - [Required] [JsonProperty("quantity")] public int Quantity { get; set; } + [Required] + [JsonProperty("quantity")] + public int Quantity { get; set; } /// /// 商品单价。 From 715a3f330a285315e501a7ca894a9b106d40e6b4 Mon Sep 17 00:00:00 2001 From: real-zony Date: Mon, 15 Jan 2024 21:19:01 +0800 Subject: [PATCH 2/5] refactor: Removed the unused NewtonJson module. --- src/Pay/EasyAbp.Abp.WeChat.Pay/AbpWeChatPayModule.cs | 4 +--- src/Pay/EasyAbp.Abp.WeChat.Pay/EasyAbp.Abp.WeChat.Pay.csproj | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/AbpWeChatPayModule.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/AbpWeChatPayModule.cs index 1fb00c3..d104d88 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/AbpWeChatPayModule.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/AbpWeChatPayModule.cs @@ -1,7 +1,6 @@ using EasyAbp.Abp.WeChat.Common; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.BlobStoring; -using Volo.Abp.Json.Newtonsoft; using Volo.Abp.Modularity; namespace EasyAbp.Abp.WeChat.Pay @@ -9,8 +8,7 @@ namespace EasyAbp.Abp.WeChat.Pay [DependsOn( typeof(AbpWeChatCommonModule), typeof(AbpBlobStoringModule), - typeof(AbpWeChatPayAbstractionsModule), - typeof(AbpJsonNewtonsoftModule) + typeof(AbpWeChatPayAbstractionsModule) )] public class AbpWeChatPayModule : AbpModule { diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/EasyAbp.Abp.WeChat.Pay.csproj b/src/Pay/EasyAbp.Abp.WeChat.Pay/EasyAbp.Abp.WeChat.Pay.csproj index a83daa7..750a07a 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/EasyAbp.Abp.WeChat.Pay.csproj +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/EasyAbp.Abp.WeChat.Pay.csproj @@ -17,7 +17,6 @@ - From 51069370a001838805fe4ff9811767e07ba96fcf Mon Sep 17 00:00:00 2001 From: real-zony Date: Mon, 15 Jan 2024 21:23:47 +0800 Subject: [PATCH 3/5] fix: Fixed the issue with incorrect response values in Native payment. --- .../Models/CreateOrderResponse.cs | 23 +++++++++++++++++++ .../NativePayment/NativePaymentService.cs | 1 + 2 files changed, 24 insertions(+) create mode 100644 src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/Models/CreateOrderResponse.cs diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/Models/CreateOrderResponse.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/Models/CreateOrderResponse.cs new file mode 100644 index 0000000..db4f83e --- /dev/null +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/Models/CreateOrderResponse.cs @@ -0,0 +1,23 @@ +using EasyAbp.Abp.WeChat.Pay.Services.ParametersModel; +using Newtonsoft.Json; + +namespace EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.NativePayment.Models; + +/// +/// Native 支付 - 统一下单 - 返回结果。 +/// +public class CreateOrderResponse : WeChatPayCommonErrorResponse +{ + /// + /// 二维码链接。 + /// + /// + /// 此URL用于生成支付二维码,然后提供给用户扫码支付。 + /// 注意: code_url 并非固定值,使用时按照 URL 格式转成二维码即可。 + /// + /// + /// 示例值: weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00 + /// + [JsonProperty("code_url")] + public string CodeUrl { get; set; } +} \ No newline at end of file diff --git a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/NativePaymentService.cs b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/NativePaymentService.cs index c7f9c31..0dc9924 100644 --- a/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/NativePaymentService.cs +++ b/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/BasicPayment/NativePayment/NativePaymentService.cs @@ -3,6 +3,7 @@ using EasyAbp.Abp.WeChat.Pay.Options; using EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.Models; using Volo.Abp.DependencyInjection; +using CreateOrderResponse = EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.NativePayment.Models.CreateOrderResponse; namespace EasyAbp.Abp.WeChat.Pay.Services.BasicPayment.NativePayment; From 901ff1102a1b626b81a541e879ac0dffc8facea7 Mon Sep 17 00:00:00 2001 From: real-zony Date: Mon, 15 Jan 2024 21:37:57 +0800 Subject: [PATCH 4/5] docs: Updated wechat pay usage document. --- docs/WeChatPay.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/docs/WeChatPay.md b/docs/WeChatPay.md index f8dbea0..22b7bff 100644 --- a/docs/WeChatPay.md +++ b/docs/WeChatPay.md @@ -1,3 +1,78 @@ +## 零、支持情况 + +### 0.0 如何直接调用微信支付 V3 的接口? + +由于精力有限,在项目初期没有完成所有微信支付 V3 接口的封装,这个时候你可以自己继承 `WeChatPayServiceBase` 基类,并直接使用基类提供的 `ApiRequester` 属性发起微信支付 V3 接口的请求。 + +所有的证书管理和签名验证都已经实现,你只需要自己编写对应的请求体对象和响应对象的类型定义。 + +你可以参考以下代码: + +```csharp +using System.Net.Http; +using System.Threading.Tasks; +using EasyAbp.Abp.WeChat.Pay.Options; +using EasyAbp.Abp.WeChat.Pay.Services.MarketingTools.VoucherService.ParametersModel; +using Volo.Abp.DependencyInjection; + +namespace EasyAbp.Abp.WeChat.Pay.Services.MarketingTools.VoucherService; + +/// +/// 代金券服务。 +/// +public class VoucherWeService : WeChatPayServiceBase +{ + public const string CreateCouponBatchUrl = "https://api.mch.weixin.qq.com/v3/marketing/favor/coupon-stocks"; + + public VoucherWeService(AbpWeChatPayOptions options, + IAbpLazyServiceProvider lazyServiceProvider) : base(options, + lazyServiceProvider) + { + } + + public Task CreateCouponBatchAsync(CreateCouponBatchRequest request) + { + return ApiRequester.RequestAsync(HttpMethod.Post, CreateCouponBatchUrl, request, MchId); + } +} +``` + +### 0.1 基础支付 + +| 服务 | 支持情况 | 备注 | +| ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| JSAPI 支付 | ![Support](https://img.shields.io/badge/-支持-bright_green.svg) | | +| APP 支付 | ![Support](https://img.shields.io/badge/-支持-bright_green.svg) | | +| H5 支付 | ![Support](https://img.shields.io/badge/-支持-bright_green.svg) | | +| Native 支付 | ![Support](https://img.shields.io/badge/-支持-bright_green.svg) | | +| 小程序支付 | ![Support](https://img.shields.io/badge/-支持-bright_green.svg) | | +| 合单支付 | ![Support](https://img.shields.io/badge/-未实现-red.svg) | | +| 付款码支付 | ![Support](https://img.shields.io/badge/-未实现-red.svg) | 付款码支付仍然使用的是 微信支付 V2 版本的 API。
目前不考虑再支持此支付方式,请考虑使用 Native 支付替代。 | + +### 0.2 经营能力 + +TODO + +### 0.3 行业方案 + +TODO + +### 0.4 营销工具 + +TODO + +### 0.5 资金应用 + +TODO + +### 0.6 风险合规 + +TODO + +### 0.7 其他能力 + +TODO + ## 一、基本模块配置 ### 1.1 模块的引用 From d0c5db36b179a230442350364daa2f86b0bf7f26 Mon Sep 17 00:00:00 2001 From: real-zony Date: Mon, 15 Jan 2024 21:40:27 +0800 Subject: [PATCH 5/5] chore: Updated common.props. --- common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.props b/common.props index d0887ea..b964dc1 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 3.0.0-preview.9 + 3.0.0-preview.10 $(NoWarn);CS1591 true EasyAbp Team