stripe 2.0.3 → 5.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1036 -0
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +24 -23
- data/History.txt +1 -593
- data/Makefile +7 -0
- data/README.md +252 -53
- data/Rakefile +18 -24
- data/VERSION +1 -1
- data/bin/stripe-console +5 -3
- data/lib/stripe/api_operations/create.rb +4 -2
- data/lib/stripe/api_operations/delete.rb +31 -3
- data/lib/stripe/api_operations/list.rb +4 -13
- data/lib/stripe/api_operations/nested_resource.rb +73 -0
- data/lib/stripe/api_operations/request.rb +92 -10
- data/lib/stripe/api_operations/save.rb +25 -13
- data/lib/stripe/api_operations/search.rb +19 -0
- data/lib/stripe/api_resource.rb +55 -11
- data/lib/stripe/api_resource_test_helpers.rb +47 -0
- data/lib/stripe/connection_manager.rb +200 -0
- data/lib/stripe/error_object.rb +93 -0
- data/lib/stripe/errors.rb +98 -13
- data/lib/stripe/instrumentation.rb +84 -0
- data/lib/stripe/list_object.rb +55 -21
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/oauth.rb +65 -0
- data/lib/stripe/object_types.rb +119 -0
- data/lib/stripe/{account.rb → resources/account.rb} +75 -38
- data/lib/stripe/resources/account_link.rb +10 -0
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +6 -1
- data/lib/stripe/resources/application_fee.rb +14 -0
- data/lib/stripe/resources/application_fee_refund.rb +31 -0
- data/lib/stripe/resources/balance.rb +8 -0
- data/lib/stripe/resources/balance_transaction.rb +10 -0
- data/lib/stripe/resources/bank_account.rb +43 -0
- data/lib/stripe/resources/billing_portal/configuration.rb +14 -0
- data/lib/stripe/resources/billing_portal/session.rb +12 -0
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +8 -4
- data/lib/stripe/resources/bitcoin_transaction.rb +16 -0
- data/lib/stripe/resources/capability.rb +34 -0
- data/lib/stripe/resources/card.rb +38 -0
- data/lib/stripe/resources/cash_balance.rb +22 -0
- data/lib/stripe/resources/charge.rb +32 -0
- data/lib/stripe/resources/checkout/session.rb +27 -0
- data/lib/stripe/resources/country_spec.rb +10 -0
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +6 -1
- data/lib/stripe/resources/credit_note.rb +33 -0
- data/lib/stripe/resources/credit_note_line_item.rb +8 -0
- data/lib/stripe/resources/customer.rb +74 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +31 -0
- data/lib/stripe/resources/discount.rb +8 -0
- data/lib/stripe/resources/dispute.rb +22 -0
- data/lib/stripe/resources/ephemeral_key.rb +20 -0
- data/lib/stripe/resources/event.rb +10 -0
- data/lib/stripe/resources/exchange_rate.rb +10 -0
- data/lib/stripe/resources/file.rb +36 -0
- data/lib/stripe/resources/file_link.rb +12 -0
- data/lib/stripe/resources/financial_connections/account.rb +31 -0
- data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
- data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
- data/lib/stripe/resources/financial_connections/session.rb +12 -0
- data/lib/stripe/resources/funding_instructions.rb +16 -0
- data/lib/stripe/resources/identity/verification_report.rb +12 -0
- data/lib/stripe/resources/identity/verification_session.rb +35 -0
- data/lib/stripe/resources/invoice.rb +83 -0
- data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +6 -1
- data/lib/stripe/resources/invoice_line_item.rb +8 -0
- data/lib/stripe/resources/issuing/authorization.rb +34 -0
- data/lib/stripe/resources/issuing/card.rb +25 -0
- data/lib/stripe/resources/issuing/card_details.rb +10 -0
- data/lib/stripe/resources/issuing/cardholder.rb +14 -0
- data/lib/stripe/resources/issuing/dispute.rb +25 -0
- data/lib/stripe/resources/issuing/transaction.rb +13 -0
- data/lib/stripe/resources/line_item.rb +8 -0
- data/lib/stripe/resources/login_link.rb +15 -0
- data/lib/stripe/resources/mandate.rb +8 -0
- data/lib/stripe/resources/order.rb +33 -0
- data/lib/stripe/resources/order_return.rb +10 -0
- data/lib/stripe/resources/payment_intent.rb +82 -0
- data/lib/stripe/resources/payment_link.rb +23 -0
- data/lib/stripe/resources/payment_method.rb +33 -0
- data/lib/stripe/resources/payout.rb +33 -0
- data/lib/stripe/resources/person.rb +32 -0
- data/lib/stripe/{plan.rb → resources/plan.rb} +5 -0
- data/lib/stripe/resources/price.rb +21 -0
- data/lib/stripe/resources/product.rb +22 -0
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/quote.rb +105 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +12 -0
- data/lib/stripe/resources/radar/value_list.rb +15 -0
- data/lib/stripe/resources/radar/value_list_item.rb +14 -0
- data/lib/stripe/resources/recipient.rb +14 -0
- data/lib/stripe/resources/recipient_transfer.rb +7 -0
- data/lib/stripe/resources/refund.rb +42 -0
- data/lib/stripe/resources/reporting/report_run.rb +13 -0
- data/lib/stripe/resources/reporting/report_type.rb +13 -0
- data/lib/stripe/resources/reversal.rb +30 -0
- data/lib/stripe/resources/review.rb +21 -0
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +43 -0
- data/lib/stripe/resources/shipping_rate.rb +12 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +16 -0
- data/lib/stripe/{sku.rb → resources/sku.rb} +7 -2
- data/lib/stripe/resources/source.rb +47 -0
- data/lib/stripe/resources/source_transaction.rb +8 -0
- data/lib/stripe/resources/subscription.rb +35 -0
- data/lib/stripe/resources/subscription_item.rb +26 -0
- data/lib/stripe/resources/subscription_schedule.rb +33 -0
- data/lib/stripe/resources/tax_code.rb +10 -0
- data/lib/stripe/resources/tax_id.rb +27 -0
- data/lib/stripe/{product.rb → resources/tax_rate.rb} +7 -3
- data/lib/stripe/resources/terminal/configuration.rb +15 -0
- data/lib/stripe/resources/terminal/connection_token.rb +12 -0
- data/lib/stripe/resources/terminal/location.rb +15 -0
- data/lib/stripe/resources/terminal/reader.rb +75 -0
- data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
- data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +5 -0
- data/lib/stripe/resources/token.rb +10 -0
- data/lib/stripe/resources/topup.rb +23 -0
- data/lib/stripe/resources/transfer.rb +27 -0
- data/lib/stripe/resources/usage_record.rb +8 -0
- data/lib/stripe/resources/usage_record_summary.rb +8 -0
- data/lib/stripe/{recipient.rb → resources/webhook_endpoint.rb} +6 -5
- data/lib/stripe/resources.rb +100 -0
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/singleton_api_resource.rb +10 -4
- data/lib/stripe/stripe_client.rb +886 -223
- data/lib/stripe/stripe_configuration.rb +194 -0
- data/lib/stripe/stripe_object.rb +301 -132
- data/lib/stripe/stripe_response.rb +89 -27
- data/lib/stripe/util.rb +272 -122
- data/lib/stripe/version.rb +3 -1
- data/lib/stripe/webhook.rb +121 -0
- data/lib/stripe.rb +94 -116
- data/stripe.gemspec +35 -16
- metadata +127 -156
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -5
- data/.travis.yml +0 -15
- data/lib/stripe/alipay_account.rb +0 -20
- data/lib/stripe/application_fee.rb +0 -20
- data/lib/stripe/application_fee_refund.rb +0 -18
- data/lib/stripe/balance.rb +0 -4
- data/lib/stripe/balance_transaction.rb +0 -9
- data/lib/stripe/bank_account.rb +0 -28
- data/lib/stripe/bitcoin_transaction.rb +0 -9
- data/lib/stripe/card.rb +0 -25
- data/lib/stripe/charge.rb +0 -80
- data/lib/stripe/country_spec.rb +0 -9
- data/lib/stripe/customer.rb +0 -77
- data/lib/stripe/dispute.rb +0 -15
- data/lib/stripe/event.rb +0 -5
- data/lib/stripe/file_upload.rb +0 -31
- data/lib/stripe/invoice.rb +0 -27
- data/lib/stripe/order.rb +0 -27
- data/lib/stripe/order_return.rb +0 -9
- data/lib/stripe/refund.rb +0 -7
- data/lib/stripe/reversal.rb +0 -18
- data/lib/stripe/source.rb +0 -11
- data/lib/stripe/subscription.rb +0 -31
- data/lib/stripe/subscription_item.rb +0 -12
- data/lib/stripe/token.rb +0 -5
- data/lib/stripe/transfer.rb +0 -16
- data/openapi/fixtures.json +0 -1383
- data/openapi/fixtures.yaml +0 -1130
- data/openapi/spec.json +0 -19749
- data/openapi/spec.yaml +0 -15359
- data/test/api_fixtures.rb +0 -29
- data/test/api_stub_helpers.rb +0 -125
- data/test/stripe/account_test.rb +0 -204
- data/test/stripe/alipay_account_test.rb +0 -19
- data/test/stripe/api_operations_test.rb +0 -31
- data/test/stripe/api_resource_test.rb +0 -496
- data/test/stripe/apple_pay_domain_test.rb +0 -33
- data/test/stripe/application_fee_refund_test.rb +0 -38
- data/test/stripe/application_fee_test.rb +0 -14
- data/test/stripe/balance_test.rb +0 -11
- data/test/stripe/bank_account_test.rb +0 -41
- data/test/stripe/bitcoin_receiver_test.rb +0 -70
- data/test/stripe/bitcoin_transaction_test.rb +0 -21
- data/test/stripe/charge_test.rb +0 -59
- data/test/stripe/country_spec_test.rb +0 -20
- data/test/stripe/coupon_test.rb +0 -44
- data/test/stripe/customer_card_test.rb +0 -42
- data/test/stripe/customer_test.rb +0 -116
- data/test/stripe/dispute_test.rb +0 -42
- data/test/stripe/errors_test.rb +0 -18
- data/test/stripe/file_upload_test.rb +0 -66
- data/test/stripe/invoice_item_test.rb +0 -55
- data/test/stripe/invoice_test.rb +0 -66
- data/test/stripe/list_object_test.rb +0 -170
- data/test/stripe/order_return_test.rb +0 -21
- data/test/stripe/order_test.rb +0 -59
- data/test/stripe/plan_test.rb +0 -52
- data/test/stripe/product_test.rb +0 -47
- data/test/stripe/recipient_card_test.rb +0 -40
- data/test/stripe/recipient_test.rb +0 -50
- data/test/stripe/refund_test.rb +0 -39
- data/test/stripe/reversal_test.rb +0 -43
- data/test/stripe/sku_test.rb +0 -50
- data/test/stripe/source_test.rb +0 -43
- data/test/stripe/stripe_client_test.rb +0 -440
- data/test/stripe/stripe_object_test.rb +0 -361
- data/test/stripe/stripe_response_test.rb +0 -46
- data/test/stripe/subscription_item_test.rb +0 -54
- data/test/stripe/subscription_test.rb +0 -60
- data/test/stripe/three_d_secure_test.rb +0 -23
- data/test/stripe/transfer_test.rb +0 -50
- data/test/stripe/util_test.rb +0 -149
- data/test/stripe_test.rb +0 -41
- data/test/test_data.rb +0 -59
- data/test/test_helper.rb +0 -41
@@ -1,70 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class BitcoinReceiverTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:bitcoin_receiver)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
receivers = Stripe::BitcoinReceiver.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/bitcoin/receivers"
|
10
|
-
assert receivers.data.kind_of?(Array)
|
11
|
-
assert receivers.first.kind_of?(Stripe::BitcoinReceiver)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
receiver = Stripe::BitcoinReceiver.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get,
|
17
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
18
|
-
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
19
|
-
end
|
20
|
-
|
21
|
-
should "be creatable" do
|
22
|
-
receiver = Stripe::BitcoinReceiver.create(amount: 100, currency: "USD")
|
23
|
-
assert_requested :post, "#{Stripe.api_base}/v1/bitcoin/receivers"
|
24
|
-
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
25
|
-
end
|
26
|
-
|
27
|
-
should "be saveable" do
|
28
|
-
receiver = Stripe::BitcoinReceiver.retrieve(FIXTURE[:id])
|
29
|
-
receiver.metadata['key'] = 'value'
|
30
|
-
receiver.save
|
31
|
-
assert_requested :post,
|
32
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
33
|
-
end
|
34
|
-
|
35
|
-
should "be updateable" do
|
36
|
-
receiver = Stripe::BitcoinReceiver.update(FIXTURE[:id], metadata: { key: 'value' })
|
37
|
-
assert_requested :post,
|
38
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
39
|
-
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "be deletable" do
|
43
|
-
receiver = Stripe::BitcoinReceiver.retrieve(FIXTURE[:id])
|
44
|
-
receiver = receiver.delete
|
45
|
-
assert_requested :delete,
|
46
|
-
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
47
|
-
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
48
|
-
end
|
49
|
-
|
50
|
-
context "#resource_url" do
|
51
|
-
should "return a customer URL" do
|
52
|
-
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
53
|
-
receiver = Stripe::BitcoinReceiver.construct_from(
|
54
|
-
customer: customer_id,
|
55
|
-
id: FIXTURE[:id]
|
56
|
-
)
|
57
|
-
assert_equal "/v1/customers/#{customer_id}/sources/#{FIXTURE[:id]}",
|
58
|
-
receiver.resource_url
|
59
|
-
end
|
60
|
-
|
61
|
-
should "return an absolute URL" do
|
62
|
-
receiver = Stripe::BitcoinReceiver.construct_from(
|
63
|
-
id: FIXTURE[:id]
|
64
|
-
)
|
65
|
-
assert_equal "/v1/bitcoin/receivers/#{FIXTURE[:id]}",
|
66
|
-
receiver.resource_url
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class BitcoinTransactionTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:bitcoin_transaction)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
transactions = Stripe::BitcoinTransaction.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/bitcoin/transactions"
|
10
|
-
assert transactions.data.kind_of?(Array)
|
11
|
-
assert transactions.first.kind_of?(Stripe::BitcoinTransaction)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
transaction = Stripe::BitcoinTransaction.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get,
|
17
|
-
"#{Stripe.api_base}/v1/bitcoin/transactions/#{FIXTURE[:id]}"
|
18
|
-
assert transaction.kind_of?(Stripe::BitcoinTransaction)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/test/stripe/charge_test.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class ChargeTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:charge)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
charges = Stripe::Charge.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/charges"
|
10
|
-
assert charges.data.kind_of?(Array)
|
11
|
-
assert charges.data[0].kind_of?(Stripe::Charge)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/charges/#{FIXTURE[:id]}"
|
17
|
-
assert charge.kind_of?(Stripe::Charge)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "be creatable" do
|
21
|
-
charge = Stripe::Charge.create(
|
22
|
-
amount: 100,
|
23
|
-
currency: "USD",
|
24
|
-
source: API_FIXTURES.fetch(:source)[:id]
|
25
|
-
)
|
26
|
-
assert_requested :post, "#{Stripe.api_base}/v1/charges"
|
27
|
-
assert charge.kind_of?(Stripe::Charge)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "be saveable" do
|
31
|
-
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
32
|
-
charge.metadata['key'] = 'value'
|
33
|
-
charge.save
|
34
|
-
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{FIXTURE[:id]}"
|
35
|
-
end
|
36
|
-
|
37
|
-
should "be updateable" do
|
38
|
-
charge = Stripe::Charge.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
39
|
-
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{FIXTURE[:id]}"
|
40
|
-
assert charge.kind_of?(Stripe::Charge)
|
41
|
-
end
|
42
|
-
|
43
|
-
context "#mark_as_fraudulent" do
|
44
|
-
should "charges should be able to be marked as fraudulent" do
|
45
|
-
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
46
|
-
charge = charge.mark_as_fraudulent
|
47
|
-
assert charge.kind_of?(Stripe::Charge)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "#mark_as_safe" do
|
52
|
-
should "charges should be able to be marked as safe" do
|
53
|
-
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
54
|
-
charge = charge.mark_as_safe
|
55
|
-
assert charge.kind_of?(Stripe::Charge)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class CountrySpecTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:country_spec)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
c = Stripe::CountrySpec.list
|
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)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
s = Stripe::CountrySpec.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/country_specs/#{FIXTURE[:id]}"
|
17
|
-
assert(s.kind_of?(Stripe::CountrySpec))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/test/stripe/coupon_test.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class CouponTest < Test::Unit::TestCase
|
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)
|
29
|
-
end
|
30
|
-
|
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]}"
|
36
|
-
end
|
37
|
-
|
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)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class CustomerCardTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:source)
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@customer =
|
9
|
-
Stripe::Customer.retrieve(API_FIXTURES.fetch(:customer)[:id])
|
10
|
-
end
|
11
|
-
|
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
|
-
end
|
19
|
-
|
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)
|
26
|
-
end
|
27
|
-
|
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)
|
33
|
-
end
|
34
|
-
|
35
|
-
should "be saveable" do
|
36
|
-
card = Stripe::Card.construct_from(FIXTURE.merge(customer: @customer.id))
|
37
|
-
card.metadata['key'] = 'value'
|
38
|
-
card.save
|
39
|
-
assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/#{FIXTURE[:id]}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class CustomerTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:customer)
|
6
|
-
|
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)
|
12
|
-
end
|
13
|
-
|
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)
|
18
|
-
end
|
19
|
-
|
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)
|
24
|
-
end
|
25
|
-
|
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]}"
|
31
|
-
end
|
32
|
-
|
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)
|
37
|
-
end
|
38
|
-
|
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)
|
44
|
-
end
|
45
|
-
|
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
|
52
|
-
end
|
53
|
-
|
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
|
60
|
-
end
|
61
|
-
|
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
|
74
|
-
|
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
|
86
|
-
end
|
87
|
-
|
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
|
97
|
-
end
|
98
|
-
|
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
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
data/test/stripe/dispute_test.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class DisputeTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:dispute)
|
6
|
-
|
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)
|
12
|
-
end
|
13
|
-
|
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)
|
18
|
-
end
|
19
|
-
|
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]}"
|
25
|
-
end
|
26
|
-
|
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
|
32
|
-
|
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
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/test/stripe/errors_test.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class StripeErrorTest < Test::Unit::TestCase
|
5
|
-
context "#to_s" do
|
6
|
-
should "convert to string" do
|
7
|
-
e = StripeError.new("message")
|
8
|
-
assert_equal "message", e.to_s
|
9
|
-
|
10
|
-
e = StripeError.new("message", http_status: 200)
|
11
|
-
assert_equal "(Status 200) message", e.to_s
|
12
|
-
|
13
|
-
e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { :request_id => "request-id" })
|
14
|
-
assert_equal "(Request request-id) message", e.to_s
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class FileUploadTest < Test::Unit::TestCase
|
5
|
-
# Note that these tests are written different from others because we
|
6
|
-
# don't have anything on the uploads service in our OpenAPI spec. This is
|
7
|
-
# something that should be looked into at some point. We may need to ship
|
8
|
-
# a separate spec for it though, so it's high effort with low reward for
|
9
|
-
# the time being.
|
10
|
-
FIXTURE = {
|
11
|
-
id: "fil_15ABpV2eZvKYlo2C7vu7XS5l",
|
12
|
-
object: "file_upload",
|
13
|
-
}.freeze
|
14
|
-
|
15
|
-
should "be listable" do
|
16
|
-
stub_request(:get, "#{Stripe.uploads_base}/v1/files").
|
17
|
-
to_return(body: JSON.generate({
|
18
|
-
data: [FIXTURE],
|
19
|
-
object: 'list',
|
20
|
-
resource_url: '/v1/files'
|
21
|
-
}))
|
22
|
-
|
23
|
-
files = Stripe::FileUpload.list
|
24
|
-
assert files.data.kind_of?(Array)
|
25
|
-
assert files.data[0].kind_of?(Stripe::FileUpload)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "be retrievable" do
|
29
|
-
stub_request(:get, "#{Stripe.uploads_base}/v1/files/#{FIXTURE[:id]}").
|
30
|
-
to_return(body: JSON.generate(FIXTURE))
|
31
|
-
|
32
|
-
file = Stripe::FileUpload.retrieve(FIXTURE[:id])
|
33
|
-
assert file.kind_of?(Stripe::FileUpload)
|
34
|
-
end
|
35
|
-
|
36
|
-
should "be creatable" do
|
37
|
-
stub_request(:post, "#{Stripe.uploads_base}/v1/files").
|
38
|
-
with(:headers => {
|
39
|
-
"Content-Type" => %r|\A#{Faraday::Request::Multipart.mime_type}|
|
40
|
-
}) { |request|
|
41
|
-
request.body =~ /FileUploadTest/
|
42
|
-
}.to_return(body: JSON.generate(FIXTURE))
|
43
|
-
|
44
|
-
file = Stripe::FileUpload.create(
|
45
|
-
purpose: "dispute_evidence",
|
46
|
-
file: File.new(__FILE__),
|
47
|
-
)
|
48
|
-
assert file.kind_of?(Stripe::FileUpload)
|
49
|
-
end
|
50
|
-
|
51
|
-
should "be creatable with Faraday::UploadIO" do
|
52
|
-
stub_request(:post, "#{Stripe.uploads_base}/v1/files").
|
53
|
-
with(:headers => {
|
54
|
-
"Content-Type" => %r|\A#{Faraday::Request::Multipart.mime_type}|
|
55
|
-
}) { |request|
|
56
|
-
request.body =~ /FileUploadTest/
|
57
|
-
}.to_return(body: JSON.generate(FIXTURE))
|
58
|
-
|
59
|
-
file = Stripe::FileUpload.create(
|
60
|
-
purpose: "dispute_evidence",
|
61
|
-
file: Faraday::UploadIO.new(File.new(__FILE__), nil),
|
62
|
-
)
|
63
|
-
assert file.kind_of?(Stripe::FileUpload)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class InvoiceItemTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:invoice_item)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
invoiceitems = Stripe::InvoiceItem.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/invoiceitems"
|
10
|
-
assert invoiceitems.data.kind_of?(Array)
|
11
|
-
assert invoiceitems.first.kind_of?(Stripe::InvoiceItem)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
item = Stripe::InvoiceItem.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get,
|
17
|
-
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
18
|
-
assert item.kind_of?(Stripe::InvoiceItem)
|
19
|
-
end
|
20
|
-
|
21
|
-
should "be creatable" do
|
22
|
-
item = Stripe::InvoiceItem.create(
|
23
|
-
amount: 100,
|
24
|
-
currency: "USD",
|
25
|
-
customer: API_FIXTURES[:customer][:id]
|
26
|
-
)
|
27
|
-
assert_requested :post,
|
28
|
-
"#{Stripe.api_base}/v1/invoiceitems"
|
29
|
-
assert item.kind_of?(Stripe::InvoiceItem)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "be saveable" do
|
33
|
-
item = Stripe::InvoiceItem.retrieve(FIXTURE[:id])
|
34
|
-
item.metadata['key'] = 'value'
|
35
|
-
item.save
|
36
|
-
assert_requested :post,
|
37
|
-
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
38
|
-
end
|
39
|
-
|
40
|
-
should "be updateable" do
|
41
|
-
item = Stripe::InvoiceItem.update(FIXTURE[:id], metadata: { key: 'value' })
|
42
|
-
assert_requested :post,
|
43
|
-
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
44
|
-
assert item.kind_of?(Stripe::InvoiceItem)
|
45
|
-
end
|
46
|
-
|
47
|
-
should "be deletable" do
|
48
|
-
item = Stripe::InvoiceItem.retrieve(FIXTURE[:id])
|
49
|
-
item = item.delete
|
50
|
-
assert_requested :delete,
|
51
|
-
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
52
|
-
assert item.kind_of?(Stripe::InvoiceItem)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/test/stripe/invoice_test.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class InvoiceTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:invoice)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
invoices = Stripe::Invoice.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/invoices"
|
10
|
-
assert invoices.data.kind_of?(Array)
|
11
|
-
assert invoices.first.kind_of?(Stripe::Invoice)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}"
|
17
|
-
assert invoice.kind_of?(Stripe::Invoice)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "be creatable" do
|
21
|
-
invoice = Stripe::Invoice.create(
|
22
|
-
:customer => API_FIXTURES[:customer][:id]
|
23
|
-
)
|
24
|
-
assert_requested :post, "#{Stripe.api_base}/v1/invoices"
|
25
|
-
assert invoice.kind_of?(Stripe::Invoice)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "be saveable" do
|
29
|
-
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
|
30
|
-
invoice.metadata['key'] = 'value'
|
31
|
-
invoice.save
|
32
|
-
assert_requested :post, "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}"
|
33
|
-
end
|
34
|
-
|
35
|
-
should "be updateable" do
|
36
|
-
invoice = Stripe::Invoice.update(FIXTURE[:id], metadata: { key: 'value' })
|
37
|
-
assert_requested :post, "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}"
|
38
|
-
assert invoice.kind_of?(Stripe::Invoice)
|
39
|
-
end
|
40
|
-
|
41
|
-
context "#pay" do
|
42
|
-
should "pay invoice" do
|
43
|
-
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
|
44
|
-
invoice = invoice.pay
|
45
|
-
assert_requested :post,
|
46
|
-
"#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}/pay"
|
47
|
-
assert invoice.kind_of?(Stripe::Invoice)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "#upcoming" do
|
52
|
-
should "retrieve upcoming invoices" do
|
53
|
-
invoice = Stripe::Invoice.upcoming(
|
54
|
-
customer: API_FIXTURES[:customer][:id],
|
55
|
-
subscription: API_FIXTURES[:subscription][:id]
|
56
|
-
)
|
57
|
-
assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming",
|
58
|
-
query: {
|
59
|
-
customer: API_FIXTURES[:customer][:id],
|
60
|
-
subscription: API_FIXTURES[:subscription][:id]
|
61
|
-
}
|
62
|
-
assert invoice.kind_of?(Stripe::Invoice)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|