stripe 5.55.0 → 13.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +567 -4
  3. data/Gemfile +12 -4
  4. data/Makefile +18 -3
  5. data/OPENAPI_VERSION +1 -0
  6. data/README.md +93 -21
  7. data/Rakefile +3 -6
  8. data/VERSION +1 -1
  9. data/examples/README.md +16 -0
  10. data/examples/example_template.rb +36 -0
  11. data/examples/meter_event_stream.rb +57 -0
  12. data/examples/thinevent_webhook_handler.rb +39 -0
  13. data/{bin → exe}/stripe-console +1 -1
  14. data/justfile +43 -0
  15. data/lib/data/ca-certificates.crt +1241 -1937
  16. data/lib/stripe/api_operations/create.rb +6 -2
  17. data/lib/stripe/api_operations/delete.rb +12 -7
  18. data/lib/stripe/api_operations/list.rb +6 -9
  19. data/lib/stripe/api_operations/nested_resource.rb +63 -35
  20. data/lib/stripe/api_operations/request.rb +29 -65
  21. data/lib/stripe/api_operations/save.rb +20 -10
  22. data/lib/stripe/api_operations/search.rb +11 -9
  23. data/lib/stripe/api_operations/singleton_save.rb +90 -0
  24. data/lib/stripe/api_requestor.rb +1131 -0
  25. data/lib/stripe/api_resource.rb +48 -18
  26. data/lib/stripe/api_resource_test_helpers.rb +9 -3
  27. data/lib/stripe/api_version.rb +8 -0
  28. data/lib/stripe/connection_manager.rb +5 -7
  29. data/lib/stripe/errors.rb +11 -13
  30. data/lib/stripe/event_types.rb +14 -0
  31. data/lib/stripe/events/v1_billing_meter_error_report_triggered_event.rb +23 -0
  32. data/lib/stripe/events/v1_billing_meter_no_meter_found_event.rb +13 -0
  33. data/lib/stripe/instrumentation.rb +37 -15
  34. data/lib/stripe/list_object.rb +5 -3
  35. data/lib/stripe/multipart_encoder.rb +7 -7
  36. data/lib/stripe/oauth.rb +14 -21
  37. data/lib/stripe/object_types.rb +151 -103
  38. data/lib/stripe/request_options.rb +129 -0
  39. data/lib/stripe/resources/account.rb +129 -25
  40. data/lib/stripe/resources/account_link.rb +12 -0
  41. data/lib/stripe/resources/account_session.rb +25 -0
  42. data/lib/stripe/resources/alipay_account.rb +1 -1
  43. data/lib/stripe/resources/apple_pay_domain.rb +38 -0
  44. data/lib/stripe/resources/application_fee.rb +9 -2
  45. data/lib/stripe/resources/application_fee_refund.rb +9 -2
  46. data/lib/stripe/resources/apps/secret.rb +55 -0
  47. data/lib/stripe/resources/balance.rb +14 -0
  48. data/lib/stripe/resources/balance_transaction.rb +19 -0
  49. data/lib/stripe/resources/bank_account.rb +53 -4
  50. data/lib/stripe/resources/billing/alert.rb +87 -0
  51. data/lib/stripe/resources/billing/credit_balance_summary.rb +14 -0
  52. data/lib/stripe/resources/billing/credit_balance_transaction.rb +26 -0
  53. data/lib/stripe/resources/billing/credit_grant.rb +90 -0
  54. data/lib/stripe/resources/billing/meter.rb +85 -0
  55. data/lib/stripe/resources/billing/meter_event.rb +26 -0
  56. data/lib/stripe/resources/billing/meter_event_adjustment.rb +26 -0
  57. data/lib/stripe/resources/billing/meter_event_summary.rb +17 -0
  58. data/lib/stripe/resources/billing_portal/configuration.rb +34 -0
  59. data/lib/stripe/resources/billing_portal/session.rb +27 -0
  60. data/lib/stripe/resources/capability.rb +7 -2
  61. data/lib/stripe/resources/card.rb +34 -3
  62. data/lib/stripe/resources/cash_balance.rb +4 -0
  63. data/lib/stripe/resources/charge.rb +52 -3
  64. data/lib/stripe/resources/checkout/session.rb +83 -5
  65. data/lib/stripe/resources/climate/order.rb +67 -0
  66. data/lib/stripe/resources/climate/product.rb +27 -0
  67. data/lib/stripe/resources/climate/supplier.rb +26 -0
  68. data/lib/stripe/resources/confirmation_token.rb +39 -0
  69. data/lib/stripe/resources/country_spec.rb +14 -0
  70. data/lib/stripe/resources/coupon.rb +48 -0
  71. data/lib/stripe/resources/credit_note.rb +67 -9
  72. data/lib/stripe/resources/credit_note_line_item.rb +4 -0
  73. data/lib/stripe/resources/customer.rb +172 -28
  74. data/lib/stripe/resources/customer_balance_transaction.rb +9 -1
  75. data/lib/stripe/resources/customer_cash_balance_transaction.rb +15 -0
  76. data/lib/stripe/resources/customer_session.rb +29 -0
  77. data/lib/stripe/resources/discount.rb +7 -0
  78. data/lib/stripe/resources/dispute.rb +41 -3
  79. data/lib/stripe/resources/entitlements/active_entitlement.rb +26 -0
  80. data/lib/stripe/resources/entitlements/feature.rb +49 -0
  81. data/lib/stripe/resources/ephemeral_key.rb +23 -0
  82. data/lib/stripe/resources/event.rb +38 -0
  83. data/lib/stripe/resources/exchange_rate.rb +34 -0
  84. data/lib/stripe/resources/file.rb +37 -15
  85. data/lib/stripe/resources/file_link.rb +26 -0
  86. data/lib/stripe/resources/financial_connections/account.rb +101 -6
  87. data/lib/stripe/resources/financial_connections/account_owner.rb +4 -0
  88. data/lib/stripe/resources/financial_connections/account_ownership.rb +4 -0
  89. data/lib/stripe/resources/financial_connections/session.rb +14 -0
  90. data/lib/stripe/resources/financial_connections/transaction.rb +26 -0
  91. data/lib/stripe/resources/forwarding/request.rb +52 -0
  92. data/lib/stripe/resources/funding_instructions.rb +8 -0
  93. data/lib/stripe/resources/identity/verification_report.rb +24 -0
  94. data/lib/stripe/resources/identity/verification_session.rb +117 -5
  95. data/lib/stripe/resources/invoice.rb +247 -20
  96. data/lib/stripe/resources/invoice_item.rb +54 -0
  97. data/lib/stripe/resources/invoice_line_item.rb +22 -1
  98. data/lib/stripe/resources/invoice_rendering_template.rb +65 -0
  99. data/lib/stripe/resources/issuing/authorization.rb +210 -5
  100. data/lib/stripe/resources/issuing/card.rb +128 -4
  101. data/lib/stripe/resources/issuing/cardholder.rb +36 -0
  102. data/lib/stripe/resources/issuing/dispute.rb +47 -2
  103. data/lib/stripe/resources/issuing/personalization_design.rb +119 -0
  104. data/lib/stripe/resources/issuing/physical_bundle.rb +26 -0
  105. data/lib/stripe/resources/issuing/token.rb +32 -0
  106. data/lib/stripe/resources/issuing/transaction.rb +79 -0
  107. data/lib/stripe/resources/line_item.rb +4 -0
  108. data/lib/stripe/resources/login_link.rb +4 -0
  109. data/lib/stripe/resources/mandate.rb +4 -0
  110. data/lib/stripe/resources/payment_intent.rb +238 -15
  111. data/lib/stripe/resources/payment_link.rb +39 -2
  112. data/lib/stripe/resources/payment_method.rb +78 -5
  113. data/lib/stripe/resources/payment_method_configuration.rb +59 -0
  114. data/lib/stripe/resources/payment_method_domain.rb +79 -0
  115. data/lib/stripe/resources/payout.rb +63 -5
  116. data/lib/stripe/resources/person.rb +8 -1
  117. data/lib/stripe/resources/plan.rb +51 -0
  118. data/lib/stripe/resources/price.rb +30 -1
  119. data/lib/stripe/resources/product.rb +55 -1
  120. data/lib/stripe/resources/product_feature.rb +13 -0
  121. data/lib/stripe/resources/promotion_code.rb +25 -0
  122. data/lib/stripe/resources/quote.rb +97 -39
  123. data/lib/stripe/resources/radar/early_fraud_warning.rb +17 -0
  124. data/lib/stripe/resources/radar/value_list.rb +56 -0
  125. data/lib/stripe/resources/radar/value_list_item.rb +46 -0
  126. data/lib/stripe/resources/refund.rb +70 -5
  127. data/lib/stripe/resources/reporting/report_run.rb +31 -0
  128. data/lib/stripe/resources/reporting/report_type.rb +21 -1
  129. data/lib/stripe/resources/reversal.rb +17 -2
  130. data/lib/stripe/resources/review.rb +24 -3
  131. data/lib/stripe/resources/setup_attempt.rb +12 -0
  132. data/lib/stripe/resources/setup_intent.rb +113 -7
  133. data/lib/stripe/resources/shipping_rate.rb +25 -0
  134. data/lib/stripe/resources/sigma/scheduled_query_run.rb +17 -0
  135. data/lib/stripe/resources/source.rb +52 -10
  136. data/lib/stripe/resources/source_transaction.rb +7 -0
  137. data/lib/stripe/resources/subscription.rb +118 -5
  138. data/lib/stripe/resources/subscription_item.rb +54 -6
  139. data/lib/stripe/resources/subscription_schedule.rb +60 -5
  140. data/lib/stripe/resources/tax/calculation.rb +48 -0
  141. data/lib/stripe/resources/tax/calculation_line_item.rb +13 -0
  142. data/lib/stripe/resources/tax/registration.rb +54 -0
  143. data/lib/stripe/resources/tax/settings.rb +17 -0
  144. data/lib/stripe/resources/tax/transaction.rb +56 -0
  145. data/lib/stripe/resources/tax/transaction_line_item.rb +13 -0
  146. data/lib/stripe/resources/tax_code.rb +9 -0
  147. data/lib/stripe/resources/tax_id.rb +34 -12
  148. data/lib/stripe/resources/tax_rate.rb +26 -0
  149. data/lib/stripe/resources/terminal/configuration.rb +54 -0
  150. data/lib/stripe/resources/terminal/connection_token.rb +16 -0
  151. data/lib/stripe/resources/terminal/location.rb +57 -0
  152. data/lib/stripe/resources/terminal/reader.rb +138 -11
  153. data/lib/stripe/resources/test_helpers/test_clock.rb +58 -3
  154. data/lib/stripe/resources/token.rb +29 -0
  155. data/lib/stripe/resources/topup.rb +40 -3
  156. data/lib/stripe/resources/transfer.rb +29 -6
  157. data/lib/stripe/resources/treasury/credit_reversal.rb +37 -0
  158. data/lib/stripe/resources/treasury/debit_reversal.rb +37 -0
  159. data/lib/stripe/resources/treasury/financial_account.rb +109 -0
  160. data/lib/stripe/resources/treasury/financial_account_features.rb +15 -0
  161. data/lib/stripe/resources/treasury/inbound_transfer.rb +130 -0
  162. data/lib/stripe/resources/treasury/outbound_payment.rb +152 -0
  163. data/lib/stripe/resources/treasury/outbound_transfer.rb +152 -0
  164. data/lib/stripe/resources/treasury/received_credit.rb +47 -0
  165. data/lib/stripe/resources/treasury/received_debit.rb +47 -0
  166. data/lib/stripe/resources/treasury/transaction.rb +26 -0
  167. data/lib/stripe/resources/treasury/transaction_entry.rb +30 -0
  168. data/lib/stripe/resources/usage_record.rb +9 -0
  169. data/lib/stripe/resources/usage_record_summary.rb +4 -0
  170. data/lib/stripe/resources/v2/billing/meter_event.rb +16 -0
  171. data/lib/stripe/resources/v2/billing/meter_event_adjustment.rb +15 -0
  172. data/lib/stripe/resources/v2/billing/meter_event_session.rb +15 -0
  173. data/lib/stripe/resources/v2/event.rb +13 -0
  174. data/lib/stripe/resources/v2/event_destination.rb +13 -0
  175. data/lib/stripe/resources/webhook_endpoint.rb +55 -0
  176. data/lib/stripe/resources.rb +51 -10
  177. data/lib/stripe/search_result_object.rb +5 -2
  178. data/lib/stripe/services/account_capability_service.rb +39 -0
  179. data/lib/stripe/services/account_external_account_service.rb +68 -0
  180. data/lib/stripe/services/account_link_service.rb +17 -0
  181. data/lib/stripe/services/account_login_link_service.rb +19 -0
  182. data/lib/stripe/services/account_person_service.rb +61 -0
  183. data/lib/stripe/services/account_service.rb +100 -0
  184. data/lib/stripe/services/account_session_service.rb +17 -0
  185. data/lib/stripe/services/apple_pay_domain_service.rb +50 -0
  186. data/lib/stripe/services/application_fee_refund_service.rb +60 -0
  187. data/lib/stripe/services/application_fee_service.rb +35 -0
  188. data/lib/stripe/services/apps/secret_service.rb +52 -0
  189. data/lib/stripe/services/apps_service.rb +13 -0
  190. data/lib/stripe/services/balance_service.rb +12 -0
  191. data/lib/stripe/services/balance_transaction_service.rb +32 -0
  192. data/lib/stripe/services/billing/alert_service.rb +74 -0
  193. data/lib/stripe/services/billing/credit_balance_summary_service.rb +19 -0
  194. data/lib/stripe/services/billing/credit_balance_transaction_service.rb +30 -0
  195. data/lib/stripe/services/billing/credit_grant_service.rb +74 -0
  196. data/lib/stripe/services/billing/meter_event_adjustment_service.rb +19 -0
  197. data/lib/stripe/services/billing/meter_event_service.rb +19 -0
  198. data/lib/stripe/services/billing/meter_event_summary_service.rb +19 -0
  199. data/lib/stripe/services/billing/meter_service.rb +81 -0
  200. data/lib/stripe/services/billing_portal/configuration_service.rb +52 -0
  201. data/lib/stripe/services/billing_portal/session_service.rb +19 -0
  202. data/lib/stripe/services/billing_portal_service.rb +14 -0
  203. data/lib/stripe/services/billing_service.rb +20 -0
  204. data/lib/stripe/services/charge_service.rb +69 -0
  205. data/lib/stripe/services/checkout/session_line_item_service.rb +19 -0
  206. data/lib/stripe/services/checkout/session_service.rb +72 -0
  207. data/lib/stripe/services/checkout_service.rb +13 -0
  208. data/lib/stripe/services/climate/order_service.rb +68 -0
  209. data/lib/stripe/services/climate/product_service.rb +30 -0
  210. data/lib/stripe/services/climate/supplier_service.rb +30 -0
  211. data/lib/stripe/services/climate_service.rb +15 -0
  212. data/lib/stripe/services/confirmation_token_service.rb +17 -0
  213. data/lib/stripe/services/country_spec_service.rb +28 -0
  214. data/lib/stripe/services/coupon_service.rb +51 -0
  215. data/lib/stripe/services/credit_note_line_item_service.rb +17 -0
  216. data/lib/stripe/services/credit_note_preview_lines_service.rb +17 -0
  217. data/lib/stripe/services/credit_note_service.rb +93 -0
  218. data/lib/stripe/services/customer_balance_transaction_service.rb +50 -0
  219. data/lib/stripe/services/customer_cash_balance_service.rb +28 -0
  220. data/lib/stripe/services/customer_cash_balance_transaction_service.rb +28 -0
  221. data/lib/stripe/services/customer_funding_instructions_service.rb +19 -0
  222. data/lib/stripe/services/customer_payment_method_service.rb +28 -0
  223. data/lib/stripe/services/customer_payment_source_service.rb +76 -0
  224. data/lib/stripe/services/customer_service.rb +89 -0
  225. data/lib/stripe/services/customer_session_service.rb +17 -0
  226. data/lib/stripe/services/customer_tax_id_service.rb +50 -0
  227. data/lib/stripe/services/dispute_service.rb +48 -0
  228. data/lib/stripe/services/entitlements/active_entitlement_service.rb +30 -0
  229. data/lib/stripe/services/entitlements/feature_service.rb +52 -0
  230. data/lib/stripe/services/entitlements_service.rb +14 -0
  231. data/lib/stripe/services/ephemeral_key_service.rb +28 -0
  232. data/lib/stripe/services/event_service.rb +22 -0
  233. data/lib/stripe/services/exchange_rate_service.rb +28 -0
  234. data/lib/stripe/services/file_link_service.rb +38 -0
  235. data/lib/stripe/services/file_service.rb +35 -0
  236. data/lib/stripe/services/financial_connections/account_owner_service.rb +19 -0
  237. data/lib/stripe/services/financial_connections/account_service.rb +81 -0
  238. data/lib/stripe/services/financial_connections/session_service.rb +30 -0
  239. data/lib/stripe/services/financial_connections/transaction_service.rb +30 -0
  240. data/lib/stripe/services/financial_connections_service.rb +15 -0
  241. data/lib/stripe/services/forwarding/request_service.rb +41 -0
  242. data/lib/stripe/services/forwarding_service.rb +13 -0
  243. data/lib/stripe/services/identity/verification_report_service.rb +30 -0
  244. data/lib/stripe/services/identity/verification_session_service.rb +106 -0
  245. data/lib/stripe/services/identity_service.rb +14 -0
  246. data/lib/stripe/services/invoice_item_service.rb +61 -0
  247. data/lib/stripe/services/invoice_line_item_service.rb +31 -0
  248. data/lib/stripe/services/invoice_rendering_template_service.rb +50 -0
  249. data/lib/stripe/services/invoice_service.rb +202 -0
  250. data/lib/stripe/services/invoice_upcoming_lines_service.rb +17 -0
  251. data/lib/stripe/services/issuing/authorization_service.rb +65 -0
  252. data/lib/stripe/services/issuing/card_service.rb +52 -0
  253. data/lib/stripe/services/issuing/cardholder_service.rb +52 -0
  254. data/lib/stripe/services/issuing/dispute_service.rb +63 -0
  255. data/lib/stripe/services/issuing/personalization_design_service.rb +52 -0
  256. data/lib/stripe/services/issuing/physical_bundle_service.rb +30 -0
  257. data/lib/stripe/services/issuing/token_service.rb +41 -0
  258. data/lib/stripe/services/issuing/transaction_service.rb +41 -0
  259. data/lib/stripe/services/issuing_service.rb +20 -0
  260. data/lib/stripe/services/mandate_service.rb +17 -0
  261. data/lib/stripe/services/oauth_service.rb +63 -0
  262. data/lib/stripe/services/payment_intent_service.rb +204 -0
  263. data/lib/stripe/services/payment_link_line_item_service.rb +17 -0
  264. data/lib/stripe/services/payment_link_service.rb +57 -0
  265. data/lib/stripe/services/payment_method_configuration_service.rb +50 -0
  266. data/lib/stripe/services/payment_method_domain_service.rb +66 -0
  267. data/lib/stripe/services/payment_method_service.rb +86 -0
  268. data/lib/stripe/services/payout_service.rb +66 -0
  269. data/lib/stripe/services/plan_service.rb +49 -0
  270. data/lib/stripe/services/price_service.rb +52 -0
  271. data/lib/stripe/services/product_feature_service.rb +50 -0
  272. data/lib/stripe/services/product_service.rb +70 -0
  273. data/lib/stripe/services/promotion_code_service.rb +50 -0
  274. data/lib/stripe/services/quote_computed_upfront_line_items_service.rb +17 -0
  275. data/lib/stripe/services/quote_line_item_service.rb +17 -0
  276. data/lib/stripe/services/quote_service.rb +92 -0
  277. data/lib/stripe/services/radar/early_fraud_warning_service.rb +32 -0
  278. data/lib/stripe/services/radar/value_list_item_service.rb +52 -0
  279. data/lib/stripe/services/radar/value_list_service.rb +63 -0
  280. data/lib/stripe/services/radar_service.rb +15 -0
  281. data/lib/stripe/services/refund_service.rb +63 -0
  282. data/lib/stripe/services/reporting/report_run_service.rb +41 -0
  283. data/lib/stripe/services/reporting/report_type_service.rb +30 -0
  284. data/lib/stripe/services/reporting_service.rb +14 -0
  285. data/lib/stripe/services/review_service.rb +33 -0
  286. data/lib/stripe/services/setup_attempt_service.rb +17 -0
  287. data/lib/stripe/services/setup_intent_service.rb +105 -0
  288. data/lib/stripe/services/shipping_rate_service.rb +50 -0
  289. data/lib/stripe/services/sigma/scheduled_query_run_service.rb +30 -0
  290. data/lib/stripe/services/sigma_service.rb +13 -0
  291. data/lib/stripe/services/source_service.rb +64 -0
  292. data/lib/stripe/services/source_transaction_service.rb +17 -0
  293. data/lib/stripe/services/subscription_item_service.rb +69 -0
  294. data/lib/stripe/services/subscription_item_usage_record_service.rb +23 -0
  295. data/lib/stripe/services/subscription_item_usage_record_summary_service.rb +19 -0
  296. data/lib/stripe/services/subscription_schedule_service.rb +72 -0
  297. data/lib/stripe/services/subscription_service.rb +127 -0
  298. data/lib/stripe/services/tax/calculation_line_item_service.rb +19 -0
  299. data/lib/stripe/services/tax/calculation_service.rb +37 -0
  300. data/lib/stripe/services/tax/registration_service.rb +54 -0
  301. data/lib/stripe/services/tax/settings_service.rb +30 -0
  302. data/lib/stripe/services/tax/transaction_line_item_service.rb +19 -0
  303. data/lib/stripe/services/tax/transaction_service.rb +48 -0
  304. data/lib/stripe/services/tax_code_service.rb +22 -0
  305. data/lib/stripe/services/tax_id_service.rb +38 -0
  306. data/lib/stripe/services/tax_rate_service.rb +38 -0
  307. data/lib/stripe/services/tax_service.rb +16 -0
  308. data/lib/stripe/services/terminal/configuration_service.rb +63 -0
  309. data/lib/stripe/services/terminal/connection_token_service.rb +19 -0
  310. data/lib/stripe/services/terminal/location_service.rb +64 -0
  311. data/lib/stripe/services/terminal/reader_service.rb +118 -0
  312. data/lib/stripe/services/terminal_service.rb +16 -0
  313. data/lib/stripe/services/test_helpers/confirmation_token_service.rb +19 -0
  314. data/lib/stripe/services/test_helpers/customer_service.rb +19 -0
  315. data/lib/stripe/services/test_helpers/issuing/authorization_service.rb +87 -0
  316. data/lib/stripe/services/test_helpers/issuing/card_service.rb +65 -0
  317. data/lib/stripe/services/test_helpers/issuing/personalization_design_service.rb +43 -0
  318. data/lib/stripe/services/test_helpers/issuing/transaction_service.rb +43 -0
  319. data/lib/stripe/services/test_helpers/issuing_service.rb +19 -0
  320. data/lib/stripe/services/test_helpers/refund_service.rb +19 -0
  321. data/lib/stripe/services/test_helpers/terminal/reader_service.rb +21 -0
  322. data/lib/stripe/services/test_helpers/terminal_service.rb +15 -0
  323. data/lib/stripe/services/test_helpers/test_clock_service.rb +63 -0
  324. data/lib/stripe/services/test_helpers/treasury/inbound_transfer_service.rb +43 -0
  325. data/lib/stripe/services/test_helpers/treasury/outbound_payment_service.rb +54 -0
  326. data/lib/stripe/services/test_helpers/treasury/outbound_transfer_service.rb +54 -0
  327. data/lib/stripe/services/test_helpers/treasury/received_credit_service.rb +21 -0
  328. data/lib/stripe/services/test_helpers/treasury/received_debit_service.rb +21 -0
  329. data/lib/stripe/services/test_helpers/treasury_service.rb +19 -0
  330. data/lib/stripe/services/test_helpers_service.rb +19 -0
  331. data/lib/stripe/services/token_service.rb +23 -0
  332. data/lib/stripe/services/topup_service.rb +49 -0
  333. data/lib/stripe/services/transfer_reversal_service.rb +56 -0
  334. data/lib/stripe/services/transfer_service.rb +47 -0
  335. data/lib/stripe/services/treasury/credit_reversal_service.rb +41 -0
  336. data/lib/stripe/services/treasury/debit_reversal_service.rb +41 -0
  337. data/lib/stripe/services/treasury/financial_account_features_service.rb +30 -0
  338. data/lib/stripe/services/treasury/financial_account_service.rb +70 -0
  339. data/lib/stripe/services/treasury/inbound_transfer_service.rb +52 -0
  340. data/lib/stripe/services/treasury/outbound_payment_service.rb +52 -0
  341. data/lib/stripe/services/treasury/outbound_transfer_service.rb +52 -0
  342. data/lib/stripe/services/treasury/received_credit_service.rb +30 -0
  343. data/lib/stripe/services/treasury/received_debit_service.rb +30 -0
  344. data/lib/stripe/services/treasury/transaction_entry_service.rb +30 -0
  345. data/lib/stripe/services/treasury/transaction_service.rb +30 -0
  346. data/lib/stripe/services/treasury_service.rb +22 -0
  347. data/lib/stripe/services/v1_services.rb +89 -0
  348. data/lib/stripe/services/v2/billing/meter_event_adjustment_service.rb +21 -0
  349. data/lib/stripe/services/v2/billing/meter_event_service.rb +21 -0
  350. data/lib/stripe/services/v2/billing/meter_event_session_service.rb +21 -0
  351. data/lib/stripe/services/v2/billing/meter_event_stream_service.rb +23 -0
  352. data/lib/stripe/services/v2/billing_service.rb +18 -0
  353. data/lib/stripe/services/v2/core/event_destination_service.rb +98 -0
  354. data/lib/stripe/services/v2/core/event_service.rb +32 -0
  355. data/lib/stripe/services/v2/core_service.rb +16 -0
  356. data/lib/stripe/services/v2_services.rb +14 -0
  357. data/lib/stripe/services/webhook_endpoint_service.rb +61 -0
  358. data/lib/stripe/services.rb +182 -0
  359. data/lib/stripe/singleton_api_resource.rb +3 -3
  360. data/lib/stripe/stripe_client.rb +55 -1028
  361. data/lib/stripe/stripe_configuration.rb +63 -42
  362. data/lib/stripe/stripe_object.rb +60 -38
  363. data/lib/stripe/stripe_response.rb +1 -3
  364. data/lib/stripe/stripe_service.rb +32 -0
  365. data/lib/stripe/thin_event.rb +37 -0
  366. data/lib/stripe/util.rb +109 -45
  367. data/lib/stripe/v2_list_object.rb +84 -0
  368. data/lib/stripe/version.rb +1 -1
  369. data/lib/stripe/webhook.rb +3 -2
  370. data/lib/stripe.rb +39 -0
  371. data/stripe.gemspec +7 -4
  372. metadata +252 -13
  373. data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
  374. data/lib/stripe/resources/bitcoin_transaction.rb +0 -16
  375. data/lib/stripe/resources/issuing/card_details.rb +0 -10
  376. data/lib/stripe/resources/order.rb +0 -33
  377. data/lib/stripe/resources/order_return.rb +0 -10
  378. data/lib/stripe/resources/recipient.rb +0 -14
  379. data/lib/stripe/resources/sku.rb +0 -13
  380. data/lib/stripe/resources/three_d_secure.rb +0 -14
@@ -1,4 +1,3 @@
1
- # File generated from our OpenAPI spec
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # rubocop:disable Metrics/MethodLength
@@ -8,112 +7,161 @@ module Stripe
8
7
  def self.object_names_to_classes
9
8
  {
10
9
  # data structures
11
- ListObject::OBJECT_NAME => ListObject,
12
- SearchResultObject::OBJECT_NAME => SearchResultObject,
10
+ ListObject.object_name => ListObject,
11
+ SearchResultObject.object_name => SearchResultObject,
12
+ File.object_name_alt => File,
13
13
 
14
- # business objects
15
- Account::OBJECT_NAME => Account,
16
- AccountLink::OBJECT_NAME => AccountLink,
17
- AlipayAccount::OBJECT_NAME => AlipayAccount,
18
- ApplePayDomain::OBJECT_NAME => ApplePayDomain,
19
- ApplicationFee::OBJECT_NAME => ApplicationFee,
20
- ApplicationFeeRefund::OBJECT_NAME => ApplicationFeeRefund,
21
- Balance::OBJECT_NAME => Balance,
22
- BalanceTransaction::OBJECT_NAME => BalanceTransaction,
23
- BankAccount::OBJECT_NAME => BankAccount,
24
- BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
25
- BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
26
- BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
27
- BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
28
- Capability::OBJECT_NAME => Capability,
29
- Card::OBJECT_NAME => Card,
30
- CashBalance::OBJECT_NAME => CashBalance,
31
- Charge::OBJECT_NAME => Charge,
32
- Checkout::Session::OBJECT_NAME => Checkout::Session,
33
- CountrySpec::OBJECT_NAME => CountrySpec,
34
- Coupon::OBJECT_NAME => Coupon,
35
- CreditNote::OBJECT_NAME => CreditNote,
36
- CreditNoteLineItem::OBJECT_NAME => CreditNoteLineItem,
37
- Customer::OBJECT_NAME => Customer,
38
- CustomerBalanceTransaction::OBJECT_NAME => CustomerBalanceTransaction,
39
- Discount::OBJECT_NAME => Discount,
40
- Dispute::OBJECT_NAME => Dispute,
41
- EphemeralKey::OBJECT_NAME => EphemeralKey,
42
- Event::OBJECT_NAME => Event,
43
- ExchangeRate::OBJECT_NAME => ExchangeRate,
44
- File::OBJECT_NAME => File,
45
- File::OBJECT_NAME_ALT => File,
46
- FileLink::OBJECT_NAME => FileLink,
47
- FinancialConnections::Account::OBJECT_NAME => FinancialConnections::Account,
48
- FinancialConnections::AccountOwner::OBJECT_NAME => FinancialConnections::AccountOwner,
49
- FinancialConnections::AccountOwnership::OBJECT_NAME =>
50
- FinancialConnections::AccountOwnership,
51
- FinancialConnections::Session::OBJECT_NAME => FinancialConnections::Session,
52
- FundingInstructions::OBJECT_NAME => FundingInstructions,
53
- Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
54
- Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
55
- Invoice::OBJECT_NAME => Invoice,
56
- InvoiceItem::OBJECT_NAME => InvoiceItem,
57
- InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
58
- Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
59
- Issuing::Card::OBJECT_NAME => Issuing::Card,
60
- Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
61
- Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
62
- Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
63
- Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
64
- LineItem::OBJECT_NAME => LineItem,
65
- LoginLink::OBJECT_NAME => LoginLink,
66
- Mandate::OBJECT_NAME => Mandate,
67
- Order::OBJECT_NAME => Order,
68
- OrderReturn::OBJECT_NAME => OrderReturn,
69
- PaymentIntent::OBJECT_NAME => PaymentIntent,
70
- PaymentLink::OBJECT_NAME => PaymentLink,
71
- PaymentMethod::OBJECT_NAME => PaymentMethod,
72
- Payout::OBJECT_NAME => Payout,
73
- Person::OBJECT_NAME => Person,
74
- Plan::OBJECT_NAME => Plan,
75
- Price::OBJECT_NAME => Price,
76
- Product::OBJECT_NAME => Product,
77
- PromotionCode::OBJECT_NAME => PromotionCode,
78
- Quote::OBJECT_NAME => Quote,
79
- Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
80
- Radar::ValueList::OBJECT_NAME => Radar::ValueList,
81
- Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
82
- Recipient::OBJECT_NAME => Recipient,
83
- RecipientTransfer::OBJECT_NAME => RecipientTransfer,
84
- Refund::OBJECT_NAME => Refund,
85
- Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun,
86
- Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
87
- Reversal::OBJECT_NAME => Reversal,
88
- Review::OBJECT_NAME => Review,
89
- SetupAttempt::OBJECT_NAME => SetupAttempt,
90
- SetupIntent::OBJECT_NAME => SetupIntent,
91
- ShippingRate::OBJECT_NAME => ShippingRate,
92
- Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
93
- SKU::OBJECT_NAME => SKU,
94
- Source::OBJECT_NAME => Source,
95
- SourceTransaction::OBJECT_NAME => SourceTransaction,
96
- Subscription::OBJECT_NAME => Subscription,
97
- SubscriptionItem::OBJECT_NAME => SubscriptionItem,
98
- SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
99
- TaxCode::OBJECT_NAME => TaxCode,
100
- TaxId::OBJECT_NAME => TaxId,
101
- TaxRate::OBJECT_NAME => TaxRate,
102
- Terminal::Configuration::OBJECT_NAME => Terminal::Configuration,
103
- Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
104
- Terminal::Location::OBJECT_NAME => Terminal::Location,
105
- Terminal::Reader::OBJECT_NAME => Terminal::Reader,
106
- TestHelpers::TestClock::OBJECT_NAME => TestHelpers::TestClock,
107
- ThreeDSecure::OBJECT_NAME => ThreeDSecure,
108
- Token::OBJECT_NAME => Token,
109
- Topup::OBJECT_NAME => Topup,
110
- Transfer::OBJECT_NAME => Transfer,
111
- UsageRecord::OBJECT_NAME => UsageRecord,
112
- UsageRecordSummary::OBJECT_NAME => UsageRecordSummary,
113
- WebhookEndpoint::OBJECT_NAME => WebhookEndpoint,
14
+ # object classes: The beginning of the section generated from our OpenAPI spec
15
+ Account.object_name => Account,
16
+ AccountLink.object_name => AccountLink,
17
+ AccountSession.object_name => AccountSession,
18
+ ApplePayDomain.object_name => ApplePayDomain,
19
+ ApplicationFee.object_name => ApplicationFee,
20
+ ApplicationFeeRefund.object_name => ApplicationFeeRefund,
21
+ Apps::Secret.object_name => Apps::Secret,
22
+ Balance.object_name => Balance,
23
+ BalanceTransaction.object_name => BalanceTransaction,
24
+ BankAccount.object_name => BankAccount,
25
+ Billing::Alert.object_name => Billing::Alert,
26
+ Billing::CreditBalanceSummary.object_name => Billing::CreditBalanceSummary,
27
+ Billing::CreditBalanceTransaction.object_name => Billing::CreditBalanceTransaction,
28
+ Billing::CreditGrant.object_name => Billing::CreditGrant,
29
+ Billing::Meter.object_name => Billing::Meter,
30
+ Billing::MeterEvent.object_name => Billing::MeterEvent,
31
+ Billing::MeterEventAdjustment.object_name => Billing::MeterEventAdjustment,
32
+ Billing::MeterEventSummary.object_name => Billing::MeterEventSummary,
33
+ BillingPortal::Configuration.object_name => BillingPortal::Configuration,
34
+ BillingPortal::Session.object_name => BillingPortal::Session,
35
+ Capability.object_name => Capability,
36
+ Card.object_name => Card,
37
+ CashBalance.object_name => CashBalance,
38
+ Charge.object_name => Charge,
39
+ Checkout::Session.object_name => Checkout::Session,
40
+ Climate::Order.object_name => Climate::Order,
41
+ Climate::Product.object_name => Climate::Product,
42
+ Climate::Supplier.object_name => Climate::Supplier,
43
+ ConfirmationToken.object_name => ConfirmationToken,
44
+ CountrySpec.object_name => CountrySpec,
45
+ Coupon.object_name => Coupon,
46
+ CreditNote.object_name => CreditNote,
47
+ CreditNoteLineItem.object_name => CreditNoteLineItem,
48
+ Customer.object_name => Customer,
49
+ CustomerBalanceTransaction.object_name => CustomerBalanceTransaction,
50
+ CustomerCashBalanceTransaction.object_name => CustomerCashBalanceTransaction,
51
+ CustomerSession.object_name => CustomerSession,
52
+ Discount.object_name => Discount,
53
+ Dispute.object_name => Dispute,
54
+ Entitlements::ActiveEntitlement.object_name => Entitlements::ActiveEntitlement,
55
+ Entitlements::Feature.object_name => Entitlements::Feature,
56
+ EphemeralKey.object_name => EphemeralKey,
57
+ Event.object_name => Event,
58
+ ExchangeRate.object_name => ExchangeRate,
59
+ File.object_name => File,
60
+ FileLink.object_name => FileLink,
61
+ FinancialConnections::Account.object_name => FinancialConnections::Account,
62
+ FinancialConnections::AccountOwner.object_name => FinancialConnections::AccountOwner,
63
+ FinancialConnections::AccountOwnership.object_name => FinancialConnections::AccountOwnership,
64
+ FinancialConnections::Session.object_name => FinancialConnections::Session,
65
+ FinancialConnections::Transaction.object_name => FinancialConnections::Transaction,
66
+ Forwarding::Request.object_name => Forwarding::Request,
67
+ FundingInstructions.object_name => FundingInstructions,
68
+ Identity::VerificationReport.object_name => Identity::VerificationReport,
69
+ Identity::VerificationSession.object_name => Identity::VerificationSession,
70
+ Invoice.object_name => Invoice,
71
+ InvoiceItem.object_name => InvoiceItem,
72
+ InvoiceLineItem.object_name => InvoiceLineItem,
73
+ InvoiceRenderingTemplate.object_name => InvoiceRenderingTemplate,
74
+ Issuing::Authorization.object_name => Issuing::Authorization,
75
+ Issuing::Card.object_name => Issuing::Card,
76
+ Issuing::Cardholder.object_name => Issuing::Cardholder,
77
+ Issuing::Dispute.object_name => Issuing::Dispute,
78
+ Issuing::PersonalizationDesign.object_name => Issuing::PersonalizationDesign,
79
+ Issuing::PhysicalBundle.object_name => Issuing::PhysicalBundle,
80
+ Issuing::Token.object_name => Issuing::Token,
81
+ Issuing::Transaction.object_name => Issuing::Transaction,
82
+ LineItem.object_name => LineItem,
83
+ LoginLink.object_name => LoginLink,
84
+ Mandate.object_name => Mandate,
85
+ PaymentIntent.object_name => PaymentIntent,
86
+ PaymentLink.object_name => PaymentLink,
87
+ PaymentMethod.object_name => PaymentMethod,
88
+ PaymentMethodConfiguration.object_name => PaymentMethodConfiguration,
89
+ PaymentMethodDomain.object_name => PaymentMethodDomain,
90
+ Payout.object_name => Payout,
91
+ Person.object_name => Person,
92
+ Plan.object_name => Plan,
93
+ Price.object_name => Price,
94
+ Product.object_name => Product,
95
+ ProductFeature.object_name => ProductFeature,
96
+ PromotionCode.object_name => PromotionCode,
97
+ Quote.object_name => Quote,
98
+ Radar::EarlyFraudWarning.object_name => Radar::EarlyFraudWarning,
99
+ Radar::ValueList.object_name => Radar::ValueList,
100
+ Radar::ValueListItem.object_name => Radar::ValueListItem,
101
+ Refund.object_name => Refund,
102
+ Reporting::ReportRun.object_name => Reporting::ReportRun,
103
+ Reporting::ReportType.object_name => Reporting::ReportType,
104
+ Reversal.object_name => Reversal,
105
+ Review.object_name => Review,
106
+ SetupAttempt.object_name => SetupAttempt,
107
+ SetupIntent.object_name => SetupIntent,
108
+ ShippingRate.object_name => ShippingRate,
109
+ Sigma::ScheduledQueryRun.object_name => Sigma::ScheduledQueryRun,
110
+ Source.object_name => Source,
111
+ SourceTransaction.object_name => SourceTransaction,
112
+ Subscription.object_name => Subscription,
113
+ SubscriptionItem.object_name => SubscriptionItem,
114
+ SubscriptionSchedule.object_name => SubscriptionSchedule,
115
+ Tax::Calculation.object_name => Tax::Calculation,
116
+ Tax::CalculationLineItem.object_name => Tax::CalculationLineItem,
117
+ Tax::Registration.object_name => Tax::Registration,
118
+ Tax::Settings.object_name => Tax::Settings,
119
+ Tax::Transaction.object_name => Tax::Transaction,
120
+ Tax::TransactionLineItem.object_name => Tax::TransactionLineItem,
121
+ TaxCode.object_name => TaxCode,
122
+ TaxId.object_name => TaxId,
123
+ TaxRate.object_name => TaxRate,
124
+ Terminal::Configuration.object_name => Terminal::Configuration,
125
+ Terminal::ConnectionToken.object_name => Terminal::ConnectionToken,
126
+ Terminal::Location.object_name => Terminal::Location,
127
+ Terminal::Reader.object_name => Terminal::Reader,
128
+ TestHelpers::TestClock.object_name => TestHelpers::TestClock,
129
+ Token.object_name => Token,
130
+ Topup.object_name => Topup,
131
+ Transfer.object_name => Transfer,
132
+ Treasury::CreditReversal.object_name => Treasury::CreditReversal,
133
+ Treasury::DebitReversal.object_name => Treasury::DebitReversal,
134
+ Treasury::FinancialAccount.object_name => Treasury::FinancialAccount,
135
+ Treasury::FinancialAccountFeatures.object_name => Treasury::FinancialAccountFeatures,
136
+ Treasury::InboundTransfer.object_name => Treasury::InboundTransfer,
137
+ Treasury::OutboundPayment.object_name => Treasury::OutboundPayment,
138
+ Treasury::OutboundTransfer.object_name => Treasury::OutboundTransfer,
139
+ Treasury::ReceivedCredit.object_name => Treasury::ReceivedCredit,
140
+ Treasury::ReceivedDebit.object_name => Treasury::ReceivedDebit,
141
+ Treasury::Transaction.object_name => Treasury::Transaction,
142
+ Treasury::TransactionEntry.object_name => Treasury::TransactionEntry,
143
+ UsageRecord.object_name => UsageRecord,
144
+ UsageRecordSummary.object_name => UsageRecordSummary,
145
+ WebhookEndpoint.object_name => WebhookEndpoint,
146
+ # object classes: The end of the section generated from our OpenAPI spec
147
+ }
148
+ end
149
+
150
+ def self.v2_object_names_to_classes
151
+ {
152
+ V2::ListObject.object_name => V2::ListObject,
153
+
154
+ # v2 object classes: The beginning of the section generated from our OpenAPI spec
155
+ V2::Billing::MeterEvent.object_name => V2::Billing::MeterEvent,
156
+ V2::Billing::MeterEventAdjustment.object_name => V2::Billing::MeterEventAdjustment,
157
+ V2::Billing::MeterEventSession.object_name => V2::Billing::MeterEventSession,
158
+ V2::Event.object_name => V2::Event,
159
+ V2::EventDestination.object_name => V2::EventDestination,
160
+ # v2 object classes: The end of the section generated from our OpenAPI spec
114
161
  }
115
162
  end
116
163
  end
117
164
  end
118
165
 
166
+ # rubocop:enable Metrics/AbcSize
119
167
  # rubocop:enable Metrics/MethodLength
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module Stripe
5
+ # RequestOptions is a class that encapsulates configurable options
6
+ # for requests made to the Stripe API. It is used by the APIRequestor
7
+ # to set per-request options.
8
+ #
9
+ # For internal use only. Does not provide a stable API and may be broken
10
+ # with future non-major changes.
11
+ module RequestOptions
12
+ # Options that a user is allowed to specify.
13
+ OPTS_USER_SPECIFIED = Set[
14
+ :api_key,
15
+ :idempotency_key,
16
+ :stripe_account,
17
+ :stripe_context,
18
+ :stripe_version
19
+ ].freeze
20
+
21
+ # Options that should be copyable from one StripeObject to another
22
+ # including options that may be internal.
23
+ OPTS_COPYABLE = (
24
+ OPTS_USER_SPECIFIED + Set[:api_base]
25
+ ).freeze
26
+
27
+ # Options that should be persisted between API requests.
28
+ OPTS_PERSISTABLE = (
29
+ OPTS_USER_SPECIFIED - Set[:idempotency_key, :stripe_context]
30
+ ).freeze
31
+
32
+ # Merges requestor options on a StripeConfiguration object
33
+ # with a per-request options hash, giving precedence
34
+ # to the per-request options. Expects StripeConfiguration and hash.
35
+ def self.merge_config_and_opts(config, req_opts)
36
+ # Raise an error if config is not a StripeConfiguration object
37
+ unless config.is_a?(StripeConfiguration)
38
+ raise ArgumentError, "config must be a Stripe::StripeConfiguration object"
39
+ end
40
+
41
+ merged_opts = {
42
+ api_key: req_opts[:api_key] || config.api_key,
43
+ idempotency_key: req_opts[:idempotency_key],
44
+ stripe_account: req_opts[:stripe_account] || config.stripe_account,
45
+ stripe_context: req_opts[:stripe_context] || config.stripe_context,
46
+ stripe_version: req_opts[:stripe_version] || config.api_version,
47
+ headers: req_opts[:headers] || {},
48
+ }
49
+
50
+ # Remove nil values from headers
51
+ merged_opts.delete_if { |_, v| v.nil? }
52
+
53
+ merged_opts
54
+ end
55
+
56
+ # Merges requestor options hash on a StripeObject
57
+ # with a per-request options hash, giving precedence
58
+ # to the per-request options. Returns the merged request options.
59
+ # Expects two hashes, expects extract_opts_from_hash to be called first!!!
60
+ def self.combine_opts(object_opts, req_opts)
61
+ merged_opts = {
62
+ api_key: req_opts[:api_key] || object_opts[:api_key],
63
+ idempotency_key: req_opts[:idempotency_key],
64
+ stripe_account: req_opts[:stripe_account] || object_opts[:stripe_account],
65
+ stripe_context: req_opts[:stripe_context] || object_opts[:stripe_context],
66
+ stripe_version: req_opts[:stripe_version] || object_opts[:stripe_version],
67
+ headers: req_opts[:headers] || {},
68
+ }
69
+
70
+ # Remove nil values from headers
71
+ merged_opts.delete_if { |_, v| v.nil? }
72
+
73
+ merged_opts
74
+ end
75
+
76
+ # Extracts options from a user-provided hash, returning a new request options hash
77
+ # containing the recognized request options and a `headers` entry for the remaining options.
78
+ def self.extract_opts_from_hash(opts)
79
+ req_opts = {}
80
+ normalized_opts = Util.normalize_opts(opts.clone)
81
+
82
+ RequestOptions.error_on_non_string_user_opts(normalized_opts)
83
+
84
+ OPTS_USER_SPECIFIED.each do |opt|
85
+ req_opts[opt] = normalized_opts[opt] if normalized_opts.key?(opt)
86
+ normalized_opts.delete(opt)
87
+ end
88
+
89
+ # Remaining user-provided opts should be treated as headers
90
+ req_opts[:headers] = Util.normalize_headers(normalized_opts) if normalized_opts.any?
91
+
92
+ req_opts
93
+ end
94
+
95
+ # Validates a normalized opts hash.
96
+ def self.error_on_non_string_user_opts(normalized_opts)
97
+ OPTS_USER_SPECIFIED.each do |opt|
98
+ next unless normalized_opts.key?(opt)
99
+
100
+ val = normalized_opts[opt]
101
+ next if val.nil?
102
+ next if val.is_a?(String)
103
+
104
+ raise ArgumentError,
105
+ "request option '#{opt}' should be a string value " \
106
+ "(was a #{val.class})"
107
+ end
108
+ end
109
+
110
+ # Get options that persist between requests
111
+ def self.persistable(req_opts)
112
+ opts_to_persist = {}
113
+
114
+ # Hash#select returns an array before 1.9
115
+ req_opts.each do |k, v|
116
+ opts_to_persist[k] = v if RequestOptions::OPTS_PERSISTABLE.include?(k)
117
+ end
118
+
119
+ opts_to_persist
120
+ end
121
+
122
+ # Get options that are copyable from StripeObject to StripeObject
123
+ def self.copyable(req_opts)
124
+ req_opts.select do |k, _v|
125
+ RequestOptions::OPTS_COPYABLE.include?(k)
126
+ end
127
+ end
128
+ end
129
+ end
@@ -2,39 +2,152 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This is an object representing a Stripe account. You can retrieve it to see
6
+ # properties on the account like its current requirements or if the account is
7
+ # enabled to make live charges or receive payouts.
8
+ #
9
+ # For accounts where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection)
10
+ # is `application`, which includes Custom accounts, the properties below are always
11
+ # returned.
12
+ #
13
+ # For accounts where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection)
14
+ # is `stripe`, which includes Standard and Express accounts, some properties are only returned
15
+ # until you create an [Account Link](https://stripe.com/api/account_links) or [Account Session](https://stripe.com/api/account_sessions)
16
+ # to start Connect Onboarding. Learn about the [differences between accounts](https://stripe.com/connect/accounts).
5
17
  class Account < APIResource
