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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1756a570e80bad5034c2ecbd051ab7035a54a816
4
- data.tar.gz: a8b893f8c144da3c21269584e8d1177361aecd48
3
+ metadata.gz: 648906b45fd753e402c10db9ccf0e970a8f428ef
4
+ data.tar.gz: f040ba7ef6493bd492768421df9f89850bed77d7
5
5
  SHA512:
6
- metadata.gz: f18e76b8191f4b3c15ea8d919c53c41d0c48d6a5a63e6f65fa735c20c6b0ec498b0d558275452f43cc6ffc35831ea89a5facbe03205b94a2638cd444ba1ed187
7
- data.tar.gz: f3cfb629f695e5507ffc1983f6dad1ec7bc48e474b04f91d7a85cfc13e91416b57a2ac13352bd62294facc026f736dffc0cbb3fca299b4a1d5794b3a2539901a
6
+ metadata.gz: ee38265c8d03b4249f5dc53789c722f2aaba4821dd63e8778023da4e732da35dd8b937d8a9a3eef2d7a6ee96752116be280f9743dc581f45c6f92270242ee5d8
7
+ data.tar.gz: d8c61cfafa7dbfe64127e513c646898e84c0f98ba32a87eaa08ad2d8d5d1dcc643fe1d61396ba5b1d45699085aa38e005543755ab2f000ab0f14b887eb62472b
@@ -1,3 +1,10 @@
1
+ ## v0.5.0 (2015-03-09)
2
+
3
+ - Add `forex_single_refund` service.
4
+ - Add `debug_mode` config:
5
+
6
+ set `Alipay.debug_mode = false` to disable options check warning in production env.
7
+
1
8
  ## v0.4.1 (2015-03-03)
2
9
 
3
10
  - Fix `single_trade_query` check options typo.
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.4.1'
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
@@ -10,5 +10,10 @@ module Alipay
10
10
  attr_accessor :pid
11
11
  attr_accessor :key
12
12
  attr_accessor :seller_email
13
+ attr_writer :debug_mode
14
+
15
+ def debug_mode?
16
+ @debug_mode.nil? ? true : !!@debug_mode
17
+ end
13
18
  end
14
19
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Alipay
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -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',
@@ -5,3 +5,4 @@ require 'fakeweb'
5
5
  Alipay.pid = 'pid'
6
6
  Alipay.key = 'key'
7
7
  Alipay.seller_email = 'chloerei@gmail.com'
8
+ Alipay.debug_mode = true
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.1
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-03 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler