stripe 1.40.0 → 1.41.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +10 -3
- data/lib/stripe/api_operations/list.rb +0 -1
- data/lib/stripe/charge.rb +1 -1
- data/lib/stripe/stripe_object.rb +1 -1
- data/lib/stripe/subscription.rb +1 -1
- data/lib/stripe/transfer.rb +1 -1
- data/lib/stripe/util.rb +1 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +14 -1
- data/test/stripe/bitcoin_receiver_test.rb +2 -2
- data/test/stripe/charge_test.rb +6 -0
- data/test/stripe/stripe_object_test.rb +1 -1
- data/test/stripe_test.rb +15 -0
- data/test/test_data.rb +7 -1
- data/test/test_helper.rb +4 -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: f758a647e45ad29868db9a730a4242bc5c28d28c
|
4
|
+
data.tar.gz: 5b9878c4db71d5d4f7690b2acc6e19cc9983b8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3626353eec44fecf27536bfc52a311018ec5734669384baafe285fd64adf3e30c0f4b0e1b44efa19cee111d7bd1434fdf30169b5342d3070bea5d5267cf4b87
|
7
|
+
data.tar.gz: 433941fb35789f121ab6518dcc3b2bf681ef75da67858bd42a85a649ca1818b8f80c31a91427dea4348ab59a8e1ea831c8208bc4ce16c50abde5d9c01499ab94
|
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.41.0
|
data/lib/stripe.rb
CHANGED
@@ -82,7 +82,7 @@ module Stripe
|
|
82
82
|
@read_timeout = 80
|
83
83
|
|
84
84
|
class << self
|
85
|
-
attr_accessor :api_key, :api_base, :verify_ssl_certs, :api_version, :connect_base, :uploads_base,
|
85
|
+
attr_accessor :stripe_account, :api_key, :api_base, :verify_ssl_certs, :api_version, :connect_base, :uploads_base,
|
86
86
|
:open_timeout, :read_timeout
|
87
87
|
|
88
88
|
attr_reader :max_network_retry_delay, :initial_network_retry_delay
|
@@ -208,7 +208,7 @@ module Stripe
|
|
208
208
|
else
|
209
209
|
response = handle_restclient_error(e, request_opts, retry_count, api_base_url)
|
210
210
|
end
|
211
|
-
rescue RestClient::Exception, Errno::ECONNREFUSED => e
|
211
|
+
rescue RestClient::Exception, Errno::ECONNREFUSED, OpenSSL::SSL::SSLError => e
|
212
212
|
response = handle_restclient_error(e, request_opts, retry_count, api_base_url)
|
213
213
|
end
|
214
214
|
|
@@ -278,10 +278,11 @@ module Stripe
|
|
278
278
|
# It is only safe to retry network failures on post and delete
|
279
279
|
# requests if we add an Idempotency-Key header
|
280
280
|
if [:post, :delete].include?(method) && self.max_network_retries > 0
|
281
|
-
headers[:idempotency_key] ||= SecureRandom.uuid
|
281
|
+
headers[:idempotency_key] ||= SecureRandom.uuid
|
282
282
|
end
|
283
283
|
|
284
284
|
headers[:stripe_version] = api_version if api_version
|
285
|
+
headers[:stripe_account] = stripe_account if stripe_account
|
285
286
|
|
286
287
|
begin
|
287
288
|
headers.update(:x_stripe_client_user_agent => JSON.generate(user_agent))
|
@@ -384,6 +385,12 @@ module Stripe
|
|
384
385
|
message = "The connection to the server (#{api_base_url}) broke before the " \
|
385
386
|
"request completed. #{connection_message}"
|
386
387
|
|
388
|
+
when OpenSSL::SSL::SSLError
|
389
|
+
message = "Could not establish a secure connection to Stripe, you may " \
|
390
|
+
"need to upgrade your OpenSSL version. To check, try running " \
|
391
|
+
"'openssl s_client -connect api.stripe.com:443' from the " \
|
392
|
+
"command line."
|
393
|
+
|
387
394
|
when RestClient::SSLCertificateNotVerified
|
388
395
|
message = "Could not verify Stripe's SSL certificate. " \
|
389
396
|
"Please make sure that your network is not intercepting certificates. " \
|
data/lib/stripe/charge.rb
CHANGED
@@ -13,7 +13,7 @@ module Stripe
|
|
13
13
|
# an `Array` and fall back to the old refund URL if necessary so as to
|
14
14
|
# maintain internal compatibility.
|
15
15
|
unless self.refunds.is_a?(Array)
|
16
|
-
|
16
|
+
self.refunds.create(params, opts)
|
17
17
|
|
18
18
|
# now that a refund has been created, we expect the state of this object
|
19
19
|
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -32,7 +32,7 @@ module Stripe
|
|
32
32
|
# considered to be equal if they have the same set of values and each one
|
33
33
|
# of those values is the same.
|
34
34
|
def ==(other)
|
35
|
-
@values == other.instance_variable_get(:@values)
|
35
|
+
other.is_a?(StripeObject) && @values == other.instance_variable_get(:@values)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Indicates whether or not the resource has been deleted on the server.
|
data/lib/stripe/subscription.rb
CHANGED
data/lib/stripe/transfer.rb
CHANGED
data/lib/stripe/util.rb
CHANGED
@@ -120,7 +120,7 @@ module Stripe
|
|
120
120
|
|
121
121
|
# do not sort the final output because arrays (and arrays of hashes
|
122
122
|
# especially) can be order sensitive, but do sort incoming parameters
|
123
|
-
params.sort_by { |(k,
|
123
|
+
params.sort_by { |(k, _)| k.to_s }.each do |key, value|
|
124
124
|
calculated_key = parent_key ? "#{parent_key}[#{key}]" : "#{key}"
|
125
125
|
if value.is_a?(Hash)
|
126
126
|
result += flatten_params(value, calculated_key)
|
data/lib/stripe/version.rb
CHANGED
@@ -445,7 +445,7 @@ module Stripe
|
|
445
445
|
opts[:url] == "#{Stripe.api_base}/v1/customers/c_test_customer" &&
|
446
446
|
opts[:headers][:stripe_account] == 'acct_abc'
|
447
447
|
end.once.returns(make_response(make_customer))
|
448
|
-
|
448
|
+
Stripe::Customer.retrieve("c_test_customer", {:stripe_account => 'acct_abc'})
|
449
449
|
end
|
450
450
|
|
451
451
|
should "passing in a stripe_account header should pass it through on save" do
|
@@ -695,6 +695,19 @@ module Stripe
|
|
695
695
|
assert_equal "myid", result.id
|
696
696
|
end
|
697
697
|
|
698
|
+
# We retry the request if we receive SSL errors, since these can be caused
|
699
|
+
# by transient network issues, in addition to compatibility issues between
|
700
|
+
# the client and server.
|
701
|
+
should 'retry failed network requests if they fail with OpenSSL::SSL::SSLError' do
|
702
|
+
Stripe.expects(:sleep_time).at_least_once.returns(0)
|
703
|
+
@mock.expects(:post).times(3).with('https://api.stripe.com/v1/charges', nil, 'amount=50¤cy=usd').raises(OpenSSL::SSL::SSLError.new('message'))
|
704
|
+
|
705
|
+
err = assert_raises Stripe::APIConnectionError do
|
706
|
+
Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
|
707
|
+
end
|
708
|
+
assert_match(/Request was retried 2 times/, err.message)
|
709
|
+
end
|
710
|
+
|
698
711
|
should 'not retry a SSLCertificateNotVerified error' do
|
699
712
|
@mock.expects(:post).times(1).with('https://api.stripe.com/v1/charges', nil, 'amount=50¤cy=usd').raises(RestClient::SSLCertificateNotVerified.new('message'))
|
700
713
|
|
@@ -47,14 +47,14 @@ module Stripe
|
|
47
47
|
should "delete a bitcoin receiver with no customer through top-level API" do
|
48
48
|
@mock.expects(:delete).with("#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_test_receiver", nil, nil).once.returns(make_response({:deleted => true, :id => "btcrcv_test_receiver"}))
|
49
49
|
receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver)
|
50
|
-
|
50
|
+
receiver.delete
|
51
51
|
assert(receiver.deleted)
|
52
52
|
end
|
53
53
|
|
54
54
|
should "delete a bitcoin receiver with a customer through customer's subresource API" do
|
55
55
|
@mock.expects(:delete).with("#{Stripe.api_base}/v1/customers/customer_foo/sources/btcrcv_test_receiver", nil, nil).once.returns(make_response({:deleted => true, :id => "btcrcv_test_receiver"}))
|
56
56
|
receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver(:customer => 'customer_foo'))
|
57
|
-
|
57
|
+
receiver.delete
|
58
58
|
assert(receiver.deleted)
|
59
59
|
end
|
60
60
|
end
|
data/test/stripe/charge_test.rb
CHANGED
@@ -72,6 +72,12 @@ module Stripe
|
|
72
72
|
assert c.card.kind_of?(Stripe::StripeObject) && c.card.object == 'card'
|
73
73
|
end
|
74
74
|
|
75
|
+
should "charges should have Outcome objects associated with their outcome property" do
|
76
|
+
@mock.expects(:get).once.returns(make_response(make_charge))
|
77
|
+
c = Stripe::Charge.retrieve("test_charge")
|
78
|
+
assert c.outcome.kind_of?(Stripe::StripeObject) && c.outcome.type == 'authorized'
|
79
|
+
end
|
80
|
+
|
75
81
|
should "execute should return a new, fully executed charge when passed correct `card` parameters" do
|
76
82
|
@mock.expects(:post).with do |url, api_key, params|
|
77
83
|
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
data/test/stripe_test.rb
CHANGED
@@ -33,4 +33,19 @@ class StripeTest < Test::Unit::TestCase
|
|
33
33
|
Stripe.max_network_retries = old
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
should "makes requests with the Stripe-Account header" do
|
38
|
+
response = make_account(
|
39
|
+
charges_enabled: false,
|
40
|
+
details_submitted: false,
|
41
|
+
email: "test+bindings@stripe.com"
|
42
|
+
)
|
43
|
+
Stripe.stripe_account = 'acct_1234'
|
44
|
+
|
45
|
+
Stripe.expects(:execute_request).with(
|
46
|
+
has_entry(:headers, has_entry(:stripe_account, 'acct_1234')),
|
47
|
+
).returns(make_response(response))
|
48
|
+
|
49
|
+
Stripe.request(:post, '/v1/account', 'sk_live12334566')
|
50
|
+
end
|
36
51
|
end
|
data/test/test_data.rb
CHANGED
@@ -152,7 +152,13 @@ module Stripe
|
|
152
152
|
:object => "charge",
|
153
153
|
:created => 1304114826,
|
154
154
|
:refunds => make_refund_array(id),
|
155
|
-
:metadata => {}
|
155
|
+
:metadata => {},
|
156
|
+
:outcome => {
|
157
|
+
type: 'authorized',
|
158
|
+
reason: nil,
|
159
|
+
seller_message: 'Payment complete.',
|
160
|
+
network_status: 'approved_by_network',
|
161
|
+
},
|
156
162
|
}.merge(params)
|
157
163
|
end
|
158
164
|
|
data/test/test_helper.rb
CHANGED
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.41.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: 2016-04-
|
12
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|