stripe 15.2.0.pre.beta.1 → 15.3.0.pre.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -0
  3. data/CONTRIBUTING.md +25 -0
  4. data/OPENAPI_VERSION +1 -1
  5. data/README.md +10 -7
  6. data/VERSION +1 -1
  7. data/lib/stripe/api_version.rb +1 -1
  8. data/lib/stripe/event_types.rb +9 -0
  9. data/lib/stripe/events/v2_core_account_link_completed_event.rb +1 -1
  10. data/lib/stripe/events/v2_money_management_inbound_transfer_bank_debit_failed_event.rb +1 -1
  11. data/lib/stripe/events/v2_money_management_inbound_transfer_bank_debit_processing_event.rb +1 -1
  12. data/lib/stripe/events/v2_money_management_inbound_transfer_bank_debit_queued_event.rb +1 -1
  13. data/lib/stripe/events/v2_money_management_inbound_transfer_bank_debit_returned_event.rb +1 -1
  14. data/lib/stripe/events/v2_money_management_inbound_transfer_bank_debit_succeeded_event.rb +1 -1
  15. data/lib/stripe/events/v2_money_management_outbound_payment_canceled_event.rb +1 -1
  16. data/lib/stripe/events/v2_money_management_outbound_payment_failed_event.rb +1 -1
  17. data/lib/stripe/events/v2_money_management_outbound_payment_posted_event.rb +1 -1
  18. data/lib/stripe/events/v2_money_management_outbound_payment_returned_event.rb +1 -1
  19. data/lib/stripe/events/v2_money_management_outbound_payment_updated_event.rb +1 -1
  20. data/lib/stripe/events/v2_off_session_payment_requires_capture_event.rb +21 -0
  21. data/lib/stripe/events/v2_payments_off_session_payment_authorization_attempt_failed_event.rb +21 -0
  22. data/lib/stripe/events/v2_payments_off_session_payment_authorization_attempt_started_event.rb +21 -0
  23. data/lib/stripe/events/v2_payments_off_session_payment_canceled_event.rb +21 -0
  24. data/lib/stripe/events/v2_payments_off_session_payment_created_event.rb +21 -0
  25. data/lib/stripe/events/v2_payments_off_session_payment_failed_event.rb +21 -0
  26. data/lib/stripe/events/v2_payments_off_session_payment_succeeded_event.rb +21 -0
  27. data/lib/stripe/object_types.rb +1 -3
  28. data/lib/stripe/resources/account.rb +47 -20
  29. data/lib/stripe/resources/account_session.rb +85 -24
  30. data/lib/stripe/resources/apple_pay_domain.rb +1 -2
  31. data/lib/stripe/resources/balance.rb +42 -0
  32. data/lib/stripe/resources/balance_transaction.rb +2 -0
  33. data/lib/stripe/resources/bank_account.rb +2 -2
  34. data/lib/stripe/resources/billing_portal/session.rb +1 -1
  35. data/lib/stripe/resources/capability.rb +1 -1
  36. data/lib/stripe/resources/charge.rb +85 -9
  37. data/lib/stripe/resources/checkout/session.rb +22 -6
  38. data/lib/stripe/resources/confirmation_token.rb +37 -97
  39. data/lib/stripe/resources/country_spec.rb +1 -1
  40. data/lib/stripe/resources/coupon.rb +1 -2
  41. data/lib/stripe/resources/credit_note.rb +10 -11
  42. data/lib/stripe/resources/customer.rb +2 -4
  43. data/lib/stripe/resources/customer_session.rb +3 -3
  44. data/lib/stripe/resources/dispute.rb +2 -2
  45. data/lib/stripe/resources/event.rb +1 -1
  46. data/lib/stripe/resources/file.rb +1 -1
  47. data/lib/stripe/resources/financial_connections/account.rb +2 -0
  48. data/lib/stripe/resources/financial_connections/institution.rb +2 -0
  49. data/lib/stripe/resources/identity/verification_report.rb +6 -0
  50. data/lib/stripe/resources/identity/verification_session.rb +17 -11
  51. data/lib/stripe/resources/invoice.rb +70 -43
  52. data/lib/stripe/resources/invoice_item.rb +2 -3
  53. data/lib/stripe/resources/invoice_line_item.rb +1 -1
  54. data/lib/stripe/resources/invoice_payment.rb +9 -2
  55. data/lib/stripe/resources/issuing/authorization.rb +8 -8
  56. data/lib/stripe/resources/issuing/card.rb +1 -1
  57. data/lib/stripe/resources/issuing/dispute.rb +3 -3
  58. data/lib/stripe/resources/order.rb +2 -55
  59. data/lib/stripe/resources/payment_attempt_record.rb +8 -0
  60. data/lib/stripe/resources/payment_intent.rb +439 -411
  61. data/lib/stripe/resources/payment_intent_amount_details_line_item.rb +7 -0
  62. data/lib/stripe/resources/payment_method.rb +50 -113
  63. data/lib/stripe/resources/payment_method_configuration.rb +297 -2
  64. data/lib/stripe/resources/payment_method_domain.rb +2 -2
  65. data/lib/stripe/resources/payment_record.rb +8 -0
  66. data/lib/stripe/resources/payout.rb +4 -4
  67. data/lib/stripe/resources/person.rb +2 -2
  68. data/lib/stripe/resources/plan.rb +2 -3
  69. data/lib/stripe/resources/price.rb +1 -1
  70. data/lib/stripe/resources/privacy/redaction_job.rb +52 -29
  71. data/lib/stripe/resources/privacy/redaction_job_validation_error.rb +12 -4
  72. data/lib/stripe/resources/product.rb +1 -61
  73. data/lib/stripe/resources/quote.rb +1 -1
  74. data/lib/stripe/resources/quote_preview_invoice.rb +2 -2
  75. data/lib/stripe/resources/quote_preview_subscription_schedule.rb +26 -1
  76. data/lib/stripe/resources/radar/value_list.rb +1 -2
  77. data/lib/stripe/resources/radar/value_list_item.rb +1 -2
  78. data/lib/stripe/resources/refund.rb +6 -1
  79. data/lib/stripe/resources/reversal.rb +1 -1
  80. data/lib/stripe/resources/review.rb +1 -1
  81. data/lib/stripe/resources/setup_intent.rb +123 -311
  82. data/lib/stripe/resources/source.rb +1 -1
  83. data/lib/stripe/resources/subscription.rb +132 -37
  84. data/lib/stripe/resources/subscription_item.rb +33 -0
  85. data/lib/stripe/resources/subscription_schedule.rb +120 -5
  86. data/lib/stripe/resources/tax/association.rb +8 -31
  87. data/lib/stripe/resources/tax/calculation.rb +4 -0
  88. data/lib/stripe/resources/tax/calculation_line_item.rb +2 -0
  89. data/lib/stripe/resources/tax/registration.rb +1 -1
  90. data/lib/stripe/resources/tax_id.rb +1 -2
  91. data/lib/stripe/resources/tax_rate.rb +2 -2
  92. data/lib/stripe/resources/terminal/configuration.rb +1 -2
  93. data/lib/stripe/resources/terminal/location.rb +2 -3
  94. data/lib/stripe/resources/terminal/reader.rb +26 -4
  95. data/lib/stripe/resources/test_helpers/test_clock.rb +1 -2
  96. data/lib/stripe/resources/token.rb +2 -2
  97. data/lib/stripe/resources/transfer.rb +1 -1
  98. data/lib/stripe/resources/v2/core/account.rb +5 -5
  99. data/lib/stripe/resources/v2/money_management/received_credit.rb +0 -20
  100. data/lib/stripe/resources/v2/money_management/received_debit.rb +0 -24
  101. data/lib/stripe/resources/v2/payments/off_session_payment.rb +74 -0
  102. data/lib/stripe/resources/webhook_endpoint.rb +1 -2
  103. data/lib/stripe/resources.rb +8 -3
  104. data/lib/stripe/services/account_external_account_service.rb +2 -3
  105. data/lib/stripe/services/account_login_link_service.rb +1 -1
  106. data/lib/stripe/services/account_person_service.rb +1 -2
  107. data/lib/stripe/services/account_service.rb +38 -13
  108. data/lib/stripe/services/account_session_service.rb +49 -24
  109. data/lib/stripe/services/apple_pay_domain_service.rb +1 -2
  110. data/lib/stripe/services/balance_service.rb +1 -1
  111. data/lib/stripe/services/balance_settings_service.rb +2 -2
  112. data/lib/stripe/services/charge_service.rb +76 -8
  113. data/lib/stripe/services/checkout/session_service.rb +14 -6
  114. data/lib/stripe/services/coupon_service.rb +1 -2
  115. data/lib/stripe/services/credit_note_service.rb +7 -8
  116. data/lib/stripe/services/customer_balance_transaction_service.rb +3 -3
  117. data/lib/stripe/services/customer_cash_balance_transaction_service.rb +2 -2
  118. data/lib/stripe/services/customer_payment_source_service.rb +1 -1
  119. data/lib/stripe/services/customer_service.rb +3 -5
  120. data/lib/stripe/services/customer_tax_id_service.rb +1 -2
  121. data/lib/stripe/services/dispute_service.rb +1 -1
  122. data/lib/stripe/services/external_account_service.rb +2 -3
  123. data/lib/stripe/services/file_service.rb +1 -1
  124. data/lib/stripe/services/identity/verification_session_service.rb +5 -5
  125. data/lib/stripe/services/invoice_item_service.rb +1 -2
  126. data/lib/stripe/services/invoice_service.rb +65 -35
  127. data/lib/stripe/services/issuing/authorization_service.rb +4 -4
  128. data/lib/stripe/services/issuing/card_service.rb +1 -1
  129. data/lib/stripe/services/issuing/dispute_service.rb +2 -2
  130. data/lib/stripe/services/order_service.rb +1 -33
  131. data/lib/stripe/services/payment_intent_service.rb +385 -386
  132. data/lib/stripe/services/payment_method_configuration_service.rb +212 -2
  133. data/lib/stripe/services/payment_method_domain_service.rb +1 -1
  134. data/lib/stripe/services/payment_method_service.rb +47 -110
  135. data/lib/stripe/services/payout_service.rb +2 -2
  136. data/lib/stripe/services/plan_service.rb +2 -3
  137. data/lib/stripe/services/price_service.rb +2 -2
  138. data/lib/stripe/services/privacy/redaction_job_service.rb +22 -13
  139. data/lib/stripe/services/privacy/redaction_job_validation_error_service.rb +1 -1
  140. data/lib/stripe/services/product_feature_service.rb +1 -2
  141. data/lib/stripe/services/product_service.rb +2 -41
  142. data/lib/stripe/services/promotion_code_service.rb +1 -1
  143. data/lib/stripe/services/quote_service.rb +1 -1
  144. data/lib/stripe/services/radar/early_fraud_warning_service.rb +1 -1
  145. data/lib/stripe/services/radar/value_list_item_service.rb +1 -2
  146. data/lib/stripe/services/radar/value_list_service.rb +1 -2
  147. data/lib/stripe/services/setup_intent_service.rb +122 -310
  148. data/lib/stripe/services/source_service.rb +1 -1
  149. data/lib/stripe/services/subscription_item_service.rb +26 -0
  150. data/lib/stripe/services/subscription_schedule_service.rb +94 -4
  151. data/lib/stripe/services/subscription_service.rb +103 -33
  152. data/lib/stripe/services/tax/calculation_service.rb +4 -0
  153. data/lib/stripe/services/tax/registration_service.rb +1 -1
  154. data/lib/stripe/services/tax_id_service.rb +1 -2
  155. data/lib/stripe/services/terminal/configuration_service.rb +1 -2
  156. data/lib/stripe/services/terminal/location_service.rb +2 -3
  157. data/lib/stripe/services/terminal/reader_service.rb +17 -3
  158. data/lib/stripe/services/test_helpers/confirmation_token_service.rb +37 -97
  159. data/lib/stripe/services/test_helpers/test_clock_service.rb +1 -2
  160. data/lib/stripe/services/token_service.rb +1 -1
  161. data/lib/stripe/services/transfer_service.rb +1 -1
  162. data/lib/stripe/services/v1_services.rb +1 -2
  163. data/lib/stripe/services/v2/billing/meter_event_session_service.rb +1 -2
  164. data/lib/stripe/services/v2/core/accounts/person_service.rb +2 -4
  165. data/lib/stripe/services/v2/core/event_destination_service.rb +4 -10
  166. data/lib/stripe/services/v2/core/event_service.rb +1 -2
  167. data/lib/stripe/services/v2/core/vault/gb_bank_account_service.rb +3 -7
  168. data/lib/stripe/services/v2/core/vault/us_bank_account_service.rb +2 -4
  169. data/lib/stripe/services/v2/money_management/adjustment_service.rb +1 -2
  170. data/lib/stripe/services/v2/money_management/financial_account_service.rb +1 -2
  171. data/lib/stripe/services/v2/money_management/financial_address_service.rb +1 -1
  172. data/lib/stripe/services/v2/money_management/inbound_transfer_service.rb +1 -2
  173. data/lib/stripe/services/v2/money_management/outbound_payment_quote_service.rb +1 -2
  174. data/lib/stripe/services/v2/money_management/outbound_payment_service.rb +2 -4
  175. data/lib/stripe/services/v2/money_management/outbound_setup_intent_service.rb +2 -4
  176. data/lib/stripe/services/v2/money_management/outbound_transfer_service.rb +2 -4
  177. data/lib/stripe/services/v2/money_management/payout_method_service.rb +3 -7
  178. data/lib/stripe/services/v2/money_management/received_credit_service.rb +1 -2
  179. data/lib/stripe/services/v2/money_management/received_debit_service.rb +1 -2
  180. data/lib/stripe/services/v2/money_management/transaction_entry_service.rb +1 -2
  181. data/lib/stripe/services/v2/money_management/transaction_service.rb +1 -2
  182. data/lib/stripe/services/v2/payment_service.rb +15 -0
  183. data/lib/stripe/services/v2/payments/off_session_payment_service.rb +138 -0
  184. data/lib/stripe/services/v2/test_helpers/financial_address_service.rb +1 -2
  185. data/lib/stripe/services/v2_services.rb +2 -1
  186. data/lib/stripe/services/webhook_endpoint_service.rb +1 -2
  187. data/lib/stripe/services.rb +2 -3
  188. data/lib/stripe/version.rb +1 -1
  189. data/rbi/stripe.rbi +3903 -4131
  190. metadata +13 -8
  191. data/lib/stripe/resources/billing/meter_error_report.rb +0 -59
  192. data/lib/stripe/resources/gift_cards/card.rb +0 -208
  193. data/lib/stripe/resources/gift_cards/transaction.rb +0 -272
  194. data/lib/stripe/services/gift_cards/card_service.rb +0 -170
  195. data/lib/stripe/services/gift_cards/transaction_service.rb +0 -209
  196. data/lib/stripe/services/gift_cards_service.rb +0 -14
