stripe 1.35.0 → 1.35.1

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: f50fd1e27e8c051d54b1b3c25f043023dd4ad639
4
- data.tar.gz: 0c181ec61f06f8930b9e869417c78d7399d98ebe
3
+ metadata.gz: ba258c6ce34968c0caaadec16763905ff632084a
4
+ data.tar.gz: d80c2169b9ae78b37236a3124419679c7a2a93f7
5
5
  SHA512:
6
- metadata.gz: af8a5469317dfc41a081c8d8e744297f778844a50f2a8699a66790638abb97081eb0660f044478ab176ec9f5f8ebcae2ea42573173f888542cf2c2b158648b82
7
- data.tar.gz: b3db8bd2ead8c03e0d7b0c2914e50f695b75f6030e606bcb2783c1c7b37257238eb56f8cf0dcda741fd80289c9093afe0803ea3a4b56cf5723b69c38adb3b0ab
6
+ metadata.gz: dcf9630e2a0cf7e77bd21a933c00f91808418913a87b367ba7d4e19add2e9fda9b9632d6c111e9e9fa8ca1b575d75f1f1c44888dcf814017e14c46672b4cd67e
7
+ data.tar.gz: 1e28646f0b94e1c56d7acd5440d17707b1b247e2c1a593595520ee650a6de08a402548e8c3c9f9d0866ba0d8ac2b02740f84faf4f111042604caaccd33810ee7
@@ -1,3 +1,7 @@
1
+ === 1.35.1 2016-02-03
2
+
3
+ * Add compatibility layer for old API versions on `Charge#refund`
4
+
1
5
  === 1.35.0 2016-02-01
2
6
 
3
7
  * Allow CA cert bundle location to be configured
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.35.0
1
+ 1.35.1
@@ -5,12 +5,24 @@ module Stripe
5
5
  include Stripe::APIOperations::Update
6
6
 
7
7
  def refund(params={}, opts={})
8
- self.refunds.create(params, opts)
8
+ # Old versions of charge objects included a `refunds` field that was just
9
+ # a vanilla array instead of a Stripe list object.
10
+ #
11
+ # Where possible, we'd still like to use the new refund endpoint (thus
12
+ # `self.refunds.create`), but detect the old API version by looking for
13
+ # an `Array` and fall back to the old refund URL if necessary so as to
14
+ # maintain internal compatibility.
15
+ unless self.refunds.is_a?(Array)
16
+ refund = self.refunds.create(params, opts)
9
17
 
10
- # now that a refund has been created, we expect the state of this object
11
- # to change as well (i.e. `refunded` will now be `true`) so refresh it
12
- # from the server
13
- self.refresh
18
+ # now that a refund has been created, we expect the state of this object
19
+ # to change as well (i.e. `refunded` will now be `true`) so refresh it
20
+ # from the server
21
+ self.refresh
22
+ else
23
+ response, opts = request(:post, refund_url, params, opts)
24
+ initialize_from(response, opts)
25
+ end
14
26
  end
15
27
 
16
28
  def capture(params={}, opts={})
@@ -58,5 +70,11 @@ module Stripe
58
70
  def close_dispute_url
59
71
  url + '/dispute/close'
60
72
  end
73
+
74
+ # Note that this is actually the *old* refund URL and its use is no longer
75
+ # preferred.
76
+ def refund_url
77
+ url + '/refund'
78
+ end
61
79
  end
62
80
  end
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.35.0'
2
+ VERSION = '1.35.1'
3
3
  end
@@ -19,6 +19,20 @@ module Stripe
19
19
  assert r.is_a?(Stripe::Refund)
20
20
  end
21
21
 
22
+ should "charges should be refundable for old API versions" do
23
+ # "refunds" was a plain array in old API versions but is not a Stripe
24
+ # list (see the implementation of `make_charge` for a current example)
25
+ data = make_charge.merge!(:refunds => [])
26
+ c = Stripe::Charge.construct_from(data)
27
+ @mock.expects(:get).never
28
+ @mock.expects(:post).once.
29
+ with("#{Stripe.api_base}/v1/charges/#{c.id}/refund", nil, '').
30
+ returns(make_response(data.merge(:refunded => true)))
31
+ c = c.refund
32
+ assert c.is_a?(Stripe::Charge)
33
+ assert c.refunded
34
+ end
35
+
22
36
  should "charges should not be deletable" do
23
37
  assert_raises NoMethodError do
24
38
  @mock.expects(:get).once.returns(make_response(make_charge))
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.35.0
4
+ version: 1.35.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-01 00:00:00.000000000 Z
12
+ date: 2016-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client