stripe 13.3.0.pre.beta.1 → 13.3.0.pre.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/OPENAPI_VERSION +1 -1
  4. data/VERSION +1 -1
  5. data/lib/stripe/api_version.rb +1 -1
  6. data/lib/stripe/object_types.rb +10 -0
  7. data/lib/stripe/resources/account.rb +230 -0
  8. data/lib/stripe/resources/account_link.rb +9 -0
  9. data/lib/stripe/resources/account_notice.rb +28 -0
  10. data/lib/stripe/resources/account_session.rb +103 -0
  11. data/lib/stripe/resources/apple_pay_domain.rb +13 -0
  12. data/lib/stripe/resources/application.rb +20 -0
  13. data/lib/stripe/resources/application_fee.rb +34 -0
  14. data/lib/stripe/resources/application_fee_refund.rb +17 -0
  15. data/lib/stripe/resources/apps/secret.rb +22 -0
  16. data/lib/stripe/resources/balance.rb +59 -0
  17. data/lib/stripe/resources/balance_transaction.rb +34 -0
  18. data/lib/stripe/resources/bank_account.rb +60 -2
  19. data/lib/stripe/resources/billing/alert.rb +21 -0
  20. data/lib/stripe/resources/billing/alert_triggered.rb +26 -0
  21. data/lib/stripe/resources/billing/credit_balance_summary.rb +25 -0
  22. data/lib/stripe/resources/billing/credit_balance_transaction.rb +49 -1
  23. data/lib/stripe/resources/billing/credit_grant.rb +46 -2
  24. data/lib/stripe/resources/billing/meter.rb +49 -7
  25. data/lib/stripe/resources/billing/meter_error_report.rb +44 -0
  26. data/lib/stripe/resources/billing/meter_event.rb +17 -3
  27. data/lib/stripe/resources/billing/meter_event_adjustment.rb +17 -1
  28. data/lib/stripe/resources/billing/meter_event_summary.rb +15 -0
  29. data/lib/stripe/resources/billing_portal/configuration.rb +70 -0
  30. data/lib/stripe/resources/billing_portal/session.rb +61 -0
  31. data/lib/stripe/resources/capability.rb +38 -0
  32. data/lib/stripe/resources/capital/financing_offer.rb +45 -0
  33. data/lib/stripe/resources/capital/financing_summary.rb +17 -0
  34. data/lib/stripe/resources/capital/financing_transaction.rb +29 -0
  35. data/lib/stripe/resources/card.rb +76 -0
  36. data/lib/stripe/resources/cash_balance.rb +14 -0
  37. data/lib/stripe/resources/charge.rb +469 -0
  38. data/lib/stripe/resources/checkout/session.rb +496 -0
  39. data/lib/stripe/resources/climate/order.rb +55 -0
  40. data/lib/stripe/resources/climate/product.rb +24 -0
  41. data/lib/stripe/resources/climate/supplier.rb +18 -0
  42. data/lib/stripe/resources/confirmation_token.rb +297 -0
  43. data/lib/stripe/resources/connect_collection_transfer.rb +24 -0
  44. data/lib/stripe/resources/country_spec.rb +27 -0
  45. data/lib/stripe/resources/coupon.rb +44 -0
  46. data/lib/stripe/resources/credit_note.rb +91 -0
  47. data/lib/stripe/resources/credit_note_line_item.rb +46 -0
  48. data/lib/stripe/resources/customer.rb +93 -0
  49. data/lib/stripe/resources/customer_balance_transaction.rb +27 -0
  50. data/lib/stripe/resources/customer_cash_balance_transaction.rb +72 -0
  51. data/lib/stripe/resources/customer_session.rb +34 -0
  52. data/lib/stripe/resources/discount.rb +29 -0
  53. data/lib/stripe/resources/dispute.rb +96 -0
  54. data/lib/stripe/resources/entitlements/active_entitlement.rb +11 -0
  55. data/lib/stripe/resources/entitlements/active_entitlement_summary.rb +23 -0
  56. data/lib/stripe/resources/entitlements/feature.rb +15 -0
  57. data/lib/stripe/resources/ephemeral_key.rb +13 -0
  58. data/lib/stripe/resources/event.rb +44 -0
  59. data/lib/stripe/resources/exchange_rate.rb +7 -0
  60. data/lib/stripe/resources/file.rb +23 -0
  61. data/lib/stripe/resources/file_link.rb +19 -0
  62. data/lib/stripe/resources/financial_connections/account.rb +84 -0
  63. data/lib/stripe/resources/financial_connections/account_inferred_balance.rb +13 -0
  64. data/lib/stripe/resources/financial_connections/account_owner.rb +17 -0
  65. data/lib/stripe/resources/financial_connections/account_ownership.rb +9 -0
  66. data/lib/stripe/resources/financial_connections/institution.rb +35 -0
  67. data/lib/stripe/resources/financial_connections/session.rb +49 -0
  68. data/lib/stripe/resources/financial_connections/transaction.rb +28 -0
  69. data/lib/stripe/resources/forwarding/request.rb +40 -0
  70. data/lib/stripe/resources/funding_instructions.rb +82 -0
  71. data/lib/stripe/resources/gift_cards/card.rb +37 -0
  72. data/lib/stripe/resources/gift_cards/transaction.rb +39 -0
  73. data/lib/stripe/resources/identity/verification_report.rb +92 -0
  74. data/lib/stripe/resources/identity/verification_session.rb +76 -0
  75. data/lib/stripe/resources/invoice.rb +337 -0
  76. data/lib/stripe/resources/invoice_item.rb +54 -0
  77. data/lib/stripe/resources/invoice_line_item.rb +83 -0
  78. data/lib/stripe/resources/invoice_payment.rb +34 -0
  79. data/lib/stripe/resources/invoice_rendering_template.rb +17 -0
  80. data/lib/stripe/resources/issuing/authorization.rb +129 -0
  81. data/lib/stripe/resources/issuing/card.rb +86 -0
  82. data/lib/stripe/resources/issuing/cardholder.rb +76 -0
  83. data/lib/stripe/resources/issuing/credit_underwriting_record.rb +57 -0
  84. data/lib/stripe/resources/issuing/dispute.rb +65 -0
  85. data/lib/stripe/resources/issuing/dispute_settlement_detail.rb +23 -0
  86. data/lib/stripe/resources/issuing/fraud_liability_debit.rb +17 -0
  87. data/lib/stripe/resources/issuing/personalization_design.rb +38 -0
  88. data/lib/stripe/resources/issuing/physical_bundle.rb +18 -0
  89. data/lib/stripe/resources/issuing/settlement.rb +49 -0
  90. data/lib/stripe/resources/issuing/token.rb +46 -0
  91. data/lib/stripe/resources/issuing/transaction.rb +106 -0
  92. data/lib/stripe/resources/line_item.rb +50 -0
  93. data/lib/stripe/resources/login_link.rb +7 -0
  94. data/lib/stripe/resources/mandate.rb +78 -0
  95. data/lib/stripe/resources/margin.rb +19 -0
  96. data/lib/stripe/resources/order.rb +202 -0
  97. data/lib/stripe/resources/payment_attempt_record.rb +73 -0
  98. data/lib/stripe/resources/payment_intent.rb +642 -0
  99. data/lib/stripe/resources/payment_link.rb +198 -0
  100. data/lib/stripe/resources/payment_method.rb +368 -0
  101. data/lib/stripe/resources/payment_method_configuration.rb +430 -0
  102. data/lib/stripe/resources/payment_method_domain.rb +57 -0
  103. data/lib/stripe/resources/payment_record.rb +73 -0
  104. data/lib/stripe/resources/payout.rb +56 -0
  105. data/lib/stripe/resources/person.rb +128 -0
  106. data/lib/stripe/resources/plan.rb +52 -0
  107. data/lib/stripe/resources/price.rb +77 -0
  108. data/lib/stripe/resources/product.rb +60 -0
  109. data/lib/stripe/resources/product_feature.rb +12 -0
  110. data/lib/stripe/resources/promotion_code.rb +35 -0
  111. data/lib/stripe/resources/quote.rb +252 -0
  112. data/lib/stripe/resources/quote_line.rb +136 -0
  113. data/lib/stripe/resources/quote_preview_invoice.rb +331 -0
  114. data/lib/stripe/resources/quote_preview_subscription_schedule.rb +159 -0
  115. data/lib/stripe/resources/radar/early_fraud_warning.rb +17 -0
  116. data/lib/stripe/resources/radar/value_list.rb +23 -0
  117. data/lib/stripe/resources/radar/value_list_item.rb +17 -0
  118. data/lib/stripe/resources/refund.rb +130 -0
  119. data/lib/stripe/resources/reporting/report_run.rb +29 -0
  120. data/lib/stripe/resources/reporting/report_type.rb +19 -0
  121. data/lib/stripe/resources/reserve_transaction.rb +22 -0
  122. data/lib/stripe/resources/reversal.rb +21 -0
  123. data/lib/stripe/resources/review.rb +36 -0
  124. data/lib/stripe/resources/setup_attempt.rb +101 -0
  125. data/lib/stripe/resources/setup_intent.rb +158 -0
  126. data/lib/stripe/resources/shipping_rate.rb +42 -0
  127. data/lib/stripe/resources/sigma/scheduled_query_run.rb +26 -0
  128. data/lib/stripe/resources/source.rb +197 -0
  129. data/lib/stripe/resources/source_mandate_notification.rb +59 -0
  130. data/lib/stripe/resources/source_transaction.rb +48 -0
  131. data/lib/stripe/resources/subscription.rb +214 -0
  132. data/lib/stripe/resources/subscription_item.rb +46 -0
  133. data/lib/stripe/resources/subscription_schedule.rb +153 -0
  134. data/lib/stripe/resources/tax/association.rb +36 -0
  135. data/lib/stripe/resources/tax/calculation.rb +72 -0
  136. data/lib/stripe/resources/tax/calculation_line_item.rb +33 -0
  137. data/lib/stripe/resources/tax/form.rb +75 -0
  138. data/lib/stripe/resources/tax/registration.rb +379 -0
  139. data/lib/stripe/resources/tax/settings.rb +33 -0
  140. data/lib/stripe/resources/tax/transaction.rb +68 -0
  141. data/lib/stripe/resources/tax/transaction_line_item.rb +30 -0
  142. data/lib/stripe/resources/tax_code.rb +9 -0
  143. data/lib/stripe/resources/tax_deducted_at_source.rb +22 -0
  144. data/lib/stripe/resources/tax_id.rb +30 -0
  145. data/lib/stripe/resources/tax_rate.rb +42 -0
  146. data/lib/stripe/resources/terminal/configuration.rb +107 -0
  147. data/lib/stripe/resources/terminal/connection_token.rb +7 -0
  148. data/lib/stripe/resources/terminal/location.rb +20 -0
  149. data/lib/stripe/resources/terminal/reader.rb +118 -0
  150. data/lib/stripe/resources/terminal/reader_collected_data.rb +16 -0
  151. data/lib/stripe/resources/test_helpers/test_clock.rb +27 -0
  152. data/lib/stripe/resources/token.rb +29 -0
  153. data/lib/stripe/resources/topup.rb +33 -0
  154. data/lib/stripe/resources/transfer.rb +35 -0
  155. data/lib/stripe/resources/treasury/credit_reversal.rb +32 -0
  156. data/lib/stripe/resources/treasury/debit_reversal.rb +38 -0
  157. data/lib/stripe/resources/treasury/financial_account.rb +57 -0
  158. data/lib/stripe/resources/treasury/financial_account_features.rb +91 -0
  159. data/lib/stripe/resources/treasury/inbound_transfer.rb +66 -0
  160. data/lib/stripe/resources/treasury/outbound_payment.rb +85 -0
  161. data/lib/stripe/resources/treasury/outbound_transfer.rb +82 -0
  162. data/lib/stripe/resources/treasury/received_credit.rb +70 -0
  163. data/lib/stripe/resources/treasury/received_debit.rb +67 -0
  164. data/lib/stripe/resources/treasury/transaction.rb +42 -0
  165. data/lib/stripe/resources/treasury/transaction_entry.rb +34 -0
  166. data/lib/stripe/resources/usage_record.rb +13 -0
  167. data/lib/stripe/resources/usage_record_summary.rb +18 -0
  168. data/lib/stripe/resources/v2/amount.rb +9 -0
  169. data/lib/stripe/resources/v2/billing/meter_event.rb +18 -0
  170. data/lib/stripe/resources/v2/billing/meter_event_adjustment.rb +20 -0
  171. data/lib/stripe/resources/v2/billing/meter_event_session.rb +14 -0
  172. data/lib/stripe/resources/v2/event.rb +21 -0
  173. data/lib/stripe/resources/v2/event_destination.rb +49 -0
  174. data/lib/stripe/resources/webhook_endpoint.rb +27 -0
  175. data/lib/stripe/resources.rb +10 -0
  176. data/lib/stripe/services/billing/credit_balance_summary_service.rb +1 -1
  177. data/lib/stripe/services/billing/credit_balance_transaction_service.rb +2 -2
  178. data/lib/stripe/services/billing/credit_grant_service.rb +3 -3
  179. data/lib/stripe/services/billing/meter_event_adjustment_service.rb +1 -1
  180. data/lib/stripe/services/billing/meter_event_service.rb +1 -1
  181. data/lib/stripe/services/billing/meter_service.rb +5 -5
  182. data/lib/stripe/stripe_object.rb +5 -0
  183. data/lib/stripe/version.rb +1 -1
  184. data/stripe.gemspec +2 -1
  185. metadata +13 -2
