stripe 3.10.0 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop_todo.yml +9 -9
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe/errors.rb +12 -12
- data/lib/stripe/stripe_client.rb +4 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/stripe_client_test.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 981d54e75ed0dc6a6c6e9134cbf338a2d8ed02e7169afc93f37c5c65d1e23955
|
4
|
+
data.tar.gz: 844de1199f90a2e1eb32f2a011fda913b0ee3c799cd670c8dd42d441d0135805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7890d0984cb8d83aec246a5fe745f2e57343e1b1c256343e79c49f35479de9cbafd90046dd00b537339a6b08257eb9dd39a1aa96f420059d5596584f7f2b7bd5
|
7
|
+
data.tar.gz: 371d48d97dedf110422c91e70b25be7aa092576f55e87d5b1cf3e3d336b847ff9e0000fa18bd5f234459f33dd9b5826a7400fc53c7ac8939ac42de3c831220f3
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-02-23 14:17:07 +0100 using RuboCop version 0.50.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -8,23 +8,23 @@
|
|
8
8
|
|
9
9
|
# Offense count: 19
|
10
10
|
Metrics/AbcSize:
|
11
|
-
Max:
|
11
|
+
Max: 45
|
12
12
|
|
13
13
|
# Offense count: 27
|
14
14
|
# Configuration parameters: CountComments, ExcludedMethods.
|
15
15
|
Metrics/BlockLength:
|
16
|
-
Max:
|
16
|
+
Max: 469
|
17
17
|
|
18
18
|
# Offense count: 8
|
19
19
|
# Configuration parameters: CountComments.
|
20
20
|
Metrics/ClassLength:
|
21
|
-
Max:
|
21
|
+
Max: 597
|
22
22
|
|
23
|
-
# Offense count:
|
23
|
+
# Offense count: 11
|
24
24
|
Metrics/CyclomaticComplexity:
|
25
25
|
Max: 13
|
26
26
|
|
27
|
-
# Offense count:
|
27
|
+
# Offense count: 259
|
28
28
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
29
29
|
# URISchemes: http, https
|
30
30
|
Metrics/LineLength:
|
@@ -33,14 +33,14 @@ Metrics/LineLength:
|
|
33
33
|
# Offense count: 32
|
34
34
|
# Configuration parameters: CountComments.
|
35
35
|
Metrics/MethodLength:
|
36
|
-
Max:
|
36
|
+
Max: 45
|
37
37
|
|
38
38
|
# Offense count: 1
|
39
39
|
# Configuration parameters: CountComments.
|
40
40
|
Metrics/ModuleLength:
|
41
41
|
Max: 305
|
42
42
|
|
43
|
-
# Offense count:
|
43
|
+
# Offense count: 6
|
44
44
|
# Configuration parameters: CountKeywordArgs.
|
45
45
|
Metrics/ParameterLists:
|
46
46
|
Max: 7
|
@@ -55,6 +55,6 @@ Style/ClassVars:
|
|
55
55
|
- 'lib/stripe/stripe_object.rb'
|
56
56
|
- 'test/stripe/api_resource_test.rb'
|
57
57
|
|
58
|
-
# Offense count:
|
58
|
+
# Offense count: 53
|
59
59
|
Style/Documentation:
|
60
60
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.11.0 - 2018-02-26
|
4
|
+
* [#628](https://github.com/stripe/stripe-ruby/pull/628) Add support for `code` attribute on all Stripe exceptions
|
5
|
+
|
3
6
|
## 3.10.0 - 2018-02-21
|
4
7
|
* [#627](https://github.com/stripe/stripe-ruby/pull/627) Add support for topups
|
5
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.11.0
|
data/lib/stripe/errors.rb
CHANGED
@@ -8,8 +8,7 @@ module Stripe
|
|
8
8
|
# about the response that conveyed the error.
|
9
9
|
attr_accessor :response
|
10
10
|
|
11
|
-
|
12
|
-
# be preferred.
|
11
|
+
attr_reader :code
|
13
12
|
attr_reader :http_body
|
14
13
|
attr_reader :http_headers
|
15
14
|
attr_reader :http_status
|
@@ -18,12 +17,13 @@ module Stripe
|
|
18
17
|
|
19
18
|
# Initializes a StripeError.
|
20
19
|
def initialize(message = nil, http_status: nil, http_body: nil, json_body: nil,
|
21
|
-
http_headers: nil)
|
20
|
+
http_headers: nil, code: nil)
|
22
21
|
@message = message
|
23
22
|
@http_status = http_status
|
24
23
|
@http_body = http_body
|
25
24
|
@http_headers = http_headers || {}
|
26
25
|
@json_body = json_body
|
26
|
+
@code = code
|
27
27
|
@request_id = @http_headers[:request_id]
|
28
28
|
end
|
29
29
|
|
@@ -55,14 +55,15 @@ module Stripe
|
|
55
55
|
# CardError is raised when a user enters a card that can't be charged for
|
56
56
|
# some reason.
|
57
57
|
class CardError < StripeError
|
58
|
-
attr_reader :param
|
58
|
+
attr_reader :param
|
59
59
|
|
60
|
+
# TODO: make code a keyword arg in next major release
|
60
61
|
def initialize(message, param, code, http_status: nil, http_body: nil, json_body: nil,
|
61
62
|
http_headers: nil)
|
62
63
|
super(message, http_status: http_status, http_body: http_body,
|
63
|
-
json_body: json_body, http_headers: http_headers
|
64
|
+
json_body: json_body, http_headers: http_headers,
|
65
|
+
code: code)
|
64
66
|
@param = param
|
65
|
-
@code = code
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
@@ -77,9 +78,10 @@ module Stripe
|
|
77
78
|
attr_accessor :param
|
78
79
|
|
79
80
|
def initialize(message, param, http_status: nil, http_body: nil, json_body: nil,
|
80
|
-
http_headers: nil)
|
81
|
+
http_headers: nil, code: nil)
|
81
82
|
super(message, http_status: http_status, http_body: http_body,
|
82
|
-
json_body: json_body, http_headers: http_headers
|
83
|
+
json_body: json_body, http_headers: http_headers,
|
84
|
+
code: code)
|
83
85
|
@param = param
|
84
86
|
end
|
85
87
|
end
|
@@ -109,13 +111,11 @@ module Stripe
|
|
109
111
|
module OAuth
|
110
112
|
# OAuthError is raised when the OAuth API returns an error.
|
111
113
|
class OAuthError < StripeError
|
112
|
-
attr_accessor :code
|
113
|
-
|
114
114
|
def initialize(code, description, http_status: nil, http_body: nil, json_body: nil,
|
115
115
|
http_headers: nil)
|
116
116
|
super(description, http_status: http_status, http_body: http_body,
|
117
|
-
json_body: json_body, http_headers: http_headers
|
118
|
-
|
117
|
+
json_body: json_body, http_headers: http_headers,
|
118
|
+
code: code)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
data/lib/stripe/stripe_client.rb
CHANGED
@@ -294,6 +294,7 @@ module Stripe
|
|
294
294
|
http_headers: resp.http_headers,
|
295
295
|
http_status: resp.http_status,
|
296
296
|
json_body: resp.data,
|
297
|
+
code: error_data[:code],
|
297
298
|
}
|
298
299
|
|
299
300
|
case resp.http_status
|
@@ -310,6 +311,9 @@ module Stripe
|
|
310
311
|
when 401
|
311
312
|
AuthenticationError.new(error_data[:message], opts)
|
312
313
|
when 402
|
314
|
+
# TODO: modify CardError constructor to make code a keyword argument
|
315
|
+
# so we don't have to delete it from opts
|
316
|
+
opts.delete(:code)
|
313
317
|
CardError.new(
|
314
318
|
error_data[:message], error_data[:param], error_data[:code],
|
315
319
|
opts
|
data/lib/stripe/version.rb
CHANGED
@@ -452,13 +452,15 @@ module Stripe
|
|
452
452
|
|
453
453
|
should "raise CardError on 402" do
|
454
454
|
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
455
|
-
.to_return(body: JSON.generate(
|
455
|
+
.to_return(body: JSON.generate(make_invalid_exp_year_error), status: 402)
|
456
456
|
client = StripeClient.new
|
457
457
|
begin
|
458
458
|
client.execute_request(:post, "/v1/charges")
|
459
459
|
rescue Stripe::CardError => e
|
460
460
|
assert_equal(402, e.http_status)
|
461
461
|
assert_equal(true, e.json_body.is_a?(Hash))
|
462
|
+
assert_equal("invalid_expiry_year", e.code)
|
463
|
+
assert_equal("exp_year", e.param)
|
462
464
|
end
|
463
465
|
end
|
464
466
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.6
|
187
|
+
rubygems_version: 2.7.6
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Ruby bindings for the Stripe API
|