6
- extend Gem::Deprecate
7
18
  extend Stripe::APIOperations::Create
8
19
  include Stripe::APIOperations::Delete
9
20
  extend Stripe::APIOperations::List
10
- include Stripe::APIOperations::Save
11
21
  extend Stripe::APIOperations::NestedResource
22
+ include Stripe::APIOperations::Save
12
23
 
13
24
  OBJECT_NAME = "account"
14
-
15
- custom_method :reject, http_verb: :post
25
+ def self.object_name
26
+ "account"
27
+ end
16
28
 
17
29
  nested_resource_class_methods :capability,
18
30
  operations: %i[retrieve update list],
19
31
  resource_plural: "capabilities"
20
- nested_resource_class_methods :person,
32
+ nested_resource_class_methods :external_account,
21
33
  operations: %i[create retrieve update delete list]
34
+ nested_resource_class_methods :login_link, operations: %i[create]
35
+ nested_resource_class_methods :person, operations: %i[create retrieve update delete list]
36
+
37
+ # With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users.
38
+ # To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings).
39
+ #
40
+ # If you've already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when
41
+ # creating the account. Connect Onboarding won't ask for the prefilled information during account onboarding.
42
+ # You can prefill any information on the account.
43
+ def self.create(params = {}, opts = {})
44
+ request_stripe_object(method: :post, path: "/v1/accounts", params: params, opts: opts)
45
+ end
46
+
47
+ # With [Connect](https://stripe.com/connect), you can delete accounts you manage.
48
+ #
49
+ # Test-mode accounts can be deleted at any time.
50
+ #
51
+ # Live-mode accounts where Stripe is responsible for negative account balances cannot be deleted, which includes Standard accounts. Live-mode accounts where your platform is liable for negative account balances, which includes Custom and Express accounts, can be deleted when all [balances](https://stripe.com/api/balance/balance_object) are zero.
52
+ #
53
+ # If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead.
54
+ def self.delete(account, params = {}, opts = {})
55
+ request_stripe_object(
56
+ method: :delete,
57
+ path: format("/v1/accounts/%<account>s", { account: CGI.escape(account) }),
58
+ params: params,
59
+ opts: opts
60
+ )
61
+ end
22
62
 