@@ -18,5 +18,64 @@ module Stripe
18
18
  def self.object_name
19
19
  "balance"
20
20
  end
21
+
22
+ class Available < Stripe::StripeObject
23
+ class SourceTypes < Stripe::StripeObject
24
+ attr_reader :bank_account, :card, :fpx
25
+ end
26
+ attr_reader :amount, :currency, :source_types
27
+ end
28
+
29
+ class ConnectReserved < Stripe::StripeObject
30
+ class SourceTypes < Stripe::StripeObject
31
+ attr_reader :bank_account, :card, :fpx
32
+ end
33
+ attr_reader :amount, :currency, :source_types
34
+ end
35
+
36
+ class InstantAvailable < Stripe::StripeObject
37
+ class NetAvailable < Stripe::StripeObject
38
+ class SourceTypes < Stripe::StripeObject
39
+ attr_reader :bank_account, :card, :fpx
40
+ end
41
+ attr_reader :amount, :destination, :source_types
42
+ end
43
+
44
+ class SourceTypes < Stripe::StripeObject
45
+ attr_reader :bank_account, :card, :fpx
46
+ end
47
+ attr_reader :amount, :currency, :net_available, :source_types
48
+ end
49
+
50
+ class Issuing < Stripe::StripeObject
51
+ class Available < Stripe::StripeObject
52
+ class SourceTypes < Stripe::StripeObject
53
+ attr_reader :bank_account, :card, :fpx
54
+ end
55
+ attr_reader :amount, :currency, :source_types
56
+ end
57
+ attr_reader :available
58
+ end
59
+
60
+ class Pending < Stripe::StripeObject
61
+ class SourceTypes < Stripe::StripeObject
62
+ attr_reader :bank_account, :card, :fpx
63
+ end
64
+ attr_reader :amount, :currency, :source_types
65
+ end
66
+ # Available funds that you can transfer or pay out automatically by Stripe or explicitly through the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). You can find the available balance for each currency and payment type in the `source_types` property.
67
+ attr_reader :available
68
+ # Funds held due to negative balances on connected accounts where [account.controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `application`, which includes Custom accounts. You can find the connect reserve balance for each currency and payment type in the `source_types` property.
69
+ attr_reader :connect_reserved
70
+ # Funds that you can pay out using Instant Payouts.
71
+ attr_reader :instant_available
72
+ # Attribute for field issuing
73
+ attr_reader :issuing
74
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
75
+ attr_reader :livemode
76
+ # String representing the object's type. Objects of the same type share the same value.
77
+ attr_reader :object
78
+ # Funds that aren't available in the balance yet. You can find the pending balance for each currency and each payment type in the `source_types` property.
79
+ attr_reader :pending
21
80
  end
22
81
  end
@@ -14,6 +14,40 @@ module Stripe
14
14
  "balance_transaction"
15
15
  end
16
16
 
17
+ class FeeDetail < Stripe::StripeObject
18
+ attr_reader :amount, :application, :currency, :description, :type
19
+ end
20
+ # Gross amount of this transaction (in cents (or local equivalent)). A positive value represents funds charged to another party, and a negative value represents funds sent to another party.
21
+ attr_reader :amount
22
+ # The date that the transaction's net funds become available in the Stripe balance.
23
+ attr_reader :available_on
24
+ # Time at which the object was created. Measured in seconds since the Unix epoch.
25
+ attr_reader :created
26
+ # Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
27
+ attr_reader :currency
28
+ # An arbitrary string attached to the object. Often useful for displaying to users.
29
+ attr_reader :description
30
+ # If applicable, this transaction uses an exchange rate. If money converts from currency A to currency B, then the `amount` in currency A, multipled by the `exchange_rate`, equals the `amount` in currency B. For example, if you charge a customer 10.00 EUR, the PaymentIntent's `amount` is `1000` and `currency` is `eur`. If this converts to 12.34 USD in your Stripe account, the BalanceTransaction's `amount` is `1234`, its `currency` is `usd`, and the `exchange_rate` is `1.234`.
31
+ attr_reader :exchange_rate
32
+ # Fees (in cents (or local equivalent)) paid for this transaction. Represented as a positive integer when assessed.
33
+ attr_reader :fee
34
+ # Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
35
+ attr_reader :fee_details
36
+ # Unique identifier for the object.
37
+ attr_reader :id
38
+ # Net impact to a Stripe balance (in cents (or local equivalent)). A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. You can calculate the net impact of a transaction on a balance by `amount` - `fee`
39
+ attr_reader :net
40
+ # String representing the object's type. Objects of the same type share the same value.
41
+ attr_reader :object
42
+ # Learn more about how [reporting categories](https://stripe.com/docs/reports/reporting-categories) can help you understand balance transactions from an accounting perspective.
43
+ attr_reader :reporting_category
44
+ # This transaction relates to the Stripe object.
45
+ attr_reader :source
46
+ # The transaction's net funds status in the Stripe balance, which are either `available` or `pending`.
47
+ attr_reader :status
48
+ # Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `payout_minimum_balance_hold`, `payout_minimum_balance_release`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types). To classify transactions for accounting purposes, consider `reporting_category` instead.
49
+ attr_reader :type
50
+
17
51
  # Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
