yl_alipay 0.15.2

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