63
+ # With [Connect](https://stripe.com/connect), you can delete accounts you manage.
64
+ #
65
+ # Test-mode accounts can be deleted at any time.
66
+ #
67
+ # Live-mode accounts where Stripe is responsible for negative account balances cannot be deleted, which includes Standard accounts. Live-mode accounts where your platform is liable for negative account balances, which includes Custom and Express accounts, can be deleted when all [balances](https://stripe.com/api/balance/balance_object) are zero.
68
+ #
69
+ # If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead.
70
+ def delete(params = {}, opts = {})
71
+ request_stripe_object(
72
+ method: :delete,
73
+ path: format("/v1/accounts/%<account>s", { account: CGI.escape(self["id"]) }),
74
+ params: params,
75
+ opts: opts
76
+ )
77
+ end
78
+
79
+ # Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). If you're not a platform, the list is empty.
80
+ def self.list(params = {}, opts = {})
81
+ request_stripe_object(method: :get, path: "/v1/accounts", params: params, opts: opts)
82
+ end
83
+
84
+ # Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first.
85
+ def persons(params = {}, opts = {})
86
+ request_stripe_object(
87
+ method: :get,
88
+ path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(self["id"]) }),
89
+ params: params,
90
+ opts: opts
91
+ )
92
+ end
93
+
94
+ # Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first.
95
+ def self.persons(account, params = {}, opts = {})
96
+ request_stripe_object(
97
+ method: :get,
98
+ path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(account) }),
99
+ params: params,
100
+ opts: opts
101
+ )
102
+ end
103
+
104
+ # With [Connect](https://stripe.com/connect), you can reject accounts that you have flagged as suspicious.
105
+ #
106
+ # Only accounts where your platform is liable for negative account balances, which includes Custom and Express accounts, can be rejected. Test-mode accounts can be rejected at any time. Live-mode accounts can only be rejected after all balances are zero.
23
107
  def reject(params = {}, opts = {})
