stripe 1.24.0 → 1.25.0

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: 7ecbd18ba821963c6f74fe3f77824f17abc2fe69
4
- data.tar.gz: 88b6c051bb7a499cd1b0fe9ca017c56ee6ad3290
3
+ metadata.gz: 1e35419ace88d4f0aec2f7e5227a02dd5d9c4338
4
+ data.tar.gz: 223e592ef5558c048bff2825d31ed6842197b874
5
5
  SHA512:
6
- metadata.gz: 8bcd08d62d22be5862e078ec20c574c2dde8045ebc4a9897853dbf695909e5a62ac9ea8cd417d9385aeba2078ff42ab9221f55e10aa9412f7d43a9fc5ca099d3
7
- data.tar.gz: 09b0cb29cba10c861f4453cb648df2dacea2e7d1424ad1a1b141083b6ff5cb3f5cfbd105665aa22c98777e7df1e8d095733e4188c9eb16f911cf1d475453137a
6
+ metadata.gz: a0056b8bff477a1a2c5e7f2d25876af0aec97002ff4383bd4e4bab53c8e0c2018a18e1f95a50a85465b7baf2309d2cbb26b97abc121e7d90aa4945f6e77df0b3
7
+ data.tar.gz: e5126b06634a7c2062bbf60f1761eded6773dddb63d45d8a67302bbfcc3b60456f4db40ffbc398d5b6a24cd1f8d00a1b2fe6e37812b94a24717054be7506816f
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.25.0 2015-08-17
2
+
3
+ * Added support for refund listing and retrieval without an associated charge
4
+
1
5
  === 1.24.0 2015-08-03
2
6
 
3
7
  * Added support for deleting managed accounts
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.24.0
1
+ 1.25.0
data/lib/stripe/refund.rb CHANGED
@@ -1,14 +1,7 @@
1
1
  module Stripe
2
2
  class Refund < APIResource
3
- include Stripe::APIOperations::Update
3
+ include Stripe::APIOperations::Create
4
4
  include Stripe::APIOperations::List
5
-
6
- def url
7
- "#{Charge.url}/#{CGI.escape(charge)}/refunds/#{CGI.escape(id)}"
8
- end
9
-
10
- def self.retrieve(id, api_key=nil)
11
- raise NotImplementedError.new("Refunds cannot be retrieved without a charge ID. Retrieve a refund using charge.refunds.retrieve('refund_id')")
12
- end
5
+ include Stripe::APIOperations::Update
13
6
  end
14
7
  end
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.24.0'
2
+ VERSION = '1.25.0'
3
3
  end
@@ -0,0 +1,55 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Stripe
4
+ class ChargeRefundTest < Test::Unit::TestCase
5
+ should "refunds should be listable" do
6
+ @mock.expects(:get).once.returns(make_response(make_charge))
7
+
8
+ charge = Stripe::Charge.retrieve('test_charge')
9
+
10
+ assert charge.refunds.first.kind_of?(Stripe::Refund)
11
+ end
12
+
13
+ should "refunds should be refreshable" do
14
+ @mock.expects(:get).twice.returns(make_response(make_charge), make_response(make_refund(:id => 'refreshed_refund')))
15
+
16
+ charge = Stripe::Charge.retrieve('test_charge')
17
+ refund = charge.refunds.first
18
+ refund.refresh
19
+
20
+ assert_equal 'refreshed_refund', refund.id
21
+ end
22
+
23
+ should "refunds should be updateable" do
24
+ @mock.expects(:get).
25
+ with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil).
26
+ once.returns(make_response(make_charge))
27
+ @mock.expects(:post).
28
+ with("#{Stripe.api_base}/v1/refunds/ref_test_refund", nil, 'metadata[key]=value').
29
+ once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
30
+
31
+ charge = Stripe::Charge.retrieve('test_charge')
32
+ refund = charge.refunds.first
33
+
34
+ assert_equal nil, refund.metadata['key']
35
+
36
+ refund.metadata['key'] = 'value'
37
+ refund.save
38
+
39
+ assert_equal 'value', refund.metadata['key']
40
+ end
41
+
42
+ should "create should return a new refund" do
43
+ @mock.expects(:get).
44
+ with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil).
45
+ once.returns(make_response(make_charge(:id => 'test_charge')))
46
+ @mock.expects(:post).
47
+ with("#{Stripe.api_base}/v1/charges/test_charge/refunds", nil, 'amount=20').
48
+ once.returns(make_response(make_refund(:id => 'test_new_refund')))
49
+
50
+ charge = Stripe::Charge.retrieve('test_charge')
51
+ refund = charge.refunds.create(:amount => 20)
52
+ assert_equal 'test_new_refund', refund.id
53
+ end
54
+ end
55
+ end
@@ -3,44 +3,52 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  module Stripe
4
4
  class RefundTest < Test::Unit::TestCase
