alipay 0.4.1 → 0.5.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -1
- data/lib/alipay.rb +5 -0
- data/lib/alipay/service.rb +22 -0
- data/lib/alipay/version.rb +1 -1
- data/test/alipay/service_test.rb +11 -0
- data/test/test_helper.rb +1 -0
- 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: 648906b45fd753e402c10db9ccf0e970a8f428ef
|
4
|
+
data.tar.gz: f040ba7ef6493bd492768421df9f89850bed77d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee38265c8d03b4249f5dc53789c722f2aaba4821dd63e8778023da4e732da35dd8b937d8a9a3eef2d7a6ee96752116be280f9743dc581f45c6f92270242ee5d8
|
7
|
+
data.tar.gz: d8c61cfafa7dbfe64127e513c646898e84c0f98ba32a87eaa08ad2d8d5d1dcc643fe1d61396ba5b1d45699085aa38e005543755ab2f000ab0f14b887eb62472b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ Please read alipay official document first: https://b.alipay.com/order/techServi
|
|
16
16
|
Add this line to your application's Gemfile:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'alipay', '~> 0.
|
19
|
+
gem 'alipay', '~> 0.5.0'
|
20
20
|
```
|
21
21
|
|
22
22
|
or development version
|
@@ -39,6 +39,7 @@ $ bundle
|
|
39
39
|
Alipay.pid = 'YOUR_PID'
|
40
40
|
Alipay.key = 'YOUR_KEY'
|
41
41
|
Alipay.seller_email = 'YOUR_SELLER_EMAIL'
|
42
|
+
Alipay.debug_mode = true # Default is true. Example for rails: !Rails.env.production?
|
42
43
|
```
|
43
44
|
|
44
45
|
### Generate payment url for web
|
data/lib/alipay.rb
CHANGED
data/lib/alipay/service.rb
CHANGED
@@ -82,6 +82,25 @@ module Alipay
|
|
82
82
|
"#{GATEWAY_URL}?#{query_string(options)}"
|
83
83
|
end
|
84
84
|
|
85
|
+
CREATE_FOREX_SINGLE_REFUND_URL_REQUIRED_OPTIONS = %w( out_return_no out_trade_no return_amount currency reason )
|
86
|
+
# 支付宝境外收单单笔退款接口
|
87
|
+
# out_return_no 退款流水单号
|
88
|
+
# out_trade_no 交易创建时的订单号
|
89
|
+
# return_amount 退款金额
|
90
|
+
# currency 退款币种,与交易创建时的币种一致
|
91
|
+
def self.create_forex_single_refund_url(options)
|
92
|
+
options = {
|
93
|
+
'service' => 'forex_refund',
|
94
|
+
'partner' => Alipay.pid,
|
95
|
+
'_input_charset' => 'utf-8',
|
96
|
+
'gmt_return' => Time.now.strftime('%Y%m%d%H%M%S')
|
97
|
+
}.merge(Utils.stringify_keys(options))
|
98
|
+
|
99
|
+
check_required_options(options, CREATE_FOREX_SINGLE_REFUND_URL_REQUIRED_OPTIONS)
|
100
|
+
|
101
|
+
"#{GATEWAY_URL}?#{query_string(options)}"
|
102
|
+
end
|
103
|
+
|
85
104
|
SEND_GOODS_CONFIRM_BY_PLATFORM_REQUIRED_OPTIONS = %w( service partner _input_charset trade_no logistics_name )
|
86
105
|
def self.send_goods_confirm_by_platform(options)
|
87
106
|
options = {
|
@@ -150,12 +169,15 @@ module Alipay
|
|
150
169
|
end
|
151
170
|
|
152
171
|
def self.check_required_options(options, names)
|
172
|
+
return if !Alipay.debug_mode?
|
173
|
+
|
153
174
|
names.each do |name|
|
154
175
|
warn("Ailpay Warn: missing required option: #{name}") unless options.has_key?(name)
|
155
176
|
end
|
156
177
|
end
|
157
178
|
|
158
179
|
def self.check_optional_options(options, names)
|
180
|
+
return if !Alipay.debug_mode?
|
159
181
|
warn("Ailpay Warn: must specify either #{names.join(' or ')}") if names.all? {|name| options[name].nil? }
|
160
182
|
end
|
161
183
|
end
|
data/lib/alipay/version.rb
CHANGED
data/test/alipay/service_test.rb
CHANGED
@@ -51,6 +51,17 @@ class Alipay::ServiceTest < Test::Unit::TestCase
|
|
51
51
|
assert_not_nil Alipay::Service.create_refund_url(options)
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_generate_create_forex_single_refund_url
|
55
|
+
options = {
|
56
|
+
:out_return_no => '1',
|
57
|
+
:out_trade_no => '12345678980',
|
58
|
+
:return_amount => 0.01,
|
59
|
+
:currency => 'USD',
|
60
|
+
:reason => '订单取消'
|
61
|
+
}
|
62
|
+
assert_not_nil Alipay::Service.create_forex_single_refund_url(options)
|
63
|
+
end
|
64
|
+
|
54
65
|
def test_generate_create_forex_trade
|
55
66
|
options = {
|
56
67
|
:notify_url => 'https://writings.io/orders/20130801000001/alipay_notify',
|
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.5.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-03-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|