stripe 5.31.0 → 5.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/VERSION +1 -1
  4. data/lib/stripe/version.rb +1 -1
  5. data/stripe.gemspec +9 -2
  6. metadata +3 -195
  7. data/.editorconfig +0 -10
  8. data/.gitattributes +0 -4
  9. data/.github/ISSUE_TEMPLATE.md +0 -5
  10. data/.github/workflows/ci.yml +0 -34
  11. data/.gitignore +0 -8
  12. data/.rubocop.yml +0 -81
  13. data/.rubocop_todo.yml +0 -33
  14. data/.travis.yml +0 -38
  15. data/.vscode/extensions.json +0 -7
  16. data/.vscode/settings.json +0 -8
  17. data/test/openapi/README.md +0 -9
  18. data/test/stripe/account_link_test.rb +0 -18
  19. data/test/stripe/account_test.rb +0 -412
  20. data/test/stripe/alipay_account_test.rb +0 -37
  21. data/test/stripe/api_operations_test.rb +0 -80
  22. data/test/stripe/api_resource_test.rb +0 -646
  23. data/test/stripe/apple_pay_domain_test.rb +0 -46
  24. data/test/stripe/application_fee_refund_test.rb +0 -37
  25. data/test/stripe/application_fee_test.rb +0 -58
  26. data/test/stripe/balance_test.rb +0 -13
  27. data/test/stripe/balance_transaction_test.rb +0 -20
  28. data/test/stripe/bank_account_test.rb +0 -36
  29. data/test/stripe/billing_portal/configuration_test.rb +0 -37
  30. data/test/stripe/billing_portal/session_test.rb +0 -18
  31. data/test/stripe/capability_test.rb +0 -45
  32. data/test/stripe/charge_test.rb +0 -64
  33. data/test/stripe/checkout/session_test.rb +0 -53
  34. data/test/stripe/connection_manager_test.rb +0 -210
  35. data/test/stripe/country_spec_test.rb +0 -20
  36. data/test/stripe/coupon_test.rb +0 -61
  37. data/test/stripe/credit_note_test.rb +0 -90
  38. data/test/stripe/customer_balance_transaction_test.rb +0 -37
  39. data/test/stripe/customer_card_test.rb +0 -48
  40. data/test/stripe/customer_test.rb +0 -226
  41. data/test/stripe/dispute_test.rb +0 -51
  42. data/test/stripe/ephemeral_key_test.rb +0 -93
  43. data/test/stripe/errors_test.rb +0 -53
  44. data/test/stripe/exchange_rate_test.rb +0 -20
  45. data/test/stripe/file_link_test.rb +0 -41
  46. data/test/stripe/file_test.rb +0 -87
  47. data/test/stripe/instrumentation_test.rb +0 -74
  48. data/test/stripe/invoice_item_test.rb +0 -66
  49. data/test/stripe/invoice_line_item_test.rb +0 -8
  50. data/test/stripe/invoice_test.rb +0 -229
  51. data/test/stripe/issuing/authorization_test.rb +0 -72
  52. data/test/stripe/issuing/card_test.rb +0 -74
  53. data/test/stripe/issuing/cardholder_test.rb +0 -53
  54. data/test/stripe/issuing/dispute_test.rb +0 -54
  55. data/test/stripe/issuing/transaction_test.rb +0 -48
  56. data/test/stripe/list_object_test.rb +0 -202
  57. data/test/stripe/login_link_test.rb +0 -37
  58. data/test/stripe/mandate_test.rb +0 -14
  59. data/test/stripe/multipart_encoder_test.rb +0 -130
  60. data/test/stripe/oauth_test.rb +0 -149
  61. data/test/stripe/order_return_test.rb +0 -21
  62. data/test/stripe/order_test.rb +0 -82
  63. data/test/stripe/payment_intent_test.rb +0 -107
  64. data/test/stripe/payment_method_test.rb +0 -84
  65. data/test/stripe/payout_test.rb +0 -72
  66. data/test/stripe/person_test.rb +0 -46
  67. data/test/stripe/plan_test.rb +0 -98
  68. data/test/stripe/price_test.rb +0 -48
  69. data/test/stripe/product_test.rb +0 -58
  70. data/test/stripe/promotion_code_test.rb +0 -42
  71. data/test/stripe/radar/early_fraud_warning_test.rb +0 -22
  72. data/test/stripe/radar/value_list_item_test.rb +0 -48
  73. data/test/stripe/radar/value_list_test.rb +0 -61
  74. data/test/stripe/recipient_test.rb +0 -62
  75. data/test/stripe/refund_test.rb +0 -39
  76. data/test/stripe/reporting/report_run_test.rb +0 -33
  77. data/test/stripe/reporting/report_type_test.rb +0 -22
  78. data/test/stripe/reversal_test.rb +0 -43
  79. data/test/stripe/review_test.rb +0 -27
  80. data/test/stripe/setup_attempt_test.rb +0 -16
  81. data/test/stripe/setup_intent_test.rb +0 -84
  82. data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
  83. data/test/stripe/sku_test.rb +0 -60
  84. data/test/stripe/source_test.rb +0 -119
  85. data/test/stripe/stripe_client_test.rb +0 -1456
  86. data/test/stripe/stripe_configuration_test.rb +0 -159
  87. data/test/stripe/stripe_object_test.rb +0 -510
  88. data/test/stripe/stripe_response_test.rb +0 -95
  89. data/test/stripe/subscription_item_test.rb +0 -84
  90. data/test/stripe/subscription_schedule_test.rb +0 -82
  91. data/test/stripe/subscription_test.rb +0 -80
  92. data/test/stripe/tax_id_test.rb +0 -31
  93. data/test/stripe/tax_rate_test.rb +0 -43
  94. data/test/stripe/terminal/connection_token_test.rb +0 -16
  95. data/test/stripe/terminal/location_test.rb +0 -68
  96. data/test/stripe/terminal/reader_test.rb +0 -62
  97. data/test/stripe/three_d_secure_test.rb +0 -23
  98. data/test/stripe/topup_test.rb +0 -62
  99. data/test/stripe/transfer_test.rb +0 -88
  100. data/test/stripe/usage_record_summary_test.rb +0 -29
  101. data/test/stripe/util_test.rb +0 -402
  102. data/test/stripe/webhook_endpoint_test.rb +0 -59
  103. data/test/stripe/webhook_test.rb +0 -135
  104. data/test/stripe_mock.rb +0 -78
  105. data/test/stripe_test.rb +0 -137
  106. data/test/test_data.rb +0 -61
  107. data/test/test_helper.rb +0 -74
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class DisputeTest < Test::Unit::TestCase
7
- should "be listable" do
8
- disputes = Stripe::Dispute.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/disputes"
10
- assert disputes.data.is_a?(Array)
11
- assert disputes.first.is_a?(Stripe::Dispute)
12
- end
13
-
14
- should "be retrievable" do
15
- dispute = Stripe::Dispute.retrieve("dp_123")
16
- assert_requested :get, "#{Stripe.api_base}/v1/disputes/dp_123"
17
- assert dispute.is_a?(Stripe::Dispute)
18
- end
19
-
20
- should "be saveable" do
21
- dispute = Stripe::Dispute.retrieve("dp_123")
22
- dispute.metadata["key"] = "value"
23
- dispute.save
24
- assert_requested :post, "#{Stripe.api_base}/v1/disputes/#{dispute.id}"
25
- end
26
-
27
- should "be updateable" do
28
- dispute = Stripe::Dispute.update("dp_123", metadata: { key: "value" })
29
- assert_requested :post, "#{Stripe.api_base}/v1/disputes/dp_123"
30
- assert dispute.is_a?(Stripe::Dispute)
31
- end
32
-
33
- context "#close" do
34
- should "be closeable" do
35
- dispute = Stripe::Dispute.retrieve("dp_123")
36
- dispute.close
37
- assert_requested :post,
38
- "#{Stripe.api_base}/v1/disputes/#{dispute.id}/close"
39
- assert dispute.is_a?(Stripe::Dispute)
40
- end
41
- end
42
-
43
- context ".close" do
44
- should "close a dispute" do
45
- dispute = Stripe::Dispute.close("dp_123")
46
- assert_requested :post, "#{Stripe.api_base}/v1/disputes/dp_123/close"
47
- assert dispute.is_a?(Stripe::Dispute)
48
- end
49
- end
50
- end
51
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class EphemeralKeyTest < Test::Unit::TestCase
7
- context "#create" do
8
- should "succeed" do
9
- key = Stripe::EphemeralKey.create(
10
- { customer: "cus_123" },
11
- stripe_version: "2017-05-25"
12
- )
13
-
14
- assert_requested(
15
- :post,
16
- "#{Stripe.api_base}/v1/ephemeral_keys",
17
- headers: { "Stripe-Version" => "2017-05-25" }
18
- )
19
-
20
- assert key.is_a?(Stripe::EphemeralKey)
21
- end
22
-
23
- context "#no global version" do
24
- should "use the correct api version" do
25
- key = Stripe::EphemeralKey.create(
26
- { customer: "cus_123" },
27
- stripe_version: "2017-06-05"
28
- )
29
-
30
- assert_requested(
31
- :post,
32
- "#{Stripe.api_base}/v1/ephemeral_keys",
33
- headers: { "Stripe-Version" => "2017-06-05" }
34
- )
35
-
36
- assert key.is_a?(Stripe::EphemeralKey)
37
- end
38
-
39
- should "error without an explicit api version" do
40
- e = assert_raises(ArgumentError) do
41
- Stripe::EphemeralKey.create(customer: "cus_123")
42
- end
43
- assert_match("stripe_version must be specified", e.message)
44
- end
45
- end
46
-
47
- context "#with global version" do
48
- setup do
49
- Stripe.api_version = "2017-05-25"
50
- end
51
-
52
- teardown do
53
- Stripe.api_version = nil
54
- end
55
-
56
- should "use the correct api version" do
57
- key = Stripe::EphemeralKey.create(
58
- { customer: "cus_123" },
59
- stripe_version: "2017-05-25"
60
- )
61
-
62
- assert key.is_a?(Stripe::EphemeralKey)
63
- end
64
-
65
- should "error without an explicit api version" do
66
- e = assert_raises(ArgumentError) do
67
- Stripe::EphemeralKey.create(customer: "cus_123")
68
- end
69
- assert_match("stripe_version must be specified", e.message)
70
- end
71
- end
72
- end
73
-
74
- context "#delete" do
75
- should "succeed" do
76
- key = Stripe::EphemeralKey.create(
77
- { customer: "cus_123" },
78
- stripe_version: "2017-05-25"
79
- )
80
-
81
- key.delete
82
- assert_requested :delete, "#{Stripe.api_base}/v1/ephemeral_keys/#{key.id}"
83
- end
84
- end
85
-
86
- context ".delete" do
87
- should "succeed" do
88
- Stripe::EphemeralKey.delete("ephkey_123")
89
- assert_requested :delete, "#{Stripe.api_base}/v1/ephemeral_keys/ephkey_123"
90
- end
91
- end
92
- end
93
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class StripeErrorTest < Test::Unit::TestCase
7
- context "StripeError" do
8
- context "#initialize" do
9
- should "initialize error if json_body is set" do
10
- e = StripeError.new("message", json_body: { error: { code: "some_error" } })
11
- assert_not_nil e.error
12
- assert_equal "some_error", e.error.code
13
- assert_nil e.error.charge
14
- end
15
- end
16
-
17
- context "#idempotent_replayed?" do
18
- should "initialize from header" do
19
- e = StripeError.new("message", http_headers: { "idempotent-replayed" => "true" })
20
- assert_equal true, e.idempotent_replayed?
21
- end
22
-
23
- should "be 'falsey' by default" do
24
- e = StripeError.new("message")
25
- refute_equal true, e.idempotent_replayed?
26
- end
27
- end
28
-
29
- context "#to_s" do
30
- should "convert to string" do
31
- e = StripeError.new("message")
32
- assert_equal "message", e.to_s
33
-
34
- e = StripeError.new("message", http_status: 200)
35
- assert_equal "(Status 200) message", e.to_s
36
-
37
- e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { "request-id" => "request-id" })
38
- assert_equal "(Request request-id) message", e.to_s
39
- end
40
- end
41
- end
42
-
43
- context "OAuth::OAuthError" do
44
- context "#initialize" do
45
- should "initialize error if json_body is set" do
46
- e = OAuth::OAuthError.new("message", "description", json_body: { error: "some_oauth_error" })
47
- assert_not_nil e.error
48
- assert_equal "some_oauth_error", e.error.error
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class ExchangeRateTest < Test::Unit::TestCase
7
- should "be listable" do
8
- list_rates = Stripe::ExchangeRate.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/exchange_rates"
10
- assert list_rates.data.is_a?(Array)
11
- assert list_rates.data.first.is_a?(Stripe::ExchangeRate)
12
- end
13
-
14
- should "be retrievable" do
15
- rates = Stripe::ExchangeRate.retrieve("usd")
16
- assert_requested :get, "#{Stripe.api_base}/v1/exchange_rates/usd"
17
- assert rates.is_a?(Stripe::ExchangeRate)
18
- end
19
- end
20
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class FileLinkTest < Test::Unit::TestCase
7
- should "be listable" do
8
- file_links = Stripe::FileLink.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/file_links"
10
- assert file_links.data.is_a?(Array)
11
- assert file_links.first.is_a?(Stripe::FileLink)
12
- end
13
-
14
- should "be retrievable" do
15
- file_link = Stripe::FileLink.retrieve("link_123")
16
- assert_requested :get, "#{Stripe.api_base}/v1/file_links/link_123"
17
- assert file_link.is_a?(Stripe::FileLink)
18
- end
19
-
20
- should "be creatable" do
21
- file_link = Stripe::FileLink.create(
22
- file: "file_123"
23
- )
24
- assert_requested :post, "#{Stripe.api_base}/v1/file_links"
25
- assert file_link.is_a?(Stripe::FileLink)
26
- end
27
-
28
- should "be saveable" do
29
- file_link = Stripe::FileLink.retrieve("link_123")
30
- file_link.metadata["key"] = "value"
31
- file_link.save
32
- assert_requested :post, "#{Stripe.api_base}/v1/file_links/#{file_link.id}"
33
- end
34
-
35
- should "be updateable" do
36
- file_link = Stripe::FileLink.update("link_123", metadata: { key: "value" })
37
- assert_requested :post, "#{Stripe.api_base}/v1/file_links/link_123"
38
- assert file_link.is_a?(Stripe::FileLink)
39
- end
40
- end
41
- end
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class FileTest < Test::Unit::TestCase
7
- should "be listable" do
8
- files = Stripe::File.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/files"
10
- assert files.data.is_a?(Array)
11
- assert files.data[0].is_a?(Stripe::File)
12
- end
13
-
14
- should "be retrievable" do
15
- file = Stripe::File.retrieve("file_123")
16
- assert_requested :get, "#{Stripe.api_base}/v1/files/file_123"
17
- assert file.is_a?(Stripe::File)
18
- end
19
-
20
- context ".create" do
21
- setup do
22
- # We don't point to the same host for the API and uploads in
23
- # production, but `stripe-mock` supports both APIs.
24
- Stripe.uploads_base = Stripe.api_base
25
-
26
- # Set `api_base` to `nil` to ensure that these requests are _not_ sent
27
- # to the default API hostname.
28
- Stripe.api_base = nil
29
- end
30
-
31
- should "be creatable with a File" do
32
- file = Stripe::File.create(
33
- purpose: "dispute_evidence",
34
- file: ::File.new(__FILE__),
35
- file_link_data: { create: true }
36
- )
37
- assert_requested :post, "#{Stripe.uploads_base}/v1/files"
38
- assert file.is_a?(Stripe::File)
39
- end
40
-
41
- should "be creatable with a Tempfile" do
42
- tempfile = Tempfile.new("foo")
43
- tempfile.write("Hello world")
44
- tempfile.rewind
45
-
46
- file = Stripe::File.create(
47
- purpose: "dispute_evidence",
48
- file: tempfile,
49
- file_link_data: { create: true }
50
- )
51
- assert_requested :post, "#{Stripe.uploads_base}/v1/files"
52
- assert file.is_a?(Stripe::File)
53
- end
54
-
55
- should "be creatable with a string" do
56
- file = Stripe::File.create(
57
- purpose: "dispute_evidence",
58
- file: "my-file-contents",
59
- file_link_data: { create: true }
60
- )
61
- assert_requested :post, "#{Stripe.uploads_base}/v1/files"
62
- assert file.is_a?(Stripe::File)
63
- end
64
-
65
- should "raise given a file object that doesn't respond to #read" do
66
- e = assert_raises(ArgumentError) do
67
- Stripe::File.create(
68
- purpose: "dispute_evidence",
69
- file: Object.new,
70
- file_link_data: { create: true }
71
- )
72
- end
73
- assert_equal "file must respond to `#read`", e.message
74
- end
75
- end
76
-
77
- should "be deserializable when `object=file`" do
78
- file = Stripe::Util.convert_to_stripe_object({ object: "file" }, {})
79
- assert file.is_a?(Stripe::File)
80
- end
81
-
82
- should "be deserializable when `object=file_upload`" do
83
- file = Stripe::Util.convert_to_stripe_object({ object: "file_upload" }, {})
84
- assert file.is_a?(Stripe::File)
85
- end
86
- end
87
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../test_helper"
4
-
5
- module Stripe
6
- class InstrumentationTest < Test::Unit::TestCase
7
- context ".notify" do
8
- teardown do
9
- Stripe::Instrumentation.send(:subscribers).clear
10
- end
11
-
12
- should "notify subscribers for the right topic" do
13
- sub1_events = []
14
- Stripe::Instrumentation.subscribe(:test1, :sub1) { |event| sub1_events << event }
15
- sub2_events = []
16
- Stripe::Instrumentation.subscribe(:test2, :sub2) { |event| sub2_events << event }
17
-
18
- Stripe::Instrumentation.notify(:test1, "hello")
19
- assert_equal(1, sub1_events.size)
20
- assert_equal(0, sub2_events.size)
21
- end
22
-
23
- should "notify multiple subscribers of the same topic" do
24
- sub1_events = []
25
- Stripe::Instrumentation.subscribe(:test, :sub1) { |event| sub1_events << event }
26
- sub2_events = []
27
- Stripe::Instrumentation.subscribe(:test, :sub2) { |event| sub2_events << event }
28
-
29
- Stripe::Instrumentation.notify(:test, "hello")
30
- assert_equal(1, sub1_events.size)
31
- assert_equal(1, sub2_events.size)
32
- end
33
-
34
- should "not notify a subscriber once it has unsubscribed" do
35
- events = []
36
- Stripe::Instrumentation.subscribe(:test, :sub) { |event| events << event }
37
-
38
- Stripe::Instrumentation.notify(:test, "hello")
39
- assert_equal(1, events.size)
40
-
41
- Stripe::Instrumentation.unsubscribe(:test, :sub)
42
- Stripe::Instrumentation.notify(:test, "hello")
43
- assert_equal(1, events.size)
44
- end
45
- end
46
-
47
- context "RequestEventBegin" do
48
- should "return a frozen object" do
49
- event = Stripe::Instrumentation::RequestBeginEvent.new(
50
- method: :get,
51
- path: "/v1/test",
52
- user_data: nil
53
- )
54
-
55
- assert(event.frozen?)
56
- end
57
- end
58
-
59
- context "RequestEventEnd" do
60
- should "return a frozen object" do
61
- event = Stripe::Instrumentation::RequestEndEvent.new(
62
- duration: 0.1,
63
- http_status: 200,
64
- method: :get,
65
- num_retries: 0,
66
- path: "/v1/test",
67
- user_data: nil
68
- )
69
-
70
- assert(event.frozen?)
71
- end
72
- end
73
- end
74
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../test_helper", __dir__)
4
-
5
- module Stripe
6
- class InvoiceItemTest < Test::Unit::TestCase
7
- should "be listable" do
8
- invoiceitems = Stripe::InvoiceItem.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/invoiceitems"
10
- assert invoiceitems.data.is_a?(Array)
11
- assert invoiceitems.first.is_a?(Stripe::InvoiceItem)
12
- end
13
-
14
- should "be retrievable" do
15
- item = Stripe::InvoiceItem.retrieve("ii_123")
16
- assert_requested :get,
17
- "#{Stripe.api_base}/v1/invoiceitems/ii_123"
18
- assert item.is_a?(Stripe::InvoiceItem)
19
- end
20
-
21
- should "be creatable" do
22
- item = Stripe::InvoiceItem.create(
23
- amount: 100,
24
- currency: "USD",
25
- customer: "cus_123"
26
- )
27
- assert_requested :post,
28
- "#{Stripe.api_base}/v1/invoiceitems"
29
- assert item.is_a?(Stripe::InvoiceItem)
30
- end
31
-
32
- should "be saveable" do
33
- item = Stripe::InvoiceItem.retrieve("ii_123")
34
- item.metadata["key"] = "value"
35
- item.save
36
- assert_requested :post,
37
- "#{Stripe.api_base}/v1/invoiceitems/#{item.id}"
38
- end
39
-
40
- should "be updateable" do
41
- item = Stripe::InvoiceItem.update("ii_123", metadata: { key: "value" })
42
- assert_requested :post,
43
- "#{Stripe.api_base}/v1/invoiceitems/ii_123"
44
- assert item.is_a?(Stripe::InvoiceItem)
45
- end
46
-
47
- context "#delete" do
48
- should "be deletable" do
49
- item = Stripe::InvoiceItem.retrieve("ii_123")
50
- item = item.delete
51
- assert_requested :delete,
52
- "#{Stripe.api_base}/v1/invoiceitems/#{item.id}"
53
- assert item.is_a?(Stripe::InvoiceItem)
54
- end
55
- end
56
-
57
- context ".delete" do
58
- should "be deletable" do
59
- item = Stripe::InvoiceItem.delete("ii_123")
60
- assert_requested :delete,
61
- "#{Stripe.api_base}/v1/invoiceitems/ii_123"
62
- assert item.is_a?(Stripe::InvoiceItem)
63
- end
64
- end
65
- end
66
- end