stripe 12.7.0.pre.beta.2 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +720 -1360
  3. data/OPENAPI_VERSION +1 -1
  4. data/README.md +4 -3
  5. data/VERSION +1 -1
  6. data/examples/README.md +11 -0
  7. data/examples/meter_event_stream.rb +47 -0
  8. data/examples/new_example.rb +24 -0
  9. data/examples/stripe_webhook_handler.rb +28 -0
  10. data/lib/stripe/api_operations/nested_resource.rb +1 -21
  11. data/lib/stripe/api_operations/request.rb +19 -70
  12. data/lib/stripe/api_operations/save.rb +4 -3
  13. data/lib/stripe/api_operations/singleton_save.rb +5 -2
  14. data/lib/stripe/api_requestor.rb +1131 -0
  15. data/lib/stripe/api_resource.rb +22 -14
  16. data/lib/stripe/api_version.rb +1 -2
  17. data/lib/stripe/connection_manager.rb +1 -1
  18. data/lib/stripe/errors.rb +8 -2
  19. data/lib/stripe/event_types.rb +14 -0
  20. data/lib/stripe/events/v1_billing_meter_error_report_triggered_event.rb +23 -0
  21. data/lib/stripe/events/v1_billing_meter_no_meter_found_event.rb +13 -0
  22. data/lib/stripe/list_object.rb +2 -3
  23. data/lib/stripe/oauth.rb +8 -15
  24. data/lib/stripe/object_types.rb +16 -20
  25. data/lib/stripe/request_options.rb +128 -0
  26. data/lib/stripe/resources/billing/credit_balance_summary.rb +14 -0
  27. data/lib/stripe/resources/billing/credit_balance_transaction.rb +26 -0
  28. data/lib/stripe/resources/billing/credit_grant.rb +88 -0
  29. data/lib/stripe/resources/customer.rb +2 -3
  30. data/lib/stripe/resources/file.rb +7 -5
  31. data/lib/stripe/resources/financial_connections/account.rb +0 -3
  32. data/lib/stripe/resources/invoice.rb +0 -81
  33. data/lib/stripe/resources/payment_intent.rb +0 -50
  34. data/lib/stripe/resources/quote.rb +4 -108
  35. data/lib/stripe/resources/source.rb +3 -2
  36. data/lib/stripe/resources/subscription.rb +6 -6
  37. data/lib/stripe/resources/subscription_schedule.rb +0 -20
  38. data/lib/stripe/resources/terminal/reader.rb +0 -60
  39. data/lib/stripe/resources/v2/billing/meter_event.rb +16 -0
  40. data/lib/stripe/resources/v2/billing/meter_event_adjustment.rb +15 -0
  41. data/lib/stripe/resources/v2/billing/meter_event_session.rb +15 -0
  42. data/lib/stripe/resources/v2/event.rb +13 -0
  43. data/lib/stripe/resources.rb +9 -18
  44. data/lib/stripe/search_result_object.rb +1 -1
  45. data/lib/stripe/services/account_capability_service.rb +39 -0
  46. data/lib/stripe/services/account_external_account_service.rb +68 -0
  47. data/lib/stripe/services/account_link_service.rb +17 -0
  48. data/lib/stripe/services/account_login_link_service.rb +19 -0
  49. data/lib/stripe/services/account_person_service.rb +61 -0
  50. data/lib/stripe/services/account_service.rb +100 -0
  51. data/lib/stripe/services/account_session_service.rb +17 -0
  52. data/lib/stripe/services/apple_pay_domain_service.rb +50 -0
  53. data/lib/stripe/services/application_fee_refund_service.rb +60 -0
  54. data/lib/stripe/services/application_fee_service.rb +35 -0
  55. data/lib/stripe/services/apps/secret_service.rb +52 -0
  56. data/lib/stripe/services/apps_service.rb +13 -0
  57. data/lib/stripe/services/balance_service.rb +12 -0
  58. data/lib/stripe/services/balance_transaction_service.rb +32 -0
  59. data/lib/stripe/services/billing/alert_service.rb +74 -0
  60. data/lib/stripe/services/billing/credit_balance_summary_service.rb +19 -0
  61. data/lib/stripe/services/billing/credit_balance_transaction_service.rb +30 -0
  62. data/lib/stripe/services/billing/credit_grant_service.rb +74 -0
  63. data/lib/stripe/services/billing/meter_event_adjustment_service.rb +19 -0
  64. data/lib/stripe/services/billing/meter_event_service.rb +19 -0
  65. data/lib/stripe/services/billing/meter_event_summary_service.rb +19 -0
  66. data/lib/stripe/services/billing/meter_service.rb +81 -0
  67. data/lib/stripe/services/billing_portal/configuration_service.rb +52 -0
  68. data/lib/stripe/services/billing_portal/session_service.rb +19 -0
  69. data/lib/stripe/services/billing_portal_service.rb +14 -0
  70. data/lib/stripe/services/billing_service.rb +20 -0
  71. data/lib/stripe/services/charge_service.rb +69 -0
  72. data/lib/stripe/services/checkout/session_line_item_service.rb +19 -0
  73. data/lib/stripe/services/checkout/session_service.rb +72 -0
  74. data/lib/stripe/services/checkout_service.rb +13 -0
  75. data/lib/stripe/services/climate/order_service.rb +68 -0
  76. data/lib/stripe/services/climate/product_service.rb +30 -0
  77. data/lib/stripe/services/climate/supplier_service.rb +30 -0
  78. data/lib/stripe/services/climate_service.rb +15 -0
  79. data/lib/stripe/services/confirmation_token_service.rb +17 -0
  80. data/lib/stripe/services/country_spec_service.rb +28 -0
  81. data/lib/stripe/services/coupon_service.rb +51 -0
  82. data/lib/stripe/services/credit_note_line_item_service.rb +17 -0
  83. data/lib/stripe/services/credit_note_preview_lines_service.rb +17 -0
  84. data/lib/stripe/services/credit_note_service.rb +93 -0
  85. data/lib/stripe/services/customer_balance_transaction_service.rb +50 -0
  86. data/lib/stripe/services/customer_cash_balance_service.rb +28 -0
  87. data/lib/stripe/services/customer_cash_balance_transaction_service.rb +28 -0
  88. data/lib/stripe/services/customer_funding_instructions_service.rb +19 -0
  89. data/lib/stripe/services/customer_payment_method_service.rb +28 -0
  90. data/lib/stripe/services/customer_payment_source_service.rb +76 -0
  91. data/lib/stripe/services/customer_service.rb +89 -0
  92. data/lib/stripe/services/customer_session_service.rb +17 -0
  93. data/lib/stripe/services/customer_tax_id_service.rb +50 -0
  94. data/lib/stripe/services/dispute_service.rb +48 -0
  95. data/lib/stripe/services/entitlements/active_entitlement_service.rb +30 -0
  96. data/lib/stripe/services/entitlements/feature_service.rb +52 -0
  97. data/lib/stripe/services/entitlements_service.rb +14 -0
  98. data/lib/stripe/services/ephemeral_key_service.rb +28 -0
  99. data/lib/stripe/services/event_service.rb +22 -0
  100. data/lib/stripe/services/exchange_rate_service.rb +28 -0
  101. data/lib/stripe/services/file_link_service.rb +38 -0
  102. data/lib/stripe/services/file_service.rb +35 -0
  103. data/lib/stripe/services/financial_connections/account_owner_service.rb +19 -0
  104. data/lib/stripe/services/financial_connections/account_service.rb +81 -0
  105. data/lib/stripe/services/financial_connections/session_service.rb +30 -0
  106. data/lib/stripe/services/financial_connections/transaction_service.rb +30 -0
  107. data/lib/stripe/services/financial_connections_service.rb +15 -0
  108. data/lib/stripe/services/forwarding/request_service.rb +41 -0
  109. data/lib/stripe/services/forwarding_service.rb +13 -0
  110. data/lib/stripe/services/identity/verification_report_service.rb +30 -0
  111. data/lib/stripe/services/identity/verification_session_service.rb +106 -0
  112. data/lib/stripe/services/identity_service.rb +14 -0
  113. data/lib/stripe/services/invoice_item_service.rb +61 -0
  114. data/lib/stripe/services/invoice_line_item_service.rb +31 -0
  115. data/lib/stripe/services/invoice_rendering_template_service.rb +50 -0
  116. data/lib/stripe/services/invoice_service.rb +202 -0
  117. data/lib/stripe/services/invoice_upcoming_lines_service.rb +17 -0
  118. data/lib/stripe/services/issuing/authorization_service.rb +65 -0
  119. data/lib/stripe/services/issuing/card_service.rb +52 -0
  120. data/lib/stripe/services/issuing/cardholder_service.rb +52 -0
  121. data/lib/stripe/services/issuing/dispute_service.rb +63 -0
  122. data/lib/stripe/services/issuing/personalization_design_service.rb +52 -0
  123. data/lib/stripe/services/issuing/physical_bundle_service.rb +30 -0
  124. data/lib/stripe/services/issuing/token_service.rb +41 -0
  125. data/lib/stripe/services/issuing/transaction_service.rb +41 -0
  126. data/lib/stripe/services/issuing_service.rb +20 -0
  127. data/lib/stripe/services/mandate_service.rb +17 -0
  128. data/lib/stripe/services/oauth_service.rb +63 -0
  129. data/lib/stripe/services/payment_intent_service.rb +204 -0
  130. data/lib/stripe/services/payment_link_line_item_service.rb +17 -0
  131. data/lib/stripe/services/payment_link_service.rb +57 -0
  132. data/lib/stripe/services/payment_method_configuration_service.rb +50 -0
  133. data/lib/stripe/services/payment_method_domain_service.rb +66 -0
  134. data/lib/stripe/services/payment_method_service.rb +86 -0
  135. data/lib/stripe/services/payout_service.rb +66 -0
  136. data/lib/stripe/services/plan_service.rb +49 -0
  137. data/lib/stripe/services/price_service.rb +52 -0
  138. data/lib/stripe/services/product_feature_service.rb +50 -0
  139. data/lib/stripe/services/product_service.rb +70 -0
  140. data/lib/stripe/services/promotion_code_service.rb +50 -0
  141. data/lib/stripe/services/quote_computed_upfront_line_items_service.rb +17 -0
  142. data/lib/stripe/services/quote_line_item_service.rb +17 -0
  143. data/lib/stripe/services/quote_service.rb +92 -0
  144. data/lib/stripe/services/radar/early_fraud_warning_service.rb +32 -0
  145. data/lib/stripe/services/radar/value_list_item_service.rb +52 -0
  146. data/lib/stripe/services/radar/value_list_service.rb +63 -0
  147. data/lib/stripe/services/radar_service.rb +15 -0
  148. data/lib/stripe/services/refund_service.rb +63 -0
  149. data/lib/stripe/services/reporting/report_run_service.rb +41 -0
  150. data/lib/stripe/services/reporting/report_type_service.rb +30 -0
  151. data/lib/stripe/services/reporting_service.rb +14 -0
  152. data/lib/stripe/services/review_service.rb +33 -0
  153. data/lib/stripe/services/setup_attempt_service.rb +17 -0
  154. data/lib/stripe/services/setup_intent_service.rb +105 -0
  155. data/lib/stripe/services/shipping_rate_service.rb +50 -0
  156. data/lib/stripe/services/sigma/scheduled_query_run_service.rb +30 -0
  157. data/lib/stripe/services/sigma_service.rb +13 -0
  158. data/lib/stripe/services/source_service.rb +64 -0
  159. data/lib/stripe/services/source_transaction_service.rb +17 -0
  160. data/lib/stripe/services/subscription_item_service.rb +69 -0
  161. data/lib/stripe/services/subscription_item_usage_record_service.rb +23 -0
  162. data/lib/stripe/services/subscription_item_usage_record_summary_service.rb +19 -0
  163. data/lib/stripe/services/subscription_schedule_service.rb +72 -0
  164. data/lib/stripe/services/subscription_service.rb +127 -0
  165. data/lib/stripe/services/tax/calculation_line_item_service.rb +19 -0
  166. data/lib/stripe/services/tax/calculation_service.rb +37 -0
  167. data/lib/stripe/services/tax/registration_service.rb +54 -0
  168. data/lib/stripe/services/tax/settings_service.rb +30 -0
  169. data/lib/stripe/services/tax/transaction_line_item_service.rb +19 -0
  170. data/lib/stripe/services/tax/transaction_service.rb +48 -0
  171. data/lib/stripe/services/tax_code_service.rb +22 -0
  172. data/lib/stripe/services/tax_id_service.rb +38 -0
  173. data/lib/stripe/services/tax_rate_service.rb +38 -0
  174. data/lib/stripe/services/tax_service.rb +16 -0
  175. data/lib/stripe/services/terminal/configuration_service.rb +63 -0
  176. data/lib/stripe/services/terminal/connection_token_service.rb +19 -0
  177. data/lib/stripe/services/terminal/location_service.rb +64 -0
  178. data/lib/stripe/services/terminal/reader_service.rb +118 -0
  179. data/lib/stripe/services/terminal_service.rb +16 -0
  180. data/lib/stripe/services/test_helpers/confirmation_token_service.rb +19 -0
  181. data/lib/stripe/services/test_helpers/customer_service.rb +19 -0
  182. data/lib/stripe/services/test_helpers/issuing/authorization_service.rb +76 -0
  183. data/lib/stripe/services/test_helpers/issuing/card_service.rb +54 -0
  184. data/lib/stripe/services/test_helpers/issuing/personalization_design_service.rb +43 -0
  185. data/lib/stripe/services/test_helpers/issuing/transaction_service.rb +43 -0
  186. data/lib/stripe/services/test_helpers/issuing_service.rb +19 -0
  187. data/lib/stripe/services/test_helpers/refund_service.rb +19 -0
  188. data/lib/stripe/services/test_helpers/terminal/reader_service.rb +21 -0
  189. data/lib/stripe/services/test_helpers/terminal_service.rb +15 -0
  190. data/lib/stripe/services/test_helpers/test_clock_service.rb +63 -0
  191. data/lib/stripe/services/test_helpers/treasury/inbound_transfer_service.rb +43 -0
  192. data/lib/stripe/services/test_helpers/treasury/outbound_payment_service.rb +54 -0
  193. data/lib/stripe/services/test_helpers/treasury/outbound_transfer_service.rb +54 -0
  194. data/lib/stripe/services/test_helpers/treasury/received_credit_service.rb +21 -0
  195. data/lib/stripe/services/test_helpers/treasury/received_debit_service.rb +21 -0
  196. data/lib/stripe/services/test_helpers/treasury_service.rb +19 -0
  197. data/lib/stripe/services/test_helpers_service.rb +19 -0
  198. data/lib/stripe/services/token_service.rb +23 -0
  199. data/lib/stripe/services/topup_service.rb +49 -0
  200. data/lib/stripe/services/transfer_reversal_service.rb +56 -0
  201. data/lib/stripe/services/transfer_service.rb +47 -0
  202. data/lib/stripe/services/treasury/credit_reversal_service.rb +41 -0
  203. data/lib/stripe/services/treasury/debit_reversal_service.rb +41 -0
  204. data/lib/stripe/services/treasury/financial_account_features_service.rb +30 -0
  205. data/lib/stripe/services/treasury/financial_account_service.rb +59 -0
  206. data/lib/stripe/services/treasury/inbound_transfer_service.rb +52 -0
  207. data/lib/stripe/services/treasury/outbound_payment_service.rb +52 -0
  208. data/lib/stripe/services/treasury/outbound_transfer_service.rb +52 -0
  209. data/lib/stripe/services/treasury/received_credit_service.rb +30 -0
  210. data/lib/stripe/services/treasury/received_debit_service.rb +30 -0
  211. data/lib/stripe/services/treasury/transaction_entry_service.rb +30 -0
  212. data/lib/stripe/services/treasury/transaction_service.rb +30 -0
  213. data/lib/stripe/services/treasury_service.rb +22 -0
  214. data/lib/stripe/services/v1_services.rb +89 -0
  215. data/lib/stripe/services/v2/billing/meter_event_adjustment_service.rb +21 -0
  216. data/lib/stripe/services/v2/billing/meter_event_service.rb +21 -0
  217. data/lib/stripe/services/v2/billing/meter_event_session_service.rb +21 -0
  218. data/lib/stripe/services/v2/billing/meter_event_stream_service.rb +23 -0
  219. data/lib/stripe/services/v2/billing_service.rb +18 -0
  220. data/lib/stripe/services/v2/core/event_service.rb +32 -0
  221. data/lib/stripe/services/v2/core_service.rb +15 -0
  222. data/lib/stripe/services/v2_services.rb +14 -0
  223. data/lib/stripe/services/webhook_endpoint_service.rb +61 -0
  224. data/lib/stripe/services.rb +181 -0
  225. data/lib/stripe/singleton_api_resource.rb +1 -18
  226. data/lib/stripe/stripe_client.rb +51 -1067
  227. data/lib/stripe/stripe_configuration.rb +32 -20
  228. data/lib/stripe/stripe_object.rb +37 -18
  229. data/lib/stripe/stripe_service.rb +32 -0
  230. data/lib/stripe/thin_event.rb +17 -0
  231. data/lib/stripe/util.rb +69 -46
  232. data/lib/stripe/v2_list_object.rb +84 -0
  233. data/lib/stripe/version.rb +1 -1
  234. data/lib/stripe/webhook.rb +1 -1
  235. data/lib/stripe.rb +15 -54
  236. metadata +203 -23
  237. data/lib/stripe/request_signing_authenticator.rb +0 -79
  238. data/lib/stripe/resources/account_notice.rb +0 -32
  239. data/lib/stripe/resources/capital/financing_offer.rb +0 -49
  240. data/lib/stripe/resources/capital/financing_summary.rb +0 -15
  241. data/lib/stripe/resources/capital/financing_transaction.rb +0 -27
  242. data/lib/stripe/resources/financial_connections/account_inferred_balance.rb +0 -14
  243. data/lib/stripe/resources/financial_connections/institution.rb +0 -26
  244. data/lib/stripe/resources/gift_cards/card.rb +0 -59
  245. data/lib/stripe/resources/gift_cards/transaction.rb +0 -93
  246. data/lib/stripe/resources/invoice_payment.rb +0 -12
  247. data/lib/stripe/resources/issuing/credit_underwriting_record.rb +0 -88
  248. data/lib/stripe/resources/issuing/dispute_settlement_detail.rb +0 -26
  249. data/lib/stripe/resources/margin.rb +0 -37
  250. data/lib/stripe/resources/order.rb +0 -120
  251. data/lib/stripe/resources/quote_preview_invoice.rb +0 -43
  252. data/lib/stripe/resources/quote_preview_subscription_schedule.rb +0 -11
  253. data/lib/stripe/resources/tax/association.rb +0 -24
  254. data/lib/stripe/resources/tax/form.rb +0 -49
  255. data/lib/stripe/resources/terminal/reader_collected_data.rb +0 -14
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class ConfirmationTokenService < StripeService
6
+ # Retrieves an existing ConfirmationToken object
7
+ def retrieve(confirmation_token, params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: format("/v1/confirmation_tokens/%<confirmation_token>s", { confirmation_token: CGI.escape(confirmation_token) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CountrySpecService < StripeService
6
+ # Lists all Country Spec objects available in the API.
7
+ def list(params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: "/v1/country_specs",
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+
17
+ # Returns a Country Spec for a given Country code.
18
+ def retrieve(country, params = {}, opts = {})
19
+ request(
20
+ method: :get,
21
+ path: format("/v1/country_specs/%<country>s", { country: CGI.escape(country) }),
22
+ params: params,
23
+ opts: opts,
24
+ base_address: :api
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,51 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CouponService < StripeService
6
+ # 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.
7
+ #
8
+ # 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.
9
+ def create(params = {}, opts = {})
10
+ request(method: :post, path: "/v1/coupons", params: params, opts: opts, base_address: :api)
11
+ end
12
+
13
+ # 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.
14
+ def delete(coupon, params = {}, opts = {})
15
+ request(
16
+ method: :delete,
17
+ path: format("/v1/coupons/%<coupon>s", { coupon: CGI.escape(coupon) }),
18
+ params: params,
19
+ opts: opts,
20
+ base_address: :api
21
+ )
22
+ end
23
+
24
+ # Returns a list of your coupons.
25
+ def list(params = {}, opts = {})
26
+ request(method: :get, path: "/v1/coupons", params: params, opts: opts, base_address: :api)
27
+ end
28
+
29
+ # Retrieves the coupon with the given ID.
30
+ def retrieve(coupon, params = {}, opts = {})
31
+ request(
32
+ method: :get,
33
+ path: format("/v1/coupons/%<coupon>s", { coupon: CGI.escape(coupon) }),
34
+ params: params,
35
+ opts: opts,
36
+ base_address: :api
37
+ )
38
+ end
39
+
40
+ # Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
41
+ def update(coupon, params = {}, opts = {})
42
+ request(
43
+ method: :post,
44
+ path: format("/v1/coupons/%<coupon>s", { coupon: CGI.escape(coupon) }),
45
+ params: params,
46
+ opts: opts,
47
+ base_address: :api
48
+ )
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CreditNoteLineItemService < StripeService
6
+ # When retrieving a credit note, you'll get a lines property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
7
+ def list(credit_note, params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: format("/v1/credit_notes/%<credit_note>s/lines", { credit_note: CGI.escape(credit_note) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CreditNotePreviewLinesService < StripeService
6
+ # When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.
7
+ def list(params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: "/v1/credit_notes/preview/lines",
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,93 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CreditNoteService < StripeService
6
+ attr_reader :line_items, :preview_lines
7
+
8
+ def initialize(requestor)
9
+ super(requestor)
10
+ @line_items = Stripe::CreditNoteLineItemService.new(@requestor)
11
+ @preview_lines = Stripe::CreditNotePreviewLinesService.new(@requestor)
12
+ end
13
+
14
+ # Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces
15
+ # its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result
16
+ # in any combination of the following:
17
+ #
18
+ #
19
+ # Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
20
+ # Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized.
21
+ # Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
22
+ #
23
+ #
24
+ # For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
25
+ #
26
+ # You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount
27
+ # or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
28
+ def create(params = {}, opts = {})
29
+ request(
30
+ method: :post,
31
+ path: "/v1/credit_notes",
32
+ params: params,
33
+ opts: opts,
34
+ base_address: :api
35
+ )
36
+ end
37
+
38
+ # Returns a list of credit notes.
39
+ def list(params = {}, opts = {})
40
+ request(
41
+ method: :get,
42
+ path: "/v1/credit_notes",
43
+ params: params,
44
+ opts: opts,
45
+ base_address: :api
46
+ )
47
+ end
48
+
49
+ # Get a preview of a credit note without creating it.
50
+ def preview(params = {}, opts = {})
51
+ request(
52
+ method: :get,
53
+ path: "/v1/credit_notes/preview",
54
+ params: params,
55
+ opts: opts,
56
+ base_address: :api
57
+ )
58
+ end
59
+
60
+ # Retrieves the credit note object with the given identifier.
61
+ def retrieve(id, params = {}, opts = {})
62
+ request(
63
+ method: :get,
64
+ path: format("/v1/credit_notes/%<id>s", { id: CGI.escape(id) }),
65
+ params: params,
66
+ opts: opts,
67
+ base_address: :api
68
+ )
69
+ end
70
+
71
+ # Updates an existing credit note.
72
+ def update(id, params = {}, opts = {})
73
+ request(
74
+ method: :post,
75
+ path: format("/v1/credit_notes/%<id>s", { id: CGI.escape(id) }),
76
+ params: params,
77
+ opts: opts,
78
+ base_address: :api
79
+ )
80
+ end
81
+
82
+ # Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
83
+ def void_credit_note(id, params = {}, opts = {})
84
+ request(
85
+ method: :post,
86
+ path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(id) }),
87
+ params: params,
88
+ opts: opts,
89
+ base_address: :api
90
+ )
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,50 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerBalanceTransactionService < StripeService
6
+ # Creates an immutable transaction that updates the customer's credit [balance](https://stripe.com/docs/billing/customer/balance).
7
+ def create(customer, params = {}, opts = {})
8
+ request(
9
+ method: :post,
10
+ path: format("/v1/customers/%<customer>s/balance_transactions", { customer: CGI.escape(customer) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+
17
+ # Returns a list of transactions that updated the customer's [balances](https://stripe.com/docs/billing/customer/balance).
18
+ def list(customer, params = {}, opts = {})
19
+ request(
20
+ method: :get,
21
+ path: format("/v1/customers/%<customer>s/balance_transactions", { customer: CGI.escape(customer) }),
22
+ params: params,
23
+ opts: opts,
24
+ base_address: :api
25
+ )
26
+ end
27
+
28
+ # Retrieves a specific customer balance transaction that updated the customer's [balances](https://stripe.com/docs/billing/customer/balance).
29
+ def retrieve(customer, transaction, params = {}, opts = {})
30
+ request(
31
+ method: :get,
32
+ path: format("/v1/customers/%<customer>s/balance_transactions/%<transaction>s", { customer: CGI.escape(customer), transaction: CGI.escape(transaction) }),
33
+ params: params,
34
+ opts: opts,
35
+ base_address: :api
36
+ )
37
+ end
38
+
39
+ # Most credit balance transaction fields are immutable, but you may update its description and metadata.
40
+ def update(customer, transaction, params = {}, opts = {})
41
+ request(
42
+ method: :post,
43
+ path: format("/v1/customers/%<customer>s/balance_transactions/%<transaction>s", { customer: CGI.escape(customer), transaction: CGI.escape(transaction) }),
44
+ params: params,
45
+ opts: opts,
46
+ base_address: :api
47
+ )
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,28 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerCashBalanceService < StripeService
6
+ # Retrieves a customer's cash balance.
7
+ def retrieve(customer, params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+
17
+ # Changes the settings on a customer's cash balance.
18
+ def update(customer, params = {}, opts = {})
19
+ request(
20
+ method: :post,
21
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
22
+ params: params,
23
+ opts: opts,
24
+ base_address: :api
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerCashBalanceTransactionService < StripeService
6
+ # Returns a list of transactions that modified the customer's [cash balance](https://stripe.com/docs/payments/customer-balance).
7
+ def list(customer, params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: format("/v1/customers/%<customer>s/cash_balance_transactions", { customer: CGI.escape(customer) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+
17
+ # Retrieves a specific cash balance transaction, which updated the customer's [cash balance](https://stripe.com/docs/payments/customer-balance).
18
+ def retrieve(customer, transaction, params = {}, opts = {})
19
+ request(
20
+ method: :get,
21
+ path: format("/v1/customers/%<customer>s/cash_balance_transactions/%<transaction>s", { customer: CGI.escape(customer), transaction: CGI.escape(transaction) }),
22
+ params: params,
23
+ opts: opts,
24
+ base_address: :api
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerFundingInstructionsService < StripeService
6
+ # Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new
7
+ # funding instructions will be created. If funding instructions have already been created for a given customer, the same
8
+ # funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
9
+ def create(customer, params = {}, opts = {})
10
+ request(
11
+ method: :post,
12
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(customer) }),
13
+ params: params,
14
+ opts: opts,
15
+ base_address: :api
16
+ )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerPaymentMethodService < StripeService
6
+ # Returns a list of PaymentMethods for a given Customer
7
+ def list(customer, params = {}, opts = {})
8
+ request(
9
+ method: :get,
10
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(customer) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+
17
+ # Retrieves a PaymentMethod object for a given Customer.
18
+ def retrieve(customer, payment_method, params = {}, opts = {})
19
+ request(
20
+ method: :get,
21
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }),
22
+ params: params,
23
+ opts: opts,
24
+ base_address: :api
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,76 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerPaymentSourceService < StripeService
6
+ # When you create a new credit card, you must specify a customer or recipient on which to create it.
7
+ #
8
+ # If the card's owner has no default card, then the new card will become the default.
9
+ # However, if the owner already has a default, then it will not change.
10
+ # To change the default, you should [update the customer](https://stripe.com/docs/api#update_customer) to have a new default_source.
11
+ def create(customer, params = {}, opts = {})
12
+ request(
13
+ method: :post,
14
+ path: format("/v1/customers/%<customer>s/sources", { customer: CGI.escape(customer) }),
15
+ params: params,
16
+ opts: opts,
17
+ base_address: :api
18
+ )
19
+ end
20
+
21
+ # Delete a specified source for a given customer.
22
+ def delete(customer, id, params = {}, opts = {})
23
+ request(
24
+ method: :delete,
25
+ path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
26
+ params: params,
27
+ opts: opts,
28
+ base_address: :api
29
+ )
30
+ end
31
+
32
+ # List sources for a specified customer.
33
+ def list(customer, params = {}, opts = {})
34
+ request(
35
+ method: :get,
36
+ path: format("/v1/customers/%<customer>s/sources", { customer: CGI.escape(customer) }),
37
+ params: params,
38
+ opts: opts,
39
+ base_address: :api
40
+ )
41
+ end
42
+
43
+ # Retrieve a specified source for a given customer.
44
+ def retrieve(customer, id, params = {}, opts = {})
45
+ request(
46
+ method: :get,
47
+ path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
48
+ params: params,
49
+ opts: opts,
50
+ base_address: :api
51
+ )
52
+ end
53
+
54
+ # Update a specified source for a given customer.
55
+ def update(customer, id, params = {}, opts = {})
56
+ request(
57
+ method: :post,
58
+ path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
59
+ params: params,
60
+ opts: opts,
61
+ base_address: :api
62
+ )
63
+ end
64
+
65
+ # Verify a specified bank account for a given customer.
66
+ def verify(customer, id, params = {}, opts = {})
67
+ request(
68
+ method: :post,
69
+ path: format("/v1/customers/%<customer>s/sources/%<id>s/verify", { customer: CGI.escape(customer), id: CGI.escape(id) }),
70
+ params: params,
71
+ opts: opts,
72
+ base_address: :api
73
+ )
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,89 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerService < StripeService
6
+ attr_reader :cash_balance, :balance_transactions, :cash_balance_transactions, :payment_sources, :tax_ids, :payment_methods, :funding_instructions
7
+
8
+ def initialize(requestor)
9
+ super(requestor)
10
+ @cash_balance = Stripe::CustomerCashBalanceService.new(@requestor)
11
+ @balance_transactions = Stripe::CustomerBalanceTransactionService.new(@requestor)
12
+ @cash_balance_transactions = Stripe::CustomerCashBalanceTransactionService.new(@requestor)
13
+ @payment_sources = Stripe::CustomerPaymentSourceService.new(@requestor)
14
+ @tax_ids = Stripe::CustomerTaxIdService.new(@requestor)
15
+ @payment_methods = Stripe::CustomerPaymentMethodService.new(@requestor)
16
+ @funding_instructions = Stripe::CustomerFundingInstructionsService.new(@requestor)
17
+ end
18
+
19
+ # Creates a new customer object.
20
+ def create(params = {}, opts = {})
21
+ request(method: :post, path: "/v1/customers", params: params, opts: opts, base_address: :api)
22
+ end
23
+
24
+ # Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
25
+ def delete(customer, params = {}, opts = {})
26
+ request(
27
+ method: :delete,
28
+ path: format("/v1/customers/%<customer>s", { customer: CGI.escape(customer) }),
29
+ params: params,
30
+ opts: opts,
31
+ base_address: :api
32
+ )
33
+ end
34
+
35
+ # Removes the currently applied discount on a customer.
36
+ def delete_discount(customer, params = {}, opts = {})
37
+ request(
38
+ method: :delete,
39
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(customer) }),
40
+ params: params,
41
+ opts: opts,
42
+ base_address: :api
43
+ )
44
+ end
45
+
46
+ # Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
47
+ def list(params = {}, opts = {})
48
+ request(method: :get, path: "/v1/customers", params: params, opts: opts, base_address: :api)
49
+ end
50
+
51
+ # Retrieves a Customer object.
52
+ def retrieve(customer, params = {}, opts = {})
53
+ request(
54
+ method: :get,
55
+ path: format("/v1/customers/%<customer>s", { customer: CGI.escape(customer) }),
56
+ params: params,
57
+ opts: opts,
58
+ base_address: :api
59
+ )
60
+ end
61
+
62
+ # Search for customers you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
63
+ # Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating
64
+ # conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
65
+ # to an hour behind during outages. Search functionality is not available to merchants in India.
66
+ def search(params = {}, opts = {})
67
+ request(
68
+ method: :get,
69
+ path: "/v1/customers/search",
70
+ params: params,
71
+ opts: opts,
72
+ base_address: :api
73
+ )
74
+ end
75
+
76
+ # Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer's active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer's current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.
77
+ #
78
+ # This request accepts mostly the same arguments as the customer creation call.
79
+ def update(customer, params = {}, opts = {})
80
+ request(
81
+ method: :post,
82
+ path: format("/v1/customers/%<customer>s", { customer: CGI.escape(customer) }),
83
+ params: params,
84
+ opts: opts,
85
+ base_address: :api
86
+ )
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerSessionService < StripeService
6
+ # Creates a Customer Session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources.
7
+ def create(params = {}, opts = {})
8
+ request(
9
+ method: :post,
10
+ path: "/v1/customer_sessions",
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,50 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class CustomerTaxIdService < StripeService
6
+ # Creates a new tax_id object for a customer.
7
+ def create(customer, params = {}, opts = {})
8
+ request(
9
+ method: :post,
10
+ path: format("/v1/customers/%<customer>s/tax_ids", { customer: CGI.escape(customer) }),
11
+ params: params,
12
+ opts: opts,
13
+ base_address: :api
14
+ )
15
+ end
16
+
17
+ # Deletes an existing tax_id object.
18
+ def delete(customer, id, params = {}, opts = {})
19
+ request(
20
+ method: :delete,
21
+ path: format("/v1/customers/%<customer>s/tax_ids/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
22
+ params: params,
23
+ opts: opts,
24
+ base_address: :api
25
+ )
26
+ end
27
+
28
+ # Returns a list of tax IDs for a customer.
29
+ def list(customer, params = {}, opts = {})
30
+ request(
31
+ method: :get,
32
+ path: format("/v1/customers/%<customer>s/tax_ids", { customer: CGI.escape(customer) }),
33
+ params: params,
34
+ opts: opts,
35
+ base_address: :api
36
+ )
37
+ end
38
+
39
+ # Retrieves the tax_id object with the given identifier.
40
+ def retrieve(customer, id, params = {}, opts = {})
41
+ request(
42
+ method: :get,
43
+ path: format("/v1/customers/%<customer>s/tax_ids/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
44
+ params: params,
45
+ opts: opts,
46
+ base_address: :api
47
+ )
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,48 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class DisputeService < StripeService
6
+ # Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost.
7
+ #
8
+ # The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible.
9
+ def close(dispute, params = {}, opts = {})
10
+ request(
11
+ method: :post,
12
+ path: format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(dispute) }),
13
+ params: params,
14
+ opts: opts,
15
+ base_address: :api
16
+ )
17
+ end
18
+
19
+ # Returns a list of your disputes.
20
+ def list(params = {}, opts = {})
21
+ request(method: :get, path: "/v1/disputes", params: params, opts: opts, base_address: :api)
22
+ end
23
+
24
+ # Retrieves the dispute with the given ID.
25
+ def retrieve(dispute, params = {}, opts = {})
26
+ request(
27
+ method: :get,
28
+ path: format("/v1/disputes/%<dispute>s", { dispute: CGI.escape(dispute) }),
29
+ params: params,
30
+ opts: opts,
31
+ base_address: :api
32
+ )
33
+ end
34
+
35
+ # When you get a dispute, contacting your customer is always the best first step. If that doesn't work, you can submit evidence to help us resolve the dispute in your favor. You can do this in your [dashboard](https://dashboard.stripe.com/disputes), but if you prefer, you can use the API to submit evidence programmatically.
36
+ #
37
+ # Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. To figure out which evidence fields to provide, see our [guide to dispute types](https://stripe.com/docs/disputes/categories).
38
+ def update(dispute, params = {}, opts = {})
39
+ request(
40
+ method: :post,
41
+ path: format("/v1/disputes/%<dispute>s", { dispute: CGI.escape(dispute) }),
42
+ params: params,
43
+ opts: opts,
44
+ base_address: :api
45
+ )
46
+ end
47
+ end
48
+ end