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
@@ -3,12 +3,46 @@
3
3
 
4
4
  module Stripe
5
5
  module BillingPortal
6
+ # A portal configuration describes the functionality and behavior of a portal session.
6
7
  class Configuration < APIResource
7
8
  extend Stripe::APIOperations::Create
8
9
  extend Stripe::APIOperations::List
9
10
  include Stripe::APIOperations::Save
10
11
 
11
12
  OBJECT_NAME = "billing_portal.configuration"
13
+ def self.object_name
14
+ "billing_portal.configuration"
15
+ end
16
+
17
+ # Creates a configuration that describes the functionality and behavior of a PortalSession
18
+ def self.create(params = {}, opts = {})
19
+ request_stripe_object(
20
+ method: :post,
21
+ path: "/v1/billing_portal/configurations",
22
+ params: params,
23
+ opts: opts
24
+ )
25
+ end
26
+
27
+ # Returns a list of configurations that describe the functionality of the customer portal.
28
+ def self.list(params = {}, opts = {})
29
+ request_stripe_object(
30
+ method: :get,
31
+ path: "/v1/billing_portal/configurations",
32
+ params: params,
33
+ opts: opts
34
+ )
35
+ end
36
+
37
+ # Updates a configuration that describes the functionality of the customer portal.
38
+ def self.update(configuration, params = {}, opts = {})
39
+ request_stripe_object(
40
+ method: :post,
41
+ path: format("/v1/billing_portal/configurations/%<configuration>s", { configuration: CGI.escape(configuration) }),
42
+ params: params,
43
+ opts: opts
44
+ )
45
+ end
12
46
  end
13
47
  end
14
48
  end
@@ -3,10 +3,37 @@
3
3
 
4
4
  module Stripe
5
5
  module BillingPortal
6
+ # The Billing customer portal is a Stripe-hosted UI for subscription and
7
+ # billing management.
8
+ #
9
+ # A portal configuration describes the functionality and features that you
10
+ # want to provide to your customers through the portal.
11
+ #
12
+ # A portal session describes the instantiation of the customer portal for
13
+ # a particular customer. By visiting the session's URL, the customer
14
+ # can manage their subscriptions and billing details. For security reasons,
15
+ # sessions are short-lived and will expire if the customer does not visit the URL.
16
+ # Create sessions on-demand when customers intend to manage their subscriptions
17
+ # and billing details.
18
+ #
19
+ # Related guide: [Customer management](https://stripe.com/customer-management)
6
20
  class Session < APIResource
7
21
  extend Stripe::APIOperations::Create
8
22
 
9
23
  OBJECT_NAME = "billing_portal.session"
24
+ def self.object_name
25
+ "billing_portal.session"
26
+ end
27
+
28
+ # Creates a session of the customer portal.
29
+ def self.create(params = {}, opts = {})
30
+ request_stripe_object(
31
+ method: :post,
32
+ path: "/v1/billing_portal/sessions",
33
+ params: params,
34
+ opts: opts
35
+ )
36
+ end
10
37
  end
11
38
  end
12
39
  end
@@ -2,11 +2,16 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This is an object representing a capability for a Stripe account.
6
+ #
7
+ # Related guide: [Account capabilities](https://stripe.com/docs/connect/account-capabilities)
5
8
  class Capability < APIResource
6
- extend Stripe::APIOperations::List
7
9
  include Stripe::APIOperations::Save
8
10
 
9
11
  OBJECT_NAME = "capability"
12
+ def self.object_name
13
+ "capability"
14
+ end
10
15
 
11
16
  def resource_url
12
17
  if !respond_to?(:account) || account.nil?
@@ -14,7 +19,7 @@ module Stripe
14
19
  "Capabilities cannot be accessed without an account ID."
15
20
  end
16
21
  "#{Account.resource_url}/#{CGI.escape(account)}/capabilities" \
17
- "/#{CGI.escape(id)}"
22
+ "/#{CGI.escape(id)}"
18
23
  end
19
24
 
20
25
  def self.retrieve(_id, _opts = {})
@@ -2,17 +2,23 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # You can store multiple cards on a customer in order to charge the customer
6
+ # later. You can also store multiple debit cards on a recipient in order to
7
+ # transfer to those cards later.
8
+ #
9
+ # Related guide: [Card payments with Sources](https://stripe.com/docs/sources/cards)
5
10
  class Card < APIResource
6
11
  include Stripe::APIOperations::Delete
7
12
  extend Stripe::APIOperations::List
8
13
  include Stripe::APIOperations::Save
9
14
 
10
15
  OBJECT_NAME = "card"
16
+ def self.object_name
17
+ "card"
18
+ end
11
19
 
12
20
  def resource_url
13
- if respond_to?(:recipient) && !recipient.nil? && !recipient.empty?
14
- "#{Recipient.resource_url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
15
- elsif respond_to?(:customer) && !customer.nil? && !customer.empty?
21
+ if respond_to?(:customer) && !customer.nil? && !customer.empty?
16
22
  "#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
17
23
  elsif respond_to?(:account) && !account.nil? && !account.empty?
18
24
  "#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
@@ -34,5 +40,30 @@ module Stripe
34
40
  "'customer_id', 'card_id')` or " \
35
41
  "`Account.retrieve_external_account('account_id', 'card_id')`"
36
42
  end
43
+
44
+ def self.delete(id, params = {}, opts = {})
45
+ raise NotImplementedError,
46
+ "Card cannot be deleted without a customer ID or an account " \
47
+ "ID. Delete a card using `Customer.delete_source(" \
48
+ "'customer_id', 'card_id')` or " \
49
+ "`Account.delete_external_account('account_id', 'card_id')`"
50
+ end
51
+
52
+ def delete(params = {}, opts = {})
53
+ request_stripe_object(
54
+ method: :delete,
55
+ path: resource_url.to_s,
56
+ params: params,
57
+ opts: opts
58
+ )
59
+ end
60
+
61
+ def self.list(params = {}, opts = {})
62
+ raise NotImplementedError,
63
+ "Cards cannot be listed without a customer ID or an account " \
64
+ "ID. List cards using `Customer.list_sources(" \
65
+ "'customer_id')` or " \
66
+ "`Account.list_external_accounts('account_id')`"
67
+ end
37
68
  end
38
69
  end
@@ -2,8 +2,12 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # A customer's `Cash balance` represents real funds. Customers can add funds to their cash balance by sending a bank transfer. These funds can be used for payment and can eventually be paid out to your bank account.
5
6
  class CashBalance < APIResource
6
7
  OBJECT_NAME = "cash_balance"
8
+ def self.object_name
9
+ "cash_balance"
10
+ end
7
11
 
8
12
  def resource_url
9
13
  if !respond_to?(:customer) || customer.nil?
@@ -2,31 +2,80 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # The `Charge` object represents a single attempt to move money into your Stripe account.
6
+ # PaymentIntent confirmation is the most common way to create Charges, but transferring
7
+ # money to a different Stripe account through Connect also creates Charges.
8
+ # Some legacy payment flows create Charges directly, which is not recommended for new integrations.
5
9
  class Charge < APIResource
6
10
  extend Stripe::APIOperations::Create
7
11
  extend Stripe::APIOperations::List
12
+ extend Stripe::APIOperations::NestedResource
8
13
  extend Stripe::APIOperations::Search
9
14
  include Stripe::APIOperations::Save
10
15
 
11
16
  OBJECT_NAME = "charge"
17
+ def self.object_name
18
+ "charge"
19
+ end
12
20
 
13
- custom_method :capture, http_verb: :post
21
+ nested_resource_class_methods :refund, operations: %i[retrieve list]
14
22
 
23
+ # Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
24
+ #
25
+ # Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail.
26
+ #
27
+ # Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture).
15
28
  def capture(params = {}, opts = {})
16
29
  request_stripe_object(
17
30
  method: :post,
18
- path: resource_url + "/capture",
31
+ path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(self["id"]) }),
32
+ params: params,
33
+ opts: opts
34
+ )
35
+ end
36
+
37
+ # Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
38
+ #
39
+ # Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail.
40
+ #
41
+ # Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture).
42
+ def self.capture(charge, params = {}, opts = {})
43
+ request_stripe_object(
44
+ method: :post,
45
+ path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(charge) }),
19
46
  params: params,
20
47
  opts: opts
21
48
  )
22
49
  end
23
50
 
51
+ # This method is no longer recommended—use the [Payment Intents API](https://stripe.com/docs/api/payment_intents)
52
+ # to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge
53
+ # object used to request payment.
54
+ def self.create(params = {}, opts = {})
55
+ request_stripe_object(method: :post, path: "/v1/charges", params: params, opts: opts)
56
+ end
57
+
58
+ # Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges appearing first.
59
+ def self.list(params = {}, opts = {})
60
+ request_stripe_object(method: :get, path: "/v1/charges", params: params, opts: opts)
61
+ end
62
+
24
63
  def self.search(params = {}, opts = {})
