stripe 1.58.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +4 -0
- data/.travis.yml +1 -2
- data/Gemfile +11 -12
- data/History.txt +8 -0
- data/README.md +44 -31
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +4 -344
- data/lib/stripe/account.rb +4 -4
- data/lib/stripe/api_operations/create.rb +2 -2
- data/lib/stripe/api_operations/delete.rb +2 -2
- data/lib/stripe/api_operations/list.rb +2 -2
- data/lib/stripe/api_operations/request.rb +9 -3
- data/lib/stripe/api_operations/save.rb +4 -6
- data/lib/stripe/api_resource.rb +2 -2
- data/lib/stripe/bank_account.rb +2 -2
- data/lib/stripe/bitcoin_receiver.rb +1 -1
- data/lib/stripe/charge.rb +12 -12
- data/lib/stripe/customer.rb +6 -6
- data/lib/stripe/dispute.rb +2 -3
- data/lib/stripe/errors.rb +20 -10
- data/lib/stripe/invoice.rb +4 -4
- data/lib/stripe/list_object.rb +2 -2
- data/lib/stripe/order.rb +4 -4
- data/lib/stripe/reversal.rb +1 -1
- data/lib/stripe/source.rb +2 -2
- data/lib/stripe/stripe_client.rb +396 -0
- data/lib/stripe/stripe_response.rb +48 -0
- data/lib/stripe/transfer.rb +2 -2
- data/lib/stripe/util.rb +6 -6
- data/lib/stripe/version.rb +1 -1
- data/spec/fixtures.json +0 -0
- data/spec/fixtures.yaml +0 -0
- data/spec/spec.json +0 -0
- data/spec/spec.yaml +0 -0
- data/stripe.gemspec +1 -1
- data/test/api_fixtures.rb +29 -0
- data/test/api_stub_helpers.rb +125 -0
- data/test/stripe/account_test.rb +153 -247
- data/test/stripe/alipay_account_test.rb +10 -2
- data/test/stripe/api_operations_test.rb +3 -3
- data/test/stripe/api_resource_test.rb +139 -499
- data/test/stripe/apple_pay_domain_test.rb +22 -23
- data/test/stripe/application_fee_refund_test.rb +22 -31
- data/test/stripe/application_fee_test.rb +6 -17
- data/test/stripe/balance_test.rb +3 -3
- data/test/stripe/bank_account_test.rb +31 -11
- data/test/stripe/bitcoin_receiver_test.rb +51 -42
- data/test/stripe/bitcoin_transaction_test.rb +11 -19
- data/test/stripe/charge_test.rb +39 -126
- data/test/stripe/country_spec_test.rb +7 -30
- data/test/stripe/coupon_test.rb +33 -17
- data/test/stripe/customer_card_test.rb +25 -46
- data/test/stripe/customer_test.rb +86 -81
- data/test/stripe/dispute_test.rb +27 -38
- data/test/stripe/errors_test.rb +2 -2
- data/test/stripe/file_upload_test.rb +32 -24
- data/test/stripe/invoice_item_test.rb +46 -10
- data/test/stripe/invoice_test.rb +48 -48
- data/test/stripe/list_object_test.rb +22 -31
- data/test/stripe/order_return_test.rb +11 -15
- data/test/stripe/order_test.rb +38 -51
- data/test/stripe/plan_test.rb +39 -18
- data/test/stripe/product_test.rb +29 -33
- data/test/stripe/recipient_card_test.rb +23 -40
- data/test/stripe/recipient_test.rb +39 -10
- data/test/stripe/refund_test.rb +20 -45
- data/test/stripe/reversal_test.rb +27 -31
- data/test/stripe/sku_test.rb +36 -19
- data/test/stripe/source_test.rb +26 -66
- data/test/stripe/stripe_client_test.rb +428 -0
- data/test/stripe/stripe_object_test.rb +6 -2
- data/test/stripe/stripe_response_test.rb +46 -0
- data/test/stripe/subscription_item_test.rb +37 -59
- data/test/stripe/subscription_test.rb +40 -176
- data/test/stripe/three_d_secure_test.rb +13 -12
- data/test/stripe/transfer_test.rb +36 -19
- data/test/stripe_test.rb +3 -36
- data/test/test_data.rb +5 -931
- data/test/test_helper.rb +21 -25
- metadata +22 -17
- data/test/stripe/charge_refund_test.rb +0 -67
- data/test/stripe/metadata_test.rb +0 -129
@@ -2,42 +2,19 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CountrySpecTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:country_spec)
|
6
|
+
|
5
7
|
should "be listable" do
|
6
|
-
@mock.expects(:get).once.
|
7
|
-
returns(make_response(country_spec_array))
|
8
8
|
c = Stripe::CountrySpec.list
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
assert(c.data.kind_of?(Array))
|
13
|
-
assert_equal('US', c.data[0].id)
|
14
|
-
assert(c.data[0].kind_of?(Stripe::CountrySpec))
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/country_specs"
|
10
|
+
assert c.data.kind_of?(Array)
|
11
|
+
assert c.data[0].kind_of?(Stripe::CountrySpec)
|
15
12
|
end
|
16
13
|
|
17
14
|
should "be retrievable" do
|
18
|
-
|
19
|
-
|
20
|
-
with('https://api.stripe.com/v1/country_specs/US', nil, nil).
|
21
|
-
returns(make_response(resp))
|
22
|
-
s = Stripe::CountrySpec.retrieve('US')
|
23
|
-
|
24
|
-
assert_equal('/v1/country_specs/US', s.resource_url)
|
25
|
-
assert_equal('country_spec', s.object)
|
15
|
+
s = Stripe::CountrySpec.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/country_specs/#{FIXTURE[:id]}"
|
26
17
|
assert(s.kind_of?(Stripe::CountrySpec))
|
27
|
-
|
28
|
-
s.supported_bank_account_currencies.map{ |k,v| assert v.kind_of?(Array) }
|
29
|
-
assert_equal(['US'], s.supported_bank_account_currencies['usd'])
|
30
|
-
assert(s.supported_payment_currencies.include?('usd'))
|
31
|
-
assert s.supported_payment_currencies.kind_of?(Array)
|
32
|
-
assert s.supported_payment_methods.kind_of?(Array)
|
33
|
-
|
34
|
-
['individual', 'company'].map{ |type|
|
35
|
-
item = s.verification_fields[type]
|
36
|
-
assert item.minimum.include?('external_account')
|
37
|
-
assert item.additional.include?('legal_entity.verification.document')
|
38
|
-
assert item.additional.kind_of?(Array)
|
39
|
-
assert item.minimum.kind_of?(Array)
|
40
|
-
}
|
41
18
|
end
|
42
19
|
end
|
43
20
|
end
|
data/test/stripe/coupon_test.rb
CHANGED
@@ -2,27 +2,43 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CouponTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:coupon)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
coupons = Stripe::Coupon.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/coupons"
|
10
|
+
assert coupons.data.kind_of?(Array)
|
11
|
+
assert coupons.first.kind_of?(Stripe::Coupon)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
coupon = Stripe::Coupon.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
|
17
|
+
assert coupon.kind_of?(Stripe::Coupon)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
coupon = Stripe::Coupon.create(
|
22
|
+
percent_off: 25,
|
23
|
+
duration: 'repeating',
|
24
|
+
duration_in_months: 3,
|
25
|
+
id: '25OFF'
|
26
|
+
)
|
27
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons"
|
28
|
+
assert coupon.kind_of?(Stripe::Coupon)
|
9
29
|
end
|
10
30
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
c.metadata['foo'] = 'bar'
|
17
|
-
c.save
|
31
|
+
should "be saveable" do
|
32
|
+
coupon = Stripe::Coupon.retrieve(FIXTURE[:id])
|
33
|
+
coupon.metadata['key'] = 'value'
|
34
|
+
coupon.save
|
35
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
|
18
36
|
end
|
19
37
|
|
20
|
-
should "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
c = Stripe::Coupon.update("test_coupon", metadata: {foo: 'bar'})
|
25
|
-
assert_equal('bar', c.metadata['foo'])
|
38
|
+
should "be updateable" do
|
39
|
+
coupon = Stripe::Coupon.update(FIXTURE[:id], metadata: { key: 'value' })
|
40
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
|
41
|
+
assert coupon.kind_of?(Stripe::Coupon)
|
26
42
|
end
|
27
43
|
end
|
28
44
|
end
|
@@ -2,62 +2,41 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CustomerCardTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:source)
|
6
6
|
|
7
|
-
|
8
|
-
@
|
9
|
-
|
7
|
+
setup do
|
8
|
+
@customer =
|
9
|
+
Stripe::Customer.retrieve(API_FIXTURES.fetch(:customer)[:id])
|
10
10
|
end
|
11
11
|
|
12
|
-
should "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
assert
|
12
|
+
should "be listable" do
|
13
|
+
sources = @customer.sources.list
|
14
|
+
assert sources.data.kind_of?(Array)
|
15
|
+
# because of the terrible :wildcard nature of sources, the API stub
|
16
|
+
# cannot currently replace this response with anything meaningful so we
|
17
|
+
# don't assert on the type of individual items like we do in other tests
|
18
18
|
end
|
19
19
|
|
20
|
-
should "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
26
|
-
card = c.sources.retrieve('card')
|
27
|
-
assert_equal CUSTOMER_CARD_URL, card.resource_url
|
20
|
+
should "be creatable" do
|
21
|
+
card = @customer.sources.create(
|
22
|
+
source: API_FIXTURES.fetch(:token)[:id]
|
23
|
+
)
|
24
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
|
25
|
+
assert card.kind_of?(Stripe::BankAccount)
|
28
26
|
end
|
29
27
|
|
30
|
-
should "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
card
|
35
|
-
card.delete
|
36
|
-
assert card.deleted
|
28
|
+
should "be deletable" do
|
29
|
+
card = Stripe::Card.construct_from(FIXTURE.merge(customer: @customer.id))
|
30
|
+
card = card.delete
|
31
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/#{FIXTURE[:id]}"
|
32
|
+
assert card.kind_of?(Stripe::Card)
|
37
33
|
end
|
38
34
|
|
39
|
-
should "
|
40
|
-
|
41
|
-
|
42
|
-
@mock.expects(:post).once.returns(make_response(make_card(:exp_year => "2100")))
|
43
|
-
card = c.sources.retrieve('card')
|
44
|
-
assert_equal "2000", card.exp_year
|
45
|
-
card.exp_year = "2100"
|
35
|
+
should "be saveable" do
|
36
|
+
card = Stripe::Card.construct_from(FIXTURE.merge(customer: @customer.id))
|
37
|
+
card.metadata['key'] = 'value'
|
46
38
|
card.save
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
should "create should return a new customer card" do
|
51
|
-
c = customer
|
52
|
-
@mock.expects(:post).once.returns(make_response(make_card(:id => "test_card")))
|
53
|
-
card = c.sources.create(:source => "tok_41YJ05ijAaWaFS")
|
54
|
-
assert_equal "test_card", card.id
|
55
|
-
end
|
56
|
-
|
57
|
-
should "raise if accessing Stripe::Card.retrieve directly" do
|
58
|
-
assert_raises NotImplementedError do
|
59
|
-
Stripe::Card.retrieve "card_12345"
|
60
|
-
end
|
39
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/#{FIXTURE[:id]}"
|
61
40
|
end
|
62
41
|
end
|
63
42
|
end
|
@@ -2,109 +2,114 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CustomerTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_customer_array))
|
7
|
-
c = Stripe::Customer.list.data
|
8
|
-
assert c.kind_of? Array
|
9
|
-
assert c[0].kind_of? Stripe::Customer
|
10
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:customer)
|
11
6
|
|
12
|
-
should "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
assert
|
7
|
+
should "be listable" do
|
8
|
+
customers = Stripe::Customer.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/customers"
|
10
|
+
assert customers.data.kind_of?(Array)
|
11
|
+
assert customers.first.kind_of?(Stripe::Customer)
|
17
12
|
end
|
18
13
|
|
19
|
-
should "
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
assert_equal "foo", c.mnemonic
|
24
|
-
c.mnemonic = "bar"
|
25
|
-
c.save
|
26
|
-
assert_equal "bar", c.mnemonic
|
14
|
+
should "be retrievable" do
|
15
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/customers/#{FIXTURE[:id]}"
|
17
|
+
assert customer.kind_of?(Stripe::Customer)
|
27
18
|
end
|
28
19
|
|
29
|
-
should "
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
c = Stripe::Customer.update("test_customer", metadata: {foo: 'bar'})
|
34
|
-
assert_equal('bar', c.metadata['foo'])
|
20
|
+
should "be creatable" do
|
21
|
+
customer = Stripe::Customer.create
|
22
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers"
|
23
|
+
assert customer.kind_of?(Stripe::Customer)
|
35
24
|
end
|
36
25
|
|
37
|
-
should "
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
should "be saveable" do
|
27
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
28
|
+
customer.metadata['key'] = 'value'
|
29
|
+
customer.save
|
30
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{FIXTURE[:id]}"
|
41
31
|
end
|
42
32
|
|
43
|
-
should "
|
44
|
-
|
45
|
-
|
46
|
-
|
33
|
+
should "be updateable" do
|
34
|
+
customer = Stripe::Customer.update(FIXTURE[:id], metadata: { key: 'value' })
|
35
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{FIXTURE[:id]}"
|
36
|
+
assert customer.kind_of?(Stripe::Customer)
|
47
37
|
end
|
48
38
|
|
49
|
-
should "be
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
url == "#{Stripe.api_base}/v1/customers/c_test_customer/subscription" && api_key.nil? && CGI.parse(params) == {'plan' => ['silver']}
|
55
|
-
end.returns(make_response(make_subscription(:plan => 'silver')))
|
56
|
-
s = c.update_subscription({:plan => 'silver'})
|
57
|
-
|
58
|
-
assert_equal 'subscription', s.object
|
59
|
-
assert_equal 'silver', s.plan.identifier
|
39
|
+
should "be deletable" do
|
40
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
41
|
+
customer = customer.delete
|
42
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{FIXTURE[:id]}"
|
43
|
+
assert customer.kind_of?(Stripe::Customer)
|
60
44
|
end
|
61
45
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscription?at_period_end=true", nil, nil).returns(make_response(make_subscription(:plan => 'silver')))
|
69
|
-
c.cancel_subscription({:at_period_end => 'true'})
|
70
|
-
|
71
|
-
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscription", nil, nil).returns(make_response(make_subscription(:plan => 'silver')))
|
72
|
-
c.cancel_subscription
|
46
|
+
context "#create_subscription" do
|
47
|
+
should "create a new subscription" do
|
48
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
49
|
+
subscription = customer.create_subscription({:plan => 'silver'})
|
50
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
51
|
+
end
|
73
52
|
end
|
74
53
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
s = c.create_subscription({:plan => 'silver'})
|
82
|
-
|
83
|
-
assert_equal 'subscription', s.object
|
84
|
-
assert_equal 'silver', s.plan.identifier
|
54
|
+
context "#create_upcoming_invoice" do
|
55
|
+
should "create a new invoice" do
|
56
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
57
|
+
invoice = customer.create_upcoming_invoice
|
58
|
+
assert invoice.kind_of?(Stripe::Invoice)
|
59
|
+
end
|
85
60
|
end
|
86
61
|
|
87
|
-
|
88
|
-
|
89
|
-
|
62
|
+
context "#update_subscription" do
|
63
|
+
should "update a subscription" do
|
64
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
65
|
+
|
66
|
+
# deprecated API and not in schema
|
67
|
+
stub_request(:post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription").
|
68
|
+
with(body: { plan: "silver" }).
|
69
|
+
to_return(body: JSON.generate(API_FIXTURES[:subscription]))
|
70
|
+
subscription = customer.update_subscription({:plan => 'silver'})
|
71
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
72
|
+
end
|
73
|
+
end
|
90
74
|
|
91
|
-
|
92
|
-
|
93
|
-
|
75
|
+
context "#cancel_subscription" do
|
76
|
+
should "cancel a subscription" do
|
77
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
78
|
+
|
79
|
+
# deprecated API and not in schema
|
80
|
+
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription").
|
81
|
+
with(query: { at_period_end: "true" }).
|
82
|
+
to_return(body: JSON.generate(API_FIXTURES[:subscription]))
|
83
|
+
subscription = customer.cancel_subscription({:at_period_end => 'true'})
|
84
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
85
|
+
end
|
94
86
|
end
|
95
87
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
88
|
+
context "#delete_discount" do
|
89
|
+
should "delete a discount" do
|
90
|
+
customer = Stripe::Customer.retrieve(FIXTURE[:id])
|
91
|
+
|
92
|
+
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount").
|
93
|
+
to_return(body: JSON.generate(API_FIXTURES[:discount]))
|
94
|
+
discount = customer.delete_discount
|
95
|
+
assert discount.kind_of?(Stripe::Customer)
|
96
|
+
end
|
100
97
|
end
|
101
98
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
99
|
+
context "source field" do
|
100
|
+
should "allow setting source with token" do
|
101
|
+
c = Stripe::Customer.new("test_customer")
|
102
|
+
c.source = "tok_123"
|
103
|
+
assert_equal "tok_123", c.source
|
104
|
+
end
|
105
|
+
|
106
|
+
should "allow setting source with hash and set flag" do
|
107
|
+
c = Stripe::Customer.new("test_customer")
|
108
|
+
c.source = {
|
109
|
+
:object => 'card'
|
110
|
+
}
|
111
|
+
assert_equal true, c.source.save_with_parent
|
112
|
+
end
|
108
113
|
end
|
109
114
|
end
|
110
115
|
end
|
data/test/stripe/dispute_test.rb
CHANGED
@@ -2,52 +2,41 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class DisputeTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_dispute))
|
7
|
-
d = Stripe::Dispute.retrieve('dp_test_dispute')
|
8
|
-
assert d.kind_of?(Stripe::Dispute)
|
9
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:dispute)
|
10
6
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
assert
|
15
|
-
|
16
|
-
assert dispute.kind_of?(Stripe::Dispute)
|
17
|
-
end
|
7
|
+
should "be listable" do
|
8
|
+
disputes = Stripe::Dispute.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/disputes"
|
10
|
+
assert disputes.data.kind_of?(Array)
|
11
|
+
assert disputes.first.kind_of?(Stripe::Dispute)
|
18
12
|
end
|
19
13
|
|
20
|
-
should "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
nil,
|
25
|
-
''
|
26
|
-
).once.returns(make_response({:id => 'dp_test_dispute', :status => 'lost'}))
|
27
|
-
d = Stripe::Dispute.new('test_dispute')
|
28
|
-
d.close
|
14
|
+
should "be retrievable" do
|
15
|
+
dispute = Stripe::Dispute.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/disputes/#{FIXTURE[:id]}"
|
17
|
+
assert dispute.kind_of?(Stripe::Dispute)
|
29
18
|
end
|
30
19
|
|
31
|
-
should "
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
assert_equal('bar', d.metadata['foo'])
|
20
|
+
should "be saveable" do
|
21
|
+
dispute = Stripe::Dispute.retrieve(FIXTURE[:id])
|
22
|
+
dispute.metadata['key'] = 'value'
|
23
|
+
dispute.save
|
24
|
+
assert_requested :post, "#{Stripe.api_base}/v1/disputes/#{FIXTURE[:id]}"
|
37
25
|
end
|
38
26
|
|
39
|
-
should "
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
'evidence[customer_name]=customer'
|
45
|
-
).once.returns(make_response(make_dispute))
|
27
|
+
should "be updateable" do
|
28
|
+
dispute = Stripe::Dispute.update(FIXTURE[:id], metadata: { key: 'value' })
|
29
|
+
assert_requested :post, "#{Stripe.api_base}/v1/disputes/#{FIXTURE[:id]}"
|
30
|
+
assert dispute.kind_of?(Stripe::Dispute)
|
31
|
+
end
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
33
|
+
context "#close" do
|
34
|
+
should "be closeable" do
|
35
|
+
dispute = Stripe::Dispute.retrieve(FIXTURE[:id])
|
36
|
+
dispute.close
|
37
|
+
assert_requested :post,
|
38
|
+
"#{Stripe.api_base}/v1/disputes/#{FIXTURE[:id]}/close"
|
39
|
+
end
|
51
40
|
end
|
52
41
|
end
|
53
42
|
end
|