24
108
  request_stripe_object(
25
109
  method: :post,
26
- path: resource_url + "/reject",
110
+ path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(self["id"]) }),
27
111
  params: params,
28
112
  opts: opts
29
113
  )
30
114
  end
31
115
 
32
- save_nested_resource :external_account
116
+ # With [Connect](https://stripe.com/connect), you can reject accounts that you have flagged as suspicious.
117
+ #
118
+ # Only accounts where your platform is liable for negative account balances, which includes Custom and Express accounts, can be rejected. Test-mode accounts can be rejected at any time. Live-mode accounts can only be rejected after all balances are zero.
119
+ def self.reject(account, params = {}, opts = {})
120
+ request_stripe_object(
121
+ method: :post,
122
+ path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(account) }),
123
+ params: params,
124
+ opts: opts
125
+ )
126
+ end
33
127
 
34
- nested_resource_class_methods :external_account,
35
- operations: %i[create retrieve update delete list]
128
+ # Updates a [connected account](https://stripe.com/connect/accounts) by setting the values of the parameters passed. Any parameters not provided are
129
+ # left unchanged.
130
+ #
131
+ # For accounts where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection)
132
+ # is application, which includes Custom accounts, you can update any information on the account.
133
+ #
134
+ # For accounts where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection)
135
+ # is stripe, which includes Standard and Express accounts, you can update all information until you create
136
+ # an [Account Link or <a href="/api/account_sessions">Account Session](https://stripe.com/api/account_links) to start Connect onboarding,
137
+ # after which some properties can no longer be updated.
138
+ #
139
+ # To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account). Refer to our
140
+ # [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts.
141
+ def self.update(account, params = {}, opts = {})
142
+ request_stripe_object(
143
+ method: :post,
144
+ path: format("/v1/accounts/%<account>s", { account: CGI.escape(account) }),
145
+ params: params,
146
+ opts: opts
147
+ )
148
+ end
36
149
 
