1
- using System ;
2
- using System . Text . Json ;
1
+ using ams_dotnet . example . tests ;
3
2
using com . alipay . ams . api ;
4
- using com . alipay . ams . api . entities ;
5
- using com . alipay . ams . api . request ;
6
3
7
4
namespace ams_dotnet
8
5
{
@@ -16,122 +13,14 @@ class Program
16
13
private const string AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhJ5vPPThv5qFZ/3/nOcjJifbq9da9Yu1Xp3wSfJq2vFo0STtws6WGg1t34709Tcg7k4H4rgUnpvBX6h6gjGrFpZLt/uu7Q+cxnWjduvjXy4kanYp5pfSuZvblGR+LPB/yVQo0dh1iDAHk17GT1GuJ0MsBVGykU2Ji+PGkAFeYpaLiLl+uBtOEK8XVyxX7DSW8QNgQpaHBHrBBESqScV2O+ZyII6tVBlYBy/1QPkFDlJHSRTCQngak5HF0WSNYrPLFSMIgrmGDBfO2PFjuqStBNjL7+x9mRSzNF+3LY+uP/XemKmSTtRU5bSM99SNCHW5VGQvJuWX9P17686yRKKYOwIDAQAB" ;
17
14
18
15
static void Main ( string [ ] args )
19
- {
20
- var client = new DefaultAlipayClient ( GatewayUrl , ClientId , MerchantPrivateKey , AlipayPublicKey ) ;
21
-
22
- string paymentId = testInstorePayment ( client ) ;
23
-
24
- //testQuery(client);
25
-
26
- //testCancel(client);
27
-
28
- //testCashierPayment(client);
29
-
30
- //testRefund(client, paymentId);
31
- }
32
-
33
- private static string testInstorePayment ( DefaultAlipayClient client )
34
- {
35
- var request = new UserPresentedCodePaymentRequest ( "288888888888888888" ) ;
36
-
37
-
38
- long amountInCents = 1000 ;
39
- request . PaymentAmount = new Amount ( "JPY" , amountInCents ) ;
40
- Order order = new Order ( ) ;
41
- order . OrderAmount = new Amount ( "JPY" , amountInCents ) ;
42
- order . OrderDescription = "New White Lace Sleeveless" ;
43
- order . ReferenceOrderId = "0000000001" ;
44
- order . Merchant = new Merchant ( "Some_Mer" , "seller231117459" , "7011" , new Store (
45
- "Some_store" , "store231117459" , "7011" ) ) ;
46
-
47
- order . Env = new Env ( ) ;
48
- order . Env . StoreTerminalId = "some_setStoreTerminalId" ;
49
- order . Env . StoreTerminalRequestTime = "2020-06-11T13:35:02+08:00" ;
50
-
51
- string paymentRequestId = "PR20190000000001_" + ( DateTime . Now - new DateTime ( 1970 , 1 , 1 ) ) . TotalMilliseconds ;
52
-
53
- request . PaymentRequestId = paymentRequestId ;
54
- request . Order = order ;
55
-
56
- Console . WriteLine ( request ) ;
57
-
58
- var response = client . Execute ( request ) ;
59
-
60
- Console . WriteLine ( "\n ============================================================\n " ) ;
61
-
62
- Console . WriteLine ( response ) ;
63
-
64
- return response . PaymentId ;
65
- }
66
-
67
- private static void testQuery ( DefaultAlipayClient client )
68
16
{
69
- PaymentInquiryRequest paymentInquiryRequest = new PaymentInquiryRequest ( ) ;
70
- paymentInquiryRequest . PaymentRequestId = "PR20190000000001_575" ;
71
-
72
- PaymentInquiryResponse paymentInquiryResponse = client . Execute ( paymentInquiryRequest ) ;
73
-
74
- Console . WriteLine ( "paymentInquiryResponse: \n " + paymentInquiryResponse ) ;
75
- }
76
-
77
- private static void testCancel ( DefaultAlipayClient client )
78
- {
79
- PaymentCancelRequest paymentCancelRequest = new PaymentCancelRequest ( ) ;
80
- paymentCancelRequest . PaymentRequestId = "PR20190000000001_575" ;
81
-
82
- PaymentCancelResponse paymentCancelResponse = client . Execute ( paymentCancelRequest ) ;
83
-
84
- Console . WriteLine ( "paymentCancelResponse: \n " + paymentCancelResponse ) ;
85
- }
86
-
87
- private static void testRefund ( DefaultAlipayClient client , string paymentId )
88
- {
89
- PaymentRefundRequest paymentRefundRequest = new PaymentRefundRequest ( ) ;
90
- paymentRefundRequest . PaymentId = paymentId ;
91
- paymentRefundRequest . RefundRequestId = "erf_PR20190000000001_575" + ( DateTime . Now - new DateTime ( 1970 , 1 , 1 ) ) . TotalMilliseconds ;
92
- paymentRefundRequest . RefundAmount = new Amount ( "JPY" , 1000 ) ;
93
- paymentRefundRequest . RefundRequestTime = DateTime . UtcNow . ToString ( "o" ) ;
94
-
95
- PaymentRefundResponse paymentRefundResponse = client . Execute ( paymentRefundRequest ) ;
96
-
97
- Console . WriteLine ( "paymentRefundResponse: \n " + paymentRefundResponse ) ;
98
- }
99
-
100
- private static string testCashierPayment ( DefaultAlipayClient client )
101
- {
102
- var request = new CommonPaymentRequest < CommonPaymentResponse > ( ) ;
103
-
104
- request . ProductCode = ProductCodeType . CASHIER_PAYMENT ;
105
- request . PaymentAmount = new Amount ( "PHP" , 300 ) ;
106
- request . PaymentMethod = new PaymentMethod ( WalletPaymentMethodType . GCASH . ToString ( ) ) ;
107
- request . PaymentNotifyUrl = "http://alipay.com" ;
108
- request . PaymentRedirectUrl = "http://alipay.com" ;
109
-
110
- long amountInCents = 1000 ;
111
- Order order = new Order ( ) ;
112
- order . OrderAmount = new Amount ( "PHP" , amountInCents ) ;
113
- order . OrderDescription = "New White Lace Sleeveless" ;
114
- order . ReferenceOrderId = "0000000001" ;
115
- order . Merchant = new Merchant ( "Some_Mer" , "seller231117459" , "7011" , new Store (
116
- "Some_store" , "store231117459" , "7011" ) ) ;
117
-
118
- order . Env = new Env ( ) ;
119
- order . Env . StoreTerminalId = "some_setStoreTerminalId" ;
120
- order . Env . StoreTerminalRequestTime = "2020-06-11T13:35:02+08:00" ;
121
17
122
- string paymentRequestId = "PR20190000000001_" + ( DateTime . Now - new DateTime ( 1970 , 1 , 1 ) ) . TotalMilliseconds ;
123
-
124
- request . PaymentRequestId = paymentRequestId ;
125
- request . Order = order ;
126
-
127
- Console . WriteLine ( request ) ;
18
+ //InstorePaymentTest.run(new DefaultAlipayClient(GatewayUrl, ClientId, MerchantPrivateKey, AlipayPublicKey), "SGD");
128
19
129
- CommonPaymentResponse response = client . Execute ( request ) ;
130
-
131
- Console . WriteLine ( "\n ============================================================\n " ) ;
132
- Console . WriteLine ( response ) ;
20
+ CashierPaymentTest . run ( new DefaultAlipayClient ( GatewayUrl , ClientId , MerchantPrivateKey , AlipayPublicKey ) , "PHP" ) ;
133
21
134
- return response . PaymentId ;
22
+ //AutoDebitTest.run(new DefaultAlipayClient(GatewayUrl, ClientIdAD, MerchantPrivateKey, AlipayPublicKeyAD), "PHP");
23
+
135
24
}
136
25
}
137
26
}
0 commit comments