File tree 10 files changed +188
-1
lines changed
test/Util.Biz.Tests.Integration/Payments/Alipay 10 files changed +188
-1
lines changed Original file line number Diff line number Diff line change @@ -454,6 +454,7 @@ https://github.com/dotnetcore/util/
454
454
- 支付宝电脑网站支付 [ 已发布]
455
455
- 支付宝手机网站支付 [ 已发布]
456
456
- 支付宝回调 [ 已发布]
457
+ - 支付宝APP支付 [ 已发布]
457
458
458
459
## 更新列表
459
460
@@ -513,3 +514,4 @@ https://github.com/dotnetcore/util/
513
514
- 2018年4月23日,更新了富文本框编辑器组件(Util.Ui.Angular/CkEditor)。
514
515
- 2018年5月22日,更新了支付宝电脑网站支付和手机网站支付操作。
515
516
- 2018年5月24日,更新了支付宝回调操作。
517
+ - 2018年6月19日,更新了支付宝APP支付。
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+ using Util . Biz . Payments . Alipay . Parameters . Requests ;
3
+ using Util . Biz . Payments . Core ;
4
+
5
+ namespace Util . Biz . Payments . Alipay . Abstractions {
6
+ /// <summary>
7
+ /// 支付宝App支付服务
8
+ /// </summary>
9
+ public interface IAlipayAppPayService {
10
+ /// <summary>
11
+ /// 支付
12
+ /// </summary>
13
+ /// <param name="request">支付参数</param>
14
+ Task < PayResult > PayAsync ( AlipayAppPayRequest request ) ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ using Util . Biz . Payments . Core ;
2
+
3
+ namespace Util . Biz . Payments . Alipay . Parameters . Requests {
4
+ /// <summary>
5
+ /// App支付参数
6
+ /// </summary>
7
+ public class AlipayAppPayRequest : PayParamBase {
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+ using Util . Biz . Payments . Alipay . Abstractions ;
3
+ using Util . Biz . Payments . Alipay . Configs ;
4
+ using Util . Biz . Payments . Alipay . Parameters . Requests ;
5
+ using Util . Biz . Payments . Alipay . Services . Base ;
6
+ using Util . Biz . Payments . Core ;
7
+
8
+ namespace Util . Biz . Payments . Alipay . Services {
9
+ /// <summary>
10
+ /// 支付宝App支付服务
11
+ /// </summary>
12
+ public class AlipayAppPayService : AlipayServiceBase , IAlipayAppPayService {
13
+ /// <summary>
14
+ /// 初始化支付宝App支付服务
15
+ /// </summary>
16
+ /// <param name="provider">支付宝配置提供器</param>
17
+ public AlipayAppPayService ( IAlipayConfigProvider provider ) : base ( provider ) {
18
+ }
19
+
20
+ /// <summary>
21
+ /// 支付
22
+ /// </summary>
23
+ /// <param name="request">支付参数</param>
24
+ public async Task < PayResult > PayAsync ( AlipayAppPayRequest request ) {
25
+ return await PayAsync ( request . ToParam ( ) ) ;
26
+ }
27
+
28
+ /// <summary>
29
+ /// 获取请求方法
30
+ /// </summary>
31
+ protected override string GetMethod ( ) {
32
+ return "alipay.trade.app.pay" ;
33
+ }
34
+
35
+ /// <summary>
36
+ /// 获取支付方式
37
+ /// </summary>
38
+ protected override PayWay GetPayWay ( ) {
39
+ return PayWay . AlipayAppPay ;
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ public enum PayWay {
19
19
/// 支付宝手机网站支付
20
20
/// </summary>
21
21
[ Description ( "支付宝手机网站支付" ) ]
22
- AlipayWapPay
22
+ AlipayWapPay ,
23
+ /// <summary>
24
+ /// 支付宝App支付
25
+ /// </summary>
26
+ [ Description ( "支付宝App支付" ) ]
27
+ AlipayAppPay
23
28
}
24
29
}
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ public IPayService CreatePayService( PayWay way ) {
35
35
return new AlipayPagePayService ( _alipayConfigProvider ) ;
36
36
case PayWay . AlipayWapPay :
37
37
return new AlipayWapPayService ( _alipayConfigProvider ) ;
38
+ case PayWay . AlipayAppPay :
39
+ return new AlipayAppPayService ( _alipayConfigProvider ) ;
38
40
}
39
41
throw new NotImplementedException ( ) ;
40
42
}
@@ -73,6 +75,13 @@ public IAlipayPagePayService CreateAlipayPagePayService() {
73
75
public IAlipayWapPayService CreateAlipayWapPayService ( ) {
74
76
return new AlipayWapPayService ( _alipayConfigProvider ) ;
75
77
}
78
+
79
+ /// <summary>
80
+ /// 创建支付宝App支付服务
81
+ /// </summary>
82
+ public IAlipayAppPayService CreateAlipayAppPayService ( ) {
83
+ return new AlipayAppPayService ( _alipayConfigProvider ) ;
84
+ }
76
85
}
77
86
}
78
87
Original file line number Diff line number Diff line change @@ -31,5 +31,9 @@ public interface IPayFactory {
31
31
/// 创建支付宝手机网站支付服务
32
32
/// </summary>
33
33
IAlipayWapPayService CreateAlipayWapPayService ( ) ;
34
+ /// <summary>
35
+ /// 创建支付宝App支付服务
36
+ /// </summary>
37
+ IAlipayAppPayService CreateAlipayAppPayService ( ) ;
34
38
}
35
39
}
Original file line number Diff line number Diff line change
1
+ using Microsoft . Extensions . DependencyInjection ;
2
+ using Microsoft . Extensions . DependencyInjection . Extensions ;
3
+ using Util . Tools . Sms . LuoSiMao ;
4
+
5
+ namespace Util . Tools . Sms . Extensions {
6
+ /// <summary>
7
+ /// 短信服务扩展
8
+ /// </summary>
9
+ public static class Extensions {
10
+ /// <summary>
11
+ /// 注册LuoSiMao短信服务
12
+ /// </summary>
13
+ /// <param name="services">服务集合</param>
14
+ /// <param name="key">密钥</param>
15
+ public static void AddLuoSiMao ( this IServiceCollection services , string key ) {
16
+ services . TryAddSingleton < ISmsConfigProvider > ( new SmsConfigProvider ( key ) ) ;
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+
3
+ namespace Util . Tools . Sms . LuoSiMao {
4
+ /// <summary>
5
+ /// 短信配置提供器
6
+ /// </summary>
7
+ public class SmsConfigProvider : ISmsConfigProvider {
8
+ /// <summary>
9
+ /// 短信配置
10
+ /// </summary>
11
+ private readonly SmsConfig _config ;
12
+
13
+ /// <summary>
14
+ /// 初始化短信配置提供器
15
+ /// </summary>
16
+ /// <param name="key">密钥</param>
17
+ public SmsConfigProvider ( string key ) {
18
+ _config = new SmsConfig ( key ) ;
19
+ }
20
+
21
+ /// <summary>
22
+ /// 获取配置
23
+ /// </summary>
24
+ public Task < SmsConfig > GetConfigAsync ( ) {
25
+ return Task . FromResult ( _config ) ;
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Threading . Tasks ;
3
+ using Util . Biz . Payments . Alipay . Services ;
4
+ using Util . Biz . Payments . Core ;
5
+ using Util . Biz . Tests . Integration . Payments . Alipay . Configs ;
6
+ using Util . Helpers ;
7
+ using Xunit ;
8
+ using Xunit . Abstractions ;
9
+
10
+ namespace Util . Biz . Tests . Integration . Payments . Alipay {
11
+ /// <summary>
12
+ /// 支付宝App支付服务测试
13
+ /// </summary>
14
+ public class AlipayAppPayServiceTest : IDisposable {
15
+ /// <summary>
16
+ /// 控制台输出
17
+ /// </summary>
18
+ private readonly ITestOutputHelper _output ;
19
+ /// <summary>
20
+ /// 支付宝App支付服务
21
+ /// </summary>
22
+ private readonly AlipayAppPayService _service ;
23
+
24
+ /// <summary>
25
+ /// 测试初始化
26
+ /// </summary>
27
+ public AlipayAppPayServiceTest ( ITestOutputHelper output ) {
28
+ _output = output ;
29
+ _service = new AlipayAppPayService ( new TestConfigProvider ( ) ) ;
30
+ }
31
+
32
+ /// <summary>
33
+ /// 测试清理
34
+ /// </summary>
35
+ public void Dispose ( ) {
36
+ Time . Reset ( ) ;
37
+ }
38
+
39
+ /// <summary>
40
+ /// 测试支付
41
+ /// </summary>
42
+ [ Fact ( Skip = "测试" ) ]
43
+ public async Task TestPayAsync_1 ( ) {
44
+ var result = await _service . PayAsync ( new PayParam {
45
+ Money = 10 ,
46
+ OrderId = Id . Guid ( )
47
+ } ) ;
48
+ _output . WriteLine ( $ "Message:{ result . Message } " ) ;
49
+ _output . WriteLine ( $ "Raw:{ result . Raw } " ) ;
50
+ Assert . True ( result . Success ) ;
51
+ }
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments