stripe 1.31.0 → 1.32.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/Gemfile +0 -6
- data/History.txt +5 -0
- data/README.rdoc +14 -8
- data/VERSION +1 -1
- data/gemfiles/default-with-activesupport.gemfile +1 -7
- data/gemfiles/json.gemfile +1 -8
- data/gemfiles/yajl.gemfile +1 -8
- data/lib/stripe.rb +68 -10
- data/lib/stripe/application_fee.rb +7 -7
- data/lib/stripe/stripe_object.rb +14 -14
- data/lib/stripe/version.rb +1 -1
- data/stripe.gemspec +1 -0
- data/test/stripe/api_resource_test.rb +114 -0
- data/test/stripe/application_fee_test.rb +12 -3
- data/test/stripe/list_object_test.rb +1 -3
- data/test/stripe/util_test.rb +10 -10
- data/test/test_helper.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482b4a27be7ebd463dacdc270465e84dd6a59a7d
|
4
|
+
data.tar.gz: b594a2a801f966bbf72f2c8825e3a56620124d01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bb43636c63f12d659e76d4e29cc02b960d738bdba5160c55232335c600845bd199bb780e4ee822b520bb8422d41450bf0f82992743f87679cd3d03f86018913
|
7
|
+
data.tar.gz: 919a6651eab63dd5b0da21841514bd904fc0ab0529778aaf36696aa81405aa863740ad78206b9d1fc5baaa56a40dcde5b0273e50728a80ae89cdf5b4a6adca7c
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -32,14 +32,7 @@ If you want to build the gem from source:
|
|
32
32
|
|
33
33
|
== Requirements
|
34
34
|
|
35
|
-
* Ruby 1.
|
36
|
-
ActiveSupport.) For Ruby versions before 1.9.2, you'll need to add this to your Gemfile:
|
37
|
-
|
38
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.2')
|
39
|
-
gem 'rest-client', '~> 1.6.8'
|
40
|
-
end
|
41
|
-
|
42
|
-
|
35
|
+
* Ruby 1.9.3 or above.
|
43
36
|
* rest-client, json
|
44
37
|
|
45
38
|
== Bundler
|
@@ -66,3 +59,16 @@ Run a single test suite:
|
|
66
59
|
Run a single test:
|
67
60
|
|
68
61
|
bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.symbols/
|
62
|
+
|
63
|
+
== Configuration
|
64
|
+
|
65
|
+
=== max_network_retries
|
66
|
+
|
67
|
+
When `max_network_retries` is set to a positive integer, stripe will retry requests that
|
68
|
+
fail on a network error. Idempotency keys will be added to post and get requests to ensure the
|
69
|
+
safety of retrying. There will be a short delay between each retry, with an exponential backoff
|
70
|
+
algorithm used to determine the length of the delay. Default value is 0.
|
71
|
+
|
72
|
+
Example:
|
73
|
+
|
74
|
+
Stripe.max_network_retries = 2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.32.0
|
@@ -1,10 +1,4 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec :path => File.join(File.dirname(__FILE__), "..")
|
3
3
|
|
4
|
-
|
5
|
-
gem 'i18n', '< 0.7'
|
6
|
-
gem 'rest-client', '~> 1.6.8'
|
7
|
-
gem 'activesupport', '~> 3.2'
|
8
|
-
else
|
9
|
-
gem 'activesupport'
|
10
|
-
end
|
4
|
+
gem 'activesupport'
|
data/gemfiles/json.gemfile
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec :path => File.join(File.dirname(__FILE__), "..")
|
3
3
|
|
4
|
-
|
5
|
-
gem 'i18n', '< 0.7'
|
6
|
-
gem 'rest-client', '~> 1.6.8'
|
7
|
-
gem 'activesupport', '~> 3.2'
|
8
|
-
else
|
9
|
-
gem 'activesupport'
|
10
|
-
end
|
11
|
-
|
4
|
+
gem 'activesupport'
|
12
5
|
gem 'json'
|
data/gemfiles/yajl.gemfile
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec :path => File.join(File.dirname(__FILE__), "..")
|
3
3
|
|
4
|
-
|
5
|
-
gem 'i18n', '< 0.7'
|
6
|
-
gem 'rest-client', '~> 1.6.8'
|
7
|
-
gem 'activesupport', '~> 3.2'
|
8
|
-
else
|
9
|
-
gem 'activesupport'
|
10
|
-
end
|
11
|
-
|
4
|
+
gem 'activesupport'
|
12
5
|
gem 'yajl-ruby'
|
data/lib/stripe.rb
CHANGED
@@ -69,6 +69,9 @@ module Stripe
|
|
69
69
|
@connect_base = 'https://connect.stripe.com'
|
70
70
|
@uploads_base = 'https://uploads.stripe.com'
|
71
71
|
|
72
|
+
@max_network_retry_delay = 2
|
73
|
+
@initial_network_retry_delay = 0.5
|
74
|
+
|
72
75
|
@ssl_bundle_path = DEFAULT_CA_BUNDLE_PATH
|
73
76
|
@verify_ssl_certs = true
|
74
77
|
|
@@ -78,6 +81,8 @@ module Stripe
|
|
78
81
|
class << self
|
79
82
|
attr_accessor :api_key, :api_base, :verify_ssl_certs, :api_version, :connect_base, :uploads_base,
|
80
83
|
:open_timeout, :read_timeout
|
84
|
+
|
85
|
+
attr_reader :max_network_retry_delay, :initial_network_retry_delay
|
81
86
|
end
|
82
87
|
|
83
88
|
def self.api_url(url='', api_base_url=nil)
|
@@ -131,19 +136,35 @@ module Stripe
|
|
131
136
|
end
|
132
137
|
end
|
133
138
|
|
134
|
-
request_opts.update(:headers => request_headers(api_key).update(headers),
|
139
|
+
request_opts.update(:headers => request_headers(api_key, method).update(headers),
|
135
140
|
:method => method, :open_timeout => open_timeout,
|
136
141
|
:payload => payload, :url => url, :timeout => read_timeout)
|
137
142
|
|
143
|
+
response = execute_request_with_rescues(request_opts, api_base_url)
|
144
|
+
|
145
|
+
[parse(response), api_key]
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.max_network_retries
|
149
|
+
@max_network_retries || 0
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.max_network_retries=(val)
|
153
|
+
@max_network_retries = val.to_i
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def self.execute_request_with_rescues(request_opts, api_base_url, retry_count = 0)
|
138
159
|
begin
|
139
160
|
response = execute_request(request_opts)
|
140
161
|
rescue SocketError => e
|
141
|
-
handle_restclient_error(e, api_base_url)
|
162
|
+
response = handle_restclient_error(e, request_opts, retry_count, api_base_url)
|
142
163
|
rescue NoMethodError => e
|
143
164
|
# Work around RestClient bug
|
144
165
|
if e.message =~ /\WRequestFailed\W/
|
145
166
|
e = APIConnectionError.new('Unexpected HTTP response code')
|
146
|
-
handle_restclient_error(e, api_base_url)
|
167
|
+
response = handle_restclient_error(e, request_opts, retry_count, api_base_url)
|
147
168
|
else
|
148
169
|
raise
|
149
170
|
end
|
@@ -151,17 +172,15 @@ module Stripe
|
|
151
172
|
if e.response
|
152
173
|
handle_api_error(e.response)
|
153
174
|
else
|
154
|
-
handle_restclient_error(e, api_base_url)
|
175
|
+
response = handle_restclient_error(e, request_opts, retry_count, api_base_url)
|
155
176
|
end
|
156
177
|
rescue RestClient::Exception, Errno::ECONNREFUSED => e
|
157
|
-
handle_restclient_error(e, api_base_url)
|
178
|
+
response = handle_restclient_error(e, request_opts, retry_count, api_base_url)
|
158
179
|
end
|
159
180
|
|
160
|
-
|
181
|
+
response
|
161
182
|
end
|
162
183
|
|
163
|
-
private
|
164
|
-
|
165
184
|
def self.user_agent
|
166
185
|
@uname ||= get_uname
|
167
186
|
lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
|
@@ -215,13 +234,19 @@ module Stripe
|
|
215
234
|
deprecate :uri_encode, "Stripe::Util#encode_parameters", 2016, 01
|
216
235
|
end
|
217
236
|
|
218
|
-
def self.request_headers(api_key)
|
237
|
+
def self.request_headers(api_key, method)
|
219
238
|
headers = {
|
220
239
|
:user_agent => "Stripe/v1 RubyBindings/#{Stripe::VERSION}",
|
221
240
|
:authorization => "Bearer #{api_key}",
|
222
241
|
:content_type => 'application/x-www-form-urlencoded'
|
223
242
|
}
|
224
243
|
|
244
|
+
# It is only safe to retry network failures on post and delete
|
245
|
+
# requests if we add an Idempotency-Key header
|
246
|
+
if [:post, :delete].include?(method) && self.max_network_retries > 0
|
247
|
+
headers[:idempotency_key] ||= SecureRandom.uuid
|
248
|
+
end
|
249
|
+
|
225
250
|
headers[:stripe_version] = api_version if api_version
|
226
251
|
|
227
252
|
begin
|
@@ -303,7 +328,15 @@ module Stripe
|
|
303
328
|
APIError.new(error[:message], resp.code, resp.body, error_obj, resp.headers)
|
304
329
|
end
|
305
330
|
|
306
|
-
def self.handle_restclient_error(e, api_base_url=nil)
|
331
|
+
def self.handle_restclient_error(e, request_opts, retry_count, api_base_url=nil)
|
332
|
+
|
333
|
+
if should_retry?(e, retry_count)
|
334
|
+
retry_count = retry_count + 1
|
335
|
+
sleep sleep_time(retry_count)
|
336
|
+
response = execute_request_with_rescues(request_opts, api_base_url, retry_count)
|
337
|
+
return response
|
338
|
+
end
|
339
|
+
|
307
340
|
api_base_url = @api_base unless api_base_url
|
308
341
|
connection_message = "Please check your internet connection and try again. " \
|
309
342
|
"If this problem persists, you should check Stripe's service status at " \
|
@@ -334,6 +367,31 @@ module Stripe
|
|
334
367
|
|
335
368
|
end
|
336
369
|
|
370
|
+
if retry_count > 0
|
371
|
+
message += " Request was retried #{retry_count} times."
|
372
|
+
end
|
373
|
+
|
337
374
|
raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
|
338
375
|
end
|
376
|
+
|
377
|
+
def self.should_retry?(e, retry_count)
|
378
|
+
return false if retry_count >= self.max_network_retries
|
379
|
+
return false if e.is_a?(RestClient::SSLCertificateNotVerified)
|
380
|
+
return true
|
381
|
+
end
|
382
|
+
|
383
|
+
def self.sleep_time(retry_count)
|
384
|
+
# This method was adapted from https://github.com/ooyala/retries/blob/master/lib/retries.rb
|
385
|
+
|
386
|
+
# The sleep time is an exponentially-increasing function of base_sleep_seconds. But, it never exceeds
|
387
|
+
# max_sleep_seconds.
|
388
|
+
sleep_seconds = [initial_network_retry_delay * (2 ** (retry_count - 1)), max_network_retry_delay].min
|
389
|
+
# Randomize to a random value in the range sleep_seconds/2 .. sleep_seconds
|
390
|
+
|
391
|
+
sleep_seconds = sleep_seconds * (0.5 * (1 + rand()))
|
392
|
+
# But never sleep less than base_sleep_seconds
|
393
|
+
sleep_seconds = [initial_network_retry_delay, sleep_seconds].max
|
394
|
+
|
395
|
+
sleep_seconds
|
396
|
+
end
|
339
397
|
end
|
@@ -6,15 +6,15 @@ module Stripe
|
|
6
6
|
'/v1/application_fees'
|
7
7
|
end
|
8
8
|
|
9
|
+
# If you don't need access to an updated fee object after the refund, it's
|
10
|
+
# more performant to just call `fee.refunds.create` directly.
|
9
11
|
def refund(params={}, opts={})
|
10
|
-
|
11
|
-
initialize_from(response, opts)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
12
|
+
self.refunds.create
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
# now that a refund has been created, we expect the state of this object
|
15
|
+
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
16
|
+
# from the server
|
17
|
+
self.refresh
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -187,19 +187,19 @@ module Stripe
|
|
187
187
|
end
|
188
188
|
|
189
189
|
obj_values.each do |k, v|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
190
|
+
if v.is_a?(Array)
|
191
|
+
original_value = obj.instance_variable_get(:@original_values)[k]
|
192
|
+
|
193
|
+
# the conditional here tests whether the old and new values are
|
194
|
+
# different (and therefore needs an update), or the same (meaning
|
195
|
+
# we can leave it out of the request)
|
196
|
+
if updated = serialize_params(v, original_value)
|
197
|
+
update_hash[k] = updated
|
198
|
+
else
|
199
|
+
update_hash.delete(k)
|
200
|
+
end
|
201
201
|
elsif v.is_a?(StripeObject) || v.is_a?(Hash)
|
202
|
-
|
202
|
+
update_hash[k] = obj.serialize_nested_object(k)
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
@@ -243,8 +243,8 @@ module Stripe
|
|
243
243
|
define_method(k_eq) do |v|
|
244
244
|
if v == ""
|
245
245
|
raise ArgumentError.new(
|
246
|
-
"You cannot set #{k} to an empty string." \
|
247
|
-
"We interpret empty strings as nil in requests." \
|
246
|
+
"You cannot set #{k} to an empty string. " \
|
247
|
+
"We interpret empty strings as nil in requests. " \
|
248
248
|
"You may set #{self}.#{k} = nil to delete the property.")
|
249
249
|
end
|
250
250
|
@values[k] = v
|
data/lib/stripe/version.rb
CHANGED
data/stripe.gemspec
CHANGED
@@ -5,6 +5,7 @@ require 'stripe/version'
|
|
5
5
|
spec = Gem::Specification.new do |s|
|
6
6
|
s.name = 'stripe'
|
7
7
|
s.version = Stripe::VERSION
|
8
|
+
s.required_ruby_version = '>= 1.9.3'
|
8
9
|
s.summary = 'Ruby bindings for the Stripe API'
|
9
10
|
s.description = 'Stripe is the easiest way to accept payments online. See https://stripe.com for details.'
|
10
11
|
s.authors = ['Ross Boucher', 'Greg Brockman']
|
@@ -658,5 +658,119 @@ module Stripe
|
|
658
658
|
account.save(:display_name => 'stripe')
|
659
659
|
end
|
660
660
|
end
|
661
|
+
|
662
|
+
context "with retries" do
|
663
|
+
|
664
|
+
setup do
|
665
|
+
Stripe.stubs(:max_network_retries).returns(2)
|
666
|
+
end
|
667
|
+
|
668
|
+
should 'retry failed network requests if specified and raise if error persists' do
|
669
|
+
Stripe.expects(:sleep_time).at_least_once.returns(0)
|
670
|
+
@mock.expects(:post).times(3).with('https://api.stripe.com/v1/charges', nil, 'amount=50¤cy=usd').raises(Errno::ECONNREFUSED.new)
|
671
|
+
|
672
|
+
err = assert_raises Stripe::APIConnectionError do
|
673
|
+
Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
|
674
|
+
end
|
675
|
+
assert_match(/Request was retried 2 times/, err.message)
|
676
|
+
end
|
677
|
+
|
678
|
+
should 'retry failed network requests if specified and return successful response' do
|
679
|
+
Stripe.expects(:sleep_time).at_least_once.returns(0)
|
680
|
+
response = make_response({"id" => "myid"})
|
681
|
+
err = Errno::ECONNREFUSED.new
|
682
|
+
@mock.expects(:post).times(2).with('https://api.stripe.com/v1/charges', nil, 'amount=50¤cy=usd').raises(err).then.returns(response)
|
683
|
+
|
684
|
+
result = Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
|
685
|
+
assert_equal "myid", result.id
|
686
|
+
end
|
687
|
+
|
688
|
+
should 'not retry a SSLCertificateNotVerified error' do
|
689
|
+
@mock.expects(:post).times(1).with('https://api.stripe.com/v1/charges', nil, 'amount=50¤cy=usd').raises(RestClient::SSLCertificateNotVerified.new('message'))
|
690
|
+
|
691
|
+
err = assert_raises Stripe::APIConnectionError do
|
692
|
+
Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
|
693
|
+
end
|
694
|
+
assert_no_match(/retried/, err.message)
|
695
|
+
end
|
696
|
+
|
697
|
+
should 'not add an idempotency key to GET requests' do
|
698
|
+
SecureRandom.expects(:uuid).times(0)
|
699
|
+
Stripe.expects(:execute_request).with do |opts|
|
700
|
+
opts[:headers][:idempotency_key].nil?
|
701
|
+
end.returns(make_response({"id" => "myid"}))
|
702
|
+
|
703
|
+
Stripe::Charge.list
|
704
|
+
end
|
705
|
+
|
706
|
+
should 'ensure there is always an idempotency_key on POST requests' do
|
707
|
+
SecureRandom.expects(:uuid).at_least_once.returns("random_key")
|
708
|
+
Stripe.expects(:execute_request).with do |opts|
|
709
|
+
opts[:headers][:idempotency_key] == "random_key"
|
710
|
+
end.returns(make_response({"id" => "myid"}))
|
711
|
+
|
712
|
+
Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
|
713
|
+
end
|
714
|
+
|
715
|
+
should 'ensure there is always an idempotency_key on DELETE requests' do
|
716
|
+
SecureRandom.expects(:uuid).at_least_once.returns("random_key")
|
717
|
+
Stripe.expects(:execute_request).with do |opts|
|
718
|
+
opts[:headers][:idempotency_key] == "random_key"
|
719
|
+
end.returns(make_response({"id" => "myid"}))
|
720
|
+
|
721
|
+
c = Stripe::Customer.construct_from(make_customer)
|
722
|
+
c.delete
|
723
|
+
end
|
724
|
+
|
725
|
+
should 'not override a provided idempotency_key' do
|
726
|
+
Stripe.expects(:execute_request).with do |opts|
|
727
|
+
opts[:headers][:idempotency_key] == "provided_key"
|
728
|
+
end.returns(make_response({"id" => "myid"}))
|
729
|
+
|
730
|
+
Stripe::Charge.create({:amount => 50, :currency => 'usd', :card => { :number => nil }}, {:idempotency_key => 'provided_key'})
|
731
|
+
end
|
732
|
+
|
733
|
+
end
|
734
|
+
|
735
|
+
context "sleep_time" do
|
736
|
+
|
737
|
+
should "should grow exponentially" do
|
738
|
+
Stripe.stubs(:rand).returns(1)
|
739
|
+
Stripe.stubs(:max_network_retry_delay).returns(999)
|
740
|
+
assert_equal(Stripe.initial_network_retry_delay, Stripe.sleep_time(1))
|
741
|
+
assert_equal(Stripe.initial_network_retry_delay * 2, Stripe.sleep_time(2))
|
742
|
+
assert_equal(Stripe.initial_network_retry_delay * 4, Stripe.sleep_time(3))
|
743
|
+
assert_equal(Stripe.initial_network_retry_delay * 8, Stripe.sleep_time(4))
|
744
|
+
end
|
745
|
+
|
746
|
+
should "enforce the max_network_retry_delay" do
|
747
|
+
Stripe.stubs(:rand).returns(1)
|
748
|
+
Stripe.stubs(:initial_network_retry_delay).returns(1)
|
749
|
+
Stripe.stubs(:max_network_retry_delay).returns(2)
|
750
|
+
assert_equal(1, Stripe.sleep_time(1))
|
751
|
+
assert_equal(2, Stripe.sleep_time(2))
|
752
|
+
assert_equal(2, Stripe.sleep_time(3))
|
753
|
+
assert_equal(2, Stripe.sleep_time(4))
|
754
|
+
end
|
755
|
+
|
756
|
+
should "add some randomness" do
|
757
|
+
random_value = 0.8
|
758
|
+
Stripe.stubs(:rand).returns(random_value)
|
759
|
+
Stripe.stubs(:initial_network_retry_delay).returns(1)
|
760
|
+
Stripe.stubs(:max_network_retry_delay).returns(8)
|
761
|
+
|
762
|
+
base_value = Stripe.initial_network_retry_delay * (0.5 * (1 + random_value))
|
763
|
+
|
764
|
+
# the initial value cannot be smaller than the base,
|
765
|
+
# so the randomness is ignored
|
766
|
+
assert_equal(Stripe.initial_network_retry_delay, Stripe.sleep_time(1))
|
767
|
+
|
768
|
+
# after the first one, the randomness is applied
|
769
|
+
assert_equal(base_value * 2, Stripe.sleep_time(2))
|
770
|
+
assert_equal(base_value * 4, Stripe.sleep_time(3))
|
771
|
+
assert_equal(base_value * 8, Stripe.sleep_time(4))
|
772
|
+
end
|
773
|
+
|
774
|
+
end
|
661
775
|
end
|
662
776
|
end
|
@@ -12,9 +12,18 @@ module Stripe
|
|
12
12
|
end
|
13
13
|
|
14
14
|
should "application fees should be refundable" do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
fee = Stripe::ApplicationFee.construct_from(make_application_fee)
|
16
|
+
|
17
|
+
# first a post to create a refund
|
18
|
+
@mock.expects(:post).once.
|
19
|
+
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}/refunds", nil, '').
|
20
|
+
returns(make_response(make_application_fee_refund))
|
21
|
+
|
22
|
+
# then a get to refresh the current object
|
23
|
+
@mock.expects(:get).once.
|
24
|
+
with("#{Stripe.api_base}/v1/application_fees/#{fee.id}", nil, nil).
|
25
|
+
returns(make_response({:id => "fee_test_fee", :refunded => true}))
|
26
|
+
|
18
27
|
fee.refund
|
19
28
|
assert fee.refunded
|
20
29
|
end
|
@@ -81,10 +81,8 @@ module Stripe
|
|
81
81
|
list = TestListObject.construct_from({ :data => [{ :id => 1 }], :has_more => true })
|
82
82
|
list.filters = { :expand => ['data.source'], :limit => 3 }
|
83
83
|
@mock.expects(:get).with do |url, _, _|
|
84
|
-
# apparently URI.parse in 1.8.7 doesn't support query parameters ...
|
85
|
-
url, query = url.split("?")
|
86
84
|
u = URI.parse(url)
|
87
|
-
params = CGI.parse(query)
|
85
|
+
params = CGI.parse(u.query)
|
88
86
|
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
89
87
|
"expand[]" => ["data.source"],
|
90
88
|
"limit" => ["3"],
|
data/test/stripe/util_test.rb
CHANGED
@@ -3,19 +3,19 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
3
3
|
module Stripe
|
4
4
|
class UtilTest < Test::Unit::TestCase
|
5
5
|
should "#encode_parameters should prepare parameters for an HTTP request" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
params = {
|
7
|
+
:a => 3,
|
8
|
+
:b => "+foo?",
|
9
|
+
:c => "bar&baz",
|
10
|
+
:d => { :a => "a", :b => "b" },
|
11
|
+
:e => [0, 1],
|
12
|
+
:f => "",
|
13
13
|
|
14
14
|
# note the empty hash won't even show up in the request
|
15
|
-
|
16
|
-
|
15
|
+
:g => [],
|
16
|
+
}
|
17
17
|
assert_equal(
|
18
|
-
"a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1",
|
18
|
+
"a=3&b=%2Bfoo%3F&c=bar%26baz&d[a]=a&d[b]=b&e[]=0&e[]=1&f=",
|
19
19
|
Stripe::Util.encode_parameters(params)
|
20
20
|
)
|
21
21
|
end
|
data/test/test_helper.rb
CHANGED
@@ -31,11 +31,11 @@ class Test::Unit::TestCase
|
|
31
31
|
setup do
|
32
32
|
@mock = mock
|
33
33
|
Stripe.mock_rest_client = @mock
|
34
|
-
Stripe.api_key="foo"
|
34
|
+
Stripe.api_key = "foo"
|
35
35
|
end
|
36
36
|
|
37
37
|
teardown do
|
38
38
|
Stripe.mock_rest_client = nil
|
39
|
-
Stripe.api_key=nil
|
39
|
+
Stripe.api_key = nil
|
40
40
|
end
|
41
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Boucher
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -251,7 +251,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
251
|
requirements:
|
252
252
|
- - ">="
|
253
253
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
254
|
+
version: 1.9.3
|
255
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
256
|
requirements:
|
257
257
|
- - ">="
|