alipay 0.13.0 → 0.14.0

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: 50fd317ffe0f09e6373ee108b7c639a86b26124b
4
- data.tar.gz: 59797caf889f4329bef61678c54f554725882f79
3
+ metadata.gz: 56fa9ffb9a707c4c25b499f1391790d4f6cc5474
4
+ data.tar.gz: 884b4d906a4081cba248165663911dd5280a35d1
5
5
  SHA512:
6
- metadata.gz: e268d0cab27568b13cecb7c3e9b4ad0e8598fbc06cd58b4dc2269baae4b6dd9961363a8c6ccee9ecfac204688df62d327ec409e751cc499820bddc2251f7deff
7
- data.tar.gz: 2b7cadd3ef6b1eb7192f8c0d541538a660a14433e296c6525da160ce9dec294f5bdcaad8a86b399e407b909337bd2e549315b404fa0e231bea3240c5cf61a270
6
+ metadata.gz: 85c28557052f7817d5b9723d8030b77b11c6f9c7ea91d6d242b4938e0afece3669174fe3cc46e709d40c46c647f35d126df8da78c641a3b9ef2faa61b822328f
7
+ data.tar.gz: 75865ab5a939cad580640768e240f4fae552fd26bdde50ae0a208253f64b9d61435c1e67be33409c0175375a4d11b136f288f51f4af3ae9d35d53cef21827ea1
@@ -1,8 +1,12 @@
1
1
  ## master
2
2
 
3
+ ## v0.13.0 (2016-12-28)
4
+
5
+ - Add `Alipay::App::Service.create_forex_trade_wap_url` method, thanks @xiaohesong #61
6
+
3
7
  ## v0.13.0 (2016-12-24)
4
8
 
5
- 1 Add `Alipay::App::Service.alipay_trade_app_pay` method, thanks @FX-HAO #64
9
+ - Add `Alipay::App::Service.alipay_trade_app_pay` method, thanks @FX-HAO #64
6
10
 
7
11
  ## v0.12.0 (2016-03-07)
