stripe 3.0.1 → 3.0.3

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: 79dc89b3485d9c9077874530b9483ba3a048b1d8
4
- data.tar.gz: a73e14de59f52f2282196f1a30537a7d6c353497
3
+ metadata.gz: 71ad66341e1b3896e85749e3f18870b734386a86
4
+ data.tar.gz: 67175bb4549ab20ca69f38016e9f7d96aedaa817
5
5
  SHA512:
6
- metadata.gz: 59133df8f5c29d44597f9a8145c77f0becf8705fe1b507b4612fb57930eb0b09afa2ef05e1ebe10c52e0749484bbcc957dbf998a2eb50df3d3d9879a9bcb2004
7
- data.tar.gz: e5b4737ca902571ed0866df6b1401c5c3a2823d70e8a8da224dc5f2266b50cb454cffade965b5746098ce07e8ce0dd6eeedfe6c0b8c444a275d935eb9e008a42
6
+ metadata.gz: f740ee89ea7c34c45944dc299ba346ad715c96b736a05dc6ad2f13337125656d049ff16a33671de454d5e2511e98e7431ae58caf275c934d957e3f608cb7df91
7
+ data.tar.gz: 04d28b541238aba0ce44820f5b1daf38a4a798892764d1d18e565d5d688b0d627895b037152ad976cbec982f1277dc6b7475bd5589ef152d6e7cbbebbb77b428
@@ -1,7 +1,21 @@
1
+ === 3.0.3 2017-07-28
2
+
3
+ * Revert `nil` to empty string coercion from 3.0.2
4
+ * Handle `invalid_client` OAuth error code
5
+ * Improve safety of error handling logic safer for unrecognized OAuth error
6
+ codes
7
+
8
+ === 3.0.2 2017-07-12 (yanked)
9
+
10
+ * Convert `nil` to empty string when serializing parameters (instead of
11
+ opaquely dropping it) -- NOTE: this change has since been reverted
12
+
1
13
  === 3.0.1 2017-07-11
2
14
 
3
- * Properties set with an API resource will now serialize that resource's ID if possible
4
- * API resources will throw an ArgumentError on save if a property has been with an API resource that cannot be serialized
15
+ * Properties set with an API resource will now serialize that resource's ID if
16
+ possible
17
+ * API resources will throw an ArgumentError on save if a property has been with
18
+ an API resource that cannot be serialized
5
19
 
6
20
  === 3.0.0 2017-06-27
7
21
 
@@ -652,3 +666,5 @@ Identical to 1.56.0 above. I incorrectly cut a patch-level release.
652
666
 
653
667
  * 1 major enhancement:
654
668
  * Initial release
669
+
670
+ # vim: set tw=79:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.1
1
+ 3.0.3
@@ -114,6 +114,12 @@ module Stripe
114
114
  end
115
115
  end
116
116
 
117
+ # InvalidClientError is raised when the client doesn't belong to you, or
118
+ # the API key mode (live or test) doesn't match the client mode. Or the
119
+ # stripe_user_id doesn't exist or isn't connected to your application.
120
+ class InvalidClientError < OAuthError
121
+ end
122
+
117
123
  # InvalidGrantError is raised when a specified code doesn't exist, is
118
124
  # expired, has been used, or doesn't belong to you; a refresh token doesn't
119
125
  # exist, or doesn't belong to you; or if an API key's mode (live or test)
@@ -244,8 +244,7 @@ module Stripe
244
244
 
245
245
  if error_data.is_a?(String)
246
246
  error = specific_oauth_error(resp, error_data)
247
- end
248
- if error.nil?
247
+ else
249
248
  error = specific_api_error(resp, error_data)
250
249
  end
251
250
 
@@ -307,13 +306,16 @@ module Stripe
307
306
  }]
308
307
 
309
308
  case error_code
309
+ when 'invalid_client' then OAuth::InvalidClientError.new(*args)
310
310
  when 'invalid_grant' then OAuth::InvalidGrantError.new(*args)
311
311
  when 'invalid_request' then OAuth::InvalidRequestError.new(*args)
312
312
  when 'invalid_scope' then OAuth::InvalidScopeError.new(*args)
313
313
  when 'unsupported_grant_type' then OAuth::UnsupportedGrantTypeError.new(*args)
314
314
  when 'unsupported_response_type' then OAuth::UnsupportedResponseTypeError.new(*args)
315
315
  else
