alipay 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +3 -3
- data/lib/alipay.rb +1 -1
- data/lib/alipay/service.rb +7 -8
- data/lib/alipay/version.rb +1 -1
- data/lib/alipay/wap/service.rb +1 -5
- data/test/alipay/service_test.rb +6 -6
- data/test/alipay/wap/service_test.rb +1 -0
- data/test/test_helper.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cba89bf78148b68186fbd85be4e3a3706e9984e6
|
4
|
+
data.tar.gz: 73fb6cda8aeadaf9e2ae410f8f57ef0caa114a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f42e34e9bc32e03aee68c35f9362ecca8b0301ca083ee154b8ce4fedda2144a93988a0fb19e5504e23458b2e962aa0938801158deb4068821652548da81adba6
|
7
|
+
data.tar.gz: 0f83397abf71b492a9882809dbf84adf697e15c7dea85be1257c17988b282493798e504f9790a3ff73503863f320d4e2bca6a974ac157257a3ed9f7f6422e924
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
##
|
1
|
+
## v0.7.0 (2015-04-07)
|
2
|
+
|
3
|
+
- Remove Alipay.seller_email setting, it can be replaced by seller_id, than same with pid.
|
4
|
+
- Alipay::Wap::Service.trade_create_direct_token add a required params: seller_account_name.
|
5
|
+
|
6
|
+
|
7
|
+
## v0.6.0 (2015-04-06)
|
2
8
|
|
3
9
|
New API:
|
4
10
|
|
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.
|
12
|
+
gem 'alipay', '~> 0.7.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -23,7 +23,6 @@ $ bundle
|
|
23
23
|
```ruby
|
24
24
|
Alipay.pid = 'YOUR_PID'
|
25
25
|
Alipay.key = 'YOUR_KEY'
|
26
|
-
Alipay.seller_email = 'YOUR_SELLER_EMAIL'
|
27
26
|
|
28
27
|
#Alipay.sign_type = 'MD5' # Available values: MD5, RSA. Default is MD5
|
29
28
|
#Alipay.debug_mode = true # Enable parameter check. Default is true.
|
@@ -38,7 +37,6 @@ Service.create_partner_trade_by_buyer_url({
|
|
38
37
|
}, {
|
39
38
|
pid: 'ANOTHER_PID',
|
40
39
|
key: 'ANOTHER_KEY',
|
41
|
-
seller_email: 'ANOTHER_SELLER_EMAIL'
|
42
40
|
})
|
43
41
|
```
|
44
42
|
|
@@ -445,6 +443,7 @@ Alipay::Wap::Service.trade_create_direct_token({ARGUMENTS}, {OPTIONS}}
|
|
445
443
|
```ruby
|
446
444
|
token = Alipay::Wap::Service.trade_create_direct_token(
|
447
445
|
req_data: {
|
446
|
+
seller_account_name: 'account@example.com',
|
448
447
|
out_trade_no: '20150401000-0001',
|
449
448
|
subject: 'Subject',
|
450
449
|
total_fee: '10.0',
|
@@ -464,6 +463,7 @@ token = Alipay::Wap::Service.trade_create_direct_token(
|
|
464
463
|
|
465
464
|
| Key | Requirement | Description |
|
466
465
|
| --- | ----------- | ----------- |
|
466
|
+
| seller_account_name | required | Alipay seller account. |
|
467
467
|
| out_order_no | required | Order id in your application. |
|
468
468
|
| subject | required | Order subject. |
|
469
469
|
| total_fee | required | Order total price. |
|
data/lib/alipay.rb
CHANGED
data/lib/alipay/service.rb
CHANGED
@@ -12,7 +12,7 @@ module Alipay
|
|
12
12
|
'service' => 'create_partner_trade_by_buyer',
|
13
13
|
'_input_charset' => 'utf-8',
|
14
14
|
'partner' => options[:pid] || Alipay.pid,
|
15
|
-
'
|
15
|
+
'seller_id' => options[:pid] || Alipay.pid,
|
16
16
|
'payment_type' => '1'
|
17
17
|
}.merge(params)
|
18
18
|
|
@@ -29,7 +29,7 @@ module Alipay
|
|
29
29
|
'service' => 'trade_create_by_buyer',
|
30
30
|
'_input_charset' => 'utf-8',
|
31
31
|
'partner' => options[:pid] || Alipay.pid,
|
32
|
-
'
|
32
|
+
'seller_id' => options[:pid] || Alipay.pid,
|
33
33
|
'payment_type' => '1'
|
34
34
|
}.merge(params)
|
35
35
|
|
@@ -50,7 +50,7 @@ module Alipay
|
|
50
50
|
'service' => 'create_direct_pay_by_user',
|
51
51
|
'_input_charset' => 'utf-8',
|
52
52
|
'partner' => options[:pid] || Alipay.pid,
|
53
|
-
'
|
53
|
+
'seller_id' => options[:pid] || Alipay.pid,
|
54
54
|
'payment_type' => '1'
|
55
55
|
}.merge(params)
|
56
56
|
|
@@ -73,7 +73,7 @@ module Alipay
|
|
73
73
|
'service' => 'refund_fastpay_by_platform_pwd', # 接口名称
|
74
74
|
'_input_charset' => 'utf-8',
|
75
75
|
'partner' => options[:pid] || Alipay.pid,
|
76
|
-
'
|
76
|
+
'seller_user_id' => options[:pid] || Alipay.pid,
|
77
77
|
'refund_date' => Time.now.strftime('%Y-%m-%d %H:%M:%S'), # 申请退款时间
|
78
78
|
'batch_num' => data.size, # 总笔数
|
79
79
|
'detail_data' => detail_data # 转换后的单笔数据集字符串
|
@@ -129,7 +129,6 @@ module Alipay
|
|
129
129
|
'service' => 'create_forex_trade',
|
130
130
|
'_input_charset' => 'utf-8',
|
131
131
|
'partner' => options[:pid] || Alipay.pid,
|
132
|
-
'seller_email' => options[:seller_email] || Alipay.seller_email
|
133
132
|
}.merge(params)
|
134
133
|
|
135
134
|
request_uri(params, options).to_s
|
@@ -171,11 +170,11 @@ module Alipay
|
|
171
170
|
raise ArgumentError, "only support RSA sign_type" if sign_type != 'RSA'
|
172
171
|
|
173
172
|
params = {
|
173
|
+
'service' => 'mobile.securitypay.pay',
|
174
174
|
'_input_charset' => 'utf-8',
|
175
175
|
'partner' => options[:pid] || Alipay.pid,
|
176
|
-
'seller_id' => options[:
|
177
|
-
'payment_type' => '1'
|
178
|
-
'service' => 'mobile.securitypay.pay'
|
176
|
+
'seller_id' => options[:pid] || Alipay.pid,
|
177
|
+
'payment_type' => '1'
|
179
178
|
}.merge(params)
|
180
179
|
|
181
180
|
request_uri(params, options).to_s
|
data/lib/alipay/version.rb
CHANGED
data/lib/alipay/wap/service.rb
CHANGED
@@ -4,7 +4,7 @@ module Alipay
|
|
4
4
|
GATEWAY_URL = 'https://wappaygw.alipay.com/service/rest.htm'
|
5
5
|
|
6
6
|
TRADE_CREATE_DIRECT_TOKEN_REQUIRED_PARAMS = %w( req_data )
|
7
|
-
REQ_DATA_REQUIRED_PARAMS = %w( subject out_trade_no total_fee call_back_url )
|
7
|
+
REQ_DATA_REQUIRED_PARAMS = %w( seller_account_name subject out_trade_no total_fee call_back_url )
|
8
8
|
def self.trade_create_direct_token(params, options = {})
|
9
9
|
params = Utils.stringify_keys(params)
|
10
10
|
Alipay::Service.check_required_params(params, TRADE_CREATE_DIRECT_TOKEN_REQUIRED_PARAMS)
|
@@ -12,10 +12,6 @@ module Alipay
|
|
12
12
|
req_data = Utils.stringify_keys(params.delete('req_data'))
|
13
13
|
Alipay::Service.check_required_params(req_data, REQ_DATA_REQUIRED_PARAMS)
|
14
14
|
|
15
|
-
req_data = {
|
16
|
-
'seller_account_name' => options[:seller_email] || Alipay.seller_email
|
17
|
-
}.merge(req_data)
|
18
|
-
|
19
15
|
xml = req_data.map {|k, v| "<#{k}>#{v.encode(:xml => :text)}</#{k}>" }.join
|
20
16
|
req_data_xml = "<direct_trade_create_req>#{xml}</direct_trade_create_req>"
|
21
17
|
|
data/test/alipay/service_test.rb
CHANGED
@@ -12,7 +12,7 @@ class Alipay::ServiceTest < Minitest::Test
|
|
12
12
|
quantity: 1
|
13
13
|
}
|
14
14
|
|
15
|
-
assert_equal 'https://mapi.alipay.com/gateway.do?service=create_partner_trade_by_buyer&_input_charset=utf-8&partner=1000000000000000&
|
15
|
+
assert_equal 'https://mapi.alipay.com/gateway.do?service=create_partner_trade_by_buyer&_input_charset=utf-8&partner=1000000000000000&seller_id=1000000000000000&payment_type=1&out_trade_no=1&subject=test&logistics_type=POST&logistics_fee=0&logistics_payment=SELLER_PAY&price=0.01&quantity=1&sign_type=MD5&sign=b5d30863b44acd8514a49b0320fb2aa2', Alipay::Service.create_partner_trade_by_buyer_url(options)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_generate_trade_create_by_buyer_url
|
@@ -25,7 +25,7 @@ class Alipay::ServiceTest < Minitest::Test
|
|
25
25
|
price: '0.01',
|
26
26
|
quantity: 1
|
27
27
|
}
|
28
|
-
assert_equal 'https://mapi.alipay.com/gateway.do?service=trade_create_by_buyer&_input_charset=utf-8&partner=1000000000000000&
|
28
|
+
assert_equal 'https://mapi.alipay.com/gateway.do?service=trade_create_by_buyer&_input_charset=utf-8&partner=1000000000000000&seller_id=1000000000000000&payment_type=1&out_trade_no=1&subject=test&logistics_type=POST&logistics_fee=0&logistics_payment=SELLER_PAY&price=0.01&quantity=1&sign_type=MD5&sign=2d296368fea70a127da939558c970bab', Alipay::Service.trade_create_by_buyer_url(options)
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_generate_create_direct_pay_by_user_url
|
@@ -35,7 +35,7 @@ class Alipay::ServiceTest < Minitest::Test
|
|
35
35
|
price: '0.01',
|
36
36
|
quantity: 1
|
37
37
|
}
|
38
|
-
assert_equal 'https://mapi.alipay.com/gateway.do?service=create_direct_pay_by_user&_input_charset=utf-8&partner=1000000000000000&
|
38
|
+
assert_equal 'https://mapi.alipay.com/gateway.do?service=create_direct_pay_by_user&_input_charset=utf-8&partner=1000000000000000&seller_id=1000000000000000&payment_type=1&out_trade_no=1&subject=test&price=0.01&quantity=1&sign_type=MD5&sign=682ad02280fca7d4c0fd22678fdddeef', Alipay::Service.create_direct_pay_by_user_url(options)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_refund_fastpay_by_platform_pwd_url
|
@@ -50,7 +50,7 @@ class Alipay::ServiceTest < Minitest::Test
|
|
50
50
|
notify_url: '/some_url',
|
51
51
|
refund_date: '2015-01-01 00:00:00'
|
52
52
|
}
|
53
|
-
assert_equal
|
53
|
+
assert_equal 'https://mapi.alipay.com/gateway.do?service=refund_fastpay_by_platform_pwd&_input_charset=utf-8&partner=1000000000000000&seller_user_id=1000000000000000&refund_date=2015-01-01+00%3A00%3A00&batch_num=1&detail_data=1%5E0.01%5Etest&batch_no=123456789¬ify_url=%2Fsome_url&sign_type=MD5&sign=def57a58e1ac21f70c45e41bd3697368', Alipay::Service.refund_fastpay_by_platform_pwd_url(options)
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_forex_refund_url
|
@@ -73,7 +73,7 @@ class Alipay::ServiceTest < Minitest::Test
|
|
73
73
|
currency: 'EUR',
|
74
74
|
total_fee: '0.01',
|
75
75
|
}
|
76
|
-
assert_equal 'https://mapi.alipay.com/gateway.do?service=create_forex_trade&_input_charset=utf-8&partner=1000000000000000&
|
76
|
+
assert_equal 'https://mapi.alipay.com/gateway.do?service=create_forex_trade&_input_charset=utf-8&partner=1000000000000000¬ify_url=https%3A%2F%2Fexample.com%2Fnotify&subject=test&out_trade_no=1¤cy=EUR&total_fee=0.01&sign_type=MD5&sign=f24fd4d76acabf860263a40805138380', Alipay::Service.create_forex_trade_url(options)
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_close_trade
|
@@ -167,7 +167,7 @@ class Alipay::ServiceTest < Minitest::Test
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def test_mobile_security_pay_url
|
170
|
-
assert_equal 'https://mapi.alipay.com/gateway.do?_input_charset=utf-8&partner=1000000000000000&seller_id=
|
170
|
+
assert_equal 'https://mapi.alipay.com/gateway.do?service=mobile.securitypay.pay&_input_charset=utf-8&partner=1000000000000000&seller_id=1000000000000000&payment_type=1&out_trade_no=1¬ify_url=%2Fsome_url&subject=subject&total_fee=0.01&body=test&sign_type=RSA&sign=EuHBKhLyXFBFM28s8nNM45r4gIWccPijVl8SHAmRaAC11wFNRiOfc3jEzJYJ%0A%2FADJNytARSNVSu3vXvRWhsNDHE9%2F%2BkFRckoXjjC10IApWa8bN7%2ByfHQk2w88%0AkDEVfv9Z%2F0t%2B8yHZD0Po4OBBHoEC9d%2FodPZYBElfcQvJ5vilQsc%3D%0A', Alipay::Service.mobile_security_pay_url({
|
171
171
|
out_trade_no: '1',
|
172
172
|
notify_url: '/some_url',
|
173
173
|
subject: 'subject',
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|