8
12
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ Alipay official document: https://b.alipay.com/order/techService.htm .
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'alipay', '~> 0.13.0'
12
+ gem 'alipay', '~> 0.14.0'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -202,6 +202,52 @@ Alipay::Service.create_direct_pay_by_user_wap_url(
202
202
 
203
203
  This is not a complete list of arguments, please read official document: http://download.alipay.com/public/api/base/alipaywapdirect.zip .
204
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
+
205
251
  ### 即时到账批量退款有密接口
206
252
 
207
253
  #### Name
@@ -488,7 +534,7 @@ Alipay::Notify.verify?({PARAMS}, {OPTIONS})
488
534
  # params except :controller_name, :action_name, :host, etc.
489
535
  notify_params = params.except(*request.path_parameters.keys)
490
536
 
491
- Alipay::Notify.verify?(notify_params)
537
+ Alipay::Notify.verify?(notify_params, options = {})
492
538
  ```
493
539
 
494
540
  ## Mobile::Service
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "minitest"
24
- spec.add_development_dependency "fakeweb"
24
+ spec.add_development_dependency "webmock"
25
25
  end
@@ -194,6 +194,21 @@ module Alipay
194
194
  request_uri(params, options).to_s
195
195
  end
196
196
 
197
+ CREATE_FOREX_TRADE_WAP_REQUIRED_PARAMS = %w( out_trade_no subject merchant_url currency )
198
+ def self.create_forex_trade_wap_url(params, options = {})
199
+ params = Utils.stringify_keys(params)
200
+ check_required_params(params, CREATE_FOREX_TRADE_WAP_REQUIRED_PARAMS)
201
+
202
+ params = {
203
+ 'service' => 'create_forex_trade_wap',
204
+ '_input_charset' => 'utf-8',
205
+ 'partner' => options[:pid] || Alipay.pid,
206
+ 'seller_id' => options[:pid] || Alipay.pid
207
+ }.merge(params)
208
+
209
+ request_uri(params, options).to_s
210
+ end
211
+
197
212
  def self.request_uri(params, options = {})
198
213
  uri = URI(GATEWAY_URL)
199
214
  uri.query = URI.encode_www_form(sign_params(params, options))
@@ -1,3 +1,3 @@
1
1
  module Alipay
2
- VERSION = "0.13.0"
2
+ VERSION = "0.14.0"
3
3
  end
@@ -13,17 +13,23 @@ class Alipay::NotifyTest < Minitest::Test
13
13
  end
14
14
 
15
15
  def test_unsign_notify
16
- FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=1234", body: "true")
16
+ stub_request(
17
+ :get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=1234"
18
+ ).to_return(body: "true")
17
19
  assert !Alipay::Notify.verify?(@unsign_params)
18
20
  end
19
21
 
20
22
  def test_verify_notify_when_true
21
- FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=1234", body: "true")
23
+ stub_request(
24
+ :get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=1234"
25
+ ).to_return(body: "true")
22
26
  assert Alipay::Notify.verify?(@sign_params)
23
27
  end
24
28
 
25
29
  def test_verify_notify_when_false
26
- FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=1234", body: "false")
30
+ stub_request(
31
+ :get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=1234"
32
+ ).to_return(body: "false")
27
33
  assert !Alipay::Notify.verify?(@sign_params)
28
34
  end
29
35
  end
@@ -92,11 +92,10 @@ class Alipay::ServiceTest < Minitest::Test
92
92
  <is_success>T</is_success>
93
93
  </alipay>
94
94
  EOF
95
- FakeWeb.register_uri(
95
+ stub_request(
96
96
  :get,
97
- %r|https://mapi\.alipay\.com/gateway\.do.*|,
98
- body: response_body
99
- )
97
+ %r|https://mapi\.alipay\.com/gateway\.do.*|
98
+ ).to_return(body: response_body)
100
99
 
101
100
  assert_equal response_body, Alipay::Service.close_trade(
102
101
  out_order_no: '1'
@@ -144,11 +143,10 @@ class Alipay::ServiceTest < Minitest::Test
144
143
  <sign_type>MD5</sign_type>
145
144
  </alipay>
146
145
  EOF
147
- FakeWeb.register_uri(
146
+ stub_request(
148
147
  :get,
149
- %r|https://mapi\.alipay\.com/gateway\.do.*|,
150
- body: response_body
151
- )
148
+ %r|https://mapi\.alipay\.com/gateway\.do.*|
149
+ ).to_return(body: response_body)
152
150
 
153
151
  assert_equal response_body, Alipay::Service.single_trade_query(
154
152
  out_trade_no: '1'
@@ -162,11 +160,10 @@ class Alipay::ServiceTest < Minitest::Test
162
160
  <is_success>T</is_success>
163
161
  </alipay>
164
162
  EOF
165
- FakeWeb.register_uri(
163
+ stub_request(
166
164
  :get,
167
- %r|https://mapi\.alipay\.com/gateway\.do.*|,
168
- body: body
169
- )
165
+ %r|https://mapi\.alipay\.com/gateway\.do.*|
166
+ ).to_return(body: body)
170
167
 
171
168
  assert_equal body, Alipay::Service.send_goods_confirm_by_platform(
172
169
  trade_no: 'trade_no',
@@ -228,8 +225,9 @@ class Alipay::ServiceTest < Minitest::Test
228
225
  <sign_type>MD5</sign_type>
229
226
  </alipay>
230
227
  EOF
231
- FakeWeb.register_uri(:get, %r|https://mapi\.alipay\.com/gateway\.do.*|, :body => body)
232
-
228
+ stub_request(
229
+ :get, %r|https://mapi\.alipay\.com/gateway\.do.*|
230
+ ).to_return(:body => body)
233
231
  assert_equal body, Alipay::Service.account_page_query(
234
232
  page_no: 1,
235
233
  gmt_start_time: (Time.now - 1).strftime('%Y-%m-%d %H:%M:%S'),
@@ -237,6 +235,19 @@ class Alipay::ServiceTest < Minitest::Test
237
235
  )
238
236
  end
239
237
 
238
+ def test_create_forex_trade_wap_url
239
+ options = {
240
+ out_trade_no: '20150401000-0001',
241
+ subject: 'Order Name',
242
+ merchant_url: 'http://example.com/itemback',
243
+ total_fee: '10.00', #or rmb_fee, only one
244
+ currency: 'USD',
245
+ return_url: 'https://example.com/orders/20150401000-0001',
246
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
247
+ }
248
+ assert_equal 'https://mapi.alipay.com/gateway.do?service=create_forex_trade_wap&_input_charset=utf-8&partner=1000000000000000&seller_id=1000000000000000&out_trade_no=20150401000-0001&subject=Order+Name&merchant_url=http%3A%2F%2Fexample.com%2Fitemback&total_fee=10.00&currency=USD&return_url=https%3A%2F%2Fexample.com%2Forders%2F20150401000-0001&notify_url=https%3A%2F%2Fexample.com%2Forders%2F20150401000-0001%2Fnotify&sign_type=MD5&sign=f15d9e3d885c12f1a994048342c07bef', Alipay::Service.create_forex_trade_wap_url(options)
249
+ end
250
+
240
251
  def test_batch_trans_notify_url
241
252
  options = {
242
253
  notify_url: 'https://example.com/orders/20150401000-0001/notify',
@@ -16,17 +16,23 @@ class Alipay::Wap::NotifyTest < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_unsign_notify
19
- FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}", body: "true")
19
+ stub_request(
20
+ :get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}"
21
+ ).to_return(body: "true")
20
22
  assert !Alipay::Wap::Notify.verify?(@notify_params)
21
23
  end
22
24
 
23
25
  def test_verify_notify_when_true
24
- FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}", body: "true")
26
+ stub_request(
27
+ :get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}"
28
+ ).to_return(body: "true")
25
29
  assert Alipay::Wap::Notify.verify?(@sign_params)
26
30
  end
27
31
 
28
32
  def test_verify_notify_when_false
29
- FakeWeb.register_uri(:get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}", body: "false")
33
+ stub_request(
34
+ :get, "https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{@notify_id}"
35
+ ).to_return(body: "false")
30
36
  assert !Alipay::Wap::Notify.verify?(@sign_params)
31
37
  end
32
38
  end
@@ -17,11 +17,10 @@ class Alipay::Wap::ServiceTest < Minitest::Test
17
17
  &sign=SIGN
18
18
  EOS
19
19
 
20
- FakeWeb.register_uri(
20
+ stub_request(
21
21
  :get,
22
- %r|https://wappaygw\.alipay\.com/service/rest\.htm.*|,
23
- body: body
24
- )
22
+ %r|https://wappaygw\.alipay\.com/service/rest\.htm.*|
23
+ ).to_return(body: body)
25
24
 
26
25
  assert_equal token, Alipay::Wap::Service.trade_create_direct_token(
27
26
  req_data: {
@@ -39,10 +38,11 @@ class Alipay::Wap::ServiceTest < Minitest::Test
39
38
  end
40
39
 
41
40
  def test_security_risk_detect
42
- FakeWeb.register_uri(
41
+ stub_request(
43
42
  :post,
44
- %r|https://wappaygw\.alipay\.com/service/rest\.htm.*|,
45
- body: ''
43
+ %r|https://wappaygw\.alipay\.com/service/rest\.htm.*|
44
+ ).to_return(
45
+ body: ' '
46
46
  )
47
47
 
48
48
  params = {
@@ -62,6 +62,6 @@ class Alipay::Wap::ServiceTest < Minitest::Test
62
62
  key: TEST_RSA_PRIVATE_KEY
63
63
  }
64
64
 
65
- assert_equal '', Alipay::Wap::Service.security_risk_detect(params, options).body
65
+ assert_equal ' ', Alipay::Wap::Service.security_risk_detect(params, options).body
66
66
  end
67
67
  end
@@ -1,6 +1,6 @@
1
1
  require 'minitest/autorun'
2
2
  require 'alipay'
3
- require 'fakeweb'
3
+ require 'webmock/minitest'
4
4
 
5
5
  Alipay.pid = '1000000000000000'
6
6
  Alipay.key = '10000000000000000000000000000000'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alipay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-24 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: fakeweb
56
+ name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="