alipay 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +6 -1
- data/LICENSE.txt +1 -1
- data/README.md +25 -759
- data/alipay.gemspec +4 -3
- data/bin/console +14 -0
- data/config.yml.example +6 -0
- data/doc/legacy_api.md +748 -0
- data/lib/alipay.rb +2 -2
- data/lib/alipay/client.rb +194 -0
- data/lib/alipay/sign/rsa2.rb +18 -0
- data/lib/alipay/version.rb +1 -1
- metadata +9 -36
- data/lib/alipay/app/service.rb +0 -27
- data/lib/alipay/app/sign.rb +0 -39
- data/test/alipay/app/service_test.rb +0 -20
- data/test/alipay/app/sign_test.rb +0 -15
- data/test/alipay/mobile/service_test.rb +0 -16
- data/test/alipay/mobile/sign_test.rb +0 -7
- data/test/alipay/notify_test.rb +0 -35
- data/test/alipay/service_test.rb +0 -265
- data/test/alipay/sign/md5_test.rb +0 -20
- data/test/alipay/sign/rsa_test.rb +0 -20
- data/test/alipay/sign_test.rb +0 -30
- data/test/alipay/utils_test.rb +0 -12
- data/test/alipay/wap/notify_test.rb +0 -38
- data/test/alipay/wap/service_test.rb +0 -67
- data/test/alipay/wap/sign_test.rb +0 -19
- data/test/alipay_test.rb +0 -11
- data/test/test_helper.rb +0 -34
data/alipay.gemspec
CHANGED
@@ -13,9 +13,10 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/chloerei/alipay"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
17
|
-
|
18
|
-
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'alipay'
|
5
|
+
require 'yaml'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
if File.exists?('config.yml')
|
9
|
+
$alipay_client = Alipay::Client.new(YAML.load_file('config.yml'))
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'irb'
|
13
|
+
|
14
|
+
IRB.start(__FILE__)
|
data/config.yml.example
ADDED
data/doc/legacy_api.md
ADDED
@@ -0,0 +1,748 @@
|
|
1
|
+
# Alipay Legacy API
|
2
|
+
|
3
|
+
*It's recommended to use new alipay api - Open API, read [Alipay::Client](../lib/alipay/client.rb) for more detail.*
|
4
|
+
|
5
|
+
A unofficial alipay ruby gem.
|
6
|
+
|
7
|
+
Alipay official document: https://b.alipay.com/order/techService.htm .
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'alipay', '~> 0.14.0'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```console
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Alipay.pid = 'YOUR_PID'
|
27
|
+
Alipay.key = 'YOUR_KEY'
|
28
|
+
|
29
|
+
#Alipay.sign_type = 'MD5' # Available values: MD5, RSA. Default is MD5
|
30
|
+
#Alipay.debug_mode = true # Enable parameter check. Default is true.
|
31
|
+
```
|
32
|
+
|
33
|
+
You can set default key, or pass a key directly to service method:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Service.create_partner_trade_by_buyer_url({
|
37
|
+
out_trade_no: 'OUT_TRADE_NO',
|
38
|
+
# Order params...
|
39
|
+
}, {
|
40
|
+
pid: 'ANOTHER_PID',
|
41
|
+
key: 'ANOTHER_KEY',
|
42
|
+
})
|
43
|
+
```
|
44
|
+
|
45
|
+
## Service
|
46
|
+
|
47
|
+
### 担保交易收款接口
|
48
|
+
|
49
|
+
#### Name
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
create_partner_trade_by_buyer
|
53
|
+
```
|
54
|
+
|
55
|
+
#### Definition
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Alipay::Service.create_partner_trade_by_buyer_url({ARGUMENTS}, {OPTIONS})
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Example
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Alipay::Service.create_partner_trade_by_buyer_url(
|
65
|
+
out_trade_no: '20150401000-0001',
|
66
|
+
subject: 'Order Name',
|
67
|
+
price: '10.00',
|
68
|
+
quantity: 12,
|
69
|
+
logistics_type: 'DIRECT',
|
70
|
+
logistics_fee: '0',
|
71
|
+
logistics_payment: 'SELLER_PAY',
|
72
|
+
return_url: 'https://example.com/orders/20150401000-0001',
|
73
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
74
|
+
)
|
75
|
+
# => 'https://mapi.alipay.com/gateway.do?service=create_partner_trade_by_buyer&...'
|
76
|
+
```
|
77
|
+
|
78
|
+
Guide consumer to this address to complete payment
|
79
|
+
|
80
|
+
#### Arguments
|
81
|
+
|
82
|
+
| Key | Requirement | Description |
|
83
|
+
| --- | ----------- | ----------- |
|
84
|
+
| out_order_no | required | Order id in your application. |
|
85
|
+
| subject | required | Order subject. |
|
86
|
+
| price | required | Order item's price. |
|
87
|
+
| quantity | required | Order item's quantity, total price is price * quantity. |
|
88
|
+
| logistics_type | required | Logistics type. Available values: POST, EXPRESS, EMS, DIRECT. |
|
89
|
+
| logistics_fee | required | Logistics fee. |
|
90
|
+
| logistics_payment | required | Who pay the logistics fee. Available values: BUYER_PAY, SELLER_PAY, BUYER_PAY_AFTER_RECEIVE. |
|
91
|
+
| return_url | optional | Redirect customer to this url after payment. |
|
92
|
+
| notify_url | optional | Alipay asyn notify url. |
|
93
|
+
|
94
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipayescow.zip .
|
95
|
+
|
96
|
+
### 确认发货接口
|
97
|
+
|
98
|
+
#### Name
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
send_goods_confirm_by_platform
|
102
|
+
```
|
103
|
+
|
104
|
+
#### Definition
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
Alipay::Service.send_goods_confirm_by_platform({ARGUMENTS}, {OPTIONS})
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Example
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
Alipay::Service.send_goods_confirm_by_platform(
|
114
|
+
trade_no: '201504010000001',
|
115
|
+
logistics_name: 'example.com',
|
116
|
+
transport_type: 'DIRECT'
|
117
|
+
)
|
118
|
+
# => '<!xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success></alipay>'
|
119
|
+
```
|
120
|
+
|
121
|
+
#### Arguments
|
122
|
+
|
123
|
+
| Key | Requirement | Description |
|
124
|
+
| --- | ----------- | ----------- |
|
125
|
+
| trade_no | required | Trade number in Alipay system, should get from notify message. |
|
126
|
+
| logistics_name | required | Logistics Name. |
|
127
|
+
| transport_type/create_transport_type | required | Allowed values: POST, EXPRESS, EMS, DIRECT. |
|
128
|
+
|
129
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipayescow.zip .
|
130
|
+
|
131
|
+
### 即时到账收款接口
|
132
|
+
|
133
|
+
#### Name
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
create_direct_pay_by_user
|
137
|
+
```
|
138
|
+
|
139
|
+
#### Definition
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
Alipay::Service.create_direct_pay_by_user_url({ARGUMENTS}, {OPTIONS})
|
143
|
+
```
|
144
|
+
|
145
|
+
#### Example
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
Alipay::Service.create_direct_pay_by_user_url(
|
149
|
+
out_trade_no: '20150401000-0001',
|
150
|
+
subject: 'Order Name',
|
151
|
+
total_fee: '10.00',
|
152
|
+
return_url: 'https://example.com/orders/20150401000-0001',
|
153
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
154
|
+
)
|
155
|
+
```
|
156
|
+
|
157
|
+
#### Arguments
|
158
|
+
|
159
|
+
| Key | Requirement | Description |
|
160
|
+
| --- | ----------- | ----------- |
|
161
|
+
| out_order_no | required | Order id in your application. |
|
162
|
+
| subject | required | Order subject. |
|
163
|
+
| total_fee | required | Order's total fee. |
|
164
|
+
| return_url | optional | Redirect customer to this url after payment. |
|
165
|
+
| notify_url | optional | Alipay asyn notify url. |
|
166
|
+
|
167
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipaydirect.zip .
|
168
|
+
|
169
|
+
### 手机网站支付接口
|
170
|
+
|
171
|
+
#### Name
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
alipay.wap.create.direct.pay.by.user
|
175
|
+
```
|
176
|
+
|
177
|
+
#### Definition
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
Alipay::Service.create_direct_pay_by_user_wap_url({ARGUMENTS}, {OPTIONS})
|
181
|
+
```
|
182
|
+
|
183
|
+
#### Example
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
Alipay::Service.create_direct_pay_by_user_wap_url(
|
187
|
+
out_trade_no: '20150401000-0001',
|
188
|
+
subject: 'Order Name',
|
189
|
+
total_fee: '10.00',
|
190
|
+
return_url: 'https://example.com/orders/20150401000-0001',
|
191
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
192
|
+
)
|
193
|
+
```
|
194
|
+
|
195
|
+
#### Arguments
|
196
|
+
|
197
|
+
| Key | Requirement | Description |
|
198
|
+
| --- | ----------- | ----------- |
|
199
|
+
| out_order_no | required | Order id in your application. |
|
200
|
+
| subject | required | Order subject. |
|
201
|
+
| total_fee | required | Order's total fee. |
|
202
|
+
| return_url | optional | Redirect customer to this url after payment. |
|
203
|
+
| notify_url | optional | Alipay asyn notify url. |
|
204
|
+
|
205
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipaywapdirect.zip .
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
### 国际支付宝移动接口
|
211
|
+
|
212
|
+
#### Name
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
create_forex_trade_wap
|
216
|
+
```
|
217
|
+
|
218
|
+
#### Definition
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
Alipay::Service.create_forex_trade_wap_url({ARGUMENTS}, {OPTIONS})
|
222
|
+
```
|
223
|
+
|
224
|
+
#### Example
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
Alipay::Service.create_forex_trade_wap_url(
|
228
|
+
out_trade_no: '20150401000-0001',
|
229
|
+
subject: 'Order Name',
|
230
|
+
merchant_url: 'http://example.com/itemback',
|
231
|
+
total_fee: '10.00', #or rmb_fee, only one
|
232
|
+
currency: 'USD',
|
233
|
+
return_url: 'https://example.com/orders/20150401000-0001',
|
234
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
235
|
+
)
|
236
|
+
```
|
237
|
+
|
238
|
+
#### Arguments
|
239
|
+
|
240
|
+
| Key | Requirement | Description |
|
241
|
+
| --- | ----------- | ----------- |
|
242
|
+
| out_order_no | required | Order id in your application. |
|
243
|
+
| subject | required | Order subject. |
|
244
|
+
| merchant_url | required | The link which customer could jump back to merchant page from Alipay cashier. |
|
245
|
+
| total_fee or rmb_fee | required | Order's total fee. |
|
246
|
+
| currency | required | currency type. |
|
247
|
+
| return_url | optional | Redirect customer to this url after payment. |
|
248
|
+
| notify_url | optional | Alipay asyn notify url. |
|
249
|
+
|
250
|
+
This is not a complete list of arguments, please read official document: https://global.alipay.com/product/mobilepayments.html .
|
251
|
+
|
252
|
+
|
253
|
+
### 即时到账批量退款有密接口
|
254
|
+
|
255
|
+
#### Name
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
refund_fastpay_by_platform_pwd
|
259
|
+
```
|
260
|
+
|
261
|
+
#### Definition
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
Alipay::Service.refund_fastpay_by_platform_pwd_url
|
265
|
+
```
|
266
|
+
|
267
|
+
#### Example
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
batch_no = Alipay::Utils.generate_batch_no # refund batch no, you SHOULD store it to db to avoid alipay duplicate refund
|
271
|
+
Alipay::Service.refund_fastpay_by_platform_pwd_url(
|
272
|
+
batch_no: batch_no,
|
273
|
+
data: [{
|
274
|
+
trade_no: '201504010000001',
|
275
|
+
amount: '10.0',
|
276
|
+
reason: 'REFUND_REASON'
|
277
|
+
}],
|
278
|
+
notify_url: 'https://example.com/orders/20150401000-0001/refund_notify'
|
279
|
+
)
|
280
|
+
# => https://mapi.alipay.com/gateway.do?service=refund_fastpay_by_platform_pwd&...
|
281
|
+
```
|
282
|
+
|
283
|
+
#### Arguments
|
284
|
+
|
285
|
+
| Key | Requirement | Description |
|
286
|
+
| --- | ----------- | ----------- |
|
287
|
+
| batch_no | required | Refund batch no, you should store it to db to avoid alipay duplicate refund. |
|
288
|
+
| data | required | Refund data, a hash array. |
|
289
|
+
| notify_url | required | Alipay notify url. |
|
290
|
+
|
291
|
+
##### Data Item
|
292
|
+
|
293
|
+
| Key | Requirement | Description |
|
294
|
+
| --- | ----------- | ----------- |
|
295
|
+
| trade_no | required | Trade number in alipay system. |
|
296
|
+
| amount | required | Refund amount. |
|
297
|
+
| reason | required | Refund reason. Less than 256 bytes, could not contain special characters: ^ $ | #. |
|
298
|
+
|
299
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipaydirect.zip .
|
300
|
+
|
301
|
+
### 关闭交易接口
|
302
|
+
|
303
|
+
#### Name
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
close_trade
|
307
|
+
```
|
308
|
+
|
309
|
+
#### Definition
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
Alipay::Service.close_trade({ARGUMENTS}, {OPTIONS})
|
313
|
+
```
|
314
|
+
|
315
|
+
#### Example
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
Alipay::Service.close_trade(
|
319
|
+
trade_no: '201504010000001'
|
320
|
+
)
|
321
|
+
# => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success></alipay>'
|
322
|
+
|
323
|
+
# When fail
|
324
|
+
# => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>F</is_success> <error>TRADE_STATUS_NOT_AVAILD</error></alipay>'
|
325
|
+
```
|
326
|
+
|
327
|
+
#### ARGUMENTS
|
328
|
+
|
329
|
+
| Key | Requirement | Description |
|
330
|
+
| --- | ----------- | ----------- |
|
331
|
+
| out_order_no | optional * | Order number in your application. |
|
332
|
+
| trade_no | optional * | Trade number in alipay system. |
|
333
|
+
|
334
|
+
\* out_order_no and trade_no must have one.
|
335
|
+
|
336
|
+
### 单笔交易查询接口
|
337
|
+
|
338
|
+
#### Name
|
339
|
+
|
340
|
+
```ruby
|
341
|
+
single_trade_query
|
342
|
+
```
|
343
|
+
|
344
|
+
#### Definition
|
345
|
+
|
346
|
+
```ruby
|
347
|
+
Alipay::Service.single_trade_query({ARGUMENTS}, {OPTIONS})
|
348
|
+
```
|
349
|
+
|
350
|
+
#### Example
|
351
|
+
|
352
|
+
```ruby
|
353
|
+
Alipay::Service.single_trade_query(
|
354
|
+
trade_no: '201504010000001'
|
355
|
+
)
|
356
|
+
# => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success>...
|
357
|
+
```
|
358
|
+
|
359
|
+
#### ARGUMENTS
|
360
|
+
|
361
|
+
| Key | Requirement | Description |
|
362
|
+
| --- | ----------- | ----------- |
|
363
|
+
| out_trade_no | optional * | Order number in your application. |
|
364
|
+
| trade_no | optional * | Trade number in alipay system. |
|
365
|
+
|
366
|
+
\* out_trade_no and trade_no must have one.
|
367
|
+
|
368
|
+
### 境外收单接口
|
369
|
+
|
370
|
+
#### Name
|
371
|
+
|
372
|
+
```ruby
|
373
|
+
create_forex_trade
|
374
|
+
```
|
375
|
+
|
376
|
+
#### Definition
|
377
|
+
|
378
|
+
```ruby
|
379
|
+
Alipay::Service.create_forex_trade_url({ARGUMENTS}, {OPTIONS})
|
380
|
+
```
|
381
|
+
|
382
|
+
#### Example
|
383
|
+
|
384
|
+
```ruby
|
385
|
+
Alipay::Service.create_forex_trade_url(
|
386
|
+
out_trade_no: '20150401000-0001',
|
387
|
+
subject: 'Subject',
|
388
|
+
currency: 'USD',
|
389
|
+
total_fee: '10.00',
|
390
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
391
|
+
)
|
392
|
+
# => 'https://mapi.alipay.com/gateway.do?service=create_forex_trade...'
|
393
|
+
```
|
394
|
+
|
395
|
+
#### ARGUMENTS
|
396
|
+
|
397
|
+
| Key | Requirement | Description |
|
398
|
+
| --- | ----------- | ----------- |
|
399
|
+
| out_trade_no | required | Order number in your application. |
|
400
|
+
| subject | required | Order subject. |
|
401
|
+
| currency | required | Abbreviated currency name. |
|
402
|
+
| total_fee | required * | Order total price. |
|
403
|
+
| notify_url | optional | Alipay asyn notify url. |
|
404
|
+
|
405
|
+
\* total_fee can be replace by rmb_fee.
|
406
|
+
|
407
|
+
### 境外收单单笔退款接口
|
408
|
+
|
409
|
+
#### Name
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
forex_refund
|
413
|
+
```
|
414
|
+
|
415
|
+
#### Definition
|
416
|
+
|
417
|
+
```ruby
|
418
|
+
Alipay::Service.forex_refund_url({ARGUMENTS}, {OPTIONS})
|
419
|
+
```
|
420
|
+
|
421
|
+
#### Example
|
422
|
+
|
423
|
+
```ruby
|
424
|
+
Alipay::Service.forex_refund_url(
|
425
|
+
out_return_no: '20150401000-0001',
|
426
|
+
out_trade_no: '201504010000001',
|
427
|
+
return_amount: '10.00',
|
428
|
+
currency: 'USD',
|
429
|
+
reason: 'Reason',
|
430
|
+
gmt_return: '20150401000000'
|
431
|
+
)
|
432
|
+
```
|
433
|
+
|
434
|
+
#### ARGUMENTS
|
435
|
+
|
436
|
+
| Key | Requirement | Description |
|
437
|
+
| --- | ----------- | ----------- |
|
438
|
+
| out_return_no | required | Refund no, you should store it to db to avoid alipay duplicate refund. |
|
439
|
+
| out_trade_no | required | Order number in your application. |
|
440
|
+
| return_amount | required | Refund amount. |
|
441
|
+
| currency | required | Abbreviated currency name. |
|
442
|
+
| reason | required | Refun reason. |
|
443
|
+
| gmt_return | required * | YYYYMMDDHHMMSS Beijing Time. |
|
444
|
+
|
445
|
+
\* Auto set Time.now if not set.
|
446
|
+
|
447
|
+
### 账单明细分页查询接口
|
448
|
+
|
449
|
+
#### Name
|
450
|
+
|
451
|
+
```ruby
|
452
|
+
account.page.query
|
453
|
+
```
|
454
|
+
|
455
|
+
#### Definition
|
456
|
+
|
457
|
+
```ruby
|
458
|
+
Alipay::Service::account_page_query({PARAMS}, {OPTIONS})
|
459
|
+
```
|
460
|
+
|
461
|
+
#### Example
|
462
|
+
|
463
|
+
```ruby
|
464
|
+
Alipay::Service.account_page_query(
|
465
|
+
page_no: 1,
|
466
|
+
gmt_start_time: '2015-10-25 00:00:00',
|
467
|
+
gmt_end_time: '2015-10-26 00:00:00'
|
468
|
+
)
|
469
|
+
```
|
470
|
+
|
471
|
+
#### Arguments
|
472
|
+
|
473
|
+
It's an unpublic api, contact support for permission and document.
|
474
|
+
|
475
|
+
### 批量付款到支付宝账户接口
|
476
|
+
|
477
|
+
#### Name
|
478
|
+
|
479
|
+
```ruby
|
480
|
+
batch_trans_notify
|
481
|
+
```
|
482
|
+
|
483
|
+
#### Definition
|
484
|
+
|
485
|
+
```ruby
|
486
|
+
Alipay::Service::batch_trans_notify_url({PARAMS}, {OPTIONS})
|
487
|
+
```
|
488
|
+
|
489
|
+
#### Example
|
490
|
+
|
491
|
+
```ruby
|
492
|
+
Alipay::Service.batch_trans_notify_url(
|
493
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify',
|
494
|
+
account_name: '毛毛',
|
495
|
+
detail_data: '0315006^testture0002@126.com^常炜买家^1000.00^hello',
|
496
|
+
batch_no: '20080107001',
|
497
|
+
batch_num: 1,
|
498
|
+
batch_fee: 1000.00,
|
499
|
+
email: 'biz_932@alitest.com'
|
500
|
+
)
|
501
|
+
#=> 'https://mapi.alipay.com/gateway.do?service=batch_trans_notify&...'
|
502
|
+
```
|
503
|
+
|
504
|
+
#### Arguments
|
505
|
+
|
506
|
+
| Key | Requirement | Description |
|
507
|
+
| --- | ----------- | ----------- |
|
508
|
+
| notify_url | required | Alipay asyn notify url. |
|
509
|
+
| account_name | required | Alipay account name of payer. |
|
510
|
+
| detail_data | required | Payment data. |
|
511
|
+
| batch_no | required | Batch transaction number. |
|
512
|
+
| batch_num | required | Batch transaction count. |
|
513
|
+
| batch_fee | required | Batch transaction total amount. |
|
514
|
+
| email | required | Alipay email account of payer. |
|
515
|
+
|
516
|
+
Document: https://doc.open.alipay.com/doc2/detail?treeId=64&articleId=103773&docType=1
|
517
|
+
|
518
|
+
### 验证通知
|
519
|
+
|
520
|
+
#### Name
|
521
|
+
|
522
|
+
```ruby
|
523
|
+
notify_verify
|
524
|
+
```
|
525
|
+
|
526
|
+
#### Definition
|
527
|
+
|
528
|
+
```ruby
|
529
|
+
Alipay::Notify.verify?({PARAMS}, {OPTIONS})
|
530
|
+
```
|
531
|
+
|
532
|
+
#### Example
|
533
|
+
|
534
|
+
```ruby
|
535
|
+
# Rails
|
536
|
+
# params except :controller_name, :action_name, :host, etc.
|
537
|
+
notify_params = params.except(*request.path_parameters.keys)
|
538
|
+
|
539
|
+
Alipay::Notify.verify?(notify_params, options = {})
|
540
|
+
```
|
541
|
+
|
542
|
+
## Mobile::Service
|
543
|
+
|
544
|
+
### 移动支付接口
|
545
|
+
|
546
|
+
#### Name
|
547
|
+
|
548
|
+
```ruby
|
549
|
+
mobile.securitypay.pay
|
550
|
+
```
|
551
|
+
|
552
|
+
#### Definition
|
553
|
+
|
554
|
+
```ruby
|
555
|
+
Alipay::Mobile::Service.mobile_securitypay_pay_string({ARGUMENTS}, {OPTIONS})
|
556
|
+
```
|
557
|
+
|
558
|
+
#### Example
|
559
|
+
|
560
|
+
```ruby
|
561
|
+
Alipay::Mobile::Service.mobile_securitypay_pay_string(
|
562
|
+
out_trade_no: '20150401000-0001',
|
563
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
564
|
+
subject: 'subject',
|
565
|
+
total_fee: '10.00',
|
566
|
+
body: 'text'
|
567
|
+
)
|
568
|
+
# => service="mobile.securitypay.pay"&_input_charset="utf-8"&partner=...
|
569
|
+
```
|
570
|
+
|
571
|
+
#### ARGUMENTS
|
572
|
+
|
573
|
+
| Key | Requirement | Description |
|
574
|
+
| --- | ----------- | ----------- |
|
575
|
+
| out_trade_no | required | Order number in your application. |
|
576
|
+
| notify_url | required | Alipay asyn notify url. |
|
577
|
+
| subject | required | Order subject. |
|
578
|
+
| total_fee | required | Order total price. |
|
579
|
+
| body | required | Order body, less than 512 bytes. |
|
580
|
+
|
581
|
+
\* This service only support RSA sign_type.
|
582
|
+
|
583
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/WS_MOBILE_PAY_SDK_BASE.zip .
|
584
|
+
|
585
|
+
## Wap::Service
|
586
|
+
|
587
|
+
### 授权接口
|
588
|
+
|
589
|
+
#### Name
|
590
|
+
|
591
|
+
```ruby
|
592
|
+
alipay.wap.trade.create.direct
|
593
|
+
```
|
594
|
+
|
595
|
+
#### Definition
|
596
|
+
|
597
|
+
```ruby
|
598
|
+
Alipay::Wap::Service.trade_create_direct_token({ARGUMENTS}, {OPTIONS}}
|
599
|
+
```
|
600
|
+
|
601
|
+
#### Example
|
602
|
+
|
603
|
+
```ruby
|
604
|
+
token = Alipay::Wap::Service.trade_create_direct_token(
|
605
|
+
req_data: {
|
606
|
+
seller_account_name: 'account@example.com',
|
607
|
+
out_trade_no: '20150401000-0001',
|
608
|
+
subject: 'Subject',
|
609
|
+
total_fee: '10.0',
|
610
|
+
call_back_url: 'https://example.com/orders/20150401000-0001',
|
611
|
+
notify_url: 'https://example.com/orders/20150401000-0001/notify'
|
612
|
+
}
|
613
|
+
)
|
614
|
+
```
|
615
|
+
|
616
|
+
#### ARGUMENTS
|
617
|
+
|
618
|
+
| Key | Requirement | Description |
|
619
|
+
| --- | ----------- | ----------- |
|
620
|
+
| req_data | required | See req_data ARGUMENTS |
|
621
|
+
|
622
|
+
##### req_data ARGUMENTS
|
623
|
+
|
624
|
+
| Key | Requirement | Description |
|
625
|
+
| --- | ----------- | ----------- |
|
626
|
+
| seller_account_name | required | Alipay seller account. |
|
627
|
+
| out_order_no | required | Order id in your application. |
|
628
|
+
| subject | required | Order subject. |
|
629
|
+
| total_fee | required | Order total price. |
|
630
|
+
| return_url | optional | Redirect customer to this url after payment. |
|
631
|
+
| notify_url | optional | Alipay asyn notify url. |
|
632
|
+
|
633
|
+
This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/WS_WAP_PAYWAP.zip .
|
634
|
+
|
635
|
+
### 交易接口
|
636
|
+
|
637
|
+
#### Name
|
638
|
+
|
639
|
+
```ruby
|
640
|
+
alipay.wap.auth.authAndExecute
|
641
|
+
```
|
642
|
+
|
643
|
+
#### Definition
|
644
|
+
|
645
|
+
```ruby
|
646
|
+
Alipay::Wap::Service.auth_and_execute_url({ARGUMENTS}, {OPTIONS})
|
647
|
+
```
|
648
|
+
|
649
|
+
#### Example
|
650
|
+
|
651
|
+
```ruby
|
652
|
+
Alipay::Wap::Service.auth_and_execute_url(request_token: token)
|
653
|
+
```
|
654
|
+
#### ARGUMENTS
|
655
|
+
|
656
|
+
| Key | Requirement | Description |
|
657
|
+
| --- | ----------- | ----------- |
|
658
|
+
| request_token | required | Get from trade_create_direct_token |
|
659
|
+
|
660
|
+
### 风险探测服务接口
|
661
|
+
|
662
|
+
#### Name
|
663
|
+
|
664
|
+
```ruby
|
665
|
+
alipay.security.risk.detect
|
666
|
+
```
|
667
|
+
|
668
|
+
#### Definition
|
669
|
+
|
670
|
+
```ruby
|
671
|
+
Alipay::Wap::Service.security_risk_detect({ARGUMENTS}, {OPTIONS})
|
672
|
+
```
|
673
|
+
|
674
|
+
#### Example
|
675
|
+
|
676
|
+
```ruby
|
677
|
+
Alipay::Wap::Service.security_risk_detect({
|
678
|
+
order_no: '1',
|
679
|
+
order_credate_time: '1970-01-01 00:00:00',
|
680
|
+
order_category: 'TestCase^AlipayGem^Ruby',
|
681
|
+
order_item_name: 'item',
|
682
|
+
order_amount: '0.01',
|
683
|
+
buyer_account_no: '2088123123',
|
684
|
+
buyer_bind_mobile: '13600000000',
|
685
|
+
buyer_reg_date: '1970-01-01 00:00:00',
|
686
|
+
terminal_type: 'WAP'
|
687
|
+
}, {
|
688
|
+
sign_type: 'RSA',
|
689
|
+
key: RSA_PRIVATE_KEY
|
690
|
+
})
|
691
|
+
```
|
692
|
+
#### ARGUMENTS
|
693
|
+
|
694
|
+
| Key | Requirement | Description |
|
695
|
+
| --- | ----------- | ----------- |
|
696
|
+
| order_no | optional | Order id in your application. |
|
697
|
+
| order_credate_time | optional | Order created time. |
|
698
|
+
| order_category | optional | Categories of Order's items. using `^` as splitter. |
|
699
|
+
| order_item_name | optional | Order subject. |
|
700
|
+
| order_amount | optional | Order item's price. |
|
701
|
+
| buyer_account_no | optional | User id in your application. |
|
702
|
+
| buyer_reg_date | optional | User created time. |
|
703
|
+
| buyer_bind_mobile | optional | User mobile phone. |
|
704
|
+
| terminal_type | optional | The terminal type which user are using to request the payment, can be `MOBILE` for App, `WAP` for mobile, `WEB` for PC. |
|
705
|
+
|
706
|
+
### 验证通知
|
707
|
+
|
708
|
+
#### Name
|
709
|
+
|
710
|
+
```ruby
|
711
|
+
notify_verify
|
712
|
+
```
|
713
|
+
|
714
|
+
#### Definition
|
715
|
+
|
716
|
+
```ruby
|
717
|
+
Alipay::Wap::Notify.verify?({PARAMS}, {OPTIONS})
|
718
|
+
```
|
719
|
+
|
720
|
+
#### Example
|
721
|
+
|
722
|
+
```ruby
|
723
|
+
# Rails
|
724
|
+
# params except :controller_name, :action_name, :host, etc.
|
725
|
+
notify_params = params.except(*request.path_parameters.keys)
|
726
|
+
|
727
|
+
Alipay::Wap::Notify.verify?(notify_params)
|
728
|
+
```
|
729
|
+
|
730
|
+
## Contributing
|
731
|
+
|
732
|
+
Bug report or pull request are welcome.
|
733
|
+
|
734
|
+
### Make a pull request
|
735
|
+
|
736
|
+
1. Fork it
|
737
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
738
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
739
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
740
|
+
5. Create new Pull Request
|
741
|
+
|
742
|
+
Please write unit test with your code if necessary.
|
743
|
+
|
744
|
+
## Donate
|
745
|
+
|
746
|
+
Donate to maintainer let him make this gem better.
|
747
|
+
|
748
|
+
Alipay donate link: http://chloerei.com/donate/ .
|