@@ -1258,7 +1258,7 @@ module Stripe
1258
1258
 
1259
1259
  # Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
1260
1260
  #
1261
- # This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our [payment method guides](https://stripe.com/docs/sources) for more detail.
1261
+ # This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our [payment method guides](https://docs.stripe.com/docs/sources) for more detail.
1262
1262
  def self.update(source, params = {}, opts = {})
1263
1263
  request_stripe_object(
1264
1264
  method: :post,
@@ -44,6 +44,18 @@ module Stripe
44
44
  attr_reader :second
45
45
  end
46
46
 
47
+ class BillingModeDetails < Stripe::StripeObject
48
+ # Details on when the current billing_mode was adopted.
49
+ attr_reader :updated_at
50
+ end
51
+
52
+ class BillingThresholds < Stripe::StripeObject
53
+ # Monetary threshold that triggers the subscription to create an invoice
54
+ attr_reader :amount_gte
55
+ # Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If true, `billing_cycle_anchor` will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged. This value may not be `true` if the subscription contains items with plans that have `aggregate_usage=last_ever`.
56
+ attr_reader :reset_billing_cycle_anchor
57
+ end
58
+
47
59
  class CancellationDetails < Stripe::StripeObject
48
60
  # Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
49
61
  attr_reader :comment
@@ -381,6 +393,18 @@ module Stripe
381
393
  end
382
394
  end
383
395
 
396
+ class BillingThresholds < Stripe::RequestParams
397
+ # Monetary threshold that triggers the subscription to advance to a new billing period
398
+ attr_accessor :amount_gte
399
+ # Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If true, `billing_cycle_anchor` will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged.
400
+ attr_accessor :reset_billing_cycle_anchor
401
+
402
+ def initialize(amount_gte: nil, reset_billing_cycle_anchor: nil)
403
+ @amount_gte = amount_gte
404
+ @reset_billing_cycle_anchor = reset_billing_cycle_anchor
405
+ end
406
+ end
407
+
384
408
  class CancellationDetails < Stripe::RequestParams
385
409
  # Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
386
410
  attr_accessor :comment
@@ -460,6 +484,15 @@ module Stripe
460
484
  end
461
485
 
462
486
  class Item < Stripe::RequestParams
487
+ class BillingThresholds < Stripe::RequestParams
488
+ # Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte))
489
+ attr_accessor :usage_gte
490
+
491
+ def initialize(usage_gte: nil)
492
+ @usage_gte = usage_gte
493
+ end
494
+ end
495
+
463
496
  class Discount < Stripe::RequestParams
464
497
  class DiscountEnd < Stripe::RequestParams
465
498
  class Duration < Stripe::RequestParams
@@ -544,6 +577,8 @@ module Stripe
544
577
  @unit_amount_decimal = unit_amount_decimal
545
578
  end
546
579
  end
580
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
581
+ attr_accessor :billing_thresholds
547
582
  # Delete all usage for a given subscription item. You must pass this when deleting a usage records subscription item. `clear_usage` has no effect if the plan has a billing meter attached.
548
583
  attr_accessor :clear_usage
549
584
  # A flag that, if set to `true`, will delete the specified item.
@@ -566,6 +601,7 @@ module Stripe
566
601
  attr_accessor :tax_rates
567
602
 
568
603
  def initialize(
604
+ billing_thresholds: nil,
569
605
  clear_usage: nil,
570
606
  deleted: nil,
571
607
  discounts: nil,
@@ -577,6 +613,7 @@ module Stripe
577
613
  quantity: nil,
578
614
  tax_rates: nil
579
615
  )
616
+ @billing_thresholds = billing_thresholds
580
617
  @clear_usage = clear_usage
581
618
  @deleted = deleted
582
619
  @discounts = discounts
@@ -693,14 +730,9 @@ module Stripe
693
730
  end
694
731
  end
695
732
 
696
- class IdBankTransfer < Stripe::RequestParams
697
- end
698
-
699
- class Konbini < Stripe::RequestParams
700
- end
701
-
702
- class SepaDebit < Stripe::RequestParams
703
- end
733
+ class IdBankTransfer < Stripe::RequestParams; end
734
+ class Konbini < Stripe::RequestParams; end
735
+ class SepaDebit < Stripe::RequestParams; end
704
736
 
705
737
  class UsBankAccount < Stripe::RequestParams
706
738
  class FinancialConnections < Stripe::RequestParams
@@ -853,9 +885,11 @@ module Stripe
853
885
  attr_accessor :automatic_tax
854
886
  # Either `now` or `unchanged`. Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
855
887
  attr_accessor :billing_cycle_anchor
888
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.
889
+ attr_accessor :billing_thresholds
856
890
  # A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
857
891
  attr_accessor :cancel_at
858
- # Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
892
+ # Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`. This param will be removed in a future API version. Please use `cancel_at` instead.
859
893
  attr_accessor :cancel_at_period_end
860
894
  # Details about why this subscription was cancelled
861
895
  attr_accessor :cancellation_details
@@ -903,11 +937,11 @@ module Stripe
903
937
  attr_accessor :prebilling
904
938
  # Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
905
939
  attr_accessor :proration_behavior
906
- # If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#upcoming_invoice) endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
940
+ # If set, prorations will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same prorations that were previewed with the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint. `proration_date` can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
907
941
  attr_accessor :proration_date
908
942
  # If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. This will be unset if you POST an empty value.
909
943
  attr_accessor :transfer_data
910
- # Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`.
944
+ # Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set, `trial_end` will override the default trial period of the plan the customer is being subscribed to. The `billing_cycle_anchor` will be updated to the `trial_end` value. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`.
911
945
  attr_accessor :trial_end
912
946
  # Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
913
947
  attr_accessor :trial_from_plan
@@ -919,6 +953,7 @@ module Stripe
919
953
  application_fee_percent: nil,
920
954
  automatic_tax: nil,
921
955
  billing_cycle_anchor: nil,
956
+ billing_thresholds: nil,
922
957
  cancel_at: nil,
923
958
  cancel_at_period_end: nil,
924
959
  cancellation_details: nil,
@@ -951,6 +986,7 @@ module Stripe
951
986
  @application_fee_percent = application_fee_percent
952
987
  @automatic_tax = automatic_tax
953
988
  @billing_cycle_anchor = billing_cycle_anchor
989
+ @billing_thresholds = billing_thresholds
954
990
  @cancel_at = cancel_at
955
991
  @cancel_at_period_end = cancel_at_period_end
956
992
  @cancellation_details = cancellation_details
@@ -981,8 +1017,7 @@ module Stripe
981
1017
  end
982
1018
  end
983
1019
 
984
- class DeleteDiscountParams < Stripe::RequestParams
985
- end
1020
+ class DeleteDiscountParams < Stripe::RequestParams; end
986
1021
 
987
1022
  class ListParams < Stripe::RequestParams
988
1023
  class AutomaticTax < Stripe::RequestParams
@@ -1248,6 +1283,18 @@ module Stripe
1248
1283
  end
1249
1284
  end
1250
1285
 
1286
+ class BillingThresholds < Stripe::RequestParams
1287
+ # Monetary threshold that triggers the subscription to advance to a new billing period
1288
+ attr_accessor :amount_gte
1289
+ # Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If true, `billing_cycle_anchor` will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged.
1290
+ attr_accessor :reset_billing_cycle_anchor
1291
+
1292
+ def initialize(amount_gte: nil, reset_billing_cycle_anchor: nil)
1293
+ @amount_gte = amount_gte
1294
+ @reset_billing_cycle_anchor = reset_billing_cycle_anchor
1295
+ end
1296
+ end
1297
+
1251
1298
  class Discount < Stripe::RequestParams
1252
1299
  class DiscountEnd < Stripe::RequestParams
1253
1300
  class Duration < Stripe::RequestParams
@@ -1315,6 +1362,15 @@ module Stripe
1315
1362
  end
1316
1363
 
1317
1364
  class Item < Stripe::RequestParams
1365
+ class BillingThresholds < Stripe::RequestParams
1366
+ # Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte))
1367
+ attr_accessor :usage_gte
1368
+
1369
+ def initialize(usage_gte: nil)
1370
+ @usage_gte = usage_gte
1371
+ end
1372
+ end
1373
+
1318
1374
  class Discount < Stripe::RequestParams
1319
1375
  class DiscountEnd < Stripe::RequestParams
1320
1376
  class Duration < Stripe::RequestParams
@@ -1411,6 +1467,8 @@ module Stripe
1411
1467
  @type = type
1412
1468
  end
1413
1469
  end
1470
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
1471
+ attr_accessor :billing_thresholds
1414
1472
  # The coupons to redeem into discounts for the subscription item.
1415
1473
  attr_accessor :discounts
1416
1474
  # 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
@@ -1429,6 +1487,7 @@ module Stripe
1429
1487
  attr_accessor :trial
1430
1488
 
1431
1489
  def initialize(
1490
+ billing_thresholds: nil,
1432
1491
  discounts: nil,
1433
1492
  metadata: nil,
1434
1493
  plan: nil,
@@ -1438,6 +1497,7 @@ module Stripe
1438
1497
  tax_rates: nil,
1439
1498
  trial: nil
1440
1499
  )
1500
+ @billing_thresholds = billing_thresholds
1441
1501
  @discounts = discounts
1442
1502
  @metadata = metadata
1443
1503
  @plan = plan
@@ -1540,14 +1600,9 @@ module Stripe
1540
1600
  end
1541
1601
  end
1542
1602
 
1543
- class IdBankTransfer < Stripe::RequestParams
1544
- end
1545
-
1546
- class Konbini < Stripe::RequestParams
1547
- end
1548
-
1549
- class SepaDebit < Stripe::RequestParams
1550
- end
1603
+ class IdBankTransfer < Stripe::RequestParams; end
1604
+ class Konbini < Stripe::RequestParams; end
1605
+ class SepaDebit < Stripe::RequestParams; end
1551
1606
 
1552
1607
  class UsBankAccount < Stripe::RequestParams
1553
1608
  class FinancialConnections < Stripe::RequestParams
@@ -1704,11 +1759,13 @@ module Stripe
1704
1759
  attr_accessor :billing_cycle_anchor
1705
1760
  # Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. When provided, the billing_cycle_anchor is set to the next occurence of the day_of_month at the hour, minute, and second UTC.
1706
1761
  attr_accessor :billing_cycle_anchor_config
1707
- # Configure billing_mode in each subscription to opt in improved credit proration behavior.
1762
+ # Controls how prorations and invoices for subscriptions are calculated and orchestrated.
1708
1763
  attr_accessor :billing_mode
1764
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.
1765
+ attr_accessor :billing_thresholds
1709
1766
  # A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
1710
1767
  attr_accessor :cancel_at
1711
- # Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
1768
+ # Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`. This param will be removed in a future API version. Please use `cancel_at` instead.
1712
1769
  attr_accessor :cancel_at_period_end
1713
1770
  # Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Defaults to `charge_automatically`.
1714
1771
  attr_accessor :collection_method
@@ -1781,6 +1838,7 @@ module Stripe
1781
1838
  billing_cycle_anchor: nil,
1782
1839
  billing_cycle_anchor_config: nil,
1783
1840
  billing_mode: nil,
1841
+ billing_thresholds: nil,
1784
1842
  cancel_at: nil,
1785
1843
  cancel_at_period_end: nil,
1786
1844
  collection_method: nil,
@@ -1817,6 +1875,7 @@ module Stripe
1817
1875
  @billing_cycle_anchor = billing_cycle_anchor
1818
1876
  @billing_cycle_anchor_config = billing_cycle_anchor_config
1819
1877
  @billing_mode = billing_mode
1878
+ @billing_thresholds = billing_thresholds
1820
1879
  @cancel_at = cancel_at
1821
1880
  @cancel_at_period_end = cancel_at_period_end
1822
1881
  @collection_method = collection_method
@@ -1866,14 +1925,26 @@ module Stripe
1866
1925
  end
1867
1926
  end
1868
1927
 
1928
+ class MigrateParams < Stripe::RequestParams
1929
+ # Controls how prorations and invoices for subscriptions are calculated and orchestrated.
1930
+ attr_accessor :billing_mode
1931
+ # Specifies which fields in the response should be expanded.
1932
+ attr_accessor :expand
1933
+
1934
+ def initialize(billing_mode: nil, expand: nil)
1935
+ @billing_mode = billing_mode
1936
+ @expand = expand
1937
+ end
1938
+ end
1939
+
1869
1940
  class ResumeParams < Stripe::RequestParams
1870
1941
  # The billing cycle anchor that applies when the subscription is resumed. Either `now` or `unchanged`. The default is `now`. For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
1871
1942
  attr_accessor :billing_cycle_anchor
1872
1943
  # Specifies which fields in the response should be expanded.
1873
1944
  attr_accessor :expand
1874
- # Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
1945
+ # Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) resulting from the `billing_cycle_anchor` being `unchanged`. When the `billing_cycle_anchor` is set to `now` (default value), no prorations are generated. If no value is passed, the default is `create_prorations`.
1875
1946
  attr_accessor :proration_behavior
1876
- # If set, the proration will be calculated as though the subscription was resumed at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint.
1947
+ # If set, prorations will be calculated as though the subscription was resumed at the given time. This can be used to apply exactly the same prorations that were previewed with the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint.
1877
1948
  attr_accessor :proration_date
1878
1949
 
1879
1950
  def initialize(
@@ -1898,11 +1969,15 @@ module Stripe
1898
1969
  attr_reader :billing_cycle_anchor
1899
1970
  # The fixed values used to calculate the `billing_cycle_anchor`.
1900
1971
  attr_reader :billing_cycle_anchor_config
1901
- # Configure billing_mode in each subscription to opt in improved credit proration behavior.
1972
+ # Controls how prorations and invoices for subscriptions are calculated and orchestrated.
1902
1973
  attr_reader :billing_mode
1974
+ # Details about when the current billing_mode was updated.
1975
+ attr_reader :billing_mode_details
1976
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
1977
+ attr_reader :billing_thresholds
1903
1978
  # A date in the future at which the subscription will automatically get canceled
1904
1979
  attr_reader :cancel_at
1905
- # Whether this subscription will (if `status=active`) or did (if `status=canceled`) cancel at the end of the current billing period.
1980
+ # Whether this subscription will (if `status=active`) or did (if `status=canceled`) cancel at the end of the current billing period. This field will be removed in a future API version. Please use `cancel_at` instead.
1906
1981
  attr_reader :cancel_at_period_end
1907
1982
  # If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with `cancel_at_period_end`, `canceled_at` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.
1908
1983
  attr_reader :canceled_at
@@ -1988,12 +2063,12 @@ module Stripe
1988
2063
  attr_reader :trial_end
1989
2064
  # Settings related to subscription trials.
1990
2065
  attr_reader :trial_settings
1991
- # If the subscription has a trial, the beginning of that trial.
2066
+ # If the subscription has a trial, the beginning of that trial. For subsequent trials, this date remains as the start of the first ever trial on the subscription.
1992
2067
  attr_reader :trial_start
1993
2068
 
1994
- # Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata).
2069
+ # Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://docs.stripe.com/metadata).
1995
2070
  #
1996
- # Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed if invoice_now and prorate are both set to true.
2071
+ # Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://docs.stripe.com/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed if invoice_now and prorate are both set to true.
1997
2072
  #
1998
2073
  # By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
1999
2074
  def cancel(params = {}, opts = {})
@@ -2005,9 +2080,9 @@ module Stripe
2005
2080
  )
2006
2081
  end
2007
2082
 
2008
- # Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata).
2083
+ # Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://docs.stripe.com/metadata).
2009
2084
  #
2010
- # Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed if invoice_now and prorate are both set to true.
2085
+ # Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://docs.stripe.com/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed if invoice_now and prorate are both set to true.
2011
2086
  #
2012
2087
  # By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
2013
2088
  def self.cancel(subscription_exposed_id, params = {}, opts = {})
@@ -2024,7 +2099,7 @@ module Stripe
2024
2099
  # When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.
2025
2100
  # The payment_behavior parameter determines the exact behavior of the initial payment.
2026
2101
  #
2027
- # To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead.
2102
+ # To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://docs.stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead.
2028
2103
  # Schedules provide the flexibility to model more complex billing configurations that change over time.
2029
2104
  def self.create(params = {}, opts = {})
2030
2105
  request_stripe_object(method: :post, path: "/v1/subscriptions", params: params, opts: opts)
@@ -2055,6 +2130,26 @@ module Stripe
2055
2130
  request_stripe_object(method: :get, path: "/v1/subscriptions", params: params, opts: opts)
2056
2131
  end
2057
2132
 
2133
+ # Upgrade the billing_mode of an existing subscription.
2134
+ def migrate(params = {}, opts = {})
2135
+ request_stripe_object(
2136
+ method: :post,
2137
+ path: format("/v1/subscriptions/%<subscription>s/migrate", { subscription: CGI.escape(self["id"]) }),
2138
+ params: params,
2139
+ opts: opts
2140
+ )
2141
+ end
2142
+
2143
+ # Upgrade the billing_mode of an existing subscription.
2144
+ def self.migrate(subscription, params = {}, opts = {})
2145
+ request_stripe_object(
2146
+ method: :post,
2147
+ path: format("/v1/subscriptions/%<subscription>s/migrate", { subscription: CGI.escape(subscription) }),
2148
+ params: params,
2149
+ opts: opts
2150
+ )
2151
+ end
2152
+
2058
2153
  # Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.
2059
2154
  def resume(params = {}, opts = {})
2060
2155
  request_stripe_object(
@@ -2090,7 +2185,7 @@ module Stripe
2090
2185
 
2091
2186
  # Updates an existing subscription to match the specified parameters.
2092
2187
  # When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes.
2093
- # To preview how the proration is calculated, use the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint.
2188
+ # To preview how the proration is calculated, use the [create preview](https://docs.stripe.com/docs/api/invoices/create_preview) endpoint.
2094
2189
  #
2095
2190
  # By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a 100 price, they'll be billed 100 immediately. If on May 15 they switch to a 200 price, then on June 1 they'll be billed 250 (200 for a renewal of her subscription, plus a 50 prorating adjustment for half of the previous month's 100 difference). Similarly, a downgrade generates a credit that is applied to the next invoice. We also prorate when you make quantity changes.
2096
2191
  #
@@ -2102,13 +2197,13 @@ module Stripe
2102
2197
  # A trial starts or ends.
2103
2198
  #
2104
2199
  #
2105
- # In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date. Learn about how [Stripe immediately attempts payment for subscription changes](https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment).
2200
+ # In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date. Learn about how [Stripe immediately attempts payment for subscription changes](https://docs.stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment).
2106
2201
  #
2107
- # If you want to charge for an upgrade immediately, pass proration_behavior as always_invoice to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription's renewal date, you need to manually [invoice the customer](https://stripe.com/docs/api/invoices/create).
2202
+ # If you want to charge for an upgrade immediately, pass proration_behavior as always_invoice to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription's renewal date, you need to manually [invoice the customer](https://docs.stripe.com/docs/api/invoices/create).
2108
2203
  #
2109
2204
  # If you don't want to prorate, set the proration_behavior option to none. With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set proration_behavior to none when switching between different billing intervals (for example, from monthly to yearly), we don't generate any credits for the old subscription's unused time. We still reset the billing date and bill immediately for the new subscription.
2110
2205
  #
2111
- # Updating the quantity on a subscription many times in an hour may result in [rate limiting. If you need to bill for a frequently changing quantity, consider integrating <a href="/docs/billing/subscriptions/usage-based">usage-based billing](https://stripe.com/docs/rate-limits) instead.
2206
+ # Updating the quantity on a subscription many times in an hour may result in [rate limiting. If you need to bill for a frequently changing quantity, consider integrating <a href="/docs/billing/subscriptions/usage-based">usage-based billing](https://docs.stripe.com/docs/rate-limits) instead.
2112
2207
  def self.update(subscription_exposed_id, params = {}, opts = {})
2113
2208
  request_stripe_object(
2114
2209
  method: :post,
@@ -15,6 +15,11 @@ module Stripe
15
15
  "subscription_item"
16
16
  end
17
17
 
18
+ class BillingThresholds < Stripe::StripeObject
19
+ # Usage threshold that triggers the subscription to create an invoice
20
+ attr_reader :usage_gte
21
+ end
22
+
18
23
  class Trial < Stripe::StripeObject
19
24
  # List of price IDs which, if present on the subscription following a paid trial, constitute opting-in to the paid trial.
20
25
  attr_reader :converts_to
@@ -38,6 +43,15 @@ module Stripe
38
43
  end
39
44
 
40
45
  class UpdateParams < Stripe::RequestParams
46
+ class BillingThresholds < Stripe::RequestParams
47
+ # Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte))
48
+ attr_accessor :usage_gte
49
+
50
+ def initialize(usage_gte: nil)
51
+ @usage_gte = usage_gte
52
+ end
53
+ end
54
+
41
55
  class Discount < Stripe::RequestParams
42
56
  class DiscountEnd < Stripe::RequestParams
43
57
  class Duration < Stripe::RequestParams
@@ -122,6 +136,8 @@ module Stripe
122
136
  @unit_amount_decimal = unit_amount_decimal
123
137
  end
124
138
  end
139
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
140
+ attr_accessor :billing_thresholds
125
141
  # The coupons to redeem into discounts for the subscription item.
126
142
  attr_accessor :discounts
127
143
  # Specifies which fields in the response should be expanded.
@@ -154,6 +170,7 @@ module Stripe
154
170
  attr_accessor :tax_rates
155
171
 
156
172
  def initialize(
173
+ billing_thresholds: nil,
157
174
  discounts: nil,
158
175
  expand: nil,
159
176
  metadata: nil,
@@ -167,6 +184,7 @@ module Stripe
167
184
  quantity: nil,
168
185
  tax_rates: nil
169
186
  )
187
+ @billing_thresholds = billing_thresholds
170
188
  @discounts = discounts
171
189
  @expand = expand
172
190
  @metadata = metadata
@@ -210,6 +228,15 @@ module Stripe
210
228
  end
211
229
 
212
230
  class CreateParams < Stripe::RequestParams
231
+ class BillingThresholds < Stripe::RequestParams
232
+ # Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte))
233
+ attr_accessor :usage_gte
234
+
235
+ def initialize(usage_gte: nil)
236
+ @usage_gte = usage_gte
237
+ end
238
+ end
239
+
213
240
  class Discount < Stripe::RequestParams
214
241
  class DiscountEnd < Stripe::RequestParams
215
242
  class Duration < Stripe::RequestParams
@@ -306,6 +333,8 @@ module Stripe
306
333
  @type = type
307
334
  end
308
335
  end
336
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
337
+ attr_accessor :billing_thresholds
309
338
  # The coupons to redeem into discounts for the subscription item.
310
339
  attr_accessor :discounts
311
340
  # Specifies which fields in the response should be expanded.
@@ -340,6 +369,7 @@ module Stripe
340
369
  attr_accessor :trial
341
370
 
342
371
  def initialize(
372
+ billing_thresholds: nil,
343
373
  discounts: nil,
344
374
  expand: nil,
345
375
  metadata: nil,
@@ -354,6 +384,7 @@ module Stripe
354
384
  tax_rates: nil,
355
385
  trial: nil
356
386
  )
387
+ @billing_thresholds = billing_thresholds
357
388
  @discounts = discounts
358
389
  @expand = expand
359
390
  @metadata = metadata
@@ -369,6 +400,8 @@ module Stripe
369
400
  @trial = trial
370
401
  end
371
402
  end
403
+ # Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
404
+ attr_reader :billing_thresholds
372
405
  # Time at which the object was created. Measured in seconds since the Unix epoch.
373
406
  attr_reader :created
374
407
  # The end time of this subscription item's current billing period.