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 +4 -4
- data/History.txt +4 -0
- data/VERSION +1 -1
- data/lib/stripe/refund.rb +2 -9
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/charge_refund_test.rb +55 -0
- data/test/stripe/refund_test.rb +23 -15
- data/test/test_data.rb +5 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e35419ace88d4f0aec2f7e5227a02dd5d9c4338
|
4
|
+
data.tar.gz: 223e592ef5558c048bff2825d31ed6842197b874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0056b8bff477a1a2c5e7f2d25876af0aec97002ff4383bd4e4bab53c8e0c2018a18e1f95a50a85465b7baf2309d2cbb26b97abc121e7d90aa4945f6e77df0b3
|
7
|
+
data.tar.gz: e5126b06634a7c2062bbf60f1761eded6773dddb63d45d8a67302bbfcc3b60456f4db40ffbc398d5b6a24cd1f8d00a1b2fe6e37812b94a24717054be7506816f
|
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
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::
|
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
|
data/lib/stripe/version.rb
CHANGED
@@ -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
|
data/test/stripe/refund_test.rb
CHANGED
@@ -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).
|
6
|
+
@mock.expects(:get).
|
7
|
+
with("#{Stripe.api_base}/v1/refunds", nil, nil).
|
8
|
+
once.returns(make_response(make_refund_array))
|
7
9
|
|
8
|
-
|
10
|
+
refunds = Stripe::Refund.all
|
9
11
|
|
10
|
-
assert
|
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).
|
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
|
-
|
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).
|
25
|
-
|
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
|
-
|
28
|
-
|
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'] = '
|
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(:
|
40
|
-
|
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
|
-
|
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(
|
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 =>
|
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.
|
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-
|
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
|