stripe 5.41.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +256 -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 +29 -10
  22. data/lib/stripe/resources/account.rb +36 -9
  23. data/lib/stripe/resources/account_link.rb +4 -0
  24. data/lib/stripe/resources/application_fee_refund.rb +5 -0
  25. data/lib/stripe/resources/apps/secret.rb +40 -0
  26. data/lib/stripe/resources/balance.rb +11 -0
  27. data/lib/stripe/resources/balance_transaction.rb +4 -0
  28. data/lib/stripe/resources/bank_account.rb +7 -0
  29. data/lib/stripe/resources/billing_portal/configuration.rb +1 -0
  30. data/lib/stripe/resources/billing_portal/session.rb +14 -0
  31. data/lib/stripe/resources/capability.rb +3 -0
  32. data/lib/stripe/resources/card.rb +6 -3
  33. data/lib/stripe/resources/cash_balance.rb +23 -0
  34. data/lib/stripe/resources/charge.rb +23 -3
  35. data/lib/stripe/resources/checkout/session.rb +41 -5
  36. data/lib/stripe/resources/country_spec.rb +6 -0
  37. data/lib/stripe/resources/coupon.rb +3 -0
  38. data/lib/stripe/resources/credit_note.rb +27 -9
  39. data/lib/stripe/resources/credit_note_line_item.rb +1 -0
  40. data/lib/stripe/resources/customer.rb +124 -12
  41. data/lib/stripe/resources/customer_balance_transaction.rb +6 -0
  42. data/lib/stripe/resources/customer_cash_balance_transaction.rb +14 -0
  43. data/lib/stripe/resources/discount.rb +4 -0
  44. data/lib/stripe/resources/dispute.rb +17 -3
  45. data/lib/stripe/resources/event.rb +29 -0
  46. data/lib/stripe/resources/exchange_rate.rb +11 -0
  47. data/lib/stripe/resources/file.rb +7 -0
  48. data/lib/stripe/resources/file_link.rb +3 -0
  49. data/lib/stripe/resources/financial_connections/account.rb +67 -0
  50. data/lib/stripe/resources/financial_connections/account_owner.rb +11 -0
  51. data/lib/stripe/resources/financial_connections/account_ownership.rb +11 -0
  52. data/lib/stripe/resources/financial_connections/session.rb +13 -0
  53. data/lib/stripe/resources/funding_instructions.rb +21 -0
  54. data/lib/stripe/resources/identity/verification_report.rb +11 -0
  55. data/lib/stripe/resources/identity/verification_session.rb +31 -5
  56. data/lib/stripe/resources/invoice.rb +105 -17
  57. data/lib/stripe/resources/invoice_item.rb +11 -0
  58. data/lib/stripe/resources/issuing/authorization.rb +25 -5
  59. data/lib/stripe/resources/issuing/card.rb +78 -8
  60. data/lib/stripe/resources/issuing/cardholder.rb +3 -0
  61. data/lib/stripe/resources/issuing/dispute.rb +13 -3
  62. data/lib/stripe/resources/issuing/transaction.rb +5 -0
  63. data/lib/stripe/resources/line_item.rb +1 -0
  64. data/lib/stripe/resources/login_link.rb +1 -0
  65. data/lib/stripe/resources/mandate.rb +1 -0
  66. data/lib/stripe/resources/payment_intent.rb +103 -6
  67. data/lib/stripe/resources/payment_link.rb +35 -0
  68. data/lib/stripe/resources/payment_method.rb +25 -5
  69. data/lib/stripe/resources/payout.rb +28 -5
  70. data/lib/stripe/resources/person.rb +6 -0
  71. data/lib/stripe/resources/plan.rb +8 -0
  72. data/lib/stripe/resources/price.rb +15 -0
  73. data/lib/stripe/resources/product.rb +17 -0
  74. data/lib/stripe/resources/promotion_code.rb +2 -0
  75. data/lib/stripe/resources/quote.rb +58 -35
  76. data/lib/stripe/resources/radar/early_fraud_warning.rb +4 -0
  77. data/lib/stripe/resources/radar/value_list.rb +3 -0
  78. data/lib/stripe/resources/radar/value_list_item.rb +3 -0
  79. data/lib/stripe/resources/refund.rb +49 -0
  80. data/lib/stripe/resources/reporting/report_run.rb +8 -0
  81. data/lib/stripe/resources/reporting/report_type.rb +8 -1
  82. data/lib/stripe/resources/reversal.rb +13 -0
  83. data/lib/stripe/resources/review.rb +14 -3
  84. data/lib/stripe/resources/setup_attempt.rb +4 -0
  85. data/lib/stripe/resources/setup_intent.rb +60 -5
  86. data/lib/stripe/resources/shipping_rate.rb +2 -0
  87. data/lib/stripe/resources/sigma/scheduled_query_run.rb +4 -0
  88. data/lib/stripe/resources/source.rb +26 -6
  89. data/lib/stripe/resources/source_transaction.rb +4 -0
  90. data/lib/stripe/resources/subscription.rb +57 -3
  91. data/lib/stripe/resources/subscription_item.rb +2 -7
  92. data/lib/stripe/resources/subscription_schedule.rb +23 -5
  93. data/lib/stripe/resources/tax/calculation.rb +33 -0
  94. data/lib/stripe/resources/tax/calculation_line_item.rb +10 -0
  95. data/lib/stripe/resources/tax/settings.rb +15 -0
  96. data/lib/stripe/resources/tax/transaction.rb +49 -0
  97. data/lib/stripe/resources/tax/transaction_line_item.rb +10 -0
  98. data/lib/stripe/resources/tax_code.rb +1 -0
  99. data/lib/stripe/resources/tax_id.rb +4 -0
  100. data/lib/stripe/resources/tax_rate.rb +3 -0
  101. data/lib/stripe/resources/terminal/configuration.rb +16 -0
  102. data/lib/stripe/resources/terminal/connection_token.rb +3 -0
  103. data/lib/stripe/resources/terminal/location.rb +3 -0
  104. data/lib/stripe/resources/terminal/reader.rb +119 -0
  105. data/lib/stripe/resources/test_helpers/test_clock.rb +35 -0
  106. data/lib/stripe/resources/token.rb +20 -0
  107. data/lib/stripe/resources/topup.rb +15 -3
  108. data/lib/stripe/resources/transfer.rb +10 -11
  109. data/lib/stripe/resources/treasury/credit_reversal.rb +14 -0
  110. data/lib/stripe/resources/treasury/debit_reversal.rb +14 -0
  111. data/lib/stripe/resources/treasury/financial_account.rb +52 -0
  112. data/lib/stripe/resources/treasury/financial_account_features.rb +12 -0
  113. data/lib/stripe/resources/treasury/inbound_transfer.rb +94 -0
  114. data/lib/stripe/resources/treasury/outbound_payment.rb +96 -0
  115. data/lib/stripe/resources/treasury/outbound_transfer.rb +100 -0
  116. data/lib/stripe/resources/treasury/received_credit.rb +30 -0
  117. data/lib/stripe/resources/treasury/received_debit.rb +30 -0
  118. data/lib/stripe/resources/treasury/transaction.rb +13 -0
  119. data/lib/stripe/resources/treasury/transaction_entry.rb +17 -0
  120. data/lib/stripe/resources/usage_record.rb +4 -0
  121. data/lib/stripe/resources/webhook_endpoint.rb +7 -0
  122. data/lib/stripe/resources.rb +27 -10
  123. data/lib/stripe/search_result_object.rb +86 -0
  124. data/lib/stripe/stripe_client.rb +37 -22
  125. data/lib/stripe/stripe_configuration.rb +5 -1
  126. data/lib/stripe/stripe_object.rb +2 -2
  127. data/lib/stripe/util.rb +85 -2
  128. data/lib/stripe/version.rb +1 -1
  129. data/lib/stripe.rb +5 -1
  130. data/stripe.gemspec +3 -3
  131. metadata +39 -14
  132. data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
  133. data/lib/stripe/resources/bitcoin_transaction.rb +0 -16
  134. data/lib/stripe/resources/issuing/card_details.rb +0 -10
  135. data/lib/stripe/resources/order.rb +0 -33
  136. data/lib/stripe/resources/order_return.rb +0 -10
  137. data/lib/stripe/resources/recipient.rb +0 -14
  138. data/lib/stripe/resources/sku.rb +0 -13
  139. data/lib/stripe/resources/three_d_secure.rb +0 -14
@@ -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
+ # They're created for every type of transaction that comes into or flows out of 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,21 +3,57 @@
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
- custom_method :expire, http_verb: :post
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
14
34
 
15
- nested_resource_class_methods :line_item, operations: %i[list]
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
16
43
 
17
- def expire(params = {}, opts = {})
44
+ def self.expire(session, params = {}, opts = {})
18
45
  request_stripe_object(
19
46
  method: :post,
20
- path: resource_url + "/expire",
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) }),
21
57
  params: params,
22
58
  opts: opts
23
59
  )
@@ -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,102 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This object represents a customer of your business. It lets you 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"
15
-
16
18
  nested_resource_class_methods :balance_transaction,
17
19
  operations: %i[create retrieve update list]
20
+ nested_resource_class_methods :cash_balance_transaction,
21
+ operations: %i[retrieve list]
18
22
  nested_resource_class_methods :tax_id,
19
23
  operations: %i[create retrieve delete list]
20
24
 
25
+ def create_funding_instructions(params = {}, opts = {})
26
+ request_stripe_object(
27
+ method: :post,
28
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(self["id"]) }),
29
+ params: params,
30
+ opts: opts
31
+ )
32
+ end
33
+
34
+ def delete_discount(params = {}, opts = {})
35
+ request_stripe_object(
36
+ method: :delete,
37
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(self["id"]) }),
38
+ params: params,
39
+ opts: opts
40
+ )
41
+ end
42
+
21
43
  def list_payment_methods(params = {}, opts = {})
