stripe 1.36.0 → 1.36.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f34746bb3a826f64477e8dff5c616665144fe56d
4
- data.tar.gz: 82e4663d7d8b3392ed36b19969d1ada2afb05115
3
+ metadata.gz: 0c61dab0439a342a7b81c1891bcc86de16f1c2e2
4
+ data.tar.gz: d703323b3ea491f50c7b2e3af3022593a4eec0e5
5
5
  SHA512:
6
- metadata.gz: bae160dd906dcd1e27be1aae953c53e39697ecf17c61baf75637a3e3b725ebc96cdadabc5c5c2025b5f940aff1f1e8952dff9314adc185754557101795a0f691
7
- data.tar.gz: ffa399f6f15e8e166995855c370629969986ddfee49b8a36b8126248be40b01a04c8135a83bc23b284f0b279b416f7676a731e08b498c206aadf037996d593d8
6
+ metadata.gz: 3f1b8e24a436c7aca910b09c4b39789c754a65894f5db8d9e7f3986d4f0c16eb79db4688fe5e8e1662873997cb6a867f9e6c90d4ecc983321e521ca5691fadd6
7
+ data.tar.gz: 32c5d898c296c3a6b41e0aad9a306d5987a4ede989d3345326856ac5130dd67751faaf97d3551a884594b22c42e05063737518651ff83d81ad2f446533f76470
@@ -9,7 +9,6 @@ rvm:
9
9
 
10
10
  gemfile:
11
11
  - gemfiles/default-with-activesupport.gemfile
12
- - gemfiles/json.gemfile
13
12
  - gemfiles/yajl.gemfile
14
13
 
15
14
  matrix:
@@ -1,3 +1,7 @@
1
+ === 1.36.1 2016-03-04
2
+
3
+ * Fix serialization when subhash given to `#save` or `#update_attributes`
4
+
1
5
  === 1.36.0 2016-02-08
2
6
 
3
7
  * Add `CountrySpec` model for looking up country payment information
