stripe 3.3.2 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +62 -0
- data/.travis.yml +1 -1
- data/Gemfile +19 -12
- data/History.txt +10 -0
- data/README.md +5 -1
- data/Rakefile +8 -5
- data/VERSION +1 -1
- data/bin/stripe-console +2 -2
- data/lib/stripe.rb +72 -74
- data/lib/stripe/account.rb +15 -17
- data/lib/stripe/alipay_account.rb +10 -7
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +1 -1
- data/lib/stripe/api_operations/list.rb +2 -2
- data/lib/stripe/api_operations/request.rb +5 -12
- data/lib/stripe/api_operations/save.rb +6 -6
- data/lib/stripe/api_resource.rb +7 -9
- data/lib/stripe/apple_pay_domain.rb +2 -2
- data/lib/stripe/application_fee.rb +5 -5
- data/lib/stripe/application_fee_refund.rb +5 -5
- data/lib/stripe/balance.rb +1 -1
- data/lib/stripe/balance_transaction.rb +2 -2
- data/lib/stripe/bank_account.rb +7 -7
- data/lib/stripe/bitcoin_receiver.rb +4 -2
- data/lib/stripe/bitcoin_transaction.rb +3 -1
- data/lib/stripe/card.rb +5 -5
- data/lib/stripe/charge.rb +18 -18
- data/lib/stripe/country_spec.rb +2 -2
- data/lib/stripe/coupon.rb +1 -1
- data/lib/stripe/customer.rb +23 -23
- data/lib/stripe/dispute.rb +3 -3
- data/lib/stripe/ephemeral_key.rb +4 -4
- data/lib/stripe/errors.rb +4 -4
- data/lib/stripe/event.rb +1 -1
- data/lib/stripe/file_upload.rb +5 -5
- data/lib/stripe/invoice.rb +7 -7
- data/lib/stripe/invoice_item.rb +1 -1
- data/lib/stripe/invoice_line_item.rb +1 -1
- data/lib/stripe/list_object.rb +14 -18
- data/lib/stripe/login_link.rb +3 -3
- data/lib/stripe/oauth.rb +15 -13
- data/lib/stripe/order.rb +5 -5
- data/lib/stripe/order_return.rb +1 -1
- data/lib/stripe/payout.rb +3 -3
- data/lib/stripe/plan.rb +1 -1
- data/lib/stripe/product.rb +1 -1
- data/lib/stripe/recipient.rb +3 -2
- data/lib/stripe/recipient_transfer.rb +1 -2
- data/lib/stripe/refund.rb +1 -1
- data/lib/stripe/reversal.rb +5 -5
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/sku.rb +1 -1
- data/lib/stripe/source.rb +13 -10
- data/lib/stripe/stripe_client.rb +149 -169
- data/lib/stripe/stripe_object.rb +77 -76
- data/lib/stripe/subscription.rb +5 -5
- data/lib/stripe/subscription_item.rb +2 -2
- data/lib/stripe/three_d_secure.rb +1 -1
- data/lib/stripe/token.rb +1 -1
- data/lib/stripe/transfer.rb +3 -3
- data/lib/stripe/util.rb +77 -62
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +14 -10
- data/stripe.gemspec +14 -14
- data/test/stripe/account_test.rb +69 -81
- data/test/stripe/alipay_account_test.rb +19 -1
- data/test/stripe/api_operations_test.rb +7 -7
- data/test/stripe/api_resource_test.rb +224 -260
- data/test/stripe/apple_pay_domain_test.rb +8 -8
- data/test/stripe/application_fee_refund_test.rb +8 -8
- data/test/stripe/application_fee_test.rb +3 -3
- data/test/stripe/balance_test.rb +2 -2
- data/test/stripe/bank_account_test.rb +9 -11
- data/test/stripe/charge_test.rb +11 -11
- data/test/stripe/country_spec_test.rb +4 -4
- data/test/stripe/coupon_test.rb +10 -10
- data/test/stripe/customer_card_test.rb +11 -15
- data/test/stripe/customer_test.rb +26 -27
- data/test/stripe/dispute_test.rb +8 -8
- data/test/stripe/ephemeral_key_test.rb +14 -14
- data/test/stripe/errors_test.rb +2 -2
- data/test/stripe/file_upload_test.rb +26 -28
- data/test/stripe/invoice_item_test.rb +14 -14
- data/test/stripe/invoice_line_item_test.rb +1 -1
- data/test/stripe/invoice_test.rb +37 -37
- data/test/stripe/list_object_test.rb +60 -76
- data/test/stripe/login_link_test.rb +14 -14
- data/test/stripe/oauth_test.rb +42 -50
- data/test/stripe/order_return_test.rb +5 -5
- data/test/stripe/order_test.rb +12 -12
- data/test/stripe/payout_test.rb +9 -9
- data/test/stripe/plan_test.rb +9 -9
- data/test/stripe/product_test.rb +8 -8
- data/test/stripe/recipient_test.rb +9 -10
- data/test/stripe/refund_test.rb +9 -9
- data/test/stripe/reversal_test.rb +10 -10
- data/test/stripe/sku_test.rb +8 -8
- data/test/stripe/source_test.rb +14 -16
- data/test/stripe/stripe_client_test.rb +235 -266
- data/test/stripe/stripe_object_test.rb +163 -147
- data/test/stripe/stripe_response_test.rb +4 -3
- data/test/stripe/subscription_item_test.rb +11 -11
- data/test/stripe/subscription_test.rb +14 -14
- data/test/stripe/three_d_secure_test.rb +2 -2
- data/test/stripe/transfer_test.rb +8 -8
- data/test/stripe/util_test.rb +59 -57
- data/test/stripe/webhook_test.rb +18 -16
- data/test/stripe_test.rb +4 -4
- data/test/test_data.rb +26 -26
- data/test/test_helper.rb +29 -25
- metadata +6 -10
- data/test/stripe/bitcoin_receiver_test.rb +0 -67
- data/test/stripe/bitcoin_transaction_test.rb +0 -19
- data/test/stripe/recipient_card_test.rb +0 -44
@@ -1,31 +1,31 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplePayDomainTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
domains = Stripe::ApplePayDomain.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains"
|
8
|
-
assert domains.data.
|
9
|
-
assert domains.data[0].
|
8
|
+
assert domains.data.is_a?(Array)
|
9
|
+
assert domains.data[0].is_a?(Stripe::ApplePayDomain)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
14
|
-
|
15
|
-
assert domain.
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains/apwc_123"
|
15
|
+
assert domain.is_a?(Stripe::ApplePayDomain)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
19
|
-
domain = Stripe::ApplePayDomain.create(:
|
19
|
+
domain = Stripe::ApplePayDomain.create(domain_name: "example.com")
|
20
20
|
assert_requested :post, "#{Stripe.api_base}/v1/apple_pay/domains"
|
21
|
-
assert domain.
|
21
|
+
assert domain.is_a?(Stripe::ApplePayDomain)
|
22
22
|
end
|
23
23
|
|
24
24
|
should "be deletable" do
|
25
25
|
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
26
26
|
domain = domain.delete
|
27
27
|
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{domain.id}"
|
28
|
-
assert domain.
|
28
|
+
assert domain.is_a?(Stripe::ApplePayDomain)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplicationFeeRefundTest < Test::Unit::TestCase
|
@@ -11,25 +11,25 @@ module Stripe
|
|
11
11
|
|
12
12
|
# notably this *doesn't* make an API call
|
13
13
|
assert_not_requested :get,
|
14
|
-
|
14
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
|
15
15
|
|
16
|
-
assert refunds.data.
|
17
|
-
assert refunds.first.
|
16
|
+
assert refunds.data.is_a?(Array)
|
17
|
+
assert refunds.first.is_a?(Stripe::ApplicationFeeRefund)
|
18
18
|
end
|
19
19
|
|
20
20
|
should "be creatable" do
|
21
21
|
refund = @fee.refunds.create
|
22
22
|
assert_requested :post,
|
23
|
-
|
24
|
-
assert refund.
|
23
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
|
24
|
+
assert refund.is_a?(Stripe::ApplicationFeeRefund)
|
25
25
|
end
|
26
26
|
|
27
27
|
should "be saveable" do
|
28
28
|
refund = @fee.refunds.first
|
29
|
-
refund.metadata[
|
29
|
+
refund.metadata["key"] = "value"
|
30
30
|
refund.save
|
31
31
|
assert_requested :post,
|
32
|
-
|
32
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{refund.id}"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplicationFeeTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
fees = Stripe::ApplicationFee.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/application_fees"
|
8
|
-
assert fees.data.
|
9
|
-
assert fees.data[0].
|
8
|
+
assert fees.data.is_a?(Array)
|
9
|
+
assert fees.data[0].is_a?(Stripe::ApplicationFee)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/test/stripe/balance_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BalanceTest < Test::Unit::TestCase
|
5
5
|
should "be retrievable" do
|
6
6
|
balance = Stripe::Balance.retrieve
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/balance"
|
8
|
-
assert balance.
|
8
|
+
assert balance.is_a?(Stripe::Balance)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BankAccountTest < Test::Unit::TestCase
|
@@ -9,27 +9,25 @@ module Stripe
|
|
9
9
|
id: "ba_123"
|
10
10
|
)
|
11
11
|
assert_equal "/v1/accounts/acct_123/external_accounts/ba_123",
|
12
|
-
|
12
|
+
bank_account.resource_url
|
13
13
|
end
|
14
14
|
|
15
15
|
should "return a customer URL" do
|
16
16
|
bank_account = Stripe::BankAccount.construct_from(
|
17
17
|
customer: "cus_123",
|
18
|
-
id: "ba_123"
|
18
|
+
id: "ba_123"
|
19
19
|
)
|
20
20
|
assert_equal "/v1/customers/cus_123/sources/ba_123",
|
21
|
-
|
21
|
+
bank_account.resource_url
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
context "#verify" do
|
26
|
-
should
|
27
|
-
bank_account = Stripe::BankAccount.construct_from(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
bank_account = bank_account.verify(amounts: [1,2])
|
32
|
-
assert bank_account.kind_of?(Stripe::BankAccount)
|
26
|
+
should "verify the account" do
|
27
|
+
bank_account = Stripe::BankAccount.construct_from(customer: "cus_123",
|
28
|
+
id: "ba_123")
|
29
|
+
bank_account = bank_account.verify(amounts: [1, 2])
|
30
|
+
assert bank_account.is_a?(Stripe::BankAccount)
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
data/test/stripe/charge_test.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ChargeTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
charges = Stripe::Charge.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/charges"
|
8
|
-
assert charges.data.
|
9
|
-
assert charges.data[0].
|
8
|
+
assert charges.data.is_a?(Array)
|
9
|
+
assert charges.data[0].is_a?(Stripe::Charge)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
charge = Stripe::Charge.retrieve("ch_123")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/charges/ch_123"
|
15
|
-
assert charge.
|
15
|
+
assert charge.is_a?(Stripe::Charge)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
19
19
|
charge = Stripe::Charge.create(
|
20
20
|
amount: 100,
|
21
21
|
currency: "USD",
|
22
|
-
source: "src_123"
|
22
|
+
source: "src_123"
|
23
23
|
)
|
24
24
|
assert_requested :post, "#{Stripe.api_base}/v1/charges"
|
25
|
-
assert charge.
|
25
|
+
assert charge.is_a?(Stripe::Charge)
|
26
26
|
end
|
27
27
|
|
28
28
|
should "be saveable" do
|
29
29
|
charge = Stripe::Charge.retrieve("ch_123")
|
30
|
-
charge.metadata[
|
30
|
+
charge.metadata["key"] = "value"
|
31
31
|
charge.save
|
32
32
|
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{charge.id}"
|
33
33
|
end
|
34
34
|
|
35
35
|
should "be updateable" do
|
36
|
-
charge = Stripe::Charge.update("ch_123", metadata: {foo:
|
36
|
+
charge = Stripe::Charge.update("ch_123", metadata: { foo: "bar" })
|
37
37
|
assert_requested :post, "#{Stripe.api_base}/v1/charges/ch_123"
|
38
|
-
assert charge.
|
38
|
+
assert charge.is_a?(Stripe::Charge)
|
39
39
|
end
|
40
40
|
|
41
41
|
context "#mark_as_fraudulent" do
|
42
42
|
should "charges should be able to be marked as fraudulent" do
|
43
43
|
charge = Stripe::Charge.retrieve("ch_123")
|
44
44
|
charge = charge.mark_as_fraudulent
|
45
|
-
assert charge.
|
45
|
+
assert charge.is_a?(Stripe::Charge)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -50,7 +50,7 @@ module Stripe
|
|
50
50
|
should "charges should be able to be marked as safe" do
|
51
51
|
charge = Stripe::Charge.retrieve("ch_123")
|
52
52
|
charge = charge.mark_as_safe
|
53
|
-
assert charge.
|
53
|
+
assert charge.is_a?(Stripe::Charge)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CountrySpecTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
c = Stripe::CountrySpec.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/country_specs"
|
8
|
-
assert c.data.
|
9
|
-
assert c.data[0].
|
8
|
+
assert c.data.is_a?(Array)
|
9
|
+
assert c.data[0].is_a?(Stripe::CountrySpec)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
s = Stripe::CountrySpec.retrieve("US")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/country_specs/US"
|
15
|
-
assert(s.
|
15
|
+
assert(s.is_a?(Stripe::CountrySpec))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/test/stripe/coupon_test.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CouponTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
coupons = Stripe::Coupon.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/coupons"
|
8
|
-
assert coupons.data.
|
9
|
-
assert coupons.first.
|
8
|
+
assert coupons.data.is_a?(Array)
|
9
|
+
assert coupons.first.is_a?(Stripe::Coupon)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
coupon = Stripe::Coupon.retrieve("25OFF")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/coupons/25OFF"
|
15
|
-
assert coupon.
|
15
|
+
assert coupon.is_a?(Stripe::Coupon)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
19
19
|
coupon = Stripe::Coupon.create(
|
20
20
|
percent_off: 25,
|
21
|
-
duration:
|
21
|
+
duration: "repeating",
|
22
22
|
duration_in_months: 3,
|
23
|
-
id:
|
23
|
+
id: "25OFF"
|
24
24
|
)
|
25
25
|
assert_requested :post, "#{Stripe.api_base}/v1/coupons"
|
26
|
-
assert coupon.
|
26
|
+
assert coupon.is_a?(Stripe::Coupon)
|
27
27
|
end
|
28
28
|
|
29
29
|
should "be saveable" do
|
30
30
|
coupon = Stripe::Coupon.retrieve("25OFF")
|
31
|
-
coupon.metadata[
|
31
|
+
coupon.metadata["key"] = "value"
|
32
32
|
coupon.save
|
33
33
|
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{coupon.id}"
|
34
34
|
end
|
35
35
|
|
36
36
|
should "be updateable" do
|
37
|
-
coupon = Stripe::Coupon.update("25OFF", metadata: { key:
|
37
|
+
coupon = Stripe::Coupon.update("25OFF", metadata: { key: "value" })
|
38
38
|
assert_requested :post, "#{Stripe.api_base}/v1/coupons/25OFF"
|
39
|
-
assert coupon.
|
39
|
+
assert coupon.is_a?(Stripe::Coupon)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CustomerCardTest < Test::Unit::TestCase
|
@@ -8,7 +8,7 @@ module Stripe
|
|
8
8
|
|
9
9
|
should "be listable" do
|
10
10
|
sources = @customer.sources.list
|
11
|
-
assert sources.data.
|
11
|
+
assert sources.data.is_a?(Array)
|
12
12
|
# because of the terrible :wildcard nature of sources, the API stub
|
13
13
|
# cannot currently replace this response with anything meaningful so we
|
14
14
|
# don't assert on the type of individual items like we do in other tests
|
@@ -16,29 +16,25 @@ module Stripe
|
|
16
16
|
|
17
17
|
should "be creatable" do
|
18
18
|
card = @customer.sources.create(
|
19
|
-
source: "tok_123"
|
19
|
+
source: "tok_123"
|
20
20
|
)
|
21
21
|
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
|
22
|
-
assert card.
|
22
|
+
assert card.is_a?(Stripe::BankAccount)
|
23
23
|
end
|
24
24
|
|
25
25
|
should "be deletable" do
|
26
|
-
card = Stripe::Card.construct_from(
|
27
|
-
|
28
|
-
id: "card_123"
|
29
|
-
})
|
26
|
+
card = Stripe::Card.construct_from(customer: @customer.id,
|
27
|
+
id: "card_123")
|
30
28
|
card = card.delete
|
31
29
|
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
|
32
|
-
assert card.
|
30
|
+
assert card.is_a?(Stripe::Card)
|
33
31
|
end
|
34
32
|
|
35
33
|
should "be saveable" do
|
36
|
-
card = Stripe::Card.construct_from(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
})
|
41
|
-
card.metadata['key'] = 'value'
|
34
|
+
card = Stripe::Card.construct_from(customer: @customer.id,
|
35
|
+
id: "card_123",
|
36
|
+
metadata: {})
|
37
|
+
card.metadata["key"] = "value"
|
42
38
|
card.save
|
43
39
|
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
|
44
40
|
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CustomerTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
customers = Stripe::Customer.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/customers"
|
8
|
-
assert customers.data.
|
9
|
-
assert customers.first.
|
8
|
+
assert customers.data.is_a?(Array)
|
9
|
+
assert customers.first.is_a?(Stripe::Customer)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
customer = Stripe::Customer.retrieve("cus_123")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123"
|
15
|
-
assert customer.
|
15
|
+
assert customer.is_a?(Stripe::Customer)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
19
19
|
customer = Stripe::Customer.create
|
20
20
|
assert_requested :post, "#{Stripe.api_base}/v1/customers"
|
21
|
-
assert customer.
|
21
|
+
assert customer.is_a?(Stripe::Customer)
|
22
22
|
end
|
23
23
|
|
24
24
|
should "be saveable" do
|
25
25
|
customer = Stripe::Customer.retrieve("cus_123")
|
26
|
-
customer.metadata[
|
26
|
+
customer.metadata["key"] = "value"
|
27
27
|
customer.save
|
28
28
|
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{customer.id}"
|
29
29
|
end
|
30
30
|
|
31
31
|
should "be updateable" do
|
32
|
-
customer = Stripe::Customer.update("cus_123", metadata: { key:
|
32
|
+
customer = Stripe::Customer.update("cus_123", metadata: { key: "value" })
|
33
33
|
assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123"
|
34
|
-
assert customer.
|
34
|
+
assert customer.is_a?(Stripe::Customer)
|
35
35
|
end
|
36
36
|
|
37
37
|
should "be deletable" do
|
38
38
|
customer = Stripe::Customer.retrieve("cus_123")
|
39
39
|
customer = customer.delete
|
40
40
|
assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}"
|
41
|
-
assert customer.
|
41
|
+
assert customer.is_a?(Stripe::Customer)
|
42
42
|
end
|
43
43
|
|
44
44
|
context "#create_subscription" do
|
45
45
|
should "create a new subscription" do
|
46
46
|
customer = Stripe::Customer.retrieve("cus_123")
|
47
|
-
subscription = customer.create_subscription(
|
48
|
-
assert subscription.
|
47
|
+
subscription = customer.create_subscription(plan: "silver")
|
48
|
+
assert subscription.is_a?(Stripe::Subscription)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -53,7 +53,7 @@ module Stripe
|
|
53
53
|
should "create a new invoice" do
|
54
54
|
customer = Stripe::Customer.retrieve("cus_123")
|
55
55
|
invoice = customer.create_upcoming_invoice
|
56
|
-
assert invoice.
|
56
|
+
assert invoice.is_a?(Stripe::Invoice)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -62,11 +62,11 @@ module Stripe
|
|
62
62
|
customer = Stripe::Customer.retrieve("cus_123")
|
63
63
|
|
64
64
|
# deprecated API and not in schema
|
65
|
-
stub_request(:post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription")
|
66
|
-
with(body: { plan: "silver" })
|
67
|
-
to_return(body: JSON.generate(
|
68
|
-
subscription = customer.update_subscription(
|
69
|
-
assert subscription.
|
65
|
+
stub_request(:post, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription")
|
66
|
+
.with(body: { plan: "silver" })
|
67
|
+
.to_return(body: JSON.generate(object: "subscription"))
|
68
|
+
subscription = customer.update_subscription(plan: "silver")
|
69
|
+
assert subscription.is_a?(Stripe::Subscription)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -75,11 +75,11 @@ module Stripe
|
|
75
75
|
customer = Stripe::Customer.retrieve("cus_123")
|
76
76
|
|
77
77
|
# deprecated API and not in schema
|
78
|
-
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription")
|
79
|
-
with(query: { at_period_end: "true" })
|
80
|
-
to_return(body: JSON.generate(
|
81
|
-
subscription = customer.cancel_subscription(
|
82
|
-
assert subscription.
|
78
|
+
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/subscription")
|
79
|
+
.with(query: { at_period_end: "true" })
|
80
|
+
.to_return(body: JSON.generate(object: "subscription"))
|
81
|
+
subscription = customer.cancel_subscription(at_period_end: "true")
|
82
|
+
assert subscription.is_a?(Stripe::Subscription)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -87,10 +87,10 @@ module Stripe
|
|
87
87
|
should "delete a discount" do
|
88
88
|
customer = Stripe::Customer.retrieve("cus_123")
|
89
89
|
|
90
|
-
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount")
|
91
|
-
to_return(body: JSON.generate(
|
90
|
+
stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount")
|
91
|
+
.to_return(body: JSON.generate(object: "customer"))
|
92
92
|
discount = customer.delete_discount
|
93
|
-
assert discount.
|
93
|
+
assert discount.is_a?(Stripe::Customer)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -104,11 +104,10 @@ module Stripe
|
|
104
104
|
should "allow setting source with hash and set flag" do
|
105
105
|
c = Stripe::Customer.new("test_customer")
|
106
106
|
c.source = {
|
107
|
-
:
|
107
|
+
object: "card",
|
108
108
|
}
|
109
109
|
assert_equal true, c.source.save_with_parent
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|