25
- _search("/v1/charges/search", params, opts)
64
+ request_stripe_object(method: :get, path: "/v1/charges/search", params: params, opts: opts)
26
65
  end
27
66
 
28
67
  def self.search_auto_paging_each(params = {}, opts = {}, &blk)
29
68
  search(params, opts).auto_paging_each(&blk)
30
69
  end
70
+
71
+ # Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
72
+ def self.update(charge, params = {}, opts = {})
73
+ request_stripe_object(
74
+ method: :post,
75
+ path: format("/v1/charges/%<charge>s", { charge: CGI.escape(charge) }),
76
+ params: params,
77
+ opts: opts
78
+ )
79
+ end
31
80
  end
32
81
  end
@@ -3,21 +3,99 @@
3
3
 
4
4
  module Stripe
5
5
  module Checkout
6
+ # A Checkout Session represents your customer's session as they pay for
7
+ # one-time purchases or subscriptions through [Checkout](https://stripe.com/docs/payments/checkout)
8
+ # or [Payment Links](https://stripe.com/docs/payments/payment-links). We recommend creating a
9
+ # new Session each time your customer attempts to pay.
10
+ #
11
+ # Once payment is successful, the Checkout Session will contain a reference
12
+ # to the [Customer](https://stripe.com/docs/api/customers), and either the successful
13
+ # [PaymentIntent](https://stripe.com/docs/api/payment_intents) or an active
14
+ # [Subscription](https://stripe.com/docs/api/subscriptions).
15
+ #
16
+ # You can create a Checkout Session on your server and redirect to its URL
17
+ # to begin Checkout.
18
+ #
19
+ # Related guide: [Checkout quickstart](https://stripe.com/docs/checkout/quickstart)
6
20
  class Session < APIResource
7
21
  extend Stripe::APIOperations::Create
8
22
  extend Stripe::APIOperations::List
9
- extend Stripe::APIOperations::NestedResource
23
+ include Stripe::APIOperations::Save
10
24
 
11
25
  OBJECT_NAME = "checkout.session"
26
+ def self.object_name
27
+ "checkout.session"
28
+ end
12
29
 
13
- custom_method :expire, http_verb: :post
14
-
15
- nested_resource_class_methods :line_item, operations: %i[list]
30
+ # Creates a Session object.
31
+ def self.create(params = {}, opts = {})
32
+ request_stripe_object(
33
+ method: :post,
34
+ path: "/v1/checkout/sessions",
35
+ params: params,
36
+ opts: opts
37
+ )
38
+ end
16
39
 
40
+ # A Session can be expired when it is in one of these statuses: open
41
+ #
42
+ # After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
17
43
  def expire(params = {}, opts = {})
18
44
  request_stripe_object(
19
45
  method: :post,
20
- path: resource_url + "/expire",
46
+ path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(self["id"]) }),
47
+ params: params,
48
+ opts: opts
49
+ )
50
+ end
51
+
52
+ # A Session can be expired when it is in one of these statuses: open
53
+ #
54
+ # After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
55
+ def self.expire(session, params = {}, opts = {})
56
+ request_stripe_object(
57
+ method: :post,
58
+ path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(session) }),
59
+ params: params,
60
+ opts: opts
61
+ )
62
+ end
63
+
64
+ # Returns a list of Checkout Sessions.
65
+ def self.list(params = {}, opts = {})
66
+ request_stripe_object(
67
+ method: :get,
68
+ path: "/v1/checkout/sessions",
69
+ params: params,
70
+ opts: opts
71
+ )
72
+ end
73
+
74
+ # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
75
+ def list_line_items(params = {}, opts = {})
76
+ request_stripe_object(
77
+ method: :get,
78
+ path: format("/v1/checkout/sessions/%<session>s/line_items", { session: CGI.escape(self["id"]) }),
79
+ params: params,
80
+ opts: opts
81
+ )
82
+ end
83
+
84
+ # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
85
+ def self.list_line_items(session, params = {}, opts = {})
86
+ request_stripe_object(
87
+ method: :get,
88
+ path: format("/v1/checkout/sessions/%<session>s/line_items", { session: CGI.escape(session) }),
89
+ params: params,
90
+ opts: opts
91
+ )
92
+ end
93
+
94
+ # Updates a Session object.
95
+ def self.update(session, params = {}, opts = {})
96
+ request_stripe_object(
97
+ method: :post,
98
+ path: format("/v1/checkout/sessions/%<session>s", { session: CGI.escape(session) }),
21
99
  params: params,
22
100
  opts: opts
23
101
  )