5
5
  should "refunds should be listable" do
6
- @mock.expects(:get).once.returns(make_response(make_charge))
6
+ @mock.expects(:get).
7
+ with("#{Stripe.api_base}/v1/refunds", nil, nil).
8
+ once.returns(make_response(make_refund_array))
7
9
 
8
- charge = Stripe::Charge.retrieve('test_charge')
10
+ refunds = Stripe::Refund.all
9
11
 
10
- assert charge.refunds.first.kind_of?(Stripe::Refund)
12
+ assert refunds.first.kind_of?(Stripe::Refund)
11
13
  end
12
14
 
13
15
  should "refunds should be refreshable" do
14
- @mock.expects(:get).twice.returns(make_response(make_charge), make_response(make_refund(:id => 'refreshed_refund')))
16
+ @mock.expects(:get).
17
+ with("#{Stripe.api_base}/v1/refunds/test_refund", nil, nil).
18
+ twice.returns(make_response(make_refund(:id => 'test_refund')),
19
+ make_response(make_refund(:id => 'refreshed_refund')))
15
20
 
16
- charge = Stripe::Charge.retrieve('test_charge')
17
- refund = charge.refunds.first
21
+ refund = Stripe::Refund.retrieve('test_refund')
18
22
  refund.refresh
19
23
 
20
24
  assert_equal 'refreshed_refund', refund.id
21
25
  end
22
26
 
23
27
  should "refunds should be updateable" do
24
- @mock.expects(:get).once.returns(make_response(make_charge))
25
- @mock.expects(:post).once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
28
+ @mock.expects(:get).
29
+ with("#{Stripe.api_base}/v1/refunds/get_refund", nil, nil).
30
+ once.returns(make_response(make_refund(:id => 'save_refund')))
26
31
 
27
- charge = Stripe::Charge.retrieve('test_charge')
28
- refund = charge.refunds.first
32
+ @mock.expects(:post).
33
+ with("#{Stripe.api_base}/v1/refunds/save_refund", nil, 'metadata[key]=value').
34
+ once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
35
+
36
+ refund = Stripe::Refund.retrieve('get_refund')
29
37
 
30
38
  assert_equal nil, refund.metadata['key']
31
39
 
32
- refund.metadata['key'] = 'valu'
40
+ refund.metadata['key'] = 'value'
33
41
  refund.save
34
42
 
35
43
  assert_equal 'value', refund.metadata['key']
36
44
  end
37
45
 
38
46
  should "create should return a new refund" do
39
- @mock.expects(:get).once.returns(make_response(make_charge))
40
- @mock.expects(:post).once.returns(make_response(make_refund(:id => 'test_new_refund')))
47
+ @mock.expects(:post).
48
+ with("#{Stripe.api_base}/v1/refunds", nil, 'charge=test_charge').
49
+ once.returns(make_response(make_refund(:id => 'test_new_refund')))
41
50
 
42
- charge = Stripe::Charge.retrieve('test_charge')
43
- refund = charge.refunds.create(:amount => 20)
51
+ refund = Stripe::Refund.create(:charge => 'test_charge')
44
52
  assert_equal 'test_new_refund', refund.id
45
53
  end
46
54
  end
data/test/test_data.rb CHANGED
@@ -284,11 +284,13 @@ module Stripe
284
284
  }
285
285
  end
286
286
 
287
- def make_refund_array(charge_id)
287
+ def make_refund_array(charge=nil)
288
+ p = charge ? {:charge => charge} : {}
289
+
288
290
  {
289
- :data => [make_refund, make_refund, make_refund],
291
+ :data => [make_refund(p), make_refund(p), make_refund(p)],
290
292
  :object => 'list',
291
- :url => '/v1/charges/' + charge_id + '/refunds'
293
+ :url => charge ? "/v1/charges/#{charge}/refunds" : '/v1/refunds'
292
294
  }
293
295
  end
294
296
 
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.24.0
4
+ version: 1.25.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: 2015-08-03 00:00:00.000000000 Z
12
+ date: 2015-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -168,6 +168,7 @@ files:
168
168
  - test/stripe/application_fee_test.rb
169
169
  - test/stripe/balance_test.rb
170
170
  - test/stripe/bitcoin_receiver_test.rb
171
+ - test/stripe/charge_refund_test.rb
171
172
  - test/stripe/charge_test.rb
172
173
  - test/stripe/coupon_test.rb
173
174
  - test/stripe/customer_card_test.rb
@@ -217,6 +218,7 @@ test_files:
217
218
  - test/stripe/application_fee_test.rb
218
219
  - test/stripe/balance_test.rb
219
220
  - test/stripe/bitcoin_receiver_test.rb
221
+ - test/stripe/charge_refund_test.rb
220
222
  - test/stripe/charge_test.rb
221
223
  - test/stripe/coupon_test.rb
222
224
  - test/stripe/customer_card_test.rb