22
44
  request_stripe_object(
23
45
  method: :get,
24
- path: resource_url + "/payment_methods",
46
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(self["id"]) }),
47
+ params: params,
48
+ opts: opts
49
+ )
50
+ end
51
+
52
+ def retrieve_payment_method(payment_method, params = {}, opts = {})
53
+ request_stripe_object(
54
+ method: :get,
55
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(self["id"]), payment_method: CGI.escape(payment_method) }),
56
+ params: params,
57
+ opts: opts
58
+ )
59
+ end
60
+
61
+ def self.create_funding_instructions(customer, params = {}, opts = {})
62
+ request_stripe_object(
63
+ method: :post,
64
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(customer) }),
65
+ params: params,
66
+ opts: opts
67
+ )
68
+ end
69
+
70
+ def self.delete_discount(customer, params = {}, opts = {})
71
+ request_stripe_object(
72
+ method: :delete,
73
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(customer) }),
74
+ params: params,
75
+ opts: opts
76
+ )
77
+ end
78
+
79
+ def self.list_payment_methods(customer, params = {}, opts = {})
80
+ request_stripe_object(
81
+ method: :get,
82
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(customer) }),
25
83
  params: params,
26
84
  opts: opts
27
85
  )
28
86
  end
29
87
 
30
- custom_method :delete_discount, http_verb: :delete, http_path: "discount"
88
+ def self.retrieve_payment_method(
89
+ customer,
90
+ payment_method,
91
+ params = {},
92
+ opts = {}
93
+ )
94
+ request_stripe_object(
95
+ method: :get,
96
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }),
97
+ params: params,
98
+ opts: opts
99
+ )
100
+ end
31
101
 
32
102
  save_nested_resource :source
33
103
  nested_resource_class_methods :source,
@@ -39,14 +109,56 @@ module Stripe
39
109
  alias detach_source delete_source
40
110
  end
41
111
 
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)
112
+ def self.search(params = {}, opts = {})
113
+ _search("/v1/customers/search", params, opts)
114
+ end
115
+
116
+ def self.search_auto_paging_each(params = {}, opts = {}, &blk)
117
+ search(params, opts).auto_paging_each(&blk)
118
+ end
119
+
120
+ def self.retrieve_cash_balance(customer, params = {}, opts = {})
121
+ request_stripe_object(
122
+ method: :get,
123
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
124
+ params: params,
125
+ opts: opts
126
+ )
127
+ end
128
+
129
+ def self.update_cash_balance(customer, params = {}, opts = {})
130
+ request_stripe_object(
131
+ method: :post,
132
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
133
+ params: params,
134
+ opts: opts
135
+ )
136
+ end
137
+
138
+ def test_helpers
139
+ TestHelpers.new(self)
140
+ end
141
+
142
+ class TestHelpers < APIResourceTestHelpers
143
+ RESOURCE_CLASS = Customer
144
+
145
+ def self.fund_cash_balance(customer, params = {}, opts = {})
146
+ request_stripe_object(
147
+ method: :post,
148
+ path: format("/v1/test_helpers/customers/%<customer>s/fund_cash_balance", { customer: CGI.escape(customer) }),
149
+ params: params,
150
+ opts: opts
151
+ )
152
+ end
153
+
154
+ def fund_cash_balance(params = {}, opts = {})
155
+ @resource.request_stripe_object(
156
+ method: :post,
157
+ path: format("/v1/test_helpers/customers/%<customer>s/fund_cash_balance", { customer: CGI.escape(@resource["id"]) }),
158
+ params: params,
159
+ opts: opts
160
+ )
161
+ end
50
162
  end
51
163
  end
52
164
  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
@@ -2,6 +2,10 @@
2
2
  # frozen_string_literal: true
3
3
 
4
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)
5
9
  class Discount < StripeObject
6
10
  OBJECT_NAME = "discount"
7
11
  end
@@ -2,18 +2,32 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # A dispute occurs when a customer questions your charge with their card issuer.
6
+ # When this happens, you're given the opportunity to respond to the dispute with
7
+ # evidence that shows that the charge is legitimate. You can find more
8
+ # information about the dispute process in our [Disputes and
9
+ # Fraud](https://stripe.com/docs/disputes) documentation.
10
+ #
11
+ # Related guide: [Disputes and fraud](https://stripe.com/docs/disputes)
5
12
  class Dispute < APIResource
6
13
  extend Stripe::APIOperations::List
7
14
  include Stripe::APIOperations::Save
8
15
 
9
16
  OBJECT_NAME = "dispute"
10
17
 
11
- custom_method :close, http_verb: :post
12
-
13
18
  def close(params = {}, opts = {})
14
19
  request_stripe_object(
15
20
  method: :post,
16
- path: resource_url + "/close",
21
+ path: format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(self["id"]) }),
22
+ params: params,
23
+ opts: opts
24
+ )
25
+ end
26
+
27
+ def self.close(dispute, params = {}, opts = {})
28
+ request_stripe_object(
29
+ method: :post,
30
+ path: format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(dispute) }),
17
31
  params: params,
18
32
  opts: opts
19
33
  )