stripe 3.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +23 -0
- data/Gemfile +1 -2
- data/History.txt +4 -0
- data/README.md +28 -3
- data/Rakefile +0 -12
- data/VERSION +1 -1
- data/lib/stripe.rb +24 -0
- data/lib/stripe/stripe_client.rb +166 -19
- data/lib/stripe/util.rb +127 -8
- data/lib/stripe/version.rb +1 -1
- data/test/api_stub_helpers.rb +0 -125
- data/test/stripe/account_test.rb +11 -13
- data/test/stripe/alipay_account_test.rb +2 -4
- data/test/stripe/api_resource_test.rb +112 -76
- data/test/stripe/apple_pay_domain_test.rb +4 -6
- data/test/stripe/application_fee_refund_test.rb +2 -5
- data/test/stripe/application_fee_test.rb +0 -2
- data/test/stripe/bank_account_test.rb +8 -13
- data/test/stripe/bitcoin_receiver_test.rb +13 -16
- data/test/stripe/bitcoin_transaction_test.rb +2 -4
- data/test/stripe/charge_test.rb +9 -11
- data/test/stripe/country_spec_test.rb +2 -4
- data/test/stripe/coupon_test.rb +6 -8
- data/test/stripe/customer_card_test.rb +13 -9
- data/test/stripe/customer_test.rb +16 -18
- data/test/stripe/dispute_test.rb +8 -10
- data/test/stripe/file_upload_test.rb +3 -3
- data/test/stripe/invoice_item_test.rb +9 -11
- data/test/stripe/invoice_line_item_test.rb +0 -1
- data/test/stripe/invoice_test.rb +39 -21
- data/test/stripe/list_object_test.rb +1 -1
- data/test/stripe/login_link_test.rb +6 -7
- data/test/stripe/order_return_test.rb +2 -4
- data/test/stripe/order_test.rb +10 -12
- data/test/stripe/payout_test.rb +7 -9
- data/test/stripe/plan_test.rb +8 -10
- data/test/stripe/product_test.rb +8 -10
- data/test/stripe/recipient_card_test.rb +13 -9
- data/test/stripe/recipient_test.rb +8 -10
- data/test/stripe/refund_test.rb +7 -9
- data/test/stripe/reversal_test.rb +5 -7
- data/test/stripe/sku_test.rb +9 -11
- data/test/stripe/source_test.rb +16 -15
- data/test/stripe/stripe_client_test.rb +190 -26
- data/test/stripe/subscription_item_test.rb +12 -14
- data/test/stripe/subscription_test.rb +10 -12
- data/test/stripe/three_d_secure_test.rb +3 -5
- data/test/stripe/transfer_test.rb +7 -9
- data/test/stripe/util_test.rb +164 -0
- data/test/test_helper.rb +33 -18
- metadata +2 -8
- data/openapi/fixtures.json +0 -1896
- data/openapi/fixtures.yaml +0 -1505
- data/openapi/spec2.json +0 -24601
- data/openapi/spec2.yaml +0 -18801
- data/test/api_fixtures.rb +0 -29
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplePayDomainTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:apple_pay_domain)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
domains = Stripe::ApplePayDomain.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains"
|
@@ -12,8 +10,8 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
domain = Stripe::ApplePayDomain.retrieve(
|
16
|
-
|
13
|
+
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains/apwc_123"
|
17
15
|
assert domain.kind_of?(Stripe::ApplePayDomain)
|
18
16
|
end
|
19
17
|
|
@@ -24,9 +22,9 @@ module Stripe
|
|
24
22
|
end
|
25
23
|
|
26
24
|
should "be deletable" do
|
27
|
-
domain = Stripe::ApplePayDomain.retrieve(
|
25
|
+
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
28
26
|
domain = domain.delete
|
29
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{
|
27
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{domain.id}"
|
30
28
|
assert domain.kind_of?(Stripe::ApplePayDomain)
|
31
29
|
end
|
32
30
|
end
|
@@ -2,11 +2,8 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplicationFeeRefundTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:fee_refund)
|
6
|
-
|
7
5
|
setup do
|
8
|
-
|
9
|
-
@fee = Stripe::ApplicationFee.retrieve(application_fee_fixture[:id])
|
6
|
+
@fee = Stripe::ApplicationFee.retrieve("fee_123")
|
10
7
|
end
|
11
8
|
|
12
9
|
should "be listable" do
|
@@ -32,7 +29,7 @@ module Stripe
|
|
32
29
|
refund.metadata['key'] = 'value'
|
33
30
|
refund.save
|
34
31
|
assert_requested :post,
|
35
|
-
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{
|
32
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{refund.id}"
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplicationFeeTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:platform_earning)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
fees = Stripe::ApplicationFee.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/application_fees"
|
@@ -2,36 +2,31 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BankAccountTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:external_account_source)
|
6
|
-
|
7
5
|
context "#resource_url" do
|
8
6
|
should "return an external account URL" do
|
9
|
-
account_id = API_FIXTURES.fetch(:account)[:id]
|
10
7
|
bank_account = Stripe::BankAccount.construct_from(
|
11
|
-
account:
|
12
|
-
id:
|
8
|
+
account: "acct_123",
|
9
|
+
id: "ba_123"
|
13
10
|
)
|
14
|
-
assert_equal "/v1/accounts
|
11
|
+
assert_equal "/v1/accounts/acct_123/external_accounts/ba_123",
|
15
12
|
bank_account.resource_url
|
16
13
|
end
|
17
14
|
|
18
15
|
should "return a customer URL" do
|
19
|
-
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
20
16
|
bank_account = Stripe::BankAccount.construct_from(
|
21
|
-
customer:
|
22
|
-
id:
|
17
|
+
customer: "cus_123",
|
18
|
+
id: "ba_123",
|
23
19
|
)
|
24
|
-
assert_equal "/v1/customers
|
20
|
+
assert_equal "/v1/customers/cus_123/sources/ba_123",
|
25
21
|
bank_account.resource_url
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
25
|
context "#verify" do
|
30
26
|
should 'verify the account' do
|
31
|
-
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
32
27
|
bank_account = Stripe::BankAccount.construct_from({
|
33
|
-
customer:
|
34
|
-
id:
|
28
|
+
customer: "cus_123",
|
29
|
+
id: "ba_123",
|
35
30
|
})
|
36
31
|
bank_account = bank_account.verify(amounts: [1,2])
|
37
32
|
assert bank_account.kind_of?(Stripe::BankAccount)
|
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BitcoinReceiverTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:bitcoin_receiver)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
receivers = Stripe::BitcoinReceiver.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/bitcoin/receivers"
|
@@ -12,9 +10,9 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
receiver = Stripe::BitcoinReceiver.retrieve(
|
13
|
+
receiver = Stripe::BitcoinReceiver.retrieve("btcrcv_123")
|
16
14
|
assert_requested :get,
|
17
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers
|
15
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_123"
|
18
16
|
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
19
17
|
end
|
20
18
|
|
@@ -25,44 +23,43 @@ module Stripe
|
|
25
23
|
end
|
26
24
|
|
27
25
|
should "be saveable" do
|
28
|
-
receiver = Stripe::BitcoinReceiver.retrieve(
|
26
|
+
receiver = Stripe::BitcoinReceiver.retrieve("btcrcv_123")
|
29
27
|
receiver.metadata['key'] = 'value'
|
30
28
|
receiver.save
|
31
29
|
assert_requested :post,
|
32
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers/#{
|
30
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/#{receiver.id}"
|
33
31
|
end
|
34
32
|
|
35
33
|
should "be updateable" do
|
36
|
-
receiver = Stripe::BitcoinReceiver.update(
|
34
|
+
receiver = Stripe::BitcoinReceiver.update("btcrcv_123", metadata: { key: 'value' })
|
37
35
|
assert_requested :post,
|
38
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers
|
36
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_123"
|
39
37
|
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
40
38
|
end
|
41
39
|
|
42
40
|
should "be deletable" do
|
43
|
-
receiver = Stripe::BitcoinReceiver.retrieve(
|
41
|
+
receiver = Stripe::BitcoinReceiver.retrieve("btcrcv_123")
|
44
42
|
receiver = receiver.delete
|
45
43
|
assert_requested :delete,
|
46
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers/#{
|
44
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/#{receiver.id}"
|
47
45
|
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
48
46
|
end
|
49
47
|
|
50
48
|
context "#resource_url" do
|
51
49
|
should "return a customer URL" do
|
52
|
-
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
53
50
|
receiver = Stripe::BitcoinReceiver.construct_from(
|
54
|
-
customer:
|
55
|
-
id:
|
51
|
+
customer: "cus_123",
|
52
|
+
id: "btcrcv_123",
|
56
53
|
)
|
57
|
-
assert_equal "/v1/customers
|
54
|
+
assert_equal "/v1/customers/cus_123/sources/btcrcv_123",
|
58
55
|
receiver.resource_url
|
59
56
|
end
|
60
57
|
|
61
58
|
should "return an absolute URL" do
|
62
59
|
receiver = Stripe::BitcoinReceiver.construct_from(
|
63
|
-
id:
|
60
|
+
id: "btcrcv_123",
|
64
61
|
)
|
65
|
-
assert_equal "/v1/bitcoin/receivers
|
62
|
+
assert_equal "/v1/bitcoin/receivers/btcrcv_123",
|
66
63
|
receiver.resource_url
|
67
64
|
end
|
68
65
|
end
|
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BitcoinTransactionTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:bitcoin_transaction)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
transactions = Stripe::BitcoinTransaction.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/bitcoin/transactions"
|
@@ -12,9 +10,9 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
transaction = Stripe::BitcoinTransaction.retrieve(
|
13
|
+
transaction = Stripe::BitcoinTransaction.retrieve("btctxn_123")
|
16
14
|
assert_requested :get,
|
17
|
-
"#{Stripe.api_base}/v1/bitcoin/transactions
|
15
|
+
"#{Stripe.api_base}/v1/bitcoin/transactions/btctxn_123"
|
18
16
|
assert transaction.kind_of?(Stripe::BitcoinTransaction)
|
19
17
|
end
|
20
18
|
end
|
data/test/stripe/charge_test.rb
CHANGED
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ChargeTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:charge)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
charges = Stripe::Charge.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/charges"
|
@@ -12,8 +10,8 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
charge = Stripe::Charge.retrieve(
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/charges
|
13
|
+
charge = Stripe::Charge.retrieve("ch_123")
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/charges/ch_123"
|
17
15
|
assert charge.kind_of?(Stripe::Charge)
|
18
16
|
end
|
19
17
|
|
@@ -21,28 +19,28 @@ module Stripe
|
|
21
19
|
charge = Stripe::Charge.create(
|
22
20
|
amount: 100,
|
23
21
|
currency: "USD",
|
24
|
-
source:
|
22
|
+
source: "src_123",
|
25
23
|
)
|
26
24
|
assert_requested :post, "#{Stripe.api_base}/v1/charges"
|
27
25
|
assert charge.kind_of?(Stripe::Charge)
|
28
26
|
end
|
29
27
|
|
30
28
|
should "be saveable" do
|
31
|
-
charge = Stripe::Charge.retrieve(
|
29
|
+
charge = Stripe::Charge.retrieve("ch_123")
|
32
30
|
charge.metadata['key'] = 'value'
|
33
31
|
charge.save
|
34
|
-
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{
|
32
|
+
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{charge.id}"
|
35
33
|
end
|
36
34
|
|
37
35
|
should "be updateable" do
|
38
|
-
charge = Stripe::Charge.update(
|
39
|
-
assert_requested :post, "#{Stripe.api_base}/v1/charges
|
36
|
+
charge = Stripe::Charge.update("ch_123", metadata: {foo: 'bar'})
|
37
|
+
assert_requested :post, "#{Stripe.api_base}/v1/charges/ch_123"
|
40
38
|
assert charge.kind_of?(Stripe::Charge)
|
41
39
|
end
|
42
40
|
|
43
41
|
context "#mark_as_fraudulent" do
|
44
42
|
should "charges should be able to be marked as fraudulent" do
|
45
|
-
charge = Stripe::Charge.retrieve(
|
43
|
+
charge = Stripe::Charge.retrieve("ch_123")
|
46
44
|
charge = charge.mark_as_fraudulent
|
47
45
|
assert charge.kind_of?(Stripe::Charge)
|
48
46
|
end
|
@@ -50,7 +48,7 @@ module Stripe
|
|
50
48
|
|
51
49
|
context "#mark_as_safe" do
|
52
50
|
should "charges should be able to be marked as safe" do
|
53
|
-
charge = Stripe::Charge.retrieve(
|
51
|
+
charge = Stripe::Charge.retrieve("ch_123")
|
54
52
|
charge = charge.mark_as_safe
|
55
53
|
assert charge.kind_of?(Stripe::Charge)
|
56
54
|
end
|
@@ -2,8 +2,6 @@ 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
|
-
|
7
5
|
should "be listable" do
|
8
6
|
c = Stripe::CountrySpec.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/country_specs"
|
@@ -12,8 +10,8 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
s = Stripe::CountrySpec.retrieve(
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/country_specs
|
13
|
+
s = Stripe::CountrySpec.retrieve("US")
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/country_specs/US"
|
17
15
|
assert(s.kind_of?(Stripe::CountrySpec))
|
18
16
|
end
|
19
17
|
end
|
data/test/stripe/coupon_test.rb
CHANGED
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CouponTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:coupon)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
coupons = Stripe::Coupon.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/coupons"
|
@@ -12,8 +10,8 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
coupon = Stripe::Coupon.retrieve(
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/coupons
|
13
|
+
coupon = Stripe::Coupon.retrieve("25OFF")
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/coupons/25OFF"
|
17
15
|
assert coupon.kind_of?(Stripe::Coupon)
|
18
16
|
end
|
19
17
|
|
@@ -29,15 +27,15 @@ module Stripe
|
|
29
27
|
end
|
30
28
|
|
31
29
|
should "be saveable" do
|
32
|
-
coupon = Stripe::Coupon.retrieve(
|
30
|
+
coupon = Stripe::Coupon.retrieve("25OFF")
|
33
31
|
coupon.metadata['key'] = 'value'
|
34
32
|
coupon.save
|
35
|
-
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{
|
33
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{coupon.id}"
|
36
34
|
end
|
37
35
|
|
38
36
|
should "be updateable" do
|
39
|
-
coupon = Stripe::Coupon.update(
|
40
|
-
assert_requested :post, "#{Stripe.api_base}/v1/coupons
|
37
|
+
coupon = Stripe::Coupon.update("25OFF", metadata: { key: 'value' })
|
38
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons/25OFF"
|
41
39
|
assert coupon.kind_of?(Stripe::Coupon)
|
42
40
|
end
|
43
41
|
end
|
@@ -2,11 +2,8 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CustomerCardTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:card)
|
6
|
-
|
7
5
|
setup do
|
8
|
-
@customer =
|
9
|
-
Stripe::Customer.retrieve(API_FIXTURES.fetch(:customer)[:id])
|
6
|
+
@customer = Stripe::Customer.retrieve("cus_123")
|
10
7
|
end
|
11
8
|
|
12
9
|
should "be listable" do
|
@@ -19,24 +16,31 @@ module Stripe
|
|
19
16
|
|
20
17
|
should "be creatable" do
|
21
18
|
card = @customer.sources.create(
|
22
|
-
source:
|
19
|
+
source: "tok_123",
|
23
20
|
)
|
24
21
|
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
|
25
22
|
assert card.kind_of?(Stripe::BankAccount)
|
26
23
|
end
|
27
24
|
|
28
25
|
should "be deletable" do
|
29
|
-
card = Stripe::Card.construct_from(
|
26
|
+
card = Stripe::Card.construct_from({
|
27
|
+
customer: @customer.id,
|
28
|
+
id: "card_123"
|
29
|
+
})
|
30
30
|
card = card.delete
|
31
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources
|
31
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
|
32
32
|
assert card.kind_of?(Stripe::Card)
|
33
33
|
end
|
34
34
|
|
35
35
|
should "be saveable" do
|
36
|
-
card = Stripe::Card.construct_from(
|
36
|
+
card = Stripe::Card.construct_from({
|
37
|
+
customer: @customer.id,
|
38
|
+
id: "card_123",
|
39
|
+
metadata: {},
|
40
|
+
})
|
37
41
|
card.metadata['key'] = 'value'
|
38
42
|
card.save
|
39
|
-
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources
|
43
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CustomerTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:customer)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
customers = Stripe::Customer.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/customers"
|
@@ -12,8 +10,8 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
customer = Stripe::Customer.retrieve(
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/customers
|
13
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123"
|
17
15
|
assert customer.kind_of?(Stripe::Customer)
|
18
16
|
end
|
19
17
|
|
@@ -24,28 +22,28 @@ module Stripe
|
|
24
22
|
end
|
25
23
|
|
26
24
|
should "be saveable" do
|
27
|
-
customer = Stripe::Customer.retrieve(
|
25
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
28
26
|
customer.metadata['key'] = 'value'
|
29
27
|
customer.save
|
30
|
-
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{
|
28
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{customer.id}"
|
31
29
|
end
|
32
30
|
|
33
31
|
should "be updateable" do
|
34
|
-
customer = Stripe::Customer.update(
|
35
|
-
assert_requested :post, "#{Stripe.api_base}/v1/customers
|
32
|
+
customer = Stripe::Customer.update("cus_123", metadata: { key: 'value' })
|
33
|
+
assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123"
|
36
34
|
assert customer.kind_of?(Stripe::Customer)
|
37
35
|
end
|
38
36
|
|
39
37
|
should "be deletable" do
|
40
|
-
customer = Stripe::Customer.retrieve(
|
38
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
41
39
|
customer = customer.delete
|
42
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{
|
40
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}"
|
43
41
|
assert customer.kind_of?(Stripe::Customer)
|
44
42
|
end
|
45
43
|
|
46
44
|
context "#create_subscription" do
|
47
45
|
should "create a new subscription" do
|
48
|
-
customer = Stripe::Customer.retrieve(
|
46
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
49
47
|
subscription = customer.create_subscription({:plan => 'silver'})
|
50
48
|
assert subscription.kind_of?(Stripe::Subscription)
|
51
49
|
end
|
@@ -53,7 +51,7 @@ module Stripe
|
|
53
51
|
|
54
52
|
context "#create_upcoming_invoice" do
|
55
53
|
should "create a new invoice" do
|
56
|
-
customer = Stripe::Customer.retrieve(
|
54
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
57
55
|
invoice = customer.create_upcoming_invoice
|
58
56
|
assert invoice.kind_of?(Stripe::Invoice)
|
59
57
|
end
|
@@ -61,12 +59,12 @@ module Stripe
|
|
61
59
|
|
62
60
|
context "#update_subscription" do
|
63
61
|
should "update a subscription" do
|
64
|
-
customer = Stripe::Customer.retrieve(
|
62
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
65
63
|
|
66
64
|
# deprecated API and not in schema
|
67
65
|
stub_request(:post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription").
|
68
66
|
with(body: { plan: "silver" }).
|
69
|
-
to_return(body: JSON.generate(
|
67
|
+
to_return(body: JSON.generate({ object: "subscription" }))
|
70
68
|
subscription = customer.update_subscription({:plan => 'silver'})
|
71
69
|
assert subscription.kind_of?(Stripe::Subscription)
|
72
70
|
end
|
@@ -74,12 +72,12 @@ module Stripe
|
|
74
72
|
|
75
73
|
context "#cancel_subscription" do
|
76
74
|
should "cancel a subscription" do
|
77
|
-
customer = Stripe::Customer.retrieve(
|
75
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
78
76
|
|
79
77
|
# deprecated API and not in schema
|
80
78
|
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription").
|
81
79
|
with(query: { at_period_end: "true" }).
|
82
|
-
to_return(body: JSON.generate(
|
80
|
+
to_return(body: JSON.generate({ object: "subscription" }))
|
83
81
|
subscription = customer.cancel_subscription({:at_period_end => 'true'})
|
84
82
|
assert subscription.kind_of?(Stripe::Subscription)
|
85
83
|
end
|
@@ -87,10 +85,10 @@ module Stripe
|
|
87
85
|
|
88
86
|
context "#delete_discount" do
|
89
87
|
should "delete a discount" do
|
90
|
-
customer = Stripe::Customer.retrieve(
|
88
|
+
customer = Stripe::Customer.retrieve("cus_123")
|
91
89
|
|
92
90
|
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount").
|
93
|
-
to_return(body: JSON.generate(
|
91
|
+
to_return(body: JSON.generate({ object: "customer" }))
|
94
92
|
discount = customer.delete_discount
|
95
93
|
assert discount.kind_of?(Stripe::Customer)
|
96
94
|
end
|