18
52
  #
19
53
  # Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history.
@@ -19,6 +19,62 @@ module Stripe
19
19
  "bank_account"
20
20
  end
21
21
 
22
+ class FutureRequirements < Stripe::StripeObject
23
+ class Error < Stripe::StripeObject
24
+ attr_reader :code, :reason, :requirement
25
+ end
26
+ attr_reader :currently_due, :errors, :past_due, :pending_verification
27
+ end
28
+
29
+ class Requirements < Stripe::StripeObject
30
+ class Error < Stripe::StripeObject
31
+ attr_reader :code, :reason, :requirement
32
+ end
33
+ attr_reader :currently_due, :errors, :past_due, :pending_verification
34
+ end
35
+ # The ID of the account that the bank account is associated with.
36
+ attr_reader :account
37
+ # The name of the person or business that owns the bank account.
38
+ attr_reader :account_holder_name
39
+ # The type of entity that holds the account. This can be either `individual` or `company`.
40
+ attr_reader :account_holder_type
41
+ # The bank account type. This can only be `checking` or `savings` in most countries. In Japan, this can only be `futsu` or `toza`.
42
+ attr_reader :account_type
43
+ # A set of available payout methods for this bank account. Only values from this set should be passed as the `method` when creating a payout.
44
+ attr_reader :available_payout_methods
45
+ # Name of the bank associated with the routing number (e.g., `WELLS FARGO`).
46
+ attr_reader :bank_name
47
+ # Two-letter ISO code representing the country the bank account is located in.
48
+ attr_reader :country
49
+ # Three-letter [ISO code for the currency](https://stripe.com/docs/payouts) paid out to the bank account.
50
+ attr_reader :currency
51
+ # The ID of the customer that the bank account is associated with.
52
+ attr_reader :customer
53
+ # Whether this bank account is the default external account for its currency.
54
+ attr_reader :default_for_currency
55
+ # Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
56
+ attr_reader :fingerprint
57
+ # Information about the [upcoming new requirements for the bank account](https://stripe.com/docs/connect/custom-accounts/future-requirements), including what information needs to be collected, and by when.
58
+ attr_reader :future_requirements
59
+ # Unique identifier for the object.
60
+ attr_reader :id
61
+ # The last four digits of the bank account number.
62
+ attr_reader :last4
63
+ # Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
64
+ attr_reader :metadata
65
+ # String representing the object's type. Objects of the same type share the same value.
66
+ attr_reader :object
67
+ # Information about the requirements for the bank account, including what information needs to be collected.
68
+ attr_reader :requirements
69
+ # The routing transit number for the bank account.
70
+ attr_reader :routing_number
71
+ # For bank accounts, possible values are `new`, `validated`, `verified`, `verification_failed`, or `errored`. A bank account that hasn't had any activity or validation performed is `new`. If Stripe can determine that the bank account exists, its status will be `validated`. Note that there often isn’t enough information to know (e.g., for smaller credit unions), and the validation is not always run. If customer bank account verification has succeeded, the bank account status will be `verified`. If the verification failed for any reason, such as microdeposit failure, the status will be `verification_failed`. If a payout sent to this bank account fails, we'll set the status to `errored` and will not continue to send [scheduled payouts](https://stripe.com/docs/payouts#payout-schedule) until the bank details are updated.
72
+ #
73
+ # For external accounts, possible values are `new`, `errored` and `verification_failed`. If a payout fails, the status is set to `errored` and scheduled payouts are stopped until account details are updated. In the US and India, if we can't [verify the owner of the bank account](https://support.stripe.com/questions/bank-account-ownership-verification), we'll set the status to `verification_failed`. Other validations aren't run against external accounts because they're only used for payouts. This means the other statuses don't apply.
74
+ attr_reader :status
75
+ # Always true for a deleted object
76
+ attr_reader :deleted
77
+
22
78
  def verify(params = {}, opts = {})
23
79
  request_stripe_object(
24
80
  method: :post,
@@ -38,10 +94,12 @@ module Stripe
38
94
  end
39
95
 
40
96
  def resource_url
41
- if respond_to?(:customer)
97
+ if !customer.nil?
42
98
  "#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
43
- elsif respond_to?(:account)
99
+ elsif !account.nil?
44
100
  "#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
101
+ else
102
+ raise InvalidRequestError, "Could not determine which URL to request: [account, customer] fields are all null"
45
103
  end
46
104
  end
47
105
 
@@ -13,6 +13,27 @@ module Stripe
13
13
  "billing.alert"
14
14
  end
15
15
 
16
+ class UsageThreshold < Stripe::StripeObject
17
+ class Filter < Stripe::StripeObject
18
+ attr_reader :customer, :type
19
+ end
20
+ attr_reader :filters, :gte, :meter, :recurrence
21
+ end
22
+ # Defines the type of the alert.
23
+ attr_reader :alert_type
24
+ # Unique identifier for the object.
25
+ attr_reader :id
26
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
27
+ attr_reader :livemode
28
+ # String representing the object's type. Objects of the same type share the same value.
29
+ attr_reader :object
30
+ # Status of the alert. This can be active, inactive or archived.
31
+ attr_reader :status
32
+ # Title of the alert.
33
+ attr_reader :title
34
+ # Encapsulates configuration of the alert to monitor usage on a specific [Billing Meter](https://stripe.com/docs/api/billing/meter).
35
+ attr_reader :usage_threshold
36
+
16
37
  # Reactivates this alert, allowing it to trigger again.
17
38
  def activate(params = {}, opts = {})
18
39
  request_stripe_object(
@@ -0,0 +1,26 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ class AlertTriggered < APIResource
7
+ OBJECT_NAME = "billing.alert_triggered"
8
+ def self.object_name
9
+ "billing.alert_triggered"
10
+ end
11
+
12
+ # A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
13
+ attr_reader :alert
14
+ # Time at which the object was created. Measured in seconds since the Unix epoch.
15
+ attr_reader :created
16
+ # ID of customer for which the alert triggered
17
+ attr_reader :customer
18
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
19
+ attr_reader :livemode
20
+ # String representing the object's type. Objects of the same type share the same value.
21
+ attr_reader :object
22
+ # The value triggering the alert
23
+ attr_reader :value
24
+ end
25
+ end
26
+ end
@@ -9,6 +9,31 @@ module Stripe
9
9
  def self.object_name
10
10
  "billing.credit_balance_summary"
11
11
  end
12
+
13
+ class Balance < Stripe::StripeObject
14
+ class AvailableBalance < Stripe::StripeObject
15
+ class Monetary < Stripe::StripeObject
16
+ attr_reader :currency, :value
17
+ end
18
+ attr_reader :monetary, :type
19
+ end
20
+
21
+ class LedgerBalance < Stripe::StripeObject
22
+ class Monetary < Stripe::StripeObject
23
+ attr_reader :currency, :value
24
+ end
25
+ attr_reader :monetary, :type
26
+ end
27
+ attr_reader :available_balance, :ledger_balance
28
+ end
29
+ # The billing credit balances. One entry per credit grant currency. If a customer only has credit grants in a single currency, then this will have a single balance entry.
30
+ attr_reader :balances
31
+ # The customer the balance is for.
32
+ attr_reader :customer
33
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
34
+ attr_reader :livemode
35
+ # String representing the object's type. Objects of the same type share the same value.
36
+ attr_reader :object
12
37
  end
13
38
  end
14
39
  end
@@ -12,7 +12,55 @@ module Stripe
12
12
  "billing.credit_balance_transaction"
13
13
  end
14
14
 
15
- # Retrieve a list of credit balance transactions
15
+ class Credit < Stripe::StripeObject
16
+ class Amount < Stripe::StripeObject
17
+ class Monetary < Stripe::StripeObject
18
+ attr_reader :currency, :value
19
+ end
20
+ attr_reader :monetary, :type
21
+ end
22
+
23
+ class CreditsApplicationInvoiceVoided < Stripe::StripeObject
24
+ attr_reader :invoice, :invoice_line_item
25
+ end
26
+ attr_reader :amount, :credits_application_invoice_voided, :type
27
+ end
28
+
29
+ class Debit < Stripe::StripeObject
30
+ class Amount < Stripe::StripeObject
31
+ class Monetary < Stripe::StripeObject
32
+ attr_reader :currency, :value
33
+ end
34
+ attr_reader :monetary, :type
35
+ end
36
+
37
+ class CreditsApplied < Stripe::StripeObject
38
+ attr_reader :invoice, :invoice_line_item
39
+ end
40
+ attr_reader :amount, :credits_applied, :type
41
+ end
42
+ # Time at which the object was created. Measured in seconds since the Unix epoch.
43
+ attr_reader :created
44
+ # Credit details for this credit balance transaction. Only present if type is `credit`.
45
+ attr_reader :credit
46
+ # The credit grant associated with this credit balance transaction.
47
+ attr_reader :credit_grant
48
+ # Debit details for this credit balance transaction. Only present if type is `debit`.
49
+ attr_reader :debit
50
+ # The effective time of this credit balance transaction.
51
+ attr_reader :effective_at
52
+ # Unique identifier for the object.
53
+ attr_reader :id
54
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
55
+ attr_reader :livemode
56
+ # String representing the object's type. Objects of the same type share the same value.
57
+ attr_reader :object
58
+ # ID of the test clock this credit balance transaction belongs to.
59
+ attr_reader :test_clock
60
+ # The type of credit balance transaction (credit or debit).
61
+ attr_reader :type
62
+
63
+ # Retrieve a list of credit balance transactions.
16
64
  def self.list(filters = {}, opts = {})
17
65
  request_stripe_object(
18
66
  method: :get,
@@ -16,7 +16,51 @@ module Stripe
16
16
  "billing.credit_grant"
17
17
  end
18
18
 
19
- # Creates a credit grant
19
+ class Amount < Stripe::StripeObject
20
+ class Monetary < Stripe::StripeObject
21
+ attr_reader :currency, :value
22
+ end
23
+ attr_reader :monetary, :type
24
+ end
25
+
26
+ class ApplicabilityConfig < Stripe::StripeObject
27
+ class Scope < Stripe::StripeObject
28
+ attr_reader :price_type
29
+ end
30
+ attr_reader :scope
31
+ end
32
+ # Attribute for field amount
33
+ attr_reader :amount
34
+ # Attribute for field applicability_config
35
+ attr_reader :applicability_config
36
+ # The category of this credit grant. This is for tracking purposes and isn't displayed to the customer.
37
+ attr_reader :category
38
+ # Time at which the object was created. Measured in seconds since the Unix epoch.
39
+ attr_reader :created
40
+ # ID of the customer receiving the billing credits.
41
+ attr_reader :customer
42
+ # The time when the billing credits become effective-when they're eligible for use.
43
+ attr_reader :effective_at
44
+ # The time when the billing credits expire. If not present, the billing credits don't expire.
45
+ attr_reader :expires_at
46
+ # Unique identifier for the object.
47
+ attr_reader :id
48
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
49
+ attr_reader :livemode
50
+ # Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
51
+ attr_reader :metadata
52
+ # A descriptive name shown in dashboard.
53
+ attr_reader :name
54
+ # String representing the object's type. Objects of the same type share the same value.
55
+ attr_reader :object
56
+ # ID of the test clock this credit grant belongs to.
57
+ attr_reader :test_clock
58
+ # Time at which the object was last updated. Measured in seconds since the Unix epoch.
59
+ attr_reader :updated
60
+ # The time when this credit grant was voided. If not present, the credit grant hasn't been voided.
61
+ attr_reader :voided_at
62
+
63
+ # Creates a credit grant.
20
64
  def self.create(params = {}, opts = {})
21
65
  request_stripe_object(
22
66
  method: :post,
@@ -56,7 +100,7 @@ module Stripe
56
100
  )
57
101
  end
58
102
 
59
- # Updates a credit grant
103
+ # Updates a credit grant.
60
104
  def self.update(id, params = {}, opts = {})
61
105
  request_stripe_object(
62
106
  method: :post,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Stripe
5
5
  module Billing
6
- # A billing meter is a resource that allows you to track usage of a particular event. For example, you might create a billing meter to track the number of API calls made by a particular user. You can then attach the billing meter to a price and attach the price to a subscription to charge the user for the number of API calls they make.
6
+ # Meters specify how to aggregate meter events over a billing period. Meter events represent the actions that customers take in your system. Meters attach to prices and form the basis of the bill.
7
7
  #
8
8
  # Related guide: [Usage based billing](https://docs.stripe.com/billing/subscriptions/usage-based)
9
9
  class Meter < APIResource
@@ -21,12 +21,54 @@ module Stripe
21
21
  operations: %i[list],
22
22
  resource_plural: "event_summaries"
23
23
 
24
- # Creates a billing meter
24
+ class CustomerMapping < Stripe::StripeObject
25
+ attr_reader :event_payload_key, :type
26
+ end
27
+
28
+ class DefaultAggregation < Stripe::StripeObject
29
+ attr_reader :formula
30
+ end
31
+
32
+ class StatusTransitions < Stripe::StripeObject
33
+ attr_reader :deactivated_at
34
+ end
35
+
36
+ class ValueSettings < Stripe::StripeObject
37
+ attr_reader :event_payload_key
38
+ end
39
+ # Time at which the object was created. Measured in seconds since the Unix epoch.
40
+ attr_reader :created
41
+ # Attribute for field customer_mapping
42
+ attr_reader :customer_mapping
43
+ # Attribute for field default_aggregation
44
+ attr_reader :default_aggregation
45
+ # The meter's name.
46
+ attr_reader :display_name
47
+ # The name of the meter event to record usage for. Corresponds with the `event_name` field on meter events.
48
+ attr_reader :event_name
49
+ # The time window to pre-aggregate meter events for, if any.
50
+ attr_reader :event_time_window
51
+ # Unique identifier for the object.
52
+ attr_reader :id
53
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
54
+ attr_reader :livemode
55
+ # String representing the object's type. Objects of the same type share the same value.
56
+ attr_reader :object
57
+ # The meter's status.
58
+ attr_reader :status
59
+ # Attribute for field status_transitions
60
+ attr_reader :status_transitions
61
+ # Time at which the object was last updated. Measured in seconds since the Unix epoch.
62
+ attr_reader :updated
63
+ # Attribute for field value_settings
64
+ attr_reader :value_settings
65
+
66
+ # Creates a billing meter.
25
67
  def self.create(params = {}, opts = {})
26
68
  request_stripe_object(method: :post, path: "/v1/billing/meters", params: params, opts: opts)
27
69
  end
28
70
 
29
- # Deactivates a billing meter
71
+ # When a meter is deactivated, no more meter events will be accepted for this meter. You can't attach a deactivated meter to a price.
30
72
  def deactivate(params = {}, opts = {})
31
73
  request_stripe_object(
32
74
  method: :post,
@@ -36,7 +78,7 @@ module Stripe
36
78
  )
37
79
  end
38
80
 
39
- # Deactivates a billing meter
81
+ # When a meter is deactivated, no more meter events will be accepted for this meter. You can't attach a deactivated meter to a price.
40
82
  def self.deactivate(id, params = {}, opts = {})
41
83
  request_stripe_object(
42
84
  method: :post,
@@ -51,7 +93,7 @@ module Stripe
51
93
  request_stripe_object(method: :get, path: "/v1/billing/meters", params: filters, opts: opts)
52
94
  end
53
95
 
54
- # Reactivates a billing meter
96
+ # When a meter is reactivated, events for this meter can be accepted and you can attach the meter to a price.
55
97
  def reactivate(params = {}, opts = {})
56
98
  request_stripe_object(
57
99
  method: :post,
@@ -61,7 +103,7 @@ module Stripe
61
103
  )
62
104
  end
63
105
 
64
- # Reactivates a billing meter
106
+ # When a meter is reactivated, events for this meter can be accepted and you can attach the meter to a price.
65
107
  def self.reactivate(id, params = {}, opts = {})
66
108
  request_stripe_object(
67
109
  method: :post,
@@ -71,7 +113,7 @@ module Stripe
71
113
  )
72
114
  end
73
115
 
74
- # Updates a billing meter
116
+ # Updates a billing meter.
75
117
  def self.update(id, params = {}, opts = {})
76
118
  request_stripe_object(
77
119
  method: :post,
@@ -0,0 +1,44 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ class MeterErrorReport < APIResource
7
+ OBJECT_NAME = "billing.meter_error_report"
8
+ def self.object_name
9
+ "billing.meter_error_report"
10
+ end
11
+
12
+ class Reason < Stripe::StripeObject
13
+ class ErrorType < Stripe::StripeObject
14
+ class SampleError < Stripe::StripeObject
15
+ class ApiRequest < Stripe::StripeObject
16
+ attr_reader :id, :idempotency_key
17
+ end
18
+ attr_reader :api_request, :error_message
19
+ end
20
+ attr_reader :sample_errors
21
+ end
22
+ attr_reader :error_count, :error_types
23
+ end
24
+
25
+ class RelatedObject < Stripe::StripeObject
26
+ attr_reader :id, :object, :url
27
+ end
28
+ # Unique identifier for the object.
29
+ attr_reader :id
30
+ # String representing the object's type. Objects of the same type share the same value.
31
+ attr_reader :object
32
+ # Attribute for field reason
33
+ attr_reader :reason
34
+ # The related objects about the error
35
+ attr_reader :related_object
36
+ # Summary of invalid events
37
+ attr_reader :summary
38
+ # Time when validation ended. Measured in seconds since the Unix epoch
39
+ attr_reader :validation_end
40
+ # Time when validation started. Measured in seconds since the Unix epoch
41
+ attr_reader :validation_start
42
+ end
43
+ end
44
+ end
@@ -3,8 +3,7 @@
3
3
 
4
4
  module Stripe
5
5
  module Billing
6
- # A billing meter event represents a customer's usage of a product. Meter events are used to bill a customer based on their usage.
7
- # Meter events are associated with billing meters, which define the shape of the event's payload and how those events are aggregated for billing.
6
+ # Meter events represent actions that customers take in your system. You can use meter events to bill a customer based on their usage. Meter events are associated with billing meters, which define both the contents of the event's payload and how to aggregate those events.
8
7
  class MeterEvent < APIResource
9
8
  extend Stripe::APIOperations::Create
10
9
 
@@ -13,7 +12,22 @@ module Stripe
13
12
  "billing.meter_event"
14
13
  end
15
14
 
16
- # Creates a billing meter event
15
+ # Time at which the object was created. Measured in seconds since the Unix epoch.
16
+ attr_reader :created
17
+ # The name of the meter event. Corresponds with the `event_name` field on a meter.
18
+ attr_reader :event_name
19
+ # A unique identifier for the event.
20
+ attr_reader :identifier
21
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
22
+ attr_reader :livemode
23
+ # String representing the object's type. Objects of the same type share the same value.
24
+ attr_reader :object
25
+ # The payload of the event. This contains the fields corresponding to a meter's `customer_mapping.event_payload_key` (default is `stripe_customer_id`) and `value_settings.event_payload_key` (default is `value`). Read more about the [payload](https://stripe.com/docs/billing/subscriptions/usage-based/recording-usage#payload-key-overrides).
26
+ attr_reader :payload
27
+ # The timestamp passed in when creating the event. Measured in seconds since the Unix epoch.
28
+ attr_reader :timestamp
29
+
30
+ # Creates a billing meter event.
17
31
  def self.create(params = {}, opts = {})
18
32
  request_stripe_object(
19
33
  method: :post,
@@ -12,7 +12,23 @@ module Stripe
12
12
  "billing.meter_event_adjustment"
13
13
  end
14
14
 
15
- # Creates a billing meter event adjustment
15
+ class Cancel < Stripe::StripeObject
16
+ attr_reader :identifier
17
+ end
18
+ # Specifies which event to cancel.
19
+ attr_reader :cancel
20
+ # The name of the meter event. Corresponds with the `event_name` field on a meter.
21
+ attr_reader :event_name
22
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
23
+ attr_reader :livemode
24
+ # String representing the object's type. Objects of the same type share the same value.
25
+ attr_reader :object
26
+ # The meter event adjustment's status.
27
+ attr_reader :status
28
+ # Specifies whether to cancel a single event or a range of events for a time period. Time period cancellation is not supported yet.
29
+ attr_reader :type
30
+
31
+ # Creates a billing meter event adjustment.
16
32
  def self.create(params = {}, opts = {})
17
33
  request_stripe_object(
18
34
  method: :post,
@@ -10,6 +10,21 @@ module Stripe
10
10
  def self.object_name
11
11
  "billing.meter_event_summary"
12
12
  end
13
+
14
+ # Aggregated value of all the events within `start_time` (inclusive) and `end_time` (inclusive). The aggregation strategy is defined on meter via `default_aggregation`.
15
+ attr_reader :aggregated_value
16
+ # End timestamp for this event summary (exclusive). Must be aligned with minute boundaries.
17
+ attr_reader :end_time
18
+ # Unique identifier for the object.
19
+ attr_reader :id
20
+ # Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
21
+ attr_reader :livemode
22
+ # The meter associated with this event summary.
23
+ attr_reader :meter
24
+ # String representing the object's type. Objects of the same type share the same value.
25
+ attr_reader :object
26
+ # Start timestamp for this event summary (inclusive). Must be aligned with minute boundaries.
27
+ attr_reader :start_time
13
28
  end
14
29
  end
15
30
  end