37
- nested_resource_class_methods :login_link, operations: %i[create]
150
+ save_nested_resource :external_account
38
151
 
39
152
  def resource_url
40
153
  if self["id"]
@@ -60,11 +173,6 @@ module Stripe
60
173
  super(id, opts)
61
174
  end
62
175
 
63
- def persons(params = {}, opts = {})
64
- resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
65
- Util.convert_to_stripe_object(resp.data, opts)
66
- end
67
-
68
176
  # We are not adding a helper for capabilities here as the Account object
69
177
  # already has a capabilities property which is a hash and not the sub-list
70
178
  # of capabilities.
@@ -97,17 +205,13 @@ module Stripe
97
205
  end
98
206
 
99
207
  def serialize_params_account(_obj, update_hash, options = {})
100
- if (entity = @values[:legal_entity])
101
- if (owners = entity[:additional_owners])
102
- entity_update = update_hash[:legal_entity] ||= {}
103
- entity_update[:additional_owners] =
104
- serialize_additional_owners(entity, owners)
105
- end
208
+ if (entity = @values[:legal_entity]) && (owners = entity[:additional_owners])
209
+ entity_update = update_hash[:legal_entity] ||= {}
210
+ entity_update[:additional_owners] =
211
+ serialize_additional_owners(entity, owners)
106
212
  end