316
- nil
316
+ # We'd prefer that all errors are typed, but we create a generic
317
+ # OAuthError in case we run into a code that we don't recognize.
318
+ OAuth::OAuthError.new(*args)
317
319
  end
318
320
  end
319
321
 
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.3'
3
3
  end
@@ -74,6 +74,19 @@ module Stripe
74
74
  }
75
75
  assert invoice.kind_of?(Stripe::Invoice)
76
76
  end
77
+
78
+ should "be callable with an empty string" do
79
+ invoice = Stripe::Invoice.upcoming(
80
+ coupon: '',
81
+ customer: API_FIXTURES[:customer][:id]
82
+ )
83
+ assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming",
84
+ query: {
85
+ coupon: '',
86
+ customer: API_FIXTURES[:customer][:id]
87
+ }
88
+ assert invoice.kind_of?(Stripe::Invoice)
89
+ end
77
90
  end
78
91
  end
79
92
  end
@@ -368,6 +368,42 @@ module Stripe
368
368
  assert_equal('invalid_grant', e.code)
369
369
  assert_equal('This authorization code has already been used. All tokens issued with this code have been revoked.', e.message)
370
370
  end
371
+
372
+ should "raise OAuth::InvalidClientError when error is a string with value 'invalid_client'" do
373
+ stub_request(:post, "#{Stripe.connect_base}/oauth/deauthorize").
374
+ to_return(body: JSON.generate({
375
+ error: "invalid_client",
376
+ error_description: "This application is not connected to stripe account acct_19tLK7DSlTMT26Mk, or that account does not exist.",
377
+ }), status: 401)
378
+
379
+ client = StripeClient.new
380
+ opts = {api_base: Stripe.connect_base}
381
+ e = assert_raises Stripe::OAuth::InvalidClientError do
382
+ client.execute_request(:post, '/oauth/deauthorize', opts)
383
+ end
384
+
385
+ assert_equal(401, e.http_status)
386
+ assert_equal('invalid_client', e.code)
387
+ assert_equal('This application is not connected to stripe account acct_19tLK7DSlTMT26Mk, or that account does not exist.', e.message)
388
+ end
389
+
390
+ should "raise Stripe::OAuthError on indeterminate OAuth error" do
391
+ stub_request(:post, "#{Stripe.connect_base}/oauth/deauthorize").
392
+ to_return(body: JSON.generate({
393
+ error: "new_code_not_recognized",
394
+ error_description: "Something.",
395
+ }), status: 401)
396
+
397
+ client = StripeClient.new
398
+ opts = {api_base: Stripe.connect_base}
399
+ e = assert_raises Stripe::OAuth::OAuthError do
400
+ client.execute_request(:post, '/oauth/deauthorize', opts)
401
+ end
402
+
403
+ assert_equal(401, e.http_status)
404
+ assert_equal("new_code_not_recognized", e.code)
405
+ assert_equal("Something.", e.message)
406
+ end
371
407
  end
372
408
 
373
409
  context "idempotency keys" do
@@ -455,6 +491,27 @@ module Stripe
455
491
  client.execute_request(:post, '/v1/charges')
456
492
  end
457
493
  end
494
+
495
+ context "params serialization" do
496
+ should 'allows empty strings in params' do
497
+ client = StripeClient.new
498
+ client.execute_request(:get, '/v1/invoices/upcoming',
499
+ params: { customer: API_FIXTURES[:customer][:id],
500
+ coupon: '' })
501
+ assert_requested(:get, "#{Stripe.api_base}/v1/invoices/upcoming?",
502
+ query: { customer: API_FIXTURES[:customer][:id],
503
+ coupon: '' })
504
+ end
505
+
506
+ should 'filter nils in params' do
507
+ client = StripeClient.new
508
+ client.execute_request(:get, '/v1/invoices/upcoming',
509
+ params: { customer: API_FIXTURES[:customer][:id],
510
+ coupon: nil })
511
+ assert_requested(:get, "#{Stripe.api_base}/v1/invoices/upcoming?",
512
+ query: { customer: API_FIXTURES[:customer][:id] })
513
+ end
514
+ end
458
515
  end
459
516
 
460
517
  context "#request" do
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.0.1
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -233,4 +233,3 @@ test_files:
233
233
  - test/stripe_test.rb
234
234
  - test/test_data.rb
235
235
  - test/test_helper.rb
236
- has_rdoc: