stripe 5.39.0 → 10.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +304 -0
  3. data/Gemfile +5 -2
  4. data/Makefile +13 -0
  5. data/OPENAPI_VERSION +1 -0
  6. data/README.md +40 -6
  7. data/VERSION +1 -1
  8. data/lib/data/ca-certificates.crt +1241 -1937
  9. data/lib/stripe/api_operations/create.rb +6 -2
  10. data/lib/stripe/api_operations/delete.rb +12 -7
  11. data/lib/stripe/api_operations/list.rb +6 -9
  12. data/lib/stripe/api_operations/nested_resource.rb +62 -34
  13. data/lib/stripe/api_operations/request.rb +10 -0
  14. data/lib/stripe/api_operations/save.rb +13 -3
  15. data/lib/stripe/api_operations/search.rb +16 -0
  16. data/lib/stripe/api_resource.rb +3 -18
  17. data/lib/stripe/api_resource_test_helpers.rb +49 -0
  18. data/lib/stripe/api_version.rb +8 -0
  19. data/lib/stripe/connection_manager.rb +22 -1
  20. data/lib/stripe/instrumentation.rb +45 -7
  21. data/lib/stripe/object_types.rb +35 -10
  22. data/lib/stripe/resources/account.rb +37 -11
  23. data/lib/stripe/resources/account_link.rb +4 -0
  24. data/lib/stripe/resources/account_session.rb +17 -0
  25. data/lib/stripe/resources/application_fee.rb +1 -2
  26. data/lib/stripe/resources/application_fee_refund.rb +5 -0
  27. data/lib/stripe/resources/apps/secret.rb +40 -0
  28. data/lib/stripe/resources/balance.rb +11 -0
  29. data/lib/stripe/resources/balance_transaction.rb +4 -0
  30. data/lib/stripe/resources/bank_account.rb +7 -0
  31. data/lib/stripe/resources/billing_portal/configuration.rb +1 -0
  32. data/lib/stripe/resources/billing_portal/session.rb +14 -0
  33. data/lib/stripe/resources/capability.rb +3 -0
  34. data/lib/stripe/resources/card.rb +6 -3
  35. data/lib/stripe/resources/cash_balance.rb +23 -0
  36. data/lib/stripe/resources/charge.rb +23 -3
  37. data/lib/stripe/resources/checkout/session.rb +49 -2
  38. data/lib/stripe/resources/country_spec.rb +6 -0
  39. data/lib/stripe/resources/coupon.rb +3 -0
  40. data/lib/stripe/resources/credit_note.rb +27 -9
  41. data/lib/stripe/resources/credit_note_line_item.rb +1 -0
  42. data/lib/stripe/resources/customer.rb +119 -15
  43. data/lib/stripe/resources/customer_balance_transaction.rb +6 -0
  44. data/lib/stripe/resources/customer_cash_balance_transaction.rb +14 -0
  45. data/lib/stripe/resources/discount.rb +5 -0
  46. data/lib/stripe/resources/dispute.rb +15 -3
  47. data/lib/stripe/resources/event.rb +30 -0
  48. data/lib/stripe/resources/exchange_rate.rb +26 -0
  49. data/lib/stripe/resources/file.rb +7 -0
  50. data/lib/stripe/resources/file_link.rb +3 -0
  51. data/lib/stripe/resources/financial_connections/account.rb +67 -0
  52. data/lib/stripe/resources/financial_connections/account_owner.rb +11 -0
  53. data/lib/stripe/resources/financial_connections/account_ownership.rb +11 -0
  54. data/lib/stripe/resources/financial_connections/session.rb +13 -0
  55. data/lib/stripe/resources/funding_instructions.rb +21 -0
  56. data/lib/stripe/resources/identity/verification_report.rb +11 -0
  57. data/lib/stripe/resources/identity/verification_session.rb +31 -5
  58. data/lib/stripe/resources/invoice.rb +100 -17
  59. data/lib/stripe/resources/invoice_item.rb +11 -0
  60. data/lib/stripe/resources/issuing/authorization.rb +114 -5
  61. data/lib/stripe/resources/issuing/card.rb +78 -8
  62. data/lib/stripe/resources/issuing/cardholder.rb +3 -0
  63. data/lib/stripe/resources/issuing/dispute.rb +13 -3
  64. data/lib/stripe/resources/issuing/token.rb +14 -0
  65. data/lib/stripe/resources/issuing/transaction.rb +49 -0
  66. data/lib/stripe/resources/line_item.rb +1 -0
  67. data/lib/stripe/resources/login_link.rb +1 -0
  68. data/lib/stripe/resources/mandate.rb +1 -0
  69. data/lib/stripe/resources/payment_intent.rb +103 -6
  70. data/lib/stripe/resources/payment_link.rb +35 -0
  71. data/lib/stripe/resources/payment_method.rb +25 -5
  72. data/lib/stripe/resources/payment_method_configuration.rb +26 -0
  73. data/lib/stripe/resources/payment_method_domain.rb +34 -0
  74. data/lib/stripe/resources/payout.rb +28 -5
  75. data/lib/stripe/resources/person.rb +6 -0
  76. data/lib/stripe/resources/plan.rb +8 -0
  77. data/lib/stripe/resources/price.rb +15 -0
  78. data/lib/stripe/resources/product.rb +17 -0
  79. data/lib/stripe/resources/promotion_code.rb +2 -0
  80. data/lib/stripe/resources/quote.rb +58 -35
  81. data/lib/stripe/resources/radar/early_fraud_warning.rb +4 -0
  82. data/lib/stripe/resources/radar/value_list.rb +3 -0
  83. data/lib/stripe/resources/radar/value_list_item.rb +3 -0
  84. data/lib/stripe/resources/refund.rb +49 -0
  85. data/lib/stripe/resources/reporting/report_run.rb +8 -0
  86. data/lib/stripe/resources/reporting/report_type.rb +8 -1
  87. data/lib/stripe/resources/reversal.rb +13 -0
  88. data/lib/stripe/resources/review.rb +14 -3
  89. data/lib/stripe/resources/setup_attempt.rb +4 -0
  90. data/lib/stripe/resources/setup_intent.rb +59 -5
  91. data/lib/stripe/resources/shipping_rate.rb +14 -0
  92. data/lib/stripe/resources/sigma/scheduled_query_run.rb +4 -0
  93. data/lib/stripe/resources/source.rb +27 -8
  94. data/lib/stripe/resources/source_transaction.rb +5 -0
  95. data/lib/stripe/resources/subscription.rb +57 -3
  96. data/lib/stripe/resources/subscription_item.rb +2 -7
  97. data/lib/stripe/resources/subscription_schedule.rb +23 -5
  98. data/lib/stripe/resources/tax/calculation.rb +33 -0
  99. data/lib/stripe/resources/tax/calculation_line_item.rb +10 -0
  100. data/lib/stripe/resources/tax/registration.rb +19 -0
  101. data/lib/stripe/resources/tax/settings.rb +15 -0
  102. data/lib/stripe/resources/tax/transaction.rb +49 -0
  103. data/lib/stripe/resources/tax/transaction_line_item.rb +10 -0
  104. data/lib/stripe/resources/tax_code.rb +1 -0
  105. data/lib/stripe/resources/tax_id.rb +4 -0
  106. data/lib/stripe/resources/tax_rate.rb +3 -0
  107. data/lib/stripe/resources/terminal/configuration.rb +16 -0
  108. data/lib/stripe/resources/terminal/connection_token.rb +3 -0
  109. data/lib/stripe/resources/terminal/location.rb +3 -0
  110. data/lib/stripe/resources/terminal/reader.rb +119 -0
  111. data/lib/stripe/resources/test_helpers/test_clock.rb +35 -0
  112. data/lib/stripe/resources/token.rb +20 -0
  113. data/lib/stripe/resources/topup.rb +15 -3
  114. data/lib/stripe/resources/transfer.rb +11 -13
  115. data/lib/stripe/resources/treasury/credit_reversal.rb +14 -0
  116. data/lib/stripe/resources/treasury/debit_reversal.rb +14 -0
  117. data/lib/stripe/resources/treasury/financial_account.rb +52 -0
  118. data/lib/stripe/resources/treasury/financial_account_features.rb +12 -0
  119. data/lib/stripe/resources/treasury/inbound_transfer.rb +94 -0
  120. data/lib/stripe/resources/treasury/outbound_payment.rb +96 -0
  121. data/lib/stripe/resources/treasury/outbound_transfer.rb +96 -0
  122. data/lib/stripe/resources/treasury/received_credit.rb +30 -0
  123. data/lib/stripe/resources/treasury/received_debit.rb +30 -0
  124. data/lib/stripe/resources/treasury/transaction.rb +13 -0
  125. data/lib/stripe/resources/treasury/transaction_entry.rb +17 -0
  126. data/lib/stripe/resources/usage_record.rb +4 -0
  127. data/lib/stripe/resources/webhook_endpoint.rb +7 -0
  128. data/lib/stripe/resources.rb +33 -10
  129. data/lib/stripe/search_result_object.rb +86 -0
  130. data/lib/stripe/stripe_client.rb +37 -22
  131. data/lib/stripe/stripe_configuration.rb +5 -1
  132. data/lib/stripe/stripe_object.rb +2 -2
  133. data/lib/stripe/util.rb +85 -2
  134. data/lib/stripe/version.rb +1 -1
  135. data/lib/stripe/webhook.rb +2 -1
  136. data/lib/stripe.rb +5 -1
  137. data/stripe.gemspec +3 -3
  138. metadata +45 -14
  139. data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
  140. data/lib/stripe/resources/bitcoin_transaction.rb +0 -16
  141. data/lib/stripe/resources/issuing/card_details.rb +0 -9
  142. data/lib/stripe/resources/order.rb +0 -33
  143. data/lib/stripe/resources/order_return.rb +0 -10
  144. data/lib/stripe/resources/recipient.rb +0 -14
  145. data/lib/stripe/resources/sku.rb +0 -13
  146. data/lib/stripe/resources/three_d_secure.rb +0 -14
@@ -2,6 +2,10 @@
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
 
@@ -0,0 +1,17 @@
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
+ end
17
+ end
@@ -8,7 +8,6 @@ module Stripe
8
8
 
9
9
  OBJECT_NAME = "application_fee"
10
10
 
11
- nested_resource_class_methods :refund,
12
- operations: %i[create retrieve update list]
11
+ nested_resource_class_methods :refund, operations: %i[create retrieve update list]
13
12
  end
14
13
  end
@@ -2,6 +2,11 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # `Application Fee Refund` objects allow you to refund an application fee that
6
+ # has previously been created but not yet refunded. Funds will be refunded to
7
+ # the Stripe account from which the fee was originally collected.
8
+ #
9
+ # Related guide: [Refunding application fees](https://stripe.com/docs/connect/destination-charges#refunding-app-fee)
5
10
  class ApplicationFeeRefund < APIResource
6
11
  extend Stripe::APIOperations::List
7
12
  include Stripe::APIOperations::Save
@@ -0,0 +1,40 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Apps
6
+ # Secret Store is an API that allows Stripe Apps developers to securely persist secrets for use by UI Extensions and app backends.
7
+ #
8
+ # The primary resource in Secret Store is a `secret`. Other apps can't view secrets created by an app. Additionally, secrets are scoped to provide further permission control.
9
+ #
10
+ # All Dashboard users and the app backend share `account` scoped secrets. Use the `account` scope for secrets that don't change per-user, like a third-party API key.
11
+ #
12
+ # A `user` scoped secret is accessible by the app backend and one specific Dashboard user. Use the `user` scope for per-user secrets like per-user OAuth tokens, where different users might have different permissions.
13
+ #
14
+ # Related guide: [Store data between page reloads](https://stripe.com/docs/stripe-apps/store-auth-data-custom-objects)
15
+ class Secret < APIResource
16
+ extend Stripe::APIOperations::Create
17
+ extend Stripe::APIOperations::List
18
+
19
+ OBJECT_NAME = "apps.secret"
20
+
21
+ def self.delete_where(params = {}, opts = {})
22
+ request_stripe_object(
23
+ method: :post,
24
+ path: "/v1/apps/secrets/delete",
25
+ params: params,
26
+ opts: opts
27
+ )
28
+ end
29
+
30
+ def self.find(params = {}, opts = {})
31
+ request_stripe_object(
32
+ method: :get,
33
+ path: "/v1/apps/secrets/find",
34
+ params: params,
35
+ opts: opts
36
+ )
37
+ end
38
+ end
39
+ end
40
+ end
@@ -2,6 +2,17 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This is an object representing your Stripe balance. You can retrieve it to see
6
+ # the balance currently on your Stripe account.
7
+ #
8
+ # You can also retrieve the balance history, which contains a list of
9
+ # [transactions](https://stripe.com/docs/reporting/balance-transaction-types) that contributed to the balance
10
+ # (charges, payouts, and so forth).
11
+ #
12
+ # The available and pending amounts for each currency are broken down further by
13
+ # payment source types.
14
+ #
15
+ # Related guide: [Understanding Connect account balances](https://stripe.com/docs/connect/account-balances)
5
16
  class Balance < SingletonAPIResource
6
17
  OBJECT_NAME = "balance"
7
18
  end
@@ -2,6 +2,10 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Balance transactions represent funds moving through your Stripe account.
6
+ # Stripe creates them for every type of transaction that enters or leaves your Stripe account balance.
7
+ #
8
+ # Related guide: [Balance transaction types](https://stripe.com/docs/reports/balance-transaction-types)
5
9
  class BalanceTransaction < APIResource
6
10
  extend Stripe::APIOperations::List
7
11
 
@@ -2,6 +2,13 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # These bank accounts are payment methods on `Customer` objects.
6
+ #
7
+ # On the other hand [External Accounts](https://stripe.com/docs/api#external_accounts) are transfer
8
+ # destinations on `Account` objects for [Custom accounts](https://stripe.com/docs/connect/custom-accounts).
9
+ # They can be bank accounts or debit cards as well, and are documented in the links above.
10
+ #
11
+ # Related guide: [Bank debits and transfers](https://stripe.com/docs/payments/bank-debits-transfers)
5
12
  class BankAccount < APIResource
6
13
  include Stripe::APIOperations::Delete
7
14
  extend Stripe::APIOperations::List
@@ -3,6 +3,7 @@
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
@@ -3,6 +3,20 @@
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
+ # Learn more in the [integration guide](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal).
6
20
  class Session < APIResource
7
21
  extend Stripe::APIOperations::Create
8
22
 
@@ -2,6 +2,9 @@
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
9
  extend Stripe::APIOperations::List
7
10
  include Stripe::APIOperations::Save
@@ -2,6 +2,11 @@
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
@@ -10,9 +15,7 @@ module Stripe
10
15
  OBJECT_NAME = "card"
11
16
 
12
17
  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?
18
+ if respond_to?(:customer) && !customer.nil? && !customer.empty?
16
19
  "#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
17
20
  elsif respond_to?(:account) && !account.nil? && !account.empty?
18
21
  "#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
@@ -0,0 +1,23 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
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.
6
+ class CashBalance < APIResource
7
+ OBJECT_NAME = "cash_balance"
8
+
9
+ def resource_url
10
+ if !respond_to?(:customer) || customer.nil?
11
+ raise NotImplementedError,
12
+ "Customer Cash Balance cannot be accessed without a customer ID."
13
+ end
14
+ "#{Customer.resource_url}/#{CGI.escape(customer)}/cash_balance"
15
+ end
16
+
17
+ def self.retrieve(_id, _opts = {})
18
+ raise NotImplementedError,
19
+ "Customer Cash Balance cannot be retrieved without a customer ID. " \
20
+ "Retrieve a Customer Cash Balance using `Customer.retrieve_cash_balance('cus_123')`"
21
+ end
22
+ end
23
+ end
@@ -2,22 +2,42 @@
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::Search
8
13
  include Stripe::APIOperations::Save
9
14
 
10
15
  OBJECT_NAME = "charge"
11
16
 
12
- custom_method :capture, http_verb: :post
13
-
14
17
  def capture(params = {}, opts = {})
15
18
  request_stripe_object(
16
19
  method: :post,
17
- path: resource_url + "/capture",
20
+ path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(self["id"]) }),
21
+ params: params,
22
+ opts: opts
23
+ )
24
+ end
25
+
26
+ def self.capture(charge, params = {}, opts = {})
27
+ request_stripe_object(
28
+ method: :post,
29
+ path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(charge) }),
18
30
  params: params,
19
31
  opts: opts
20
32
  )
21
33
  end
34
+
35
+ def self.search(params = {}, opts = {})
36
+ _search("/v1/charges/search", params, opts)
37
+ end
38
+
39
+ def self.search_auto_paging_each(params = {}, opts = {}, &blk)
40
+ search(params, opts).auto_paging_each(&blk)
41
+ end
22
42
  end
23
43
  end
@@ -3,14 +3,61 @@
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
10
23
 
11
24
  OBJECT_NAME = "checkout.session"
12
25
 
13
- nested_resource_class_methods :line_item, operations: %i[list]
26
+ def expire(params = {}, opts = {})
27
+ request_stripe_object(
28
+ method: :post,
29
+ path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(self["id"]) }),
30
+ params: params,
31
+ opts: opts
32
+ )
33
+ end
34
+
35
+ def list_line_items(params = {}, opts = {})
36
+ request_stripe_object(
37
+ method: :get,
38
+ path: format("/v1/checkout/sessions/%<session>s/line_items", { session: CGI.escape(self["id"]) }),
39
+ params: params,
40
+ opts: opts
41
+ )
42
+ end
43
+
44
+ def self.expire(session, params = {}, opts = {})
45
+ request_stripe_object(
46
+ method: :post,
47
+ path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(session) }),
48
+ params: params,
49
+ opts: opts
50
+ )
51
+ end
52
+
53
+ def self.list_line_items(session, params = {}, opts = {})
54
+ request_stripe_object(
55
+ method: :get,
56
+ path: format("/v1/checkout/sessions/%<session>s/line_items", { session: CGI.escape(session) }),
57
+ params: params,
58
+ opts: opts
59
+ )
60
+ end
14
61
  end
15
62
  end
16
63
  end
@@ -2,6 +2,12 @@
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
 
@@ -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
@@ -2,6 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Issue a credit note to adjust an invoice's amount after the invoice is finalized.
6
+ #
7
+ # Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)
5
8
  class CreditNote < APIResource
6
9
  extend Stripe::APIOperations::Create
7
10
  extend Stripe::APIOperations::List
@@ -9,25 +12,40 @@ module Stripe
9
12
 
10
13
  OBJECT_NAME = "credit_note"
11
14
 
12
- custom_method :void_credit_note, http_verb: :post, http_path: "void"
13
-
14
15
  def void_credit_note(params = {}, opts = {})
15
16
  request_stripe_object(
16
17
  method: :post,
17
- path: resource_url + "/void",
18
+ path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(self["id"]) }),
19
+ params: params,
20
+ opts: opts
21
+ )
22
+ end
23
+
24
+ def self.list_preview_line_items(params = {}, opts = {})
25
+ request_stripe_object(
26
+ method: :get,
27
+ path: "/v1/credit_notes/preview/lines",
18
28
  params: params,
19
29
  opts: opts
20
30
  )
21
31
  end
22
32
 
23
- def self.preview(params, opts = {})
24
- resp, opts = execute_resource_request(:get, resource_url + "/preview", params, opts)
25
- Util.convert_to_stripe_object(resp.data, opts)
33
+ def self.preview(params = {}, opts = {})
34
+ request_stripe_object(
35
+ method: :get,
36
+ path: "/v1/credit_notes/preview",
37
+ params: params,
38
+ opts: opts
39
+ )
26
40
  end
27
41
 