@@ -0,0 +1,67 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Climate
6
+ # Orders represent your intent to purchase a particular Climate product. When you create an order, the
7
+ # payment is deducted from your merchant balance.
8
+ class Order < APIResource
9
+ extend Stripe::APIOperations::Create
10
+ extend Stripe::APIOperations::List
11
+ include Stripe::APIOperations::Save
12
+
13
+ OBJECT_NAME = "climate.order"
14
+ def self.object_name
15
+ "climate.order"
16
+ end
17
+
18
+ # Cancels a Climate order. You can cancel an order within 24 hours of creation. Stripe refunds the
19
+ # reservation amount_subtotal, but not the amount_fees for user-triggered cancellations. Frontier
20
+ # might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe
21
+ # provides 90 days advance notice and refunds the amount_total.
22
+ def cancel(params = {}, opts = {})
23
+ request_stripe_object(
24
+ method: :post,
25
+ path: format("/v1/climate/orders/%<order>s/cancel", { order: CGI.escape(self["id"]) }),
26
+ params: params,
27
+ opts: opts
28
+ )
29
+ end
30
+
31
+ # Cancels a Climate order. You can cancel an order within 24 hours of creation. Stripe refunds the
32
+ # reservation amount_subtotal, but not the amount_fees for user-triggered cancellations. Frontier
33
+ # might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe
34
+ # provides 90 days advance notice and refunds the amount_total.
35
+ def self.cancel(order, params = {}, opts = {})
36
+ request_stripe_object(
37
+ method: :post,
38
+ path: format("/v1/climate/orders/%<order>s/cancel", { order: CGI.escape(order) }),
39
+ params: params,
40
+ opts: opts
41
+ )
42
+ end
43
+
44
+ # Creates a Climate order object for a given Climate product. The order will be processed immediately
45
+ # after creation and payment will be deducted your Stripe balance.
46
+ def self.create(params = {}, opts = {})
47
+ request_stripe_object(method: :post, path: "/v1/climate/orders", params: params, opts: opts)
48
+ end
49
+
50
+ # Lists all Climate order objects. The orders are returned sorted by creation date, with the
51
+ # most recently created orders appearing first.
52
+ def self.list(params = {}, opts = {})
53
+ request_stripe_object(method: :get, path: "/v1/climate/orders", params: params, opts: opts)
54
+ end
55
+
56
+ # Updates the specified order by setting the values of the parameters passed.
57
+ def self.update(order, params = {}, opts = {})
58
+ request_stripe_object(
59
+ method: :post,
60
+ path: format("/v1/climate/orders/%<order>s", { order: CGI.escape(order) }),
61
+ params: params,
62
+ opts: opts
63
+ )
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,27 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Climate
6
+ # A Climate product represents a type of carbon removal unit available for reservation.
7
+ # You can retrieve it to see the current price and availability.
8
+ class Product < APIResource
9
+ extend Stripe::APIOperations::List
10
+
11
+ OBJECT_NAME = "climate.product"
12
+ def self.object_name
13
+ "climate.product"
14
+ end
15
+
16
+ # Lists all available Climate product objects.
17
+ def self.list(params = {}, opts = {})
18
+ request_stripe_object(
19
+ method: :get,
20
+ path: "/v1/climate/products",
21
+ params: params,
22
+ opts: opts
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Climate
6
+ # A supplier of carbon removal.
7
+ class Supplier < APIResource
8
+ extend Stripe::APIOperations::List
9
+
10
+ OBJECT_NAME = "climate.supplier"
11
+ def self.object_name
12
+ "climate.supplier"
13
+ end
14
+
15
+ # Lists all available Climate supplier objects.
16
+ def self.list(params = {}, opts = {})
17
+ request_stripe_object(
18
+ method: :get,
19
+ path: "/v1/climate/suppliers",
20
+ params: params,
21
+ opts: opts
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,39 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ # ConfirmationTokens help transport client side data collected by Stripe JS over
6
+ # to your server for confirming a PaymentIntent or SetupIntent. If the confirmation
7
+ # is successful, values present on the ConfirmationToken are written onto the Intent.
8
+ #
9
+ # To learn more about how to use ConfirmationToken, visit the related guides:
10
+ # - [Finalize payments on the server](https://stripe.com/docs/payments/finalize-payments-on-the-server)
11
+ # - [Build two-step confirmation](https://stripe.com/docs/payments/build-a-two-step-confirmation).
12
+ class ConfirmationToken < APIResource
13
+ OBJECT_NAME = "confirmation_token"
14
+ def self.object_name
15
+ "confirmation_token"
16
+ end
17
+
18
+ def test_helpers
19
+ TestHelpers.new(self)
20
+ end
21
+
22
+ class TestHelpers < APIResourceTestHelpers
23
+ RESOURCE_CLASS = ConfirmationToken
24
+ def self.resource_class
25
+ "ConfirmationToken"
26
+ end
27
+
28
+ # Creates a test mode Confirmation Token server side for your integration tests.
29
+ def self.create(params = {}, opts = {})
30
+ request_stripe_object(
31
+ method: :post,
32
+ path: "/v1/test_helpers/confirmation_tokens",
33
+ params: params,
34
+ opts: opts
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,9 +2,23 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Stripe needs to collect certain pieces of information about each account
6
+ # created. These requirements can differ depending on the account's country. The
7
+ # Country Specs API makes these rules available to your integration.
8
+ #
9
+ # You can also view the information from this API call as [an online
10
+ # guide](https://stripe.com/docs/connect/required-verification-information).
5
11
  class CountrySpec < APIResource
6
12
  extend Stripe::APIOperations::List
7
13
 
8
14
  OBJECT_NAME = "country_spec"
15
+ def self.object_name
16
+ "country_spec"
17
+ end
18
+
19
+ # Lists all Country Spec objects available in the API.
20
+ def self.list(params = {}, opts = {})
21
+ request_stripe_object(method: :get, path: "/v1/country_specs", params: params, opts: opts)
22
+ end
9
23
  end
10
24
  end
@@ -2,6 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # A coupon contains information about a percent-off or amount-off discount you
6
+ # might want to apply to a customer. Coupons may be applied to [subscriptions](https://stripe.com/docs/api#subscriptions), [invoices](https://stripe.com/docs/api#invoices),
7
+ # [checkout sessions](https://stripe.com/docs/api/checkout/sessions), [quotes](https://stripe.com/docs/api#quotes), and more. Coupons do not work with conventional one-off [charges](https://stripe.com/docs/api#create_charge) or [payment intents](https://stripe.com/docs/api/payment_intents).
5
8
  class Coupon < APIResource
6
9
  extend Stripe::APIOperations::Create
7
10
  include Stripe::APIOperations::Delete
@@ -9,5 +12,50 @@ module Stripe
9
12
  include Stripe::APIOperations::Save
10
13
 
11
14
  OBJECT_NAME = "coupon"
15
+ def self.object_name
16
+ "coupon"
17
+ end
18
+
19
+ # You can create coupons easily via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.
20
+ #
21
+ # A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that amount will be subtracted from any invoice's subtotal. For example, an invoice with a subtotal of 100 will have a final total of 0 if a coupon with an amount_off of 200 is applied to it and an invoice with a subtotal of 300 will have a final total of 100 if a coupon with an amount_off of 200 is applied to it.
22
+ def self.create(params = {}, opts = {})
23
+ request_stripe_object(method: :post, path: "/v1/coupons", params: params, opts: opts)
24
+ end
25
+
26
+ # You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API.
27
+ def self.delete(coupon, params = {}, opts = {})
28
+ request_stripe_object(
29
+ method: :delete,
30
+ path: format("/v1/coupons/%<coupon>s", { coupon: CGI.escape(coupon) }),
31
+ params: params,
32
+ opts: opts
33
+ )
34
+ end
35
+
36
+ # You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API.
37
+ def delete(params = {}, opts = {})
38
+ request_stripe_object(
39
+ method: :delete,
40
+ path: format("/v1/coupons/%<coupon>s", { coupon: CGI.escape(self["id"]) }),
41
+ params: params,
42
+ opts: opts
43
+ )
44
+ end
45
+
46
+ # Returns a list of your coupons.
47
+ def self.list(params = {}, opts = {})
48
+ request_stripe_object(method: :get, path: "/v1/coupons", params: params, opts: opts)
49
+ end
50
+
51
+ # Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
52
+ def self.update(coupon, params = {}, opts = {})
53
+ request_stripe_object(
54
+ method: :post,
55
+ path: format("/v1/coupons/%<coupon>s", { coupon: CGI.escape(coupon) }),
56
+ params: params,
57
+ opts: opts
58
+ )
59
+ end
12
60
  end
13
61
  end