alipay 0.6.0.beta1 → 0.6.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bab9b64bdcabb60a0b79b493c3e78593a054d7c1
4
- data.tar.gz: 07a77403d825afd35f50c31ddbc37ab8233db8eb
3
+ metadata.gz: 71cda0616aea582148d328443b0125336f53ccd7
4
+ data.tar.gz: 20c42fb725858fe8b9beb6f82d0c3d7868eb2048
5
5
  SHA512:
6
- metadata.gz: de941fe25b59b27f1945a216c70e6e9324564dfe222414dbcb4ed48a2df4c0fb485424d533c50c7f1aaed32a7c6f7b04f72839cf1e49cefe7ffcb204a4d035c2
7
- data.tar.gz: e27a47136177767eb98388791d2887b8ab8c4260920b6f220fe14cb13cf0760edc5969961ba785c2bc0f5478c840a64f1cf382c5d9b0f1cd16233bfd8c21497a
6
+ metadata.gz: a5f1bb00e7372766e6af487093e775efe68f9ac08bc55a1127babbb8998244bea7c41ab30e6346b4060f0e5c7de8c1ad25ff5df2abbffa8540a439350d43cbfa
7
+ data.tar.gz: c6d52bf5024cf63e171e044bf34d0b1782e4ad4a48a2fa7773156990b3b97f06edcad400c363e2e12708fc29bd98dcfa93638408cab3038e85589de29f1a4db2
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .idea
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ - 2.1.5
5
+ - 2.0.0
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- ## v0.6.0-beta1
1
+ ## v0.6.0.beta2 (2015-04-01)
2
+
3
+ - Move `Alipay::Service::Wap` to `Alipay::Wap::Service`
4
+ - Move `Alipay::Sign::Wap` to `Alipay::Wap::Sign`
5
+ - Move `Alipay::Notify::Wap` to `Alipay::Wap::Notify`
6
+ - Rename `Alipay::Service.create_forex_single_refund_url` to `Alipay::Service.forex_refund_url`
7
+ - Rename `Alipay::Service.create_forex_trade` to `Alipay::Service.create_forex_trade_url`
8
+ - Rename `Alipay::Service.create_refund_url` to `Alipay::Service.refund_fastpay_by_platform_pwd_url`
9
+ - All service methods accept `options` args to config pid, seller_email and key.
10
+
11
+ ## v0.6.0.beta1 (2015-03-26)
2
12
 
3
13
  Usage:
4
14
 
data/README.md CHANGED
@@ -1,214 +1,490 @@
1
1
  # Alipay
2
2
 
3
- A simple alipay ruby gem, without unnecessary magic or wraper, it's directly facing how alipay api works.
3
+ A unofficial alipay ruby gem.
4
4
 
5
- It contain this API:
5
+ Alipay official document: https://b.alipay.com/order/techService.htm .
6
6
 