28
- def self.list_preview_line_items(params, opts = {})
29
- resp, opts = execute_resource_request(:get, resource_url + "/preview/lines", params, opts)
30
- Util.convert_to_stripe_object(resp.data, opts)
42
+ def self.void_credit_note(id, params = {}, opts = {})
43
+ request_stripe_object(
44
+ method: :post,
45
+ path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(id) }),
46
+ params: params,
47
+ opts: opts
48
+ )
31
49
  end
32
50
  end
33
51
  end
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # The credit note line item object
5
6
  class CreditNoteLineItem < StripeObject
6
7
  OBJECT_NAME = "credit_note_line_item"
7
8
  end
@@ -2,32 +2,94 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This object represents a customer of your business. Use it to create recurring charges and track payments that belong to the same customer.
6
+ #
7
+ # Related guide: [Save a card during payment](https://stripe.com/docs/payments/save-during-payment)
5
8
  class Customer < APIResource
6
9
  extend Stripe::APIOperations::Create
7
10
  include Stripe::APIOperations::Delete
8
11
  extend Stripe::APIOperations::List
12
+ extend Stripe::APIOperations::Search
9
13
  include Stripe::APIOperations::Save
10
14
  extend Stripe::APIOperations::NestedResource
11
15
 
12
16
  OBJECT_NAME = "customer"
13
17
 
14
- custom_method :list_payment_methods, http_verb: :get, http_path: "payment_methods"
18
+ nested_resource_class_methods :balance_transaction, operations: %i[create retrieve update list]
19
+ nested_resource_class_methods :cash_balance_transaction, operations: %i[retrieve list]
20
+ nested_resource_class_methods :tax_id, operations: %i[create retrieve delete list]
15
21
 
16
- nested_resource_class_methods :balance_transaction,
17
- operations: %i[create retrieve update list]
18
- nested_resource_class_methods :tax_id,
19
- operations: %i[create retrieve delete list]
22
+ def create_funding_instructions(params = {}, opts = {})
23
+ request_stripe_object(
24
+ method: :post,
25
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(self["id"]) }),
26
+ params: params,
27
+ opts: opts
28
+ )
29
+ end
30
+
31
+ def delete_discount(params = {}, opts = {})
32
+ request_stripe_object(
33
+ method: :delete,
34
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(self["id"]) }),
35
+ params: params,
36
+ opts: opts
37
+ )
38
+ end
20
39
 
21
40
  def list_payment_methods(params = {}, opts = {})
22
41
  request_stripe_object(
23
42
  method: :get,
24
- path: resource_url + "/payment_methods",
43
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(self["id"]) }),
44
+ params: params,
45
+ opts: opts
46
+ )
47
+ end
48
+
49
+ def retrieve_payment_method(payment_method, params = {}, opts = {})
50
+ request_stripe_object(
51
+ method: :get,
52
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(self["id"]), payment_method: CGI.escape(payment_method) }),
53
+ params: params,
54
+ opts: opts
55
+ )
56
+ end
57
+
58
+ def self.create_funding_instructions(customer, params = {}, opts = {})
59
+ request_stripe_object(
60
+ method: :post,
61
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(customer) }),
62
+ params: params,
63
+ opts: opts
64
+ )
65
+ end
66
+
67
+ def self.delete_discount(customer, params = {}, opts = {})
68
+ request_stripe_object(
69
+ method: :delete,
70
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(customer) }),
71
+ params: params,
72
+ opts: opts
73
+ )
74
+ end
75
+
76
+ def self.list_payment_methods(customer, params = {}, opts = {})
77
+ request_stripe_object(
78
+ method: :get,
79
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(customer) }),
25
80
  params: params,
26
81
  opts: opts
27
82
  )
28
83
  end
29
84
 
30
- custom_method :delete_discount, http_verb: :delete, http_path: "discount"
85
+ def self.retrieve_payment_method(customer, payment_method, params = {}, opts = {})
86
+ request_stripe_object(
87
+ method: :get,
88
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }),
89
+ params: params,
90
+ opts: opts
91
+ )
92
+ end
31
93
 
32
94
  save_nested_resource :source
33
95
  nested_resource_class_methods :source,
