stripe 4.10.0 → 5.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +316 -1
  3. data/CODE_OF_CONDUCT.md +77 -0
  4. data/Gemfile +10 -14
  5. data/Makefile +7 -0
  6. data/README.md +186 -62
  7. data/Rakefile +8 -7
  8. data/VERSION +1 -1
  9. data/lib/stripe/api_operations/create.rb +1 -1
  10. data/lib/stripe/api_operations/delete.rb +28 -2
  11. data/lib/stripe/api_operations/list.rb +1 -12
  12. data/lib/stripe/api_operations/nested_resource.rb +38 -28
  13. data/lib/stripe/api_operations/request.rb +81 -9
  14. data/lib/stripe/api_operations/save.rb +8 -7
  15. data/lib/stripe/api_operations/search.rb +19 -0
  16. data/lib/stripe/api_resource.rb +45 -3
  17. data/lib/stripe/api_resource_test_helpers.rb +47 -0
  18. data/lib/stripe/connection_manager.rb +200 -0
  19. data/lib/stripe/error_object.rb +93 -0
  20. data/lib/stripe/errors.rb +31 -10
  21. data/lib/stripe/instrumentation.rb +84 -0
  22. data/lib/stripe/list_object.rb +41 -7
  23. data/lib/stripe/multipart_encoder.rb +131 -0
  24. data/lib/stripe/oauth.rb +8 -6
  25. data/lib/stripe/object_types.rb +119 -0
  26. data/lib/stripe/{account.rb → resources/account.rb} +48 -30
  27. data/lib/stripe/{account_link.rb → resources/account_link.rb} +2 -1
  28. data/lib/stripe/resources/alipay_account.rb +34 -0
  29. data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +2 -1
  30. data/lib/stripe/resources/application_fee.rb +14 -0
  31. data/lib/stripe/resources/application_fee_refund.rb +31 -0
  32. data/lib/stripe/{balance.rb → resources/balance.rb} +2 -1
  33. data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +2 -5
  34. data/lib/stripe/resources/bank_account.rb +43 -0
  35. data/lib/stripe/{issuing/dispute.rb → resources/billing_portal/configuration.rb} +4 -3
  36. data/lib/stripe/resources/billing_portal/session.rb +12 -0
  37. data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +4 -3
  38. data/lib/stripe/resources/bitcoin_transaction.rb +16 -0
  39. data/lib/stripe/resources/capability.rb +34 -0
  40. data/lib/stripe/{card.rb → resources/card.rb} +13 -4
  41. data/lib/stripe/resources/cash_balance.rb +22 -0
  42. data/lib/stripe/resources/charge.rb +32 -0
  43. data/lib/stripe/resources/checkout/session.rb +27 -0
  44. data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +2 -1
  45. data/lib/stripe/{coupon.rb → resources/coupon.rb} +3 -2
  46. data/lib/stripe/resources/credit_note.rb +33 -0
  47. data/lib/stripe/resources/credit_note_line_item.rb +8 -0
  48. data/lib/stripe/resources/customer.rb +74 -0
  49. data/lib/stripe/resources/customer_balance_transaction.rb +31 -0
  50. data/lib/stripe/resources/discount.rb +8 -0
  51. data/lib/stripe/resources/dispute.rb +22 -0
  52. data/lib/stripe/{ephemeral_key.rb → resources/ephemeral_key.rb} +6 -2
  53. data/lib/stripe/{event.rb → resources/event.rb} +2 -1
  54. data/lib/stripe/{exchange_rate.rb → resources/exchange_rate.rb} +2 -1
  55. data/lib/stripe/resources/file.rb +36 -0
  56. data/lib/stripe/{file_link.rb → resources/file_link.rb} +3 -2
  57. data/lib/stripe/resources/financial_connections/account.rb +31 -0
  58. data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
  59. data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
  60. data/lib/stripe/resources/financial_connections/session.rb +12 -0
  61. data/lib/stripe/resources/funding_instructions.rb +16 -0
  62. data/lib/stripe/resources/identity/verification_report.rb +12 -0
  63. data/lib/stripe/resources/identity/verification_session.rb +35 -0
  64. data/lib/stripe/resources/invoice.rb +83 -0
  65. data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +3 -2
  66. data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +2 -1
  67. data/lib/stripe/resources/issuing/authorization.rb +34 -0
  68. data/lib/stripe/resources/issuing/card.rb +25 -0
  69. data/lib/stripe/resources/issuing/card_details.rb +10 -0
  70. data/lib/stripe/{issuing → resources/issuing}/cardholder.rb +3 -2
  71. data/lib/stripe/resources/issuing/dispute.rb +25 -0
  72. data/lib/stripe/{issuing → resources/issuing}/transaction.rb +3 -2
  73. data/lib/stripe/resources/line_item.rb +8 -0
  74. data/lib/stripe/resources/login_link.rb +15 -0
  75. data/lib/stripe/resources/mandate.rb +8 -0
  76. data/lib/stripe/resources/order.rb +33 -0
  77. data/lib/stripe/{order_return.rb → resources/order_return.rb} +2 -1
  78. data/lib/stripe/resources/payment_intent.rb +82 -0
  79. data/lib/stripe/resources/payment_link.rb +23 -0
  80. data/lib/stripe/resources/payment_method.rb +33 -0
  81. data/lib/stripe/resources/payout.rb +33 -0
  82. data/lib/stripe/{person.rb → resources/person.rb} +9 -3
  83. data/lib/stripe/{plan.rb → resources/plan.rb} +2 -1
  84. data/lib/stripe/resources/price.rb +21 -0
  85. data/lib/stripe/resources/product.rb +22 -0
  86. data/lib/stripe/resources/promotion_code.rb +12 -0
  87. data/lib/stripe/resources/quote.rb +105 -0
  88. data/lib/stripe/resources/radar/early_fraud_warning.rb +12 -0
  89. data/lib/stripe/{radar → resources/radar}/value_list.rb +3 -2
  90. data/lib/stripe/{radar → resources/radar}/value_list_item.rb +3 -2
  91. data/lib/stripe/{recipient.rb → resources/recipient.rb} +3 -6
  92. data/lib/stripe/{recipient_transfer.rb → resources/recipient_transfer.rb} +1 -1
  93. data/lib/stripe/resources/refund.rb +42 -0
  94. data/lib/stripe/{reporting → resources/reporting}/report_run.rb +3 -2
  95. data/lib/stripe/{reporting → resources/reporting}/report_type.rb +3 -2
  96. data/lib/stripe/resources/reversal.rb +30 -0
  97. data/lib/stripe/resources/review.rb +21 -0
  98. data/lib/stripe/resources/setup_attempt.rb +10 -0
  99. data/lib/stripe/resources/setup_intent.rb +43 -0
  100. data/lib/stripe/{product.rb → resources/shipping_rate.rb} +4 -4
  101. data/lib/stripe/{sigma → resources/sigma}/scheduled_query_run.rb +3 -2
  102. data/lib/stripe/{sku.rb → resources/sku.rb} +4 -3
  103. data/lib/stripe/resources/source.rb +47 -0
  104. data/lib/stripe/{source_transaction.rb → resources/source_transaction.rb} +2 -1
  105. data/lib/stripe/resources/subscription.rb +35 -0
  106. data/lib/stripe/resources/subscription_item.rb +26 -0
  107. data/lib/stripe/resources/subscription_schedule.rb +33 -0
  108. data/lib/stripe/resources/tax_code.rb +10 -0
  109. data/lib/stripe/resources/tax_id.rb +27 -0
  110. data/lib/stripe/{refund.rb → resources/tax_rate.rb} +3 -2
  111. data/lib/stripe/{terminal/reader.rb → resources/terminal/configuration.rb} +3 -2
  112. data/lib/stripe/resources/terminal/connection_token.rb +12 -0
  113. data/lib/stripe/{terminal → resources/terminal}/location.rb +3 -2
  114. data/lib/stripe/resources/terminal/reader.rb +75 -0
  115. data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
  116. data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +2 -1
  117. data/lib/stripe/{token.rb → resources/token.rb} +2 -1
  118. data/lib/stripe/resources/topup.rb +23 -0
  119. data/lib/stripe/resources/transfer.rb +27 -0
  120. data/lib/stripe/resources/usage_record.rb +8 -0
  121. data/lib/stripe/{usage_record_summary.rb → resources/usage_record_summary.rb} +2 -1
  122. data/lib/stripe/{webhook_endpoint.rb → resources/webhook_endpoint.rb} +3 -2
  123. data/lib/stripe/resources.rb +100 -0
  124. data/lib/stripe/search_result_object.rb +86 -0
  125. data/lib/stripe/singleton_api_resource.rb +3 -1
  126. data/lib/stripe/stripe_client.rb +661 -266
  127. data/lib/stripe/stripe_configuration.rb +194 -0
  128. data/lib/stripe/stripe_object.rb +80 -61
  129. data/lib/stripe/stripe_response.rb +87 -27
  130. data/lib/stripe/util.rb +128 -117
  131. data/lib/stripe/version.rb +1 -1
  132. data/lib/stripe/webhook.rb +43 -10
  133. data/lib/stripe.rb +46 -197
  134. data/stripe.gemspec +24 -8
  135. metadata +123 -283
  136. data/.gitattributes +0 -4
  137. data/.github/ISSUE_TEMPLATE.md +0 -5
  138. data/.gitignore +0 -8
  139. data/.rubocop.yml +0 -32
  140. data/.rubocop_todo.yml +0 -50
  141. data/.travis.yml +0 -42
  142. data/lib/stripe/alipay_account.rb +0 -27
  143. data/lib/stripe/application_fee.rb +0 -23
  144. data/lib/stripe/application_fee_refund.rb +0 -22
  145. data/lib/stripe/bank_account.rb +0 -32
  146. data/lib/stripe/bitcoin_transaction.rb +0 -15
  147. data/lib/stripe/charge.rb +0 -84
  148. data/lib/stripe/checkout/session.rb +0 -11
  149. data/lib/stripe/customer.rb +0 -90
  150. data/lib/stripe/dispute.rb +0 -19
  151. data/lib/stripe/file.rb +0 -37
  152. data/lib/stripe/invoice.rb +0 -48
  153. data/lib/stripe/issuer_fraud_record.rb +0 -9
  154. data/lib/stripe/issuing/authorization.rb +0 -22
  155. data/lib/stripe/issuing/card.rb +0 -18
  156. data/lib/stripe/issuing/card_details.rb +0 -9
  157. data/lib/stripe/login_link.rb +0 -11
  158. data/lib/stripe/order.rb +0 -31
  159. data/lib/stripe/payment_intent.rb +0 -26
  160. data/lib/stripe/payment_method.rb +0 -23
  161. data/lib/stripe/payout.rb +0 -20
  162. data/lib/stripe/reversal.rb +0 -22
  163. data/lib/stripe/review.rb +0 -14
  164. data/lib/stripe/source.rb +0 -38
  165. data/lib/stripe/subscription.rb +0 -25
  166. data/lib/stripe/subscription_item.rb +0 -17
  167. data/lib/stripe/subscription_schedule.rb +0 -32
  168. data/lib/stripe/subscription_schedule_revision.rb +0 -25
  169. data/lib/stripe/terminal/connection_token.rb +0 -11
  170. data/lib/stripe/topup.rb +0 -16
  171. data/lib/stripe/transfer.rb +0 -23
  172. data/lib/stripe/usage_record.rb +0 -14
  173. data/test/api_stub_helpers.rb +0 -1
  174. data/test/openapi/README.md +0 -9
  175. data/test/stripe/account_external_accounts_operations_test.rb +0 -69
  176. data/test/stripe/account_link_test.rb +0 -18
  177. data/test/stripe/account_login_links_operations_test.rb +0 -21
  178. data/test/stripe/account_persons_operations_test.rb +0 -70
  179. data/test/stripe/account_test.rb +0 -256
  180. data/test/stripe/alipay_account_test.rb +0 -37
  181. data/test/stripe/api_operations_test.rb +0 -81
  182. data/test/stripe/api_resource_test.rb +0 -526
  183. data/test/stripe/apple_pay_domain_test.rb +0 -33
  184. data/test/stripe/application_fee_refund_test.rb +0 -37
  185. data/test/stripe/application_fee_refunds_operations_test.rb +0 -56
  186. data/test/stripe/application_fee_test.rb +0 -14
  187. data/test/stripe/balance_test.rb +0 -13
  188. data/test/stripe/bank_account_test.rb +0 -36
  189. data/test/stripe/charge_test.rb +0 -59
  190. data/test/stripe/checkout/session_test.rb +0 -41
  191. data/test/stripe/country_spec_test.rb +0 -20
  192. data/test/stripe/coupon_test.rb +0 -51
  193. data/test/stripe/customer_card_test.rb +0 -42
  194. data/test/stripe/customer_sources_operations_test.rb +0 -64
  195. data/test/stripe/customer_test.rb +0 -115
  196. data/test/stripe/dispute_test.rb +0 -42
  197. data/test/stripe/ephemeral_key_test.rb +0 -86
  198. data/test/stripe/errors_test.rb +0 -20
  199. data/test/stripe/exchange_rate_test.rb +0 -20
  200. data/test/stripe/file_link_test.rb +0 -41
  201. data/test/stripe/file_test.rb +0 -73
  202. data/test/stripe/file_upload_test.rb +0 -76
  203. data/test/stripe/invoice_item_test.rb +0 -55
  204. data/test/stripe/invoice_line_item_test.rb +0 -8
  205. data/test/stripe/invoice_test.rb +0 -161
  206. data/test/stripe/issuer_fraud_record_test.rb +0 -20
  207. data/test/stripe/issuing/authorization_test.rb +0 -50
  208. data/test/stripe/issuing/card_test.rb +0 -53
  209. data/test/stripe/issuing/cardholder_test.rb +0 -53
  210. data/test/stripe/issuing/dispute_test.rb +0 -45
  211. data/test/stripe/issuing/transaction_test.rb +0 -48
  212. data/test/stripe/list_object_test.rb +0 -156
  213. data/test/stripe/login_link_test.rb +0 -37
  214. data/test/stripe/oauth_test.rb +0 -88
  215. data/test/stripe/order_return_test.rb +0 -21
  216. data/test/stripe/order_test.rb +0 -57
  217. data/test/stripe/payment_intent_test.rb +0 -80
  218. data/test/stripe/payment_method_test.rb +0 -66
  219. data/test/stripe/payout_test.rb +0 -50
  220. data/test/stripe/person_test.rb +0 -46
  221. data/test/stripe/plan_test.rb +0 -92
  222. data/test/stripe/product_test.rb +0 -49
  223. data/test/stripe/radar/value_list_item_test.rb +0 -38
  224. data/test/stripe/radar/value_list_test.rb +0 -51
  225. data/test/stripe/recipient_test.rb +0 -49
  226. data/test/stripe/refund_test.rb +0 -39
  227. data/test/stripe/reporting/report_run_test.rb +0 -33
  228. data/test/stripe/reporting/report_type_test.rb +0 -22
  229. data/test/stripe/reversal_test.rb +0 -43
  230. data/test/stripe/review_test.rb +0 -27
  231. data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
  232. data/test/stripe/sku_test.rb +0 -50
  233. data/test/stripe/source_test.rb +0 -86
  234. data/test/stripe/source_transaction_test.rb +0 -19
  235. data/test/stripe/stripe_client_test.rb +0 -823
  236. data/test/stripe/stripe_object_test.rb +0 -525
  237. data/test/stripe/stripe_response_test.rb +0 -49
  238. data/test/stripe/subscription_item_test.rb +0 -53
  239. data/test/stripe/subscription_schedule_revision_test.rb +0 -37
  240. data/test/stripe/subscription_schedule_revisions_operations_test.rb +0 -35
  241. data/test/stripe/subscription_schedule_test.rb +0 -64
  242. data/test/stripe/subscription_test.rb +0 -60
  243. data/test/stripe/terminal/connection_token_test.rb +0 -16
  244. data/test/stripe/terminal/location_test.rb +0 -58
  245. data/test/stripe/terminal/reader_test.rb +0 -52
  246. data/test/stripe/three_d_secure_test.rb +0 -23
  247. data/test/stripe/topup_test.rb +0 -54
  248. data/test/stripe/transfer_reversals_operations_test.rb +0 -57
  249. data/test/stripe/transfer_test.rb +0 -43
  250. data/test/stripe/usage_record_summary_test.rb +0 -19
  251. data/test/stripe/usage_record_test.rb +0 -28
  252. data/test/stripe/util_test.rb +0 -402
  253. data/test/stripe/webhook_endpoint_test.rb +0 -42
  254. data/test/stripe/webhook_test.rb +0 -96
  255. data/test/stripe_mock.rb +0 -77
  256. data/test/stripe_test.rb +0 -63
  257. data/test/test_data.rb +0 -61
  258. data/test/test_helper.rb +0 -73
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class ApplicationFeeRefundsOperationsTest < Test::Unit::TestCase
7
- setup do
8
- @application_fee_id = "fee_123"
9
- @refund_id = "fr_123"
10
- end
11
-
12
- context "#create_refund" do
13
- should "create a refund" do
14
- refund = Stripe::ApplicationFee.create_refund(
15
- @application_fee_id
16
- )
17
- assert_requested :post, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds"
18
- assert refund.is_a?(Stripe::ApplicationFeeRefund)
19
- end
20
- end
21
-
22
- context "#retrieve_refund" do
23
- should "retrieve a refund" do
24
- refund = Stripe::ApplicationFee.retrieve_refund(
25
- @application_fee_id,
26
- @refund_id
27
- )
28
- assert_requested :get, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds/#{@refund_id}"
29
- assert refund.is_a?(Stripe::ApplicationFeeRefund)
30
- end
31
- end
32
-
33
- context "#update_refund" do
34
- should "update a refund" do
35
- refund = Stripe::ApplicationFee.update_refund(
36
- @application_fee_id,
37
- @refund_id,
38
- metadata: { foo: "bar" }
39
- )
40
- assert_requested :post, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds/#{@refund_id}"
41
- assert refund.is_a?(Stripe::ApplicationFeeRefund)
42
- end
43
- end
44
-
45
- context "#list_refunds" do
46
- should "list the application fee's refuns" do
47
- refunds = Stripe::ApplicationFee.list_refunds(
48
- @application_fee_id
49
- )
50
- assert_requested :get, "#{Stripe.api_base}/v1/application_fees/#{@application_fee_id}/refunds"
51
- assert refunds.is_a?(Stripe::ListObject)
52
- assert refunds.data.is_a?(Array)
53
- end
54
- end
55
- end
56
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class ApplicationFeeTest < Test::Unit::TestCase
7
- should "be listable" do
8
- fees = Stripe::ApplicationFee.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/application_fees"
10
- assert fees.data.is_a?(Array)
11
- assert fees.data[0].is_a?(Stripe::ApplicationFee)
12
- end
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class BalanceTest < Test::Unit::TestCase
7
- should "be retrievable" do
8
- balance = Stripe::Balance.retrieve
9
- assert_requested :get, "#{Stripe.api_base}/v1/balance"
10
- assert balance.is_a?(Stripe::Balance)
11
- end
12
- end
13
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class BankAccountTest < Test::Unit::TestCase
7
- context "#resource_url" do
8
- should "return an external account URL" do
9
- bank_account = Stripe::BankAccount.construct_from(
10
- account: "acct_123",
11
- id: "ba_123"
12
- )
13
- assert_equal "/v1/accounts/acct_123/external_accounts/ba_123",
14
- bank_account.resource_url
15
- end
16
-
17
- should "return a customer URL" do
18
- bank_account = Stripe::BankAccount.construct_from(
19
- customer: "cus_123",
20
- id: "ba_123"
21
- )
22
- assert_equal "/v1/customers/cus_123/sources/ba_123",
23
- bank_account.resource_url
24
- end
25
- end
26
-
27
- context "#verify" do
28
- should "verify the account" do
29
- bank_account = Stripe::BankAccount.construct_from(customer: "cus_123",
30
- id: "ba_123")
31
- bank_account = bank_account.verify(amounts: [1, 2])
32
- assert bank_account.is_a?(Stripe::BankAccount)
33
- end
34
- end
35
- end
36
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class ChargeTest < Test::Unit::TestCase
7
- should "be listable" do
8
- charges = Stripe::Charge.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/charges"
10
- assert charges.data.is_a?(Array)
11
- assert charges.data[0].is_a?(Stripe::Charge)
12
- end
13
-
14
- should "be retrievable" do
15
- charge = Stripe::Charge.retrieve("ch_123")
16
- assert_requested :get, "#{Stripe.api_base}/v1/charges/ch_123"
17
- assert charge.is_a?(Stripe::Charge)
18
- end
19
-
20
- should "be creatable" do
21
- charge = Stripe::Charge.create(
22
- amount: 100,
23
- currency: "USD",
24
- source: "src_123"
25
- )
26
- assert_requested :post, "#{Stripe.api_base}/v1/charges"
27
- assert charge.is_a?(Stripe::Charge)
28
- end
29
-
30
- should "be saveable" do
31
- charge = Stripe::Charge.retrieve("ch_123")
32
- charge.metadata["key"] = "value"
33
- charge.save
34
- assert_requested :post, "#{Stripe.api_base}/v1/charges/#{charge.id}"
35
- end
36
-
37
- should "be updateable" do
38
- charge = Stripe::Charge.update("ch_123", metadata: { foo: "bar" })
39
- assert_requested :post, "#{Stripe.api_base}/v1/charges/ch_123"
40
- assert charge.is_a?(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("ch_123")
46
- charge = charge.mark_as_fraudulent
47
- assert charge.is_a?(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("ch_123")
54
- charge = charge.mark_as_safe
55
- assert charge.is_a?(Stripe::Charge)
56
- end
57
- end
58
- end
59
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- module Checkout
7
- class SessionTest < Test::Unit::TestCase
8
- should "be creatable" do
9
- session = Stripe::Checkout::Session.create(
10
- cancel_url: "https://stripe.com/cancel",
11
- client_reference_id: "1234",
12
- line_items: [
13
- {
14
- amount: 123,
15
- currency: "usd",
16
- description: "item 1",
17
- images: [
18
- "https://stripe.com/img1",
19
- ],
20
- name: "name",
21
- quantity: 2,
22
- },
23
- ],
24
- payment_intent_data: [
25
- receipt_email: "test@stripe.com",
26
- ],
27
- payment_method_types: ["card"],
28
- success_url: "https://stripe.com/success"
29
- )
30
- assert_requested :post, "#{Stripe.api_base}/v1/checkout/sessions"
31
- assert session.is_a?(Stripe::Checkout::Session)
32
- end
33
-
34
- should "be retrievable" do
35
- charge = Stripe::Checkout::Session.retrieve("cs_123")
36
- assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123"
37
- assert charge.is_a?(Stripe::Checkout::Session)
38
- end
39
- end
40
- end
41
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class CountrySpecTest < Test::Unit::TestCase
7
- should "be listable" do
8
- c = Stripe::CountrySpec.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/country_specs"
10
- assert c.data.is_a?(Array)
11
- assert c.data[0].is_a?(Stripe::CountrySpec)
12
- end
13
-
14
- should "be retrievable" do
15
- s = Stripe::CountrySpec.retrieve("US")
16
- assert_requested :get, "#{Stripe.api_base}/v1/country_specs/US"
17
- assert(s.is_a?(Stripe::CountrySpec))
18
- end
19
- end
20
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class CouponTest < Test::Unit::TestCase
7
- should "be listable" do
8
- coupons = Stripe::Coupon.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/coupons"
10
- assert coupons.data.is_a?(Array)
11
- assert coupons.first.is_a?(Stripe::Coupon)
12
- end
13
-
14
- should "be retrievable" do
15
- coupon = Stripe::Coupon.retrieve("25OFF")
16
- assert_requested :get, "#{Stripe.api_base}/v1/coupons/25OFF"
17
- assert coupon.is_a?(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.is_a?(Stripe::Coupon)
29
- end
30
-
31
- should "be saveable" do
32
- coupon = Stripe::Coupon.retrieve("25OFF")
33
- coupon.metadata["key"] = "value"
34
- coupon.save
35
- assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{coupon.id}"
36
- end
37
-
38
- should "be updateable" do
39
- coupon = Stripe::Coupon.update("25OFF", metadata: { key: "value" })
40
- assert_requested :post, "#{Stripe.api_base}/v1/coupons/25OFF"
41
- assert coupon.is_a?(Stripe::Coupon)
42
- end
43
-
44
- should "be deletable" do
45
- coupon = Stripe::Coupon.retrieve("25OFF")
46
- coupon = coupon.delete
47
- assert_requested :delete, "#{Stripe.api_base}/v1/coupons/#{coupon.id}"
48
- assert coupon.is_a?(Stripe::Coupon)
49
- end
50
- end
51
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class CustomerCardTest < Test::Unit::TestCase
7
- setup do
8
- @customer = Stripe::Customer.retrieve("cus_123")
9
- end
10
-
11
- should "be listable" do
12
- sources = @customer.sources.list
13
- assert sources.data.is_a?(Array)
14
- # because of the terrible :wildcard nature of sources, the API stub
15
- # cannot currently replace this response with anything meaningful so we
16
- # don't assert on the type of individual items like we do in other tests
17
- end
18
-
19
- should "be creatable" do
20
- @customer.sources.create(
21
- source: "tok_123"
22
- )
23
- assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources"
24
- end
25
-
26
- should "be deletable" do
27
- card = Stripe::Card.construct_from(customer: @customer.id,
28
- id: "card_123")
29
- card.delete
30
- assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
31
- end
32
-
33
- should "be saveable" do
34
- card = Stripe::Card.construct_from(customer: @customer.id,
35
- id: "card_123",
36
- metadata: {})
37
- card.metadata["key"] = "value"
38
- card.save
39
- assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer.id}/sources/card_123"
40
- end
41
- end
42
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class CustomerSourcesOperationsTest < Test::Unit::TestCase
7
- setup do
8
- @customer_id = "cus_123"
9
- @source_id = "ba_123"
10
- end
11
-
12
- context "#create_source" do
13
- should "create a source" do
14
- Stripe::Customer.create_source(
15
- @customer_id,
16
- source: "tok_123"
17
- )
18
- assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
19
- end
20
- end
21
-
22
- context "#retrieve_source" do
23
- should "retrieve a source" do
24
- Stripe::Customer.retrieve_source(
25
- @customer_id,
26
- @source_id
27
- )
28
- assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
29
- end
30
- end
31
-
32
- context "#update_source" do
33
- should "update a source" do
34
- Stripe::Customer.update_source(
35
- @customer_id,
36
- @source_id,
37
- metadata: { foo: "bar" }
38
- )
39
- assert_requested :post, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
40
- end
41
- end
42
-
43
- context "#delete_source" do
44
- should "delete a source" do
45
- Stripe::Customer.delete_source(
46
- @customer_id,
47
- @source_id
48
- )
49
- assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources/#{@source_id}"
50
- end
51
- end
52
-
53
- context "#list_sources" do
54
- should "list the customer's sources" do
55
- sources = Stripe::Customer.list_sources(
56
- @customer_id
57
- )
58
- assert_requested :get, "#{Stripe.api_base}/v1/customers/#{@customer_id}/sources"
59
- assert sources.is_a?(Stripe::ListObject)
60
- assert sources.data.is_a?(Array)
61
- end
62
- end
63
- end
64
- end
@@ -1,115 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class CustomerTest < Test::Unit::TestCase
7
- should "be listable" do
8
- customers = Stripe::Customer.list
9
- assert_requested :get, "#{Stripe.api_base}/v1/customers"
10
- assert customers.data.is_a?(Array)
11
- assert customers.first.is_a?(Stripe::Customer)
12
- end
13
-
14
- should "be retrievable" do
15
- customer = Stripe::Customer.retrieve("cus_123")
16
- assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123"
17
- assert customer.is_a?(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.is_a?(Stripe::Customer)
24
- end
25
-
26
- should "be saveable" do
27
- customer = Stripe::Customer.retrieve("cus_123")
28
- customer.metadata["key"] = "value"
29
- customer.save
30
- assert_requested :post, "#{Stripe.api_base}/v1/customers/#{customer.id}"
31
- end
32
-
33
- should "be updateable" do
34
- customer = Stripe::Customer.update("cus_123", metadata: { key: "value" })
35
- assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123"
36
- assert customer.is_a?(Stripe::Customer)
37
- end
38
-
39
- should "be deletable" do
40
- customer = Stripe::Customer.retrieve("cus_123")
41
- customer = customer.delete
42
- assert_requested :delete, "#{Stripe.api_base}/v1/customers/#{customer.id}"
43
- assert customer.is_a?(Stripe::Customer)
44
- end
45
-
46
- context "#create_subscription" do
47
- should "create a new subscription" do
48
- customer = Stripe::Customer.retrieve("cus_123")
49
- subscription = customer.create_subscription(items: [{ plan: "silver" }])
50
- assert subscription.is_a?(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("cus_123")
57
- invoice = customer.create_upcoming_invoice
58
- assert invoice.is_a?(Stripe::Invoice)
59
- end
60
- end
61
-
62
- context "#update_subscription" do
63
- should "update a subscription" do
64
- customer = Stripe::Customer.retrieve("cus_123")
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(object: "subscription"))
70
- subscription = customer.update_subscription(plan: "silver")
71
- assert subscription.is_a?(Stripe::Subscription)
72
- end
73
- end
74
-
75
- context "#cancel_subscription" do
76
- should "cancel a subscription" do
77
- customer = Stripe::Customer.retrieve("cus_123")
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(object: "subscription"))
83
- subscription = customer.cancel_subscription(at_period_end: "true")
84
- assert subscription.is_a?(Stripe::Subscription)
85
- end
86
- end
87
-
88
- context "#delete_discount" do
89
- should "delete a discount" do
90
- customer = Stripe::Customer.retrieve("cus_123")
91
-
92
- stub_request(:delete, "#{Stripe.api_base}/v1/customers/#{customer.id}/discount")
93
- .to_return(body: JSON.generate(object: "customer"))
94
- discount = customer.delete_discount
95
- assert discount.is_a?(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
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
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
- end
40
- end
41
- end
42
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
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
- end
86
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require ::File.expand_path("../../test_helper", __FILE__)
4
-
5
- module Stripe
6
- class StripeErrorTest < Test::Unit::TestCase
7
- context "#to_s" do
8
- should "convert to string" do
9
- e = StripeError.new("message")
10
- assert_equal "message", e.to_s
11
-
12
- e = StripeError.new("message", http_status: 200)
13
- assert_equal "(Status 200) message", e.to_s
14
-
15
- e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { request_id: "request-id" })
16
- assert_equal "(Request request-id) message", e.to_s
17
- end
18
- end
19
- end
20
- end