7
- * Generate payment url (web, wap)
8
- * Send goods
9
- * Close trade
10
- * Verify notify (web, wap, app)
11
-
12
- Please read alipay official document first: https://b.alipay.com/order/techService.htm .
7
+ Master branch(v0.6.0) is in develop, checkout [v0.5.0](https://github.com/chloerei/alipay/tree/v0.5.0) if you want to use in production.
13
8
 
14
9
  ## Installation
15
10
 
16
11
  Add this line to your application's Gemfile:
17
12
 
18
13
  ```ruby
19
- gem 'alipay', '~> 0.5.0'
14
+ gem 'alipay', '~> 0.6.0.beta2'
20
15
  ```
21
16
 
22
- or development version
17
+ or master branch:
23
18
 
24
19
  ```ruby
25
- gem 'alipay', :github => 'chloerei/alipay'
20
+ gem 'alipay', github: 'chloerei/alipay'
26
21
  ```
27
22
 
28
23
  And then execute:
29
24
 
30
- ```sh
25
+ ```console
31
26
  $ bundle
32
27
  ```
33
28
 
34
- ## Usage
35
-
36
- ### Config
29
+ ## Configuration
37
30
 
38
31
  ```ruby
39
32
  Alipay.pid = 'YOUR_PID'
40
33
  Alipay.key = 'YOUR_KEY'
41
34
  Alipay.seller_email = 'YOUR_SELLER_EMAIL'
42
- Alipay.debug_mode = true # Default is true. Example for rails: !Rails.env.production?
35
+
36
+ #Alipay.sign_type = 'MD5' # Available values: MD5, RSA. Default is MD5
37
+ #Alipay.debug_mode = true # Enable parameter check. Default is true.
43
38
  ```
44
39
 
45
- ### Generate payment url for web
40
+ You can set default key, or pass a key directly to service method:
46
41
 
47
42
  ```ruby
48
- options = {
49
- :out_trade_no => 'YOUR_ORDER_ID',
50
- :subject => 'YOUR_ORDER_SUBJECCT',
51
- :logistics_type => 'DIRECT',
52
- :logistics_fee => '0',
53
- :logistics_payment => 'SELLER_PAY',
54
- :price => '10.00',
55
- :quantity => 12,
56
- :discount => '20.00',
57
- :return_url => 'YOUR_ORDER_RETURN_URL', # https://writings.io/orders/20130801000001
58
- :notify_url => 'YOUR_ORDER_NOTIFY_URL' # https://writings.io/orders/20130801000001/alipay_notify
59
- }
60
-
61
- Alipay::Service.create_partner_trade_by_buyer_url(options)
62
- # => 'https://mapi.alipay.com/gateway.do?out_trade_no=...'
43
+ Service.create_partner_trade_by_buyer_url({
44
+ out_trade_no: 'OUT_TRADE_NO',
45
+ # Order params...
46
+ }, {
47
+ pid: 'ANOTHER_PID',
48
+ key: 'ANOTHER_KEY',
49
+ seller_email: 'ANOTHER_SELLER_EMAIL'
50
+ })
63
51
  ```
64
52
 
65
- You can redirect user to this payment url, and user will see a payment page for his/her order.
53
+ ## Service
66
54
 
67
- Current support three payment type:
55
+ ### 担保交易收款接口
68
56
 
69
- Alipay::Service#create_partner_trade_by_buyer_url # 担保交易
70
- Alipay::Service#trade_create_by_buyer_url # 标准双接口
71
- Alipay::Service#create_direct_pay_by_user_url # 即时到帐
57
+ #### Name
72
58
 
73
- ### Generate payment url for wap
59
+ ```ruby
60
+ create_partner_trade_by_buyer
61
+ ```
62
+
63
+ #### Definition
74
64
 
75
65
  ```ruby
76
- options = {
77
- :req_data => {
78
- :out_trade_no => 'YOUR_ORDER_ID', # 20130801000001
79
- :subject => 'YOUR_ORDER_SUBJECCT', # Writings.io Base Account x 12
80
- :total_fee => 'TOTAL_FEE',
81
- :notify_url => 'YOUR_ORDER_NOTIFY_URL', # https://writings.io/orders/20130801000001/alipay_notify
82
- :call_back_url => 'YOUR_ORDER_RETURN_URL' # https://writings.io/orders/20130801000001
83
- }
84
- }
66
+ Alipay::Service.create_partner_trade_by_buyer_url({ARGUMENTS}, {OPTIONS})
67
+ ```
85
68
 
86
- token = Alipay::Service::Wap.trade_create_direct_token(options)
87
- Alipay::Service::Wap.auth_and_execute(request_token: token)
88
- # => 'http://wappaygw.alipay.com/service/rest.htm?req_data=...'
69
+ #### Example
70
+
71
+ ```ruby
72
+ Alipay::Service.create_partner_trade_by_buyer_url(
73
+ out_trade_no: '20150401000-0001',
74
+ subject: 'Order Name',
75
+ price: '10.00',
76
+ quantity: 12,
77
+ logistics_type: 'DIRECT',
78
+ logistics_fee: '0',
79
+ logistics_payment: 'SELLER_PAY',
80
+ return_url: 'https://example.com/orders/20150401000-0001',
81
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
82
+ )
83
+ # => 'https://mapi.alipay.com/gateway.do?service=create_partner_trade_by_buyer&...'
89
84
  ```
90
85
 
91
- You can redirect user to this payment url, and user will see a payment page for his/her order.
86
+ Guide consumer to this address to complete payment
87
+
88
+ #### Arguments
89
+
90
+ | Key | Requirement | Description |
91
+ | --- | ----------- | ----------- |
92
+ | out_order_no | required | Order id in your application. |
93
+ | subject | required | Order subject. |
94
+ | price | required | Order item's price. |
95
+ | quantity | required | Order item's quantity, total price is price * quantity. |
96
+ | logistics_type | required | Logistics type. Available values: POST, EXPRESS, EMS, DIRECT. |
97
+ | logistics_fee | required | Logistics fee. |
98
+ | logistics_payment | required | Who pay the logistics fee. Available values: BUYER_PAY, SELLER_PAY, BUYER_PAY_AFTER_RECEIVE. |
99
+ | return_url | optional | Redirect customer to this url after payment. |
100
+ | notify_url | optional | Alipay asyn notify url. |
92
101
 
93
- Current only support this payment type:
102
+ This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipayescow.zip .
94
103
 
95
- Alipay::Service::Wap.auth_and_execute # 即时到帐
104
+ ### 确认发货接口
96
105
 
97
- ### Send goods
106
+ #### Name
98
107
 
99
108
  ```ruby
100
- options = {
101
- :trade_no => 'TRADE_NO',
102
- :logistics_name => 'writings.io',
103
- :transport_type => 'DIRECT'
104
- }
109
+ send_goods_confirm_by_platform
110
+ ```
111
+
112
+ #### Definition
105
113
 
106
- Alipay::Service.send_goods_confirm_by_platform(options)
114
+ ```ruby
115
+ Alipay::Service.send_goods_confirm_by_platform({ARGUMENTS}, {OPTIONS})
116
+ ```
117
+
118
+ #### Example
119
+
120
+ ```ruby
121
+ Alipay::Service.send_goods_confirm_by_platform(
122
+ trade_no: '201504010000001',
123
+ logistics_name: 'example.com'
124
+ )
107
125
  # => '<!xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success></alipay>'
108
126
  ```
109
127
 
110
- ### Close trade
128
+ #### Arguments
129
+
130
+ | Key | Requirement | Description |
131
+ | --- | ----------- | ----------- |
132
+ | trade_no | required | Trade number in Alipay system, should get from notify message. |
133
+ | logistics_name | required | Logistics Name. |
134
+
135
+ This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipayescow.zip .
136
+
137
+ ### 即时到账收款接口
138
+
139
+ #### Name
140
+
141
+ ```ruby
142
+ create_direct_pay_by_user
143
+ ```
144
+
145
+ #### Definition
146
+
147
+ ```ruby
148
+ Alipay::Service.create_direct_pay_by_user_url({ARGUMENTS}, {OPTIONS})
149
+ ```
150
+
151
+ #### Example
152
+
153
+ ```ruby
154
+ Alipay::Service.create_direct_pay_by_user_url(
155
+ out_trade_no: '20150401000-0001',
156
+ subject: 'Order Name',
157
+ price: '10.00',
158
+ quantity: 12,
159
+ return_url: 'https://example.com/orders/20150401000-0001',
160
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
161
+ )
162
+ ```
163
+
164
+ #### Arguments
165
+
166
+ | Key | Requirement | Description |
167
+ | --- | ----------- | ----------- |
168
+ | out_order_no | required | Order id in your application. |
169
+ | subject | required | Order subject. |
170
+ | price | required * | Order item's price. |
171
+ | quantity | required * | Order item's quantity, total price is price * quantity. |
172
+ | return_url | optional | Redirect customer to this url after payment. |
173
+ | notify_url | optional | Alipay asyn notify url. |
174
+
175
+ \* Can be replaced by total_fee. When total_fee is set, price and quantity could not be set.
176
+
177
+ This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipaydirect.zip .
178
+
179
+ ### 即时到账批量退款有密接口
180
+
181
+ #### Name
182
+
183
+ ```ruby
184
+ refund_fastpay_by_platform_pwd
185
+ ```
186
+
187
+ #### Definition
188
+
189
+ ```ruby
190
+ Alipay::Service.refund_fastpay_by_platform_pwd_url
191
+ ```
192
+
193
+ #### Example
194
+
195
+ ```ruby
196
+ batch_no = Alipay::Utils.generate_batch_no # refund batch no, you SHOULD store it to db to avoid alipay duplicate refund
197
+ Alipay::Service.refund_fastpay_by_platform_pwd_url(
198
+ batch_no: batch_no,
199
+ data: [{
200
+ trade_no: '201504010000001',
201
+ amount: '10.0',
202
+ reason: 'REFUND_REASON'
203
+ }],
204
+ notify_url: 'https://example.com/orders/20150401000-0001/refund_notify'
205
+ )
206
+ # => https://mapi.alipay.com/gateway.do?service=refund_fastpay_by_platform_pwd&...
207
+ ```
208
+
209
+ #### Arguments
210
+
211
+ | Key | Requirement | Description |
212
+ | --- | ----------- | ----------- |
213
+ | batch_no | required | Refund batch no, you should store it to db to avoid alipay duplicate refund. |
214
+ | data | required | Refund data, a hash array. |
215
+ | notify_url | required | Alipay notify url. |
216
+
217
+ ##### Data Item
218
+
219
+ | Key | Requirement | Description |
220
+ | --- | ----------- | ----------- |
221
+ | trade_no | required | Trade number in alipay system. |
222
+ | amount | required | Refund amount. |
223
+ | reason | required | Refund reason. Less than 256 bytes, could not contain special characters: ^ $ &#124; #. |
224
+
225
+ This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipaydirect.zip .
226
+
227
+ ### 关闭交易接口
228
+
229
+ #### Name
230
+
231
+ ```ruby
232
+ close_trade
233
+ ```
234
+
235
+ #### Definition
236
+
237
+ ```ruby
238
+ Alipay::Service.close_trade({ARGUMENTS}, {OPTIONS})
239
+ ```
240
+
241
+ #### Example
111
242
 
112
243
  ```ruby
113
244
  Alipay::Service.close_trade(
114
- :trade_no => 'TRADE_NO',
115
- :out_order_no => 'the-out-order-no'
245
+ trade_no: '201504010000001'
116
246
  )
117
247
  # => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success></alipay>'
248
+
249
+ # When fail
250
+ # => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>F</is_success> <error>TRADE_STATUS_NOT_AVAILD</error></alipay>'
118
251
  ```
119
252
 
120
- You must specify either `trade_no` or `out_order_no`.
253
+ #### ARGUMENTS
254
+
255
+ | Key | Requirement | Description |
256
+ | --- | ----------- | ----------- |
257
+ | out_order_no | optional * | Order number in your application. |
258
+ | trade_no | optional * | Trade number in alipay system. |
259
+
260
+ \* out_order_no and trade_no must have one.
121
261
 
122
- If Alipay fail to close trade, this method will return XML similar to:
262
+ ### 单笔交易查询接口
123
263
 
124
- ```xml
125
- <?xml version="1.0" encoding="utf-8"?>
126
- <alipay>
127
- <is_success>F</is_success>
128
- <error>TRADE_STATUS_NOT_AVAILD</error>
129
- </alipay>
264
+ #### Name
265
+
266
+ ```ruby
267
+ single_trade_query
130
268
  ```
131
269
 
132
- ## Single trade query
270
+ #### Definition
133
271
 
134
- The parameters same as [Close trade](#user-content-close-trade)
272
+ ```ruby
273
+ Alipay::Service.single_trade_query({ARGUMENTS}, {OPTIONS})
274
+ ```
275
+
276
+ #### Example
135
277
 
136
278
  ```ruby
137
279
  Alipay::Service.single_trade_query(
138
- :trade_no => 'TRADE_NO',
139
- :out_order_no => 'the-out-order-no'
280
+ trade_no: '201504010000001'
140
281
  )
141
- # => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success><request><param name="trade_no">TRADE_NO</param><param name="_input_charset">utf-8</param><param name="service">single_trade_query</param><param name="partner">PARTNER</param></request><response><trade><additional_trade_status>DAEMON_CONFIRM_CLOSE</additional_trade_status><buyer_email>foo@gmail.com</buyer_email><buyer_id>BUYER_ID</buyer_id><discount>0.00</discount><flag_trade_locked>0</flag_trade_locked><gmt_close>2015-01-20 02:37:00</gmt_close><gmt_create>2015-01-20 02:17:00</gmt_create><gmt_last_modified_time>2015-01-20 02:37:00</gmt_last_modified_time><is_total_fee_adjust>F</is_total_fee_adjust><operator_role>B</operator_role><out_trade_no>OUT_TRADE_NO</out_trade_no><payment_type>1</payment_type><price>640.00</price><quantity>1</quantity><seller_email>bar@example.com</seller_email><seller_id>SELLER_ID</seller_id><subject>YOUR ORDER SUBJECT</subject><to_buyer_fee>0.00</to_buyer_fee><to_seller_fee>0.00</to_seller_fee><total_fee>640.00</total_fee><trade_no>TRADE_NO</trade_no><trade_status>TRADE_CLOSED</trade_status><use_coupon>F</use_coupon></trade></response><sign>SIGN</sign><sign_type>MD5</sign_type></alipay>'
282
+ # => '<?xml version="1.0" encoding="utf-8"?><alipay><is_success>T</is_success>...
142
283
  ```
143
284
 
144
- ### Refund
285
+ #### ARGUMENTS
286
+
287
+ | Key | Requirement | Description |
288
+ | --- | ----------- | ----------- |
289
+ | out_trade_no | optional * | Order number in your application. |
290
+ | trade_no | optional * | Trade number in alipay system. |
291
+
292
+ \* out_trade_no and trade_no must have one.
293
+
294
+ ### 境外收单接口
295
+
296
+ #### Name
145
297
 
146
298
  ```ruby
147
- batch_no = Alipay::Utils.generate_batch_no # refund batch no, you SHOULD store it to db to avoid alipay duplicate refund
148
- options = {
149
- batch_no: batch_no,
150
- data: [{:trade_no => 'TRADE_NO', :amount => '10.0', :reason => 'REFUND_REASON'}],
151
- notify_url: 'YOUR_ORDER_NOTIFY_URL' # https://writings.io/orders/20130801000001/alipay_refund_notify
152
- }
153
-
154
- Alipay::Service.create_refund_url(options)
155
- ```
156
-
157
- Batch No. Generate Demo: http://git.io/GcXKJw
158
- Notify Url Demo: http://git.io/pst4Tw
159
-
160
- ### Verify notify
161
-
162
- ```ruby
163
- # Example in rails,
164
- # notify url MUST be set when generate payment url
165
-
166
- def alipay_web_notify
167
- # except :controller_name, :action_name, :host, etc.
168
- notify_params = params.except(*request.path_parameters.keys)
169
-
170
- if Alipay::Notify.verify?(notify_params)
171
- # Valid notify, code your business logic.
172
- # trade_status is base on your payment type
173
- # Example:
174
- #
175
- # case params[:trade_status]
176
- # when 'WAIT_BUYER_PAY'
177
- # when 'WAIT_SELLER_SEND_GOODS'
178
- # when 'TRADE_FINISHED'
179
- # when 'TRADE_CLOSED'
180
- # end
181
- render :text => 'success'
182
- else
183
- render :text => 'error'
184
- end
185
- end
186
-
187
- def alipay_wap_notify
188
- # except :controller_name, :action_name, :host, etc.
189
- notify_params = params.except(*request.path_parameters.keys)
190
-
191
- if Alipay::Notify::Wap.verify?(notify_params)
192
- # valid notify, code your business logic.
193
- # you may want to get you order id:
194
- # order_id = Hash.from_xml(params[:notify_data])['notify']['out_trade_no']
195
- render :text => 'success'
196
- else
197
- render :text => 'error'
198
- end
199
- end
200
-
201
- def alipay_app_notify
202
- # except :controller_name, :action_name, :host, etc.
203
- notify_params = params.except(*request.path_parameters.keys)
204
-
205
- if Alipay::Notify::App.verify?(notify_params)
206
- # valid notify, code your business logic.
207
- render :text => 'success'
208
- else
209
- render :text => 'error'
210
- end
211
- end
299
+ create_forex_trade
300
+ ```
301
+
302
+ #### Definition
303
+
304
+ ```ruby
305
+ Alipay::Service.create_forex_trade_url({ARGUMENTS}, {OPTIONS})
306
+ ```
307
+
308
+ #### Example
309
+
310
+ ```ruby
311
+ Alipay::Service.create_forex_trade_url(
312
+ out_trade_no: '20150401000-0001',
313
+ subject: 'Subject',
314
+ currency: 'USD',
315
+ total_fee: '10.00',
316
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
317
+ )
318
+ # => 'https://mapi.alipay.com/gateway.do?service=create_forex_trade...'
319
+ ```
320
+
321
+ #### ARGUMENTS
322
+
323
+ | Key | Requirement | Description |
324
+ | --- | ----------- | ----------- |
325
+ | out_trade_no | required | Order number in your application. |
326
+ | subject | required | Order subject. |
327
+ | currency | required | Abbreviated currency name. |
328
+ | total_fee | required | Order total price. |
329
+ | notify_url | optional | Alipay asyn notify url. |
330
+
331
+ ### 境外收单单笔退款接口
332
+
333
+ #### Name
334
+
335
+ ```ruby
336
+ forex_refund
337
+ ```
338
+
339
+ #### Definition
340
+
341
+ ```ruby
342
+ Alipay::Service.forex_refund_url({ARGUMENTS}, {OPTIONS})
343
+ ```
344
+
345
+ #### Example
346
+
347
+ ```ruby
348
+ Alipay::Service.forex_refund_url(
349
+ out_return_no: '20150401000-0001',
350
+ out_trade_no: '201504010000001',
351
+ return_amount: '10.00',
352
+ currency: 'USD',
353
+ reason: 'Reason',
354
+ gmt_return: '2015-04-01 00:00:00'
355
+ )
356
+ ```
357
+
358
+ #### ARGUMENTS
359
+
360
+ | Key | Requirement | Description |
361
+ | --- | ----------- | ----------- |
362
+ | out_return_no | required | Refund no, you should store it to db to avoid alipay duplicate refund. |
363
+ | out_trade_no | required | Order number in your application. |
364
+ | return_amount | required | Refund amount. |
365
+ | currency | required | Abbreviated currency name. |
366
+ | reason | required | Refun reason. |
367
+ | notify_url | optional | Alipay asyn notify url. |
368
+
369
+ ### 验证通知
370
+
371
+ #### Name
372
+
373
+ ```ruby
374
+ notify_verify
375
+ ```
376
+
377
+ #### Definition
378
+
379
+ ```ruby
380
+ Alipay::Notify.verify?({PARAMS}, {OPTIONS})
381
+ ```
382
+
383
+ #### Example
384
+
385
+ ```ruby
386
+ # Rails
387
+ # params except :controller_name, :action_name, :host, etc.
388
+ notify_params = params.except(*request.path_parameters.keys)
389
+
390
+ Alipay::Notify.verify?(notify_params)
391
+ ```
392
+
393
+ ## Wap::Service
394
+
395
+ ### 授权接口
396
+
397
+ #### Name
398
+
399
+ ```ruby
400
+ alipay.wap.trade.create.direct
401
+ ```
402
+
403
+ #### Definition
404
+
405
+ ```ruby
406
+ Alipay::Wap::Service.trade_create_direct_token({ARGUMENTS}, {OPTIONS}}
407
+ ```
408
+
409
+ #### Example
410
+
411
+ ```ruby
412
+ token = Alipay::Wap::Service.trade_create_direct_token(
413
+ req_data: {
414
+ out_trade_no: '20150401000-0001',
415
+ subject: 'Subject',
416
+ total_fee: '10.0',
417
+ call_back_url: 'https://example.com/orders/20150401000-0001',
418
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
419
+ }
420
+ )
421
+ ```
422
+
423
+ #### ARGUMENTS
424
+
425
+ | Key | Requirement | Description |
426
+ | --- | ----------- | ----------- |
427
+ | req_data | required | See req_data ARGUMENTS |
428
+
429
+ ##### req_data ARGUMENTS
430
+
431
+ | Key | Requirement | Description |
432
+ | --- | ----------- | ----------- |
433
+ | out_order_no | required | Order id in your application. |
434
+ | subject | required | Order subject. |
435
+ | total_fee | required | Order total price. |
436
+ | return_url | optional | Redirect customer to this url after payment. |
437
+ | notify_url | optional | Alipay asyn notify url. |
438
+
439
+ This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/WS_WAP_PAYWAP.zip .
440
+
441
+ ### 交易接口
442
+
443
+ #### Name
444
+
445
+ ```ruby
446
+ alipay.wap.auth.authAndExecute
447
+ ```
448
+
449
+ #### Definition
450
+
451
+ ```ruby
452
+ Alipay::Wap::Service.auth_and_execute({ARGUMENTS}, {OPTIONS})
453
+ ```
454
+
455
+ #### Example
456
+
457
+ ```ruby
458
+ Alipay::Wap::Service.auth_and_execute(request_token: token)
459
+ ```
460
+ #### ARGUMENTS
461
+
462
+ | Key | Requirement | Description |
463
+ | --- | ----------- | ----------- |
464
+ | request_token | required | Get from trade_create_direct_token |
465
+
466
+ ### 验证通知
467
+
468
+ #### Name
469
+
470
+ ```ruby
471
+ notify_verify
472
+ ```
473
+
474
+ #### Definition
475
+
476
+ ```ruby
477
+ Alipay::Wap::Notify.verify?({PARAMS}, {OPTIONS})
478
+ ```
479
+
480
+ #### Example
481
+
482
+ ```ruby
483
+ # Rails
484
+ # params except :controller_name, :action_name, :host, etc.
485
+ notify_params = params.except(*request.path_parameters.keys)
486
+
487
+ Alipay::Wap::Notify.verify?(notify_params)
212
488
  ```
213
489
 
214
490
  ## Contributing