stripe 4.10.0 → 5.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +316 -1
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +10 -14
- data/Makefile +7 -0
- data/README.md +186 -62
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +28 -2
- data/lib/stripe/api_operations/list.rb +1 -12
- data/lib/stripe/api_operations/nested_resource.rb +38 -28
- data/lib/stripe/api_operations/request.rb +81 -9
- data/lib/stripe/api_operations/save.rb +8 -7
- data/lib/stripe/api_operations/search.rb +19 -0
- data/lib/stripe/api_resource.rb +45 -3
- 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 +31 -10
- data/lib/stripe/instrumentation.rb +84 -0
- data/lib/stripe/list_object.rb +41 -7
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/oauth.rb +8 -6
- data/lib/stripe/object_types.rb +119 -0
- data/lib/stripe/{account.rb → resources/account.rb} +48 -30
- data/lib/stripe/{account_link.rb → resources/account_link.rb} +2 -1
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +2 -1
- data/lib/stripe/resources/application_fee.rb +14 -0
- data/lib/stripe/resources/application_fee_refund.rb +31 -0
- data/lib/stripe/{balance.rb → resources/balance.rb} +2 -1
- data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +2 -5
- data/lib/stripe/resources/bank_account.rb +43 -0
- data/lib/stripe/{issuing/dispute.rb → resources/billing_portal/configuration.rb} +4 -3
- data/lib/stripe/resources/billing_portal/session.rb +12 -0
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +4 -3
- data/lib/stripe/resources/bitcoin_transaction.rb +16 -0
- data/lib/stripe/resources/capability.rb +34 -0
- data/lib/stripe/{card.rb → resources/card.rb} +13 -4
- 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/{country_spec.rb → resources/country_spec.rb} +2 -1
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +3 -2
- 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/{ephemeral_key.rb → resources/ephemeral_key.rb} +6 -2
- data/lib/stripe/{event.rb → resources/event.rb} +2 -1
- data/lib/stripe/{exchange_rate.rb → resources/exchange_rate.rb} +2 -1
- data/lib/stripe/resources/file.rb +36 -0
- data/lib/stripe/{file_link.rb → resources/file_link.rb} +3 -2
- 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} +3 -2
- data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +2 -1
- 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/{issuing → resources/issuing}/cardholder.rb +3 -2
- data/lib/stripe/resources/issuing/dispute.rb +25 -0
- data/lib/stripe/{issuing → resources/issuing}/transaction.rb +3 -2
- 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/{order_return.rb → resources/order_return.rb} +2 -1
- 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/{person.rb → resources/person.rb} +9 -3
- data/lib/stripe/{plan.rb → resources/plan.rb} +2 -1
- 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/{radar → resources/radar}/value_list.rb +3 -2
- data/lib/stripe/{radar → resources/radar}/value_list_item.rb +3 -2
- data/lib/stripe/{recipient.rb → resources/recipient.rb} +3 -6
- data/lib/stripe/{recipient_transfer.rb → resources/recipient_transfer.rb} +1 -1
- data/lib/stripe/resources/refund.rb +42 -0
- data/lib/stripe/{reporting → resources/reporting}/report_run.rb +3 -2
- data/lib/stripe/{reporting → resources/reporting}/report_type.rb +3 -2
- 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/{product.rb → resources/shipping_rate.rb} +4 -4
- data/lib/stripe/{sigma → resources/sigma}/scheduled_query_run.rb +3 -2
- data/lib/stripe/{sku.rb → resources/sku.rb} +4 -3
- data/lib/stripe/resources/source.rb +47 -0
- data/lib/stripe/{source_transaction.rb → resources/source_transaction.rb} +2 -1
- 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/{refund.rb → resources/tax_rate.rb} +3 -2
- data/lib/stripe/{terminal/reader.rb → resources/terminal/configuration.rb} +3 -2
- data/lib/stripe/resources/terminal/connection_token.rb +12 -0
- data/lib/stripe/{terminal → resources/terminal}/location.rb +3 -2
- 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} +2 -1
- data/lib/stripe/{token.rb → resources/token.rb} +2 -1
- 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/{usage_record_summary.rb → resources/usage_record_summary.rb} +2 -1
- data/lib/stripe/{webhook_endpoint.rb → resources/webhook_endpoint.rb} +3 -2
- data/lib/stripe/resources.rb +100 -0
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/singleton_api_resource.rb +3 -1
- data/lib/stripe/stripe_client.rb +661 -266
- data/lib/stripe/stripe_configuration.rb +194 -0
- data/lib/stripe/stripe_object.rb +80 -61
- data/lib/stripe/stripe_response.rb +87 -27
- data/lib/stripe/util.rb +128 -117
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +43 -10
- data/lib/stripe.rb +46 -197
- data/stripe.gemspec +24 -8
- metadata +123 -283
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -8
- data/.rubocop.yml +0 -32
- data/.rubocop_todo.yml +0 -50
- data/.travis.yml +0 -42
- data/lib/stripe/alipay_account.rb +0 -27
- data/lib/stripe/application_fee.rb +0 -23
- data/lib/stripe/application_fee_refund.rb +0 -22
- data/lib/stripe/bank_account.rb +0 -32
- data/lib/stripe/bitcoin_transaction.rb +0 -15
- data/lib/stripe/charge.rb +0 -84
- data/lib/stripe/checkout/session.rb +0 -11
- data/lib/stripe/customer.rb +0 -90
- data/lib/stripe/dispute.rb +0 -19
- data/lib/stripe/file.rb +0 -37
- data/lib/stripe/invoice.rb +0 -48
- data/lib/stripe/issuer_fraud_record.rb +0 -9
- data/lib/stripe/issuing/authorization.rb +0 -22
- data/lib/stripe/issuing/card.rb +0 -18
- data/lib/stripe/issuing/card_details.rb +0 -9
- data/lib/stripe/login_link.rb +0 -11
- data/lib/stripe/order.rb +0 -31
- data/lib/stripe/payment_intent.rb +0 -26
- data/lib/stripe/payment_method.rb +0 -23
- data/lib/stripe/payout.rb +0 -20
- data/lib/stripe/reversal.rb +0 -22
- data/lib/stripe/review.rb +0 -14
- data/lib/stripe/source.rb +0 -38
- data/lib/stripe/subscription.rb +0 -25
- data/lib/stripe/subscription_item.rb +0 -17
- data/lib/stripe/subscription_schedule.rb +0 -32
- data/lib/stripe/subscription_schedule_revision.rb +0 -25
- data/lib/stripe/terminal/connection_token.rb +0 -11
- data/lib/stripe/topup.rb +0 -16
- data/lib/stripe/transfer.rb +0 -23
- data/lib/stripe/usage_record.rb +0 -14
- data/test/api_stub_helpers.rb +0 -1
- data/test/openapi/README.md +0 -9
- data/test/stripe/account_external_accounts_operations_test.rb +0 -69
- data/test/stripe/account_link_test.rb +0 -18
- data/test/stripe/account_login_links_operations_test.rb +0 -21
- data/test/stripe/account_persons_operations_test.rb +0 -70
- data/test/stripe/account_test.rb +0 -256
- data/test/stripe/alipay_account_test.rb +0 -37
- data/test/stripe/api_operations_test.rb +0 -81
- data/test/stripe/api_resource_test.rb +0 -526
- data/test/stripe/apple_pay_domain_test.rb +0 -33
- data/test/stripe/application_fee_refund_test.rb +0 -37
- data/test/stripe/application_fee_refunds_operations_test.rb +0 -56
- data/test/stripe/application_fee_test.rb +0 -14
- data/test/stripe/balance_test.rb +0 -13
- data/test/stripe/bank_account_test.rb +0 -36
- data/test/stripe/charge_test.rb +0 -59
- data/test/stripe/checkout/session_test.rb +0 -41
- data/test/stripe/country_spec_test.rb +0 -20
- data/test/stripe/coupon_test.rb +0 -51
- data/test/stripe/customer_card_test.rb +0 -42
- data/test/stripe/customer_sources_operations_test.rb +0 -64
- data/test/stripe/customer_test.rb +0 -115
- data/test/stripe/dispute_test.rb +0 -42
- data/test/stripe/ephemeral_key_test.rb +0 -86
- data/test/stripe/errors_test.rb +0 -20
- data/test/stripe/exchange_rate_test.rb +0 -20
- data/test/stripe/file_link_test.rb +0 -41
- data/test/stripe/file_test.rb +0 -73
- data/test/stripe/file_upload_test.rb +0 -76
- data/test/stripe/invoice_item_test.rb +0 -55
- data/test/stripe/invoice_line_item_test.rb +0 -8
- data/test/stripe/invoice_test.rb +0 -161
- data/test/stripe/issuer_fraud_record_test.rb +0 -20
- data/test/stripe/issuing/authorization_test.rb +0 -50
- data/test/stripe/issuing/card_test.rb +0 -53
- data/test/stripe/issuing/cardholder_test.rb +0 -53
- data/test/stripe/issuing/dispute_test.rb +0 -45
- data/test/stripe/issuing/transaction_test.rb +0 -48
- data/test/stripe/list_object_test.rb +0 -156
- data/test/stripe/login_link_test.rb +0 -37
- data/test/stripe/oauth_test.rb +0 -88
- data/test/stripe/order_return_test.rb +0 -21
- data/test/stripe/order_test.rb +0 -57
- data/test/stripe/payment_intent_test.rb +0 -80
- data/test/stripe/payment_method_test.rb +0 -66
- data/test/stripe/payout_test.rb +0 -50
- data/test/stripe/person_test.rb +0 -46
- data/test/stripe/plan_test.rb +0 -92
- data/test/stripe/product_test.rb +0 -49
- data/test/stripe/radar/value_list_item_test.rb +0 -38
- data/test/stripe/radar/value_list_test.rb +0 -51
- data/test/stripe/recipient_test.rb +0 -49
- data/test/stripe/refund_test.rb +0 -39
- data/test/stripe/reporting/report_run_test.rb +0 -33
- data/test/stripe/reporting/report_type_test.rb +0 -22
- data/test/stripe/reversal_test.rb +0 -43
- data/test/stripe/review_test.rb +0 -27
- data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
- data/test/stripe/sku_test.rb +0 -50
- data/test/stripe/source_test.rb +0 -86
- data/test/stripe/source_transaction_test.rb +0 -19
- data/test/stripe/stripe_client_test.rb +0 -823
- data/test/stripe/stripe_object_test.rb +0 -525
- data/test/stripe/stripe_response_test.rb +0 -49
- data/test/stripe/subscription_item_test.rb +0 -53
- data/test/stripe/subscription_schedule_revision_test.rb +0 -37
- data/test/stripe/subscription_schedule_revisions_operations_test.rb +0 -35
- data/test/stripe/subscription_schedule_test.rb +0 -64
- data/test/stripe/subscription_test.rb +0 -60
- data/test/stripe/terminal/connection_token_test.rb +0 -16
- data/test/stripe/terminal/location_test.rb +0 -58
- data/test/stripe/terminal/reader_test.rb +0 -52
- data/test/stripe/three_d_secure_test.rb +0 -23
- data/test/stripe/topup_test.rb +0 -54
- data/test/stripe/transfer_reversals_operations_test.rb +0 -57
- data/test/stripe/transfer_test.rb +0 -43
- data/test/stripe/usage_record_summary_test.rb +0 -19
- data/test/stripe/usage_record_test.rb +0 -28
- data/test/stripe/util_test.rb +0 -402
- data/test/stripe/webhook_endpoint_test.rb +0 -42
- data/test/stripe/webhook_test.rb +0 -96
- data/test/stripe_mock.rb +0 -77
- data/test/stripe_test.rb +0 -63
- data/test/test_data.rb +0 -61
- data/test/test_helper.rb +0 -73
@@ -1,81 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require ::File.expand_path("../../test_helper", __FILE__)
|
5
|
-
|
6
|
-
module Stripe
|
7
|
-
class ApiOperationsTest < Test::Unit::TestCase
|
8
|
-
class UpdateableResource < APIResource
|
9
|
-
include Stripe::APIOperations::Save
|
10
|
-
|
11
|
-
OBJECT_NAME = "updateableresource".freeze
|
12
|
-
|
13
|
-
def self.protected_fields
|
14
|
-
[:protected]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context ".update" do
|
19
|
-
should "post the correct parameters to the resource URL" do
|
20
|
-
stub_request(:post, "#{Stripe.api_base}/v1/updateableresources/id")
|
21
|
-
.with(body: { foo: "bar" })
|
22
|
-
.to_return(body: JSON.generate(foo: "bar"))
|
23
|
-
resource = UpdateableResource.update("id", foo: "bar")
|
24
|
-
assert_equal("bar", resource.foo)
|
25
|
-
end
|
26
|
-
|
27
|
-
should "error on protected fields" do
|
28
|
-
e = assert_raises do
|
29
|
-
UpdateableResource.update("id", protected: "bar")
|
30
|
-
end
|
31
|
-
assert_equal "Cannot update protected field: protected", e.message
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context ".nested_resource_class_methods" do
|
36
|
-
class MainResource < APIResource
|
37
|
-
extend Stripe::APIOperations::NestedResource
|
38
|
-
OBJECT_NAME = "mainresource".freeze
|
39
|
-
nested_resource_class_methods :nested,
|
40
|
-
operations: %i[create retrieve update delete list]
|
41
|
-
end
|
42
|
-
|
43
|
-
should "define a create method" do
|
44
|
-
stub_request(:post, "#{Stripe.api_base}/v1/mainresources/id/nesteds")
|
45
|
-
.with(body: { foo: "bar" })
|
46
|
-
.to_return(body: JSON.generate(id: "nested_id", object: "nested", foo: "bar"))
|
47
|
-
nested_resource = MainResource.create_nested("id", foo: "bar")
|
48
|
-
assert_equal "bar", nested_resource.foo
|
49
|
-
end
|
50
|
-
|
51
|
-
should "define a retrieve method" do
|
52
|
-
stub_request(:get, "#{Stripe.api_base}/v1/mainresources/id/nesteds/nested_id")
|
53
|
-
.to_return(body: JSON.generate(id: "nested_id", object: "nested", foo: "bar"))
|
54
|
-
nested_resource = MainResource.retrieve_nested("id", "nested_id")
|
55
|
-
assert_equal "bar", nested_resource.foo
|
56
|
-
end
|
57
|
-
|
58
|
-
should "define an update method" do
|
59
|
-
stub_request(:post, "#{Stripe.api_base}/v1/mainresources/id/nesteds/nested_id")
|
60
|
-
.with(body: { foo: "baz" })
|
61
|
-
.to_return(body: JSON.generate(id: "nested_id", object: "nested", foo: "baz"))
|
62
|
-
nested_resource = MainResource.update_nested("id", "nested_id", foo: "baz")
|
63
|
-
assert_equal "baz", nested_resource.foo
|
64
|
-
end
|
65
|
-
|
66
|
-
should "define a delete method" do
|
67
|
-
stub_request(:delete, "#{Stripe.api_base}/v1/mainresources/id/nesteds/nested_id")
|
68
|
-
.to_return(body: JSON.generate(id: "nested_id", object: "nested", deleted: true))
|
69
|
-
nested_resource = MainResource.delete_nested("id", "nested_id")
|
70
|
-
assert_equal true, nested_resource.deleted
|
71
|
-
end
|
72
|
-
|
73
|
-
should "define a list method" do
|
74
|
-
stub_request(:get, "#{Stripe.api_base}/v1/mainresources/id/nesteds")
|
75
|
-
.to_return(body: JSON.generate(object: "list", data: []))
|
76
|
-
nested_resources = MainResource.list_nesteds("id")
|
77
|
-
assert nested_resources.data.is_a?(Array)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,526 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require ::File.expand_path("../../test_helper", __FILE__)
|
5
|
-
|
6
|
-
module Stripe
|
7
|
-
class ApiResourceTest < Test::Unit::TestCase
|
8
|
-
class NestedTestAPIResource < Stripe::APIResource
|
9
|
-
save_nested_resource :external_account
|
10
|
-
end
|
11
|
-
|
12
|
-
context ".save_nested_resource" do
|
13
|
-
should "can have a scalar set" do
|
14
|
-
r = NestedTestAPIResource.new("test_resource")
|
15
|
-
r.external_account = "tok_123"
|
16
|
-
assert_equal "tok_123", r.external_account
|
17
|
-
end
|
18
|
-
|
19
|
-
should "set a flag if given an object source" do
|
20
|
-
r = NestedTestAPIResource.new("test_resource")
|
21
|
-
r.external_account = {
|
22
|
-
object: "card",
|
23
|
-
}
|
24
|
-
assert_equal true, r.external_account.save_with_parent
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
should "creating a new APIResource should not fetch over the network" do
|
29
|
-
Stripe::Customer.new("someid")
|
30
|
-
assert_not_requested :get, %r{#{Stripe.api_base}/.*}
|
31
|
-
end
|
32
|
-
|
33
|
-
should "creating a new APIResource from a hash should not fetch over the network" do
|
34
|
-
Stripe::Customer.construct_from(id: "somecustomer",
|
35
|
-
card: { id: "somecard", object: "card" },
|
36
|
-
object: "customer")
|
37
|
-
assert_not_requested :get, %r{#{Stripe.api_base}/.*}
|
38
|
-
end
|
39
|
-
|
40
|
-
should "setting an attribute should not cause a network request" do
|
41
|
-
c = Stripe::Customer.new("cus_123")
|
42
|
-
c.card = { id: "somecard", object: "card" }
|
43
|
-
assert_not_requested :get, %r{#{Stripe.api_base}/.*}
|
44
|
-
assert_not_requested :post, %r{#{Stripe.api_base}/.*}
|
45
|
-
end
|
46
|
-
|
47
|
-
should "accessing id should not issue a fetch" do
|
48
|
-
c = Stripe::Customer.new("cus_123")
|
49
|
-
c.id
|
50
|
-
assert_not_requested :get, %r{#{Stripe.api_base}/.*}
|
51
|
-
end
|
52
|
-
|
53
|
-
should "not specifying api credentials should raise an exception" do
|
54
|
-
Stripe.api_key = nil
|
55
|
-
assert_raises Stripe::AuthenticationError do
|
56
|
-
Stripe::Customer.new("cus_123").refresh
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
should "using a nil api key should raise an exception" do
|
61
|
-
assert_raises TypeError do
|
62
|
-
Stripe::Customer.list({}, nil)
|
63
|
-
end
|
64
|
-
assert_raises TypeError do
|
65
|
-
Stripe::Customer.list({}, api_key: nil)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
should "specifying api credentials containing whitespace should raise an exception" do
|
70
|
-
Stripe.api_key = "key "
|
71
|
-
assert_raises Stripe::AuthenticationError do
|
72
|
-
Stripe::Customer.new("cus_123").refresh
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
should "send expand on fetch properly" do
|
77
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
|
78
|
-
.with(query: { "expand" => ["customer"] })
|
79
|
-
.to_return(body: JSON.generate(charge_fixture))
|
80
|
-
|
81
|
-
Stripe::Charge.retrieve(id: "ch_123", expand: [:customer])
|
82
|
-
end
|
83
|
-
|
84
|
-
should "preserve expand across refreshes" do
|
85
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
|
86
|
-
.with(query: { "expand" => ["customer"] })
|
87
|
-
.to_return(body: JSON.generate(charge_fixture))
|
88
|
-
|
89
|
-
ch = Stripe::Charge.retrieve(id: "ch_123", expand: [:customer])
|
90
|
-
ch.refresh
|
91
|
-
end
|
92
|
-
|
93
|
-
should "send expand when fetching through ListObject" do
|
94
|
-
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123")
|
95
|
-
.to_return(body: JSON.generate(customer_fixture))
|
96
|
-
|
97
|
-
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123/sources/cc_test_card")
|
98
|
-
.with(query: { "expand" => ["customer"] })
|
99
|
-
.to_return(body: JSON.generate(customer_fixture))
|
100
|
-
|
101
|
-
customer = Stripe::Customer.retrieve("cus_123")
|
102
|
-
customer.sources.retrieve(id: "cc_test_card", expand: [:customer])
|
103
|
-
end
|
104
|
-
|
105
|
-
context "when specifying per-object credentials" do
|
106
|
-
context "with no global API key set" do
|
107
|
-
should "use the per-object credential when creating" do
|
108
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
109
|
-
.with(headers: { "Authorization" => "Bearer sk_test_local" })
|
110
|
-
.to_return(body: JSON.generate(charge_fixture))
|
111
|
-
|
112
|
-
Stripe::Charge.create({ source: "tok_visa" },
|
113
|
-
"sk_test_local")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context "with a global API key set" do
|
118
|
-
setup do
|
119
|
-
Stripe.api_key = "global"
|
120
|
-
end
|
121
|
-
|
122
|
-
teardown do
|
123
|
-
Stripe.api_key = nil
|
124
|
-
end
|
125
|
-
|
126
|
-
should "use the per-object credential when creating" do
|
127
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
128
|
-
.with(headers: { "Authorization" => "Bearer sk_test_local" })
|
129
|
-
.to_return(body: JSON.generate(charge_fixture))
|
130
|
-
|
131
|
-
Stripe::Charge.create({ source: "tok_visa" },
|
132
|
-
"sk_test_local")
|
133
|
-
end
|
134
|
-
|
135
|
-
should "use the per-object credential when retrieving and making other calls" do
|
136
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
|
137
|
-
.with(headers: { "Authorization" => "Bearer sk_test_local" })
|
138
|
-
.to_return(body: JSON.generate(charge_fixture))
|
139
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges/ch_123/refunds")
|
140
|
-
.with(headers: { "Authorization" => "Bearer sk_test_local" })
|
141
|
-
.to_return(body: "{}")
|
142
|
-
|
143
|
-
ch = Stripe::Charge.retrieve("ch_123", "sk_test_local")
|
144
|
-
ch.refunds.create
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context "with valid credentials" do
|
150
|
-
should "urlencode values in GET params" do
|
151
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
152
|
-
.with(query: { customer: "test customer" })
|
153
|
-
.to_return(body: JSON.generate(data: [charge_fixture]))
|
154
|
-
charges = Stripe::Charge.list(customer: "test customer").data
|
155
|
-
assert charges.is_a? Array
|
156
|
-
end
|
157
|
-
|
158
|
-
should "construct URL properly with base query parameters" do
|
159
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
160
|
-
.with(query: { customer: "cus_123" })
|
161
|
-
.to_return(body: JSON.generate(data: [charge_fixture],
|
162
|
-
url: "/v1/charges"))
|
163
|
-
charges = Stripe::Charge.list(customer: "cus_123")
|
164
|
-
|
165
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
166
|
-
.with(query: { customer: "cus_123", created: "123" })
|
167
|
-
.to_return(body: JSON.generate(data: [charge_fixture],
|
168
|
-
url: "/v1/charges"))
|
169
|
-
charges.list(created: 123)
|
170
|
-
end
|
171
|
-
|
172
|
-
should "setting a nil value for a param should exclude that param from the request" do
|
173
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
174
|
-
.with(query: { offset: 5, sad: false })
|
175
|
-
.to_return(body: JSON.generate(count: 1, data: [charge_fixture]))
|
176
|
-
Stripe::Charge.list(count: nil, offset: 5, sad: false)
|
177
|
-
|
178
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
179
|
-
.with(body: { "amount" => "50", "currency" => "usd" })
|
180
|
-
.to_return(body: JSON.generate(count: 1, data: [charge_fixture]))
|
181
|
-
Stripe::Charge.create(amount: 50, currency: "usd", card: { number: nil })
|
182
|
-
end
|
183
|
-
|
184
|
-
should "not trigger a warning if a known opt, such as idempotency_key, is in opts" do
|
185
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
186
|
-
.to_return(body: JSON.generate(charge_fixture))
|
187
|
-
old_stderr = $stderr
|
188
|
-
$stderr = StringIO.new
|
189
|
-
begin
|
190
|
-
Stripe::Charge.create({ amount: 100, currency: "usd", card: "sc_token" }, idempotency_key: "12345")
|
191
|
-
assert $stderr.string.empty?
|
192
|
-
ensure
|
193
|
-
$stderr = old_stderr
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
should "trigger a warning if a known opt, such as idempotency_key, is in params" do
|
198
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
199
|
-
.to_return(body: JSON.generate(charge_fixture))
|
200
|
-
old_stderr = $stderr
|
201
|
-
$stderr = StringIO.new
|
202
|
-
begin
|
203
|
-
Stripe::Charge.create(amount: 100, currency: "usd", card: "sc_token", idempotency_key: "12345")
|
204
|
-
assert_match Regexp.new("WARNING:"), $stderr.string
|
205
|
-
ensure
|
206
|
-
$stderr = old_stderr
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
should "requesting with a unicode ID should result in a request" do
|
211
|
-
stub_request(:get, "#{Stripe.api_base}/v1/customers/%E2%98%83")
|
212
|
-
.to_return(body: JSON.generate(make_missing_id_error), status: 404)
|
213
|
-
c = Stripe::Customer.new("☃")
|
214
|
-
assert_raises(Stripe::InvalidRequestError) { c.refresh }
|
215
|
-
end
|
216
|
-
|
217
|
-
should "requesting with no ID should result in an InvalidRequestError with no request" do
|
218
|
-
c = Stripe::Customer.new
|
219
|
-
assert_raises(Stripe::InvalidRequestError) { c.refresh }
|
220
|
-
end
|
221
|
-
|
222
|
-
should "making a GET request with parameters should have a query string and no body" do
|
223
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
224
|
-
.with(query: { limit: 1 })
|
225
|
-
.to_return(body: JSON.generate(data: [charge_fixture]))
|
226
|
-
Stripe::Charge.list(limit: 1)
|
227
|
-
end
|
228
|
-
|
229
|
-
should "making a POST request with parameters should have a body and no query string" do
|
230
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges")
|
231
|
-
.with(body: { "amount" => "100", "currency" => "usd", "card" => "sc_token" })
|
232
|
-
.to_return(body: JSON.generate(charge_fixture))
|
233
|
-
Stripe::Charge.create(amount: 100, currency: "usd", card: "sc_token")
|
234
|
-
end
|
235
|
-
|
236
|
-
should "loading an object should issue a GET request" do
|
237
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
|
238
|
-
.to_return(body: JSON.generate(charge_fixture))
|
239
|
-
c = Stripe::Charge.new("ch_123")
|
240
|
-
c.refresh
|
241
|
-
end
|
242
|
-
|
243
|
-
should "using array accessors should be the same as the method interface" do
|
244
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
|
245
|
-
.to_return(body: JSON.generate(charge_fixture))
|
246
|
-
c = Stripe::Charge.new("cus_123")
|
247
|
-
c.refresh
|
248
|
-
assert_equal c.created, c[:created]
|
249
|
-
assert_equal c.created, c["created"]
|
250
|
-
c["created"] = 12_345
|
251
|
-
assert_equal c.created, 12_345
|
252
|
-
end
|
253
|
-
|
254
|
-
should "accessing a property other than id or parent on an unfetched object should fetch it" do
|
255
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
256
|
-
.with(query: { customer: "cus_123" })
|
257
|
-
.to_return(body: JSON.generate(customer_fixture))
|
258
|
-
c = Stripe::Customer.new("cus_123")
|
259
|
-
c.charges
|
260
|
-
end
|
261
|
-
|
262
|
-
should "updating an object should issue a POST request with only the changed properties" do
|
263
|
-
stub_request(:post, "#{Stripe.api_base}/v1/customers/cus_123")
|
264
|
-
.with(body: { "description" => "another_mn" })
|
265
|
-
.to_return(body: JSON.generate(customer_fixture))
|
266
|
-
c = Stripe::Customer.construct_from(customer_fixture)
|
267
|
-
c.description = "another_mn"
|
268
|
-
c.save
|
269
|
-
end
|
270
|
-
|
271
|
-
should "updating should merge in returned properties" do
|
272
|
-
stub_request(:post, "#{Stripe.api_base}/v1/customers/cus_123")
|
273
|
-
.with(body: { "description" => "another_mn" })
|
274
|
-
.to_return(body: JSON.generate(customer_fixture))
|
275
|
-
c = Stripe::Customer.new("cus_123")
|
276
|
-
c.description = "another_mn"
|
277
|
-
c.save
|
278
|
-
assert_equal false, c.livemode
|
279
|
-
end
|
280
|
-
|
281
|
-
should "updating should fail if api_key is overwritten with nil" do
|
282
|
-
c = Stripe::Customer.new
|
283
|
-
assert_raises TypeError do
|
284
|
-
c.save({}, api_key: nil)
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
should "updating should use the supplied api_key" do
|
289
|
-
stub_request(:post, "#{Stripe.api_base}/v1/customers")
|
290
|
-
.with(headers: { "Authorization" => "Bearer sk_test_local" })
|
291
|
-
.to_return(body: JSON.generate(customer_fixture))
|
292
|
-
c = Stripe::Customer.new
|
293
|
-
c.save({}, api_key: "sk_test_local")
|
294
|
-
assert_equal false, c.livemode
|
295
|
-
end
|
296
|
-
|
297
|
-
should "deleting should send no props and result in an object that has no props other deleted" do
|
298
|
-
stub_request(:delete, "#{Stripe.api_base}/v1/customers/cus_123")
|
299
|
-
.to_return(body: JSON.generate("id" => "cus_123", "deleted" => true))
|
300
|
-
c = Stripe::Customer.construct_from(customer_fixture)
|
301
|
-
c.delete
|
302
|
-
end
|
303
|
-
|
304
|
-
should "loading all of an APIResource should return an array of recursively instantiated objects" do
|
305
|
-
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
306
|
-
.to_return(body: JSON.generate(data: [charge_fixture]))
|
307
|
-
charges = Stripe::Charge.list.data
|
308
|
-
assert charges.is_a? Array
|
309
|
-
assert charges[0].is_a? Stripe::Charge
|
310
|
-
assert charges[0].source.is_a?(Stripe::StripeObject)
|
311
|
-
end
|
312
|
-
|
313
|
-
should "passing in a stripe_account header should pass it through on call" do
|
314
|
-
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123")
|
315
|
-
.with(headers: { "Stripe-Account" => "acct_123" })
|
316
|
-
.to_return(body: JSON.generate(customer_fixture))
|
317
|
-
Stripe::Customer.retrieve("cus_123", stripe_account: "acct_123")
|
318
|
-
end
|
319
|
-
|
320
|
-
should "passing in a stripe_account header should pass it through on save" do
|
321
|
-
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123")
|
322
|
-
.with(headers: { "Stripe-Account" => "acct_123" })
|
323
|
-
.to_return(body: JSON.generate(customer_fixture))
|
324
|
-
c = Stripe::Customer.retrieve("cus_123", stripe_account: "acct_123")
|
325
|
-
|
326
|
-
stub_request(:post, "#{Stripe.api_base}/v1/customers/cus_123")
|
327
|
-
.with(headers: { "Stripe-Account" => "acct_123" })
|
328
|
-
.to_return(body: JSON.generate(customer_fixture))
|
329
|
-
c.description = "FOO"
|
330
|
-
c.save
|
331
|
-
end
|
332
|
-
|
333
|
-
should "add key to nested objects" do
|
334
|
-
acct = Stripe::Account.construct_from(id: "myid",
|
335
|
-
legal_entity: {
|
336
|
-
size: "l",
|
337
|
-
score: 4,
|
338
|
-
height: 10,
|
339
|
-
})
|
340
|
-
|
341
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
|
342
|
-
.with(body: { legal_entity: { first_name: "Bob" } })
|
343
|
-
.to_return(body: JSON.generate("id" => "myid"))
|
344
|
-
|
345
|
-
acct.legal_entity.first_name = "Bob"
|
346
|
-
acct.save
|
347
|
-
end
|
348
|
-
|
349
|
-
should "save nothing if nothing changes" do
|
350
|
-
acct = Stripe::Account.construct_from(id: "acct_id",
|
351
|
-
metadata: {
|
352
|
-
key: "value",
|
353
|
-
})
|
354
|
-
|
355
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/acct_id")
|
356
|
-
.with(body: {})
|
357
|
-
.to_return(body: JSON.generate("id" => "acct_id"))
|
358
|
-
|
359
|
-
acct.save
|
360
|
-
end
|
361
|
-
|
362
|
-
should "not save nested API resources" do
|
363
|
-
ch = Stripe::Charge.construct_from(id: "ch_id",
|
364
|
-
customer: {
|
365
|
-
object: "customer",
|
366
|
-
id: "customer_id",
|
367
|
-
})
|
368
|
-
|
369
|
-
stub_request(:post, "#{Stripe.api_base}/v1/charges/ch_id")
|
370
|
-
.with(body: {})
|
371
|
-
.to_return(body: JSON.generate("id" => "ch_id"))
|
372
|
-
|
373
|
-
ch.customer.description = "Bob"
|
374
|
-
ch.save
|
375
|
-
end
|
376
|
-
|
377
|
-
should "correctly handle replaced nested objects" do
|
378
|
-
acct = Stripe::Account.construct_from(
|
379
|
-
id: "acct_123",
|
380
|
-
company: {
|
381
|
-
name: "company_name",
|
382
|
-
address: {
|
383
|
-
line1: "test",
|
384
|
-
city: "San Francisco",
|
385
|
-
},
|
386
|
-
}
|
387
|
-
)
|
388
|
-
|
389
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/acct_123")
|
390
|
-
.with(body: { company: { address: { line1: "Test2", city: "" } } })
|
391
|
-
.to_return(body: JSON.generate("id" => "my_id"))
|
392
|
-
|
393
|
-
acct.company.address = { line1: "Test2" }
|
394
|
-
acct.save
|
395
|
-
end
|
396
|
-
|
397
|
-
should "correctly handle array setting" do
|
398
|
-
acct = Stripe::Account.construct_from(id: "myid",
|
399
|
-
legal_entity: {})
|
400
|
-
|
401
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
|
402
|
-
.with(body: { legal_entity: { additional_owners: [{ first_name: "Bob" }] } })
|
403
|
-
.to_return(body: JSON.generate("id" => "myid"))
|
404
|
-
|
405
|
-
acct.legal_entity.additional_owners = [{ first_name: "Bob" }]
|
406
|
-
acct.save
|
407
|
-
end
|
408
|
-
|
409
|
-
should "correctly handle array insertion" do
|
410
|
-
acct = Stripe::Account.construct_from(id: "myid",
|
411
|
-
legal_entity: {
|
412
|
-
additional_owners: [],
|
413
|
-
})
|
414
|
-
|
415
|
-
# Note that this isn't a perfect check because we're using webmock's
|
416
|
-
# data decoding, which isn't aware of the Stripe array encoding that we
|
417
|
-
# use here.
|
418
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
|
419
|
-
.with(body: { legal_entity: { additional_owners: [{ first_name: "Bob" }] } })
|
420
|
-
.to_return(body: JSON.generate("id" => "myid"))
|
421
|
-
|
422
|
-
acct.legal_entity.additional_owners << { first_name: "Bob" }
|
423
|
-
acct.save
|
424
|
-
end
|
425
|
-
|
426
|
-
should "correctly handle array updates" do
|
427
|
-
acct = Stripe::Account.construct_from(id: "myid",
|
428
|
-
legal_entity: {
|
429
|
-
additional_owners: [{ first_name: "Bob" }, { first_name: "Jane" }],
|
430
|
-
})
|
431
|
-
|
432
|
-
# Note that this isn't a perfect check because we're using webmock's
|
433
|
-
# data decoding, which isn't aware of the Stripe array encoding that we
|
434
|
-
# use here.
|
435
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
|
436
|
-
.with(body: { legal_entity: { additional_owners: [{ first_name: "Janet" }] } })
|
437
|
-
.to_return(body: JSON.generate("id" => "myid"))
|
438
|
-
|
439
|
-
acct.legal_entity.additional_owners[1].first_name = "Janet"
|
440
|
-
acct.save
|
441
|
-
end
|
442
|
-
|
443
|
-
should "correctly handle array noops" do
|
444
|
-
acct = Stripe::Account.construct_from(id: "myid",
|
445
|
-
legal_entity: {
|
446
|
-
additional_owners: [{ first_name: "Bob" }],
|
447
|
-
},
|
448
|
-
currencies_supported: %w[usd cad])
|
449
|
-
|
450
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
|
451
|
-
.with(body: {})
|
452
|
-
.to_return(body: JSON.generate("id" => "myid"))
|
453
|
-
|
454
|
-
acct.save
|
455
|
-
end
|
456
|
-
|
457
|
-
should "correctly handle hash noops" do
|
458
|
-
acct = Stripe::Account.construct_from(id: "myid",
|
459
|
-
legal_entity: {
|
460
|
-
address: { line1: "1 Two Three" },
|
461
|
-
})
|
462
|
-
|
463
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/myid")
|
464
|
-
.with(body: {})
|
465
|
-
.to_return(body: JSON.generate("id" => "myid"))
|
466
|
-
|
467
|
-
acct.save
|
468
|
-
end
|
469
|
-
|
470
|
-
should "should create a new resource when an object without an id is saved" do
|
471
|
-
account = Stripe::Account.construct_from(id: nil,
|
472
|
-
display_name: nil)
|
473
|
-
|
474
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts")
|
475
|
-
.with(body: { display_name: "stripe" })
|
476
|
-
.to_return(body: JSON.generate("id" => "acct_123"))
|
477
|
-
|
478
|
-
account.display_name = "stripe"
|
479
|
-
account.save
|
480
|
-
end
|
481
|
-
|
482
|
-
should "set attributes as part of save" do
|
483
|
-
account = Stripe::Account.construct_from(id: nil,
|
484
|
-
display_name: nil)
|
485
|
-
|
486
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts")
|
487
|
-
.with(body: { display_name: "stripe", metadata: { key: "value" } })
|
488
|
-
.to_return(body: JSON.generate("id" => "acct_123"))
|
489
|
-
|
490
|
-
account.save(display_name: "stripe", metadata: { key: "value" })
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
|
-
@@fixtures = {}
|
495
|
-
setup do
|
496
|
-
if @@fixtures.empty?
|
497
|
-
cache_fixture(:charge) do
|
498
|
-
Charge.retrieve("ch_123")
|
499
|
-
end
|
500
|
-
cache_fixture(:customer) do
|
501
|
-
Customer.retrieve("cus_123")
|
502
|
-
end
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
|
-
private
|
507
|
-
|
508
|
-
def charge_fixture
|
509
|
-
@@fixtures[:charge]
|
510
|
-
end
|
511
|
-
|
512
|
-
def customer_fixture
|
513
|
-
@@fixtures[:customer]
|
514
|
-
end
|
515
|
-
|
516
|
-
# Expects to retrieve a fixture from stripe-mock (an API call should be
|
517
|
-
# included in the block to yield to) and does very simple memoization.
|
518
|
-
def cache_fixture(key)
|
519
|
-
return @@fixtures[key] if @@fixtures.key?(key)
|
520
|
-
|
521
|
-
obj = yield
|
522
|
-
@@fixtures[key] = obj.instance_variable_get(:@values).freeze
|
523
|
-
@@fixtures[key]
|
524
|
-
end
|
525
|
-
end
|
526
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require ::File.expand_path("../../test_helper", __FILE__)
|
4
|
-
|
5
|
-
module Stripe
|
6
|
-
class ApplePayDomainTest < Test::Unit::TestCase
|
7
|
-
should "be listable" do
|
8
|
-
domains = Stripe::ApplePayDomain.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains"
|
10
|
-
assert domains.data.is_a?(Array)
|
11
|
-
assert domains.data[0].is_a?(Stripe::ApplePayDomain)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains/apwc_123"
|
17
|
-
assert domain.is_a?(Stripe::ApplePayDomain)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "be creatable" do
|
21
|
-
domain = Stripe::ApplePayDomain.create(domain_name: "example.com")
|
22
|
-
assert_requested :post, "#{Stripe.api_base}/v1/apple_pay/domains"
|
23
|
-
assert domain.is_a?(Stripe::ApplePayDomain)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "be deletable" do
|
27
|
-
domain = Stripe::ApplePayDomain.retrieve("apwc_123")
|
28
|
-
domain = domain.delete
|
29
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{domain.id}"
|
30
|
-
assert domain.is_a?(Stripe::ApplePayDomain)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require ::File.expand_path("../../test_helper", __FILE__)
|
4
|
-
|
5
|
-
module Stripe
|
6
|
-
class ApplicationFeeRefundTest < Test::Unit::TestCase
|
7
|
-
setup do
|
8
|
-
@fee = Stripe::ApplicationFee.retrieve("fee_123")
|
9
|
-
end
|
10
|
-
|
11
|
-
should "be listable" do
|
12
|
-
refunds = @fee.refunds
|
13
|
-
|
14
|
-
# notably this *doesn't* make an API call
|
15
|
-
assert_not_requested :get,
|
16
|
-
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
|
17
|
-
|
18
|
-
assert refunds.data.is_a?(Array)
|
19
|
-
assert refunds.first.is_a?(Stripe::ApplicationFeeRefund)
|
20
|
-
end
|
21
|
-
|
22
|
-
should "be creatable" do
|
23
|
-
refund = @fee.refunds.create
|
24
|
-
assert_requested :post,
|
25
|
-
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
|
26
|
-
assert refund.is_a?(Stripe::ApplicationFeeRefund)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "be saveable" do
|
30
|
-
refund = @fee.refunds.first
|
31
|
-
refund.metadata["key"] = "value"
|
32
|
-
refund.save
|
33
|
-
assert_requested :post,
|
34
|
-
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{refund.id}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|