@@ -1,4 +1,4 @@
1
- = Stripe Ruby bindings {<img src="https://travis-ci.org/stripe/stripe-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/stripe/stripe-ruby]
1
+ # Stripe Ruby Bindings [![Build Status](https://travis-ci.org/stripe/stripe-ruby.png?branch=master)](https://travis-ci.org/stripe/stripe-ruby)
2
2
 
3
3
  The Stripe Ruby bindings provide a small SDK for convenient access to the
4
4
  Stripe API from applications written in the Ruby language. It provides a
@@ -15,38 +15,40 @@ The bindings also provide other features. For example:
15
15
  * Built-in mechanisms for the serialization of parameters according to the
16
16
  expectations of Stripe's API.
17
17
 
18
- == Documentation
18
+ ## Documentation
19
19
 
20
- {Ruby API Docs}[https://stripe.com/docs/api/ruby#intro]
20
+ See the [Ruby API docs](https://stripe.com/docs/api/ruby#intro).
21
21
 
22
- == Installation
22
+ ## Installation
23
23
 
24
- You don't need this source code unless you want to modify the gem. If
25
- you just want to use the Stripe Ruby bindings, you should run:
24
+ You don't need this source code unless you want to modify the gem. If you just
25
+ want to use the Stripe Ruby bindings, you should run:
26
26
 
27
- gem install stripe
27
+ gem install stripe
28
28
 
29
29
  If you want to build the gem from source:
30
30
 
31
- gem build stripe.gemspec
31
+ gem build stripe.gemspec
32
32
 
33
- == Requirements
33
+ ## Requirements
34
34
 
35
35
  * Ruby 1.9.3 or above.
36
- * rest-client, json
36
+ * rest-client
37
37
 
38
- == Bundler
38
+ ## Bundler
39
39
 
40
- If you are installing via bundler, you should be sure to use the https
41
- rubygems source in your Gemfile, as any gems fetched over http could potentially be
40
+ If you are installing via bundler, you should be sure to use the https rubygems
41
+ source in your Gemfile, as any gems fetched over http could potentially be
42
42
  compromised in transit and alter the code of gems fetched securely over https:
43
43
 
44
- source 'https://rubygems.org'
44
+ ``` ruby
45
+ source 'https://rubygems.org'
45
46
 
46
- gem 'rails'
47
- gem 'stripe'
47
+ gem 'rails'
48
+ gem 'stripe'
49
+ ```
48
50
 
49
- == Development
51
+ ## Development
50
52
 
51
53
  Run all tests:
52
54
 
@@ -64,20 +66,21 @@ Update bundled CA certificates from the [Mozilla cURL release][curl]:
64
66
 
65
67
  bundle exec rake update_certs
66
68
 
67
- == Configuration
69
+ ## Configuration
68
70
 
69
- === ca_bundle_path
71
+ ### ca_bundle_path
70
72
 
71
73
  The location of a file containing a bundle of CA certificates. By default the
72
74
  library will use an included bundle that can successfully validate Stripe
73
75
  certificates.
74
76
 
75
- === max_network_retries
77
+ ### max_network_retries
76
78
 
77
- When `max_network_retries` is set to a positive integer, stripe will retry requests that
78
- fail on a network error. Idempotency keys will be added to post and get requests to ensure the
79
- safety of retrying. There will be a short delay between each retry, with an exponential backoff
80
- algorithm used to determine the length of the delay. Default value is 0.
79
+ When `max_network_retries` is set to a positive integer, stripe will retry
80
+ requests that fail on a network error. Idempotency keys will be added to post
81
+ and get requests to ensure the safety of retrying. There will be a short delay
82
+ between each retry, with an exponential backoff algorithm used to determine the
83
+ length of the delay. Default value is 0.
81
84
 
82
85
  Example:
83
86
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.36.0
1
+ 1.36.1
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
3
2
 
4
- libs = " -r irb/completion"
5
- libs << " -r #{File.dirname(__FILE__) + '/../lib/stripe'}"
6
- puts "Loading stripe gem"
7
- exec "#{irb} #{libs} --simple-prompt"
3
+ require 'irb'
4
+ require 'irb/completion'
5
+
6
+ require "#{File.dirname(__FILE__)}/../lib/stripe"
7
+
8
+ # Config IRB to enable --simple-prompt and auto indent
9
+ IRB.conf[:PROMPT_MODE] = :SIMPLE
10
+ IRB.conf[:AUTO_INDENT] = true
11
+
12
+ puts "Loaded gem 'stripe'"
13
+
14
+ IRB.start
@@ -17,7 +17,7 @@ module Stripe
17
17
  # Let the caller override the URL but avoid serializing it.
18
18
  req_url = params.delete(:req_url) || save_url
19
19
 
20
- # We started unintentionally (sort of) allowing attributes send to
20
+ # We started unintentionally (sort of) allowing attributes sent to
21
21
  # +save+ to override values used during the update. So as not to break
22
22
  # the API, this makes that official here.
23
23
  update_attributes(params)
@@ -9,7 +9,7 @@ module Stripe
9
9
  # If you don't need access to an updated fee object after the refund, it's
10
10
  # more performant to just call `fee.refunds.create` directly.
11
11
  def refund(params={}, opts={})
12
- self.refunds.create
12
+ self.refunds.create(params, opts)
13
13
 
14
14
  # now that a refund has been created, we expect the state of this object
15
15
  # to change as well (i.e. `refunded` will now be `true`) so refresh it
@@ -152,6 +152,7 @@ module Stripe
152
152
  # the object has been reassigned
153
153
  # e.g. as object.key = {foo => bar}
154
154
  update = new_value
155
+ update = update.to_hash if update.is_a?(StripeObject)
155
156
  new_keys = update.keys.map(&:to_sym)
156
157
 
157
158
  # remove keys at the server, but not known locally
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.36.0'
2
+ VERSION = '1.36.1'
3
3
  end
@@ -14,7 +14,6 @@ spec = Gem::Specification.new do |s|
14
14
  s.license = 'MIT'
15
15
 
16
16
  s.add_dependency('rest-client', '~> 1.4')
17
- s.add_dependency('json', '~> 1.8.1')
18
17
 
19
18
  s.add_development_dependency('mocha', '~> 0.13.2')
20
19
  s.add_development_dependency('shoulda', '~> 3.4.0')
@@ -652,10 +652,10 @@ module Stripe
652
652
  :display_name => nil,
653
653
  })
654
654
 
655
- @mock.expects(:post).once.with("#{Stripe.api_base}/v1/accounts", nil, 'display_name=stripe').
655
+ @mock.expects(:post).once.with("#{Stripe.api_base}/v1/accounts", nil, 'display_name=stripe&metadata[key]=value').
656
656
  returns(make_response({"id" => "charge_id"}))
657
657
 
658
- account.save(:display_name => 'stripe')
658
+ account.save(:display_name => 'stripe', :metadata => {:key => 'value' })
659
659
  end
660
660
  end
661
661
 
@@ -665,14 +665,14 @@ module Stripe
665
665
  Stripe.stubs(:max_network_retries).returns(2)
666
666
  end
667
667
 
668
- should 'retry failed network requests if specified and raise if error persists' do
668
+ should 'retry failed network requests if specified and raise if error persists' do
669
669
  Stripe.expects(:sleep_time).at_least_once.returns(0)
670
670
  @mock.expects(:post).times(3).with('https://api.stripe.com/v1/charges', nil, 'amount=50&currency=usd').raises(Errno::ECONNREFUSED.new)
671
-
671
+
672
672
  err = assert_raises Stripe::APIConnectionError do
673
673
  Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
674
674
  end
675
- assert_match(/Request was retried 2 times/, err.message)
675
+ assert_match(/Request was retried 2 times/, err.message)
676
676
  end
677
677
 
678
678
  should 'retry failed network requests if specified and return successful response' do
@@ -687,11 +687,11 @@ module Stripe
687
687
 
688
688
  should 'not retry a SSLCertificateNotVerified error' do
689
689
  @mock.expects(:post).times(1).with('https://api.stripe.com/v1/charges', nil, 'amount=50&currency=usd').raises(RestClient::SSLCertificateNotVerified.new('message'))
690
-
690
+
691
691
  err = assert_raises Stripe::APIConnectionError do
692
692
  Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
693
- end
694
- assert_no_match(/retried/, err.message)
693
+ end
694
+ assert_no_match(/retried/, err.message)
695
695
  end
696
696
 
697
697
  should 'not add an idempotency key to GET requests' do
@@ -45,10 +45,23 @@ module Stripe
45
45
  end
46
46
 
47
47
  should "recursively call to_hash on its values" do
48
+ # deep nested hash (when contained in an array) or StripeObject
48
49
  nested_hash = { :id => 7, :foo => 'bar' }
49
50
  nested = Stripe::StripeObject.construct_from(nested_hash)
50
- obj = Stripe::StripeObject.construct_from({ :id => 1, :nested => nested, :list => [nested] })
51
- expected_hash = { :id => 1, :nested => nested_hash, :list => [nested_hash] }
51
+
52
+ obj = Stripe::StripeObject.construct_from({
53
+ :id => 1,
54
+ # simple hash that contains a StripeObject to help us test deep
55
+ # recursion
56
+ :nested => { :object => 'list', :data => [nested] },
57
+ :list => [nested]
58
+ })
59
+
60
+ expected_hash = {
61
+ :id => 1,
62
+ :nested => { :object => 'list', :data => [nested_hash] },
63
+ :list => [nested_hash]
64
+ }
52
65
  assert_equal expected_hash, obj.to_hash
53
66
  end
54
67
 
@@ -71,6 +84,12 @@ module Stripe
71
84
  assert_equal "foo", obj.unknown
72
85
  end
73
86
 
87
+ should "#update_attributes with a hash" do
88
+ obj = Stripe::StripeObject.construct_from({})
89
+ obj.update_attributes(:metadata => { :foo => 'bar' })
90
+ assert_equal Stripe::StripeObject, obj.metadata.class
91
+ end
92
+
74
93
  should "warn that #refresh_from is deprecated" do
75
94
  old_stderr = $stderr
76
95
  $stderr = StringIO.new
@@ -183,5 +202,17 @@ module Stripe
183
202
  obj.foo = ["0-index", "1-index", "2-index"]
184
203
  assert_equal({}, Stripe::StripeObject.serialize_params(obj))
185
204
  end
205
+
206
+ should "#serialize_params with a StripeObject" do
207
+ obj = Stripe::StripeObject.construct_from({})
208
+
209
+ # using an #update_attributes will end up converting a Hash into a
210
+ # StripeObject
211
+ obj.metadata =
212
+ Stripe::StripeObject.construct_from({ :foo => 'bar' })
213
+
214
+ serialized = Stripe::StripeObject.serialize_params(obj)
215
+ assert_equal({ :foo => "bar" }, serialized[:metadata])
216
+ end
186
217
  end
187
218
  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.36.0
4
+ version: 1.36.1
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-02-08 00:00:00.000000000 Z
12
+ date: 2016-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.4'
28
- - !ruby/object:Gem::Dependency
29
- name: json
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: 1.8.1
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: 1.8.1
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: mocha
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -153,12 +139,11 @@ files:
153
139
  - Gemfile
154
140
  - History.txt
155
141
  - LICENSE
156
- - README.rdoc
142
+ - README.md
157
143
  - Rakefile
158
144
  - VERSION
159
145
  - bin/stripe-console
160
146
  - gemfiles/default-with-activesupport.gemfile
161
- - gemfiles/json.gemfile
162
147
  - gemfiles/yajl.gemfile
163
148
  - lib/data/ca-certificates.crt
164
149
  - lib/stripe.rb
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => File.join(File.dirname(__FILE__), "..")
3
-
4
- gem 'activesupport'
5
- gem 'json'