@@ -39,14 +101,56 @@ module Stripe
39
101
  alias detach_source delete_source
40
102
  end
41
103
 
42
- # Deletes a discount associated with the customer.
43
- #
44
- # Returns the deleted discount. The customer object is not updated,
45
- # so you must call `refresh` on it to get a new version with the
46
- # discount removed.
47
- def delete_discount
48
- resp, opts = execute_resource_request(:delete, resource_url + "/discount")
49
- Util.convert_to_stripe_object(resp.data, opts)
104
+ def self.search(params = {}, opts = {})
105
+ _search("/v1/customers/search", params, opts)
106
+ end
107
+
108
+ def self.search_auto_paging_each(params = {}, opts = {}, &blk)
109
+ search(params, opts).auto_paging_each(&blk)
110
+ end
111
+
112
+ def self.retrieve_cash_balance(customer, params = {}, opts = {})
113
+ request_stripe_object(
114
+ method: :get,
115
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
116
+ params: params,
117
+ opts: opts
118
+ )
119
+ end
120
+
121
+ def self.update_cash_balance(customer, params = {}, opts = {})
122
+ request_stripe_object(
123
+ method: :post,
124
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
125
+ params: params,
126
+ opts: opts
127
+ )
128
+ end
129
+
130
+ def test_helpers
131
+ TestHelpers.new(self)
132
+ end
133
+
134
+ class TestHelpers < APIResourceTestHelpers
135
+ RESOURCE_CLASS = Customer
136
+
137
+ def self.fund_cash_balance(customer, params = {}, opts = {})
138
+ request_stripe_object(
139
+ method: :post,
140
+ path: format("/v1/test_helpers/customers/%<customer>s/fund_cash_balance", { customer: CGI.escape(customer) }),
141
+ params: params,
142
+ opts: opts
143
+ )
144
+ end
145
+
146
+ def fund_cash_balance(params = {}, opts = {})
147
+ @resource.request_stripe_object(
148
+ method: :post,
149
+ path: format("/v1/test_helpers/customers/%<customer>s/fund_cash_balance", { customer: CGI.escape(@resource["id"]) }),
150
+ params: params,
151
+ opts: opts
152
+ )
153
+ end
50
154
  end
51
155
  end
52
156
  end
@@ -2,6 +2,12 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Each customer has a [Balance](https://stripe.com/docs/api/customers/object#customer_object-balance) value,
6
+ # which denotes a debit or credit that's automatically applied to their next invoice upon finalization.
7
+ # You may modify the value directly by using the [update customer API](https://stripe.com/docs/api/customers/update),
8
+ # or by creating a Customer Balance Transaction, which increments or decrements the customer's `balance` by the specified `amount`.
9
+ #
10
+ # Related guide: [Customer balance](https://stripe.com/docs/billing/customer/balance)
5
11
  class CustomerBalanceTransaction < APIResource
6
12
  extend Stripe::APIOperations::List
7
13
  include Stripe::APIOperations::Save
@@ -0,0 +1,14 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ # Customers with certain payments enabled have a cash balance, representing funds that were paid
6
+ # by the customer to a merchant, but have not yet been allocated to a payment. Cash Balance Transactions
7
+ # represent when funds are moved into or out of this balance. This includes funding by the customer, allocation
8
+ # to payments, and refunds to the customer.
9
+ class CustomerCashBalanceTransaction < APIResource
10
+ extend Stripe::APIOperations::List
11
+
12
+ OBJECT_NAME = "customer_cash_balance_transaction"
13
+ end
14
+ end
@@ -1,6 +1,11 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
5
+ # A discount represents the actual application of a [coupon](https://stripe.com/docs/api#coupons) or [promotion code](https://stripe.com/docs/api#promotion_codes).
6
+ # It contains information about when the discount began, when it will end, and what it is applied to.
7
+ #
8
+ # Related guide: [Applying discounts to subscriptions](https://stripe.com/docs/billing/subscriptions/discounts)
4
9
  class Discount < StripeObject
5
10
  OBJECT_NAME = "discount"
6
11
  end