107
- if (individual = @values[:individual])
108
- if individual.is_a?(Person) && !update_hash.key?(:individual)
109
- update_hash[:individual] = individual.serialize_params(options)
110
- end
213
+ if (individual = @values[:individual]) && (individual.is_a?(Person) && !update_hash.key?(:individual))
214
+ update_hash[:individual] = individual.serialize_params(options)
111
215
  end
112
216
  update_hash
113
217
  end
@@ -2,9 +2,21 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Account Links are the means by which a Connect platform grants a connected account permission to access
6
+ # Stripe-hosted applications, such as Connect Onboarding.
7
+ #
8
+ # Related guide: [Connect Onboarding](https://stripe.com/docs/connect/custom/hosted-onboarding)
5
9
  class AccountLink < APIResource
6
10
  extend Stripe::APIOperations::Create
7
11
 
8
12
  OBJECT_NAME = "account_link"
13
+ def self.object_name
14
+ "account_link"
15
+ end
16
+
17
+ # Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
18
+ def self.create(params = {}, opts = {})
19
+ request_stripe_object(method: :post, path: "/v1/account_links", params: params, opts: opts)
20
+ end
9
21
  end
10
22
  end
@@ -0,0 +1,25 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ # An AccountSession allows a Connect platform to grant access to a connected account in Connect embedded components.
6
+ #
7
+ # We recommend that you create an AccountSession each time you need to display an embedded component
8
+ # to your user. Do not save AccountSessions to your database as they expire relatively
9
+ # quickly, and cannot be used more than once.
10
+ #
11
+ # Related guide: [Connect embedded components](https://stripe.com/docs/connect/get-started-connect-embedded-components)
12
+ class AccountSession < APIResource
13
+ extend Stripe::APIOperations::Create
14
+
15
+ OBJECT_NAME = "account_session"
16
+ def self.object_name
17
+ "account_session"
18
+ end
19
+
20
+ # Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access.
21
+ def self.create(params = {}, opts = {})
22
+ request_stripe_object(method: :post, path: "/v1/account_sessions", params: params, opts: opts)
23
+ end
24
+ end
25
+ end