stripe 15.1.0 → 15.2.0

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 (243) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -6
  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/resources/account.rb +47 -20
  9. data/lib/stripe/resources/account_session.rb +111 -7
  10. data/lib/stripe/resources/apple_pay_domain.rb +1 -2
  11. data/lib/stripe/resources/balance.rb +42 -0
  12. data/lib/stripe/resources/balance_transaction.rb +2 -0
  13. data/lib/stripe/resources/bank_account.rb +2 -2
  14. data/lib/stripe/resources/billing_portal/session.rb +1 -1
  15. data/lib/stripe/resources/capability.rb +1 -1
  16. data/lib/stripe/resources/charge.rb +13 -5
  17. data/lib/stripe/resources/checkout/session.rb +20 -4
  18. data/lib/stripe/resources/confirmation_token.rb +33 -87
  19. data/lib/stripe/resources/country_spec.rb +1 -1
  20. data/lib/stripe/resources/coupon.rb +1 -2
  21. data/lib/stripe/resources/credit_note.rb +12 -9
  22. data/lib/stripe/resources/customer.rb +2 -4
  23. data/lib/stripe/resources/customer_session.rb +3 -3
  24. data/lib/stripe/resources/dispute.rb +2 -2
  25. data/lib/stripe/resources/event.rb +1 -1
  26. data/lib/stripe/resources/file.rb +1 -1
  27. data/lib/stripe/resources/identity/verification_report.rb +6 -0
  28. data/lib/stripe/resources/identity/verification_session.rb +17 -11
  29. data/lib/stripe/resources/invoice.rb +114 -27
  30. data/lib/stripe/resources/invoice_item.rb +2 -3
  31. data/lib/stripe/resources/invoice_line_item.rb +1 -1
  32. data/lib/stripe/resources/invoice_payment.rb +9 -2
  33. data/lib/stripe/resources/issuing/authorization.rb +8 -8
  34. data/lib/stripe/resources/issuing/card.rb +1 -1
  35. data/lib/stripe/resources/issuing/dispute.rb +3 -3
  36. data/lib/stripe/resources/payment_intent.rb +196 -302
  37. data/lib/stripe/resources/payment_method.rb +46 -103
  38. data/lib/stripe/resources/payment_method_configuration.rb +297 -2
  39. data/lib/stripe/resources/payment_method_domain.rb +2 -2
  40. data/lib/stripe/resources/payout.rb +4 -4
  41. data/lib/stripe/resources/person.rb +2 -2
  42. data/lib/stripe/resources/plan.rb +2 -3
  43. data/lib/stripe/resources/price.rb +1 -1
  44. data/lib/stripe/resources/product.rb +1 -2
  45. data/lib/stripe/resources/radar/value_list.rb +1 -2
  46. data/lib/stripe/resources/radar/value_list_item.rb +1 -2
  47. data/lib/stripe/resources/refund.rb +6 -1
  48. data/lib/stripe/resources/reversal.rb +1 -1
  49. data/lib/stripe/resources/review.rb +1 -1
  50. data/lib/stripe/resources/setup_intent.rb +111 -281
  51. data/lib/stripe/resources/source.rb +1 -1
  52. data/lib/stripe/resources/subscription.rb +89 -29
  53. data/lib/stripe/resources/subscription_item.rb +33 -0
  54. data/lib/stripe/resources/subscription_schedule.rb +119 -4
  55. data/lib/stripe/resources/tax/calculation.rb +4 -0
  56. data/lib/stripe/resources/tax/calculation_line_item.rb +2 -0
  57. data/lib/stripe/resources/tax/registration.rb +1 -1
  58. data/lib/stripe/resources/tax_id.rb +1 -2
  59. data/lib/stripe/resources/tax_rate.rb +2 -2
  60. data/lib/stripe/resources/terminal/configuration.rb +1 -2
  61. data/lib/stripe/resources/terminal/location.rb +2 -3
  62. data/lib/stripe/resources/terminal/reader.rb +275 -3
  63. data/lib/stripe/resources/test_helpers/test_clock.rb +1 -2
  64. data/lib/stripe/resources/token.rb +2 -2
  65. data/lib/stripe/resources/transfer.rb +1 -1
  66. data/lib/stripe/resources/webhook_endpoint.rb +1 -2
  67. data/lib/stripe/services/account_external_account_service.rb +2 -3
  68. data/lib/stripe/services/account_login_link_service.rb +1 -1
  69. data/lib/stripe/services/account_person_service.rb +1 -2
  70. data/lib/stripe/services/account_service.rb +38 -13
  71. data/lib/stripe/services/account_session_service.rb +75 -7
  72. data/lib/stripe/services/apple_pay_domain_service.rb +1 -2
  73. data/lib/stripe/services/balance_service.rb +1 -1
  74. data/lib/stripe/services/charge_service.rb +4 -4
  75. data/lib/stripe/services/checkout/session_service.rb +11 -3
  76. data/lib/stripe/services/coupon_service.rb +1 -2
  77. data/lib/stripe/services/credit_note_service.rb +7 -8
  78. data/lib/stripe/services/customer_balance_transaction_service.rb +3 -3
  79. data/lib/stripe/services/customer_cash_balance_transaction_service.rb +2 -2
  80. data/lib/stripe/services/customer_payment_source_service.rb +1 -1
  81. data/lib/stripe/services/customer_service.rb +3 -5
  82. data/lib/stripe/services/customer_tax_id_service.rb +1 -2
  83. data/lib/stripe/services/dispute_service.rb +1 -1
  84. data/lib/stripe/services/file_service.rb +1 -1
  85. data/lib/stripe/services/identity/verification_session_service.rb +5 -5
  86. data/lib/stripe/services/invoice_item_service.rb +1 -2
  87. data/lib/stripe/services/invoice_service.rb +92 -23
  88. data/lib/stripe/services/issuing/authorization_service.rb +4 -4
  89. data/lib/stripe/services/issuing/card_service.rb +1 -1
  90. data/lib/stripe/services/issuing/dispute_service.rb +2 -2
  91. data/lib/stripe/services/payment_intent_service.rb +176 -292
  92. data/lib/stripe/services/payment_method_configuration_service.rb +212 -2
  93. data/lib/stripe/services/payment_method_domain_service.rb +1 -1
  94. data/lib/stripe/services/payment_method_service.rb +43 -100
  95. data/lib/stripe/services/payout_service.rb +2 -2
  96. data/lib/stripe/services/plan_service.rb +2 -3
  97. data/lib/stripe/services/price_service.rb +2 -2
  98. data/lib/stripe/services/product_feature_service.rb +1 -2
  99. data/lib/stripe/services/product_service.rb +2 -3
  100. data/lib/stripe/services/promotion_code_service.rb +1 -1
  101. data/lib/stripe/services/radar/early_fraud_warning_service.rb +1 -1
  102. data/lib/stripe/services/radar/value_list_item_service.rb +1 -2
  103. data/lib/stripe/services/radar/value_list_service.rb +1 -2
  104. data/lib/stripe/services/setup_intent_service.rb +110 -280
  105. data/lib/stripe/services/source_service.rb +1 -1
  106. data/lib/stripe/services/subscription_item_service.rb +26 -0
  107. data/lib/stripe/services/subscription_schedule_service.rb +93 -3
  108. data/lib/stripe/services/subscription_service.rb +77 -26
  109. data/lib/stripe/services/tax/calculation_service.rb +4 -0
  110. data/lib/stripe/services/tax/registration_service.rb +1 -1
  111. data/lib/stripe/services/tax_id_service.rb +1 -2
  112. data/lib/stripe/services/terminal/configuration_service.rb +1 -2
  113. data/lib/stripe/services/terminal/location_service.rb +2 -3
  114. data/lib/stripe/services/terminal/reader_service.rb +106 -2
  115. data/lib/stripe/services/test_helpers/confirmation_token_service.rb +33 -87
  116. data/lib/stripe/services/test_helpers/terminal/reader_service.rb +43 -0
  117. data/lib/stripe/services/test_helpers/test_clock_service.rb +1 -2
  118. data/lib/stripe/services/token_service.rb +1 -1
  119. data/lib/stripe/services/transfer_service.rb +1 -1
  120. data/lib/stripe/services/v2/billing/meter_event_session_service.rb +1 -2
  121. data/lib/stripe/services/v2/core/event_destination_service.rb +4 -10
  122. data/lib/stripe/services/v2/core/event_service.rb +1 -2
  123. data/lib/stripe/services/webhook_endpoint_service.rb +1 -2
  124. data/lib/stripe/version.rb +1 -1
  125. data/rbi/stripe/resources/account.rbi +46 -23
  126. data/rbi/stripe/resources/account_session.rbi +131 -12
  127. data/rbi/stripe/resources/apple_pay_domain.rbi +1 -3
  128. data/rbi/stripe/resources/balance.rbi +55 -0
  129. data/rbi/stripe/resources/balance_transaction.rbi +3 -0
  130. data/rbi/stripe/resources/bank_account.rbi +2 -2
  131. data/rbi/stripe/resources/billing/alert.rbi +2 -2
  132. data/rbi/stripe/resources/billing_portal/session.rbi +1 -1
  133. data/rbi/stripe/resources/capability.rbi +1 -1
  134. data/rbi/stripe/resources/charge.rbi +17 -5
  135. data/rbi/stripe/resources/checkout/session.rbi +22 -6
  136. data/rbi/stripe/resources/confirmation_token.rbi +33 -99
  137. data/rbi/stripe/resources/country_spec.rbi +1 -1
  138. data/rbi/stripe/resources/coupon.rbi +1 -3
  139. data/rbi/stripe/resources/credit_note.rbi +14 -9
  140. data/rbi/stripe/resources/customer.rbi +2 -6
  141. data/rbi/stripe/resources/customer_session.rbi +3 -3
  142. data/rbi/stripe/resources/dispute.rbi +2 -2
  143. data/rbi/stripe/resources/event.rbi +1 -1
  144. data/rbi/stripe/resources/file.rbi +1 -1
  145. data/rbi/stripe/resources/identity/verification_report.rbi +9 -0
  146. data/rbi/stripe/resources/identity/verification_session.rbi +20 -11
  147. data/rbi/stripe/resources/invoice.rbi +109 -33
  148. data/rbi/stripe/resources/invoice_item.rbi +2 -4
  149. data/rbi/stripe/resources/invoice_line_item.rbi +1 -1
  150. data/rbi/stripe/resources/invoice_payment.rbi +9 -2
  151. data/rbi/stripe/resources/issuing/authorization.rbi +8 -8
  152. data/rbi/stripe/resources/issuing/card.rbi +1 -1
  153. data/rbi/stripe/resources/issuing/dispute.rbi +3 -3
  154. data/rbi/stripe/resources/payment_intent.rbi +201 -349
  155. data/rbi/stripe/resources/payment_method.rbi +46 -116
  156. data/rbi/stripe/resources/payment_method_configuration.rbi +334 -4
  157. data/rbi/stripe/resources/payment_method_domain.rbi +2 -2
  158. data/rbi/stripe/resources/payout.rbi +4 -4
  159. data/rbi/stripe/resources/person.rbi +2 -2
  160. data/rbi/stripe/resources/plan.rbi +2 -4
  161. data/rbi/stripe/resources/price.rbi +1 -1
  162. data/rbi/stripe/resources/product.rbi +1 -3
  163. data/rbi/stripe/resources/radar/value_list.rbi +1 -3
  164. data/rbi/stripe/resources/radar/value_list_item.rbi +1 -3
  165. data/rbi/stripe/resources/refund.rbi +5 -1
  166. data/rbi/stripe/resources/reversal.rbi +1 -1
  167. data/rbi/stripe/resources/review.rbi +1 -1
  168. data/rbi/stripe/resources/setup_intent.rbi +111 -325
  169. data/rbi/stripe/resources/source.rbi +1 -1
  170. data/rbi/stripe/resources/subscription.rbi +99 -36
  171. data/rbi/stripe/resources/subscription_item.rbi +36 -2
  172. data/rbi/stripe/resources/subscription_schedule.rbi +138 -10
  173. data/rbi/stripe/resources/tax/calculation.rbi +5 -1
  174. data/rbi/stripe/resources/tax/calculation_line_item.rbi +3 -0
  175. data/rbi/stripe/resources/tax/registration.rbi +1 -1
  176. data/rbi/stripe/resources/tax_id.rbi +1 -3
  177. data/rbi/stripe/resources/tax_rate.rbi +2 -2
  178. data/rbi/stripe/resources/terminal/configuration.rbi +1 -3
  179. data/rbi/stripe/resources/terminal/location.rbi +2 -4
  180. data/rbi/stripe/resources/terminal/reader.rbi +265 -5
  181. data/rbi/stripe/resources/test_helpers/test_clock.rbi +1 -3
  182. data/rbi/stripe/resources/token.rbi +2 -2
  183. data/rbi/stripe/resources/transfer.rbi +1 -1
  184. data/rbi/stripe/resources/webhook_endpoint.rbi +1 -3
  185. data/rbi/stripe/services/account_external_account_service.rbi +2 -4
  186. data/rbi/stripe/services/account_login_link_service.rbi +1 -1
  187. data/rbi/stripe/services/account_person_service.rbi +1 -3
  188. data/rbi/stripe/services/account_service.rbi +40 -16
  189. data/rbi/stripe/services/account_session_service.rbi +86 -12
  190. data/rbi/stripe/services/apple_pay_domain_service.rbi +1 -3
  191. data/rbi/stripe/services/balance_service.rbi +1 -1
  192. data/rbi/stripe/services/billing/alert_service.rbi +2 -2
  193. data/rbi/stripe/services/charge_service.rbi +4 -4
  194. data/rbi/stripe/services/checkout/session_service.rbi +12 -5
  195. data/rbi/stripe/services/coupon_service.rbi +1 -3
  196. data/rbi/stripe/services/credit_note_service.rbi +7 -8
  197. data/rbi/stripe/services/customer_balance_transaction_service.rbi +3 -3
  198. data/rbi/stripe/services/customer_cash_balance_transaction_service.rbi +2 -2
  199. data/rbi/stripe/services/customer_payment_source_service.rbi +1 -1
  200. data/rbi/stripe/services/customer_service.rbi +3 -7
  201. data/rbi/stripe/services/customer_tax_id_service.rbi +1 -3
  202. data/rbi/stripe/services/dispute_service.rbi +1 -1
  203. data/rbi/stripe/services/file_service.rbi +1 -1
  204. data/rbi/stripe/services/identity/verification_session_service.rbi +5 -5
  205. data/rbi/stripe/services/invoice_item_service.rbi +1 -3
  206. data/rbi/stripe/services/invoice_service.rbi +90 -29
  207. data/rbi/stripe/services/issuing/authorization_service.rbi +4 -4
  208. data/rbi/stripe/services/issuing/card_service.rbi +1 -1
  209. data/rbi/stripe/services/issuing/dispute_service.rbi +2 -2
  210. data/rbi/stripe/services/payment_intent_service.rbi +179 -339
  211. data/rbi/stripe/services/payment_method_configuration_service.rbi +236 -4
  212. data/rbi/stripe/services/payment_method_domain_service.rbi +1 -1
  213. data/rbi/stripe/services/payment_method_service.rbi +43 -113
  214. data/rbi/stripe/services/payout_service.rbi +2 -2
  215. data/rbi/stripe/services/plan_service.rbi +2 -4
  216. data/rbi/stripe/services/price_service.rbi +2 -2
  217. data/rbi/stripe/services/product_feature_service.rbi +1 -3
  218. data/rbi/stripe/services/product_service.rbi +2 -4
  219. data/rbi/stripe/services/promotion_code_service.rbi +1 -1
  220. data/rbi/stripe/services/radar/early_fraud_warning_service.rbi +1 -1
  221. data/rbi/stripe/services/radar/value_list_item_service.rbi +1 -3
  222. data/rbi/stripe/services/radar/value_list_service.rbi +1 -3
  223. data/rbi/stripe/services/setup_intent_service.rbi +110 -324
  224. data/rbi/stripe/services/source_service.rbi +1 -1
  225. data/rbi/stripe/services/subscription_item_service.rbi +28 -2
  226. data/rbi/stripe/services/subscription_schedule_service.rbi +107 -9
  227. data/rbi/stripe/services/subscription_service.rbi +85 -33
  228. data/rbi/stripe/services/tax/calculation_service.rbi +5 -1
  229. data/rbi/stripe/services/tax/registration_service.rbi +1 -1
  230. data/rbi/stripe/services/tax_id_service.rbi +1 -3
  231. data/rbi/stripe/services/terminal/configuration_service.rbi +1 -3
  232. data/rbi/stripe/services/terminal/location_service.rbi +2 -4
  233. data/rbi/stripe/services/terminal/reader_service.rbi +115 -4
  234. data/rbi/stripe/services/test_helpers/confirmation_token_service.rbi +33 -99
  235. data/rbi/stripe/services/test_helpers/terminal/reader_service.rbi +31 -0
  236. data/rbi/stripe/services/test_helpers/test_clock_service.rbi +1 -3
  237. data/rbi/stripe/services/token_service.rbi +1 -1
  238. data/rbi/stripe/services/transfer_service.rbi +1 -1
  239. data/rbi/stripe/services/v2/billing/meter_event_session_service.rbi +1 -3
  240. data/rbi/stripe/services/v2/core/event_destination_service.rbi +4 -12
  241. data/rbi/stripe/services/v2/core/event_service.rbi +1 -3
  242. data/rbi/stripe/services/webhook_endpoint_service.rbi +1 -3
  243. metadata +3 -2
@@ -1229,7 +1229,7 @@ module Stripe
1229
1229
 
1230
1230
  # Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
1231
1231
  #
1232
- # 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.
1232
+ # 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.
1233
1233
  def self.update(source, params = {}, opts = {})
1234
1234
  request_stripe_object(
1235
1235
  method: :post,
@@ -44,6 +44,13 @@ module Stripe
44
44
  attr_reader :second
45
45
  end
46
46
 
47
+ class BillingThresholds < Stripe::StripeObject
48
+ # Monetary threshold that triggers the subscription to create an invoice
49
+ attr_reader :amount_gte
50
+ # 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`.
51
+ attr_reader :reset_billing_cycle_anchor
52
+ end
53
+
47
54
  class CancellationDetails < Stripe::StripeObject
48
55
  # Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
49
56
  attr_reader :comment
@@ -320,6 +327,18 @@ module Stripe
320
327
  end
321
328
  end
322
329
 
330
+ class BillingThresholds < Stripe::RequestParams
331
+ # Monetary threshold that triggers the subscription to advance to a new billing period
332
+ attr_accessor :amount_gte
333
+ # 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.
334
+ attr_accessor :reset_billing_cycle_anchor
335
+
336
+ def initialize(amount_gte: nil, reset_billing_cycle_anchor: nil)
337
+ @amount_gte = amount_gte
338
+ @reset_billing_cycle_anchor = reset_billing_cycle_anchor
339
+ end
340
+ end
341
+
323
342
  class CancellationDetails < Stripe::RequestParams
324
343
  # Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
325
344
  attr_accessor :comment
@@ -371,6 +390,15 @@ module Stripe
371
390
  end
372
391
 
373
392
  class Item < Stripe::RequestParams
393
+ class BillingThresholds < Stripe::RequestParams
394
+ # 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))
395
+ attr_accessor :usage_gte
396
+
397
+ def initialize(usage_gte: nil)
398
+ @usage_gte = usage_gte
399
+ end
400
+ end
401
+
374
402
  class Discount < Stripe::RequestParams
375
403
  # ID of the coupon to create a new discount for.
376
404
  attr_accessor :coupon
@@ -427,6 +455,8 @@ module Stripe
427
455
  @unit_amount_decimal = unit_amount_decimal
428
456
  end
429
457
  end
458
+ # 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.
459
+ attr_accessor :billing_thresholds
430
460
  # 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.
431
461
  attr_accessor :clear_usage
432
462
  # A flag that, if set to `true`, will delete the specified item.
@@ -449,6 +479,7 @@ module Stripe
449
479
  attr_accessor :tax_rates
450
480
 
451
481
  def initialize(
482
+ billing_thresholds: nil,
452
483
  clear_usage: nil,
453
484
  deleted: nil,
454
485
  discounts: nil,
@@ -460,6 +491,7 @@ module Stripe
460
491
  quantity: nil,
461
492
  tax_rates: nil
462
493
  )
494
+ @billing_thresholds = billing_thresholds
463
495
  @clear_usage = clear_usage
464
496
  @deleted = deleted
465
497
  @discounts = discounts
@@ -576,11 +608,8 @@ module Stripe
576
608
  end
577
609
  end
578
610
 
579
- class Konbini < Stripe::RequestParams
580
- end
581
-
582
- class SepaDebit < Stripe::RequestParams
583
- end
611
+ class Konbini < Stripe::RequestParams; end
612
+ class SepaDebit < Stripe::RequestParams; end
584
613
 
585
614
  class UsBankAccount < Stripe::RequestParams
586
615
  class FinancialConnections < Stripe::RequestParams
@@ -714,9 +743,11 @@ module Stripe
714
743
  attr_accessor :automatic_tax
715
744
  # 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).
716
745
  attr_accessor :billing_cycle_anchor
746
+ # 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.
747
+ attr_accessor :billing_thresholds
717
748
  # 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.
718
749
  attr_accessor :cancel_at
719
- # Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
750
+ # 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.
720
751
  attr_accessor :cancel_at_period_end
721
752
  # Details about why this subscription was cancelled
722
753
  attr_accessor :cancellation_details
@@ -762,11 +793,11 @@ module Stripe
762
793
  attr_accessor :pending_invoice_item_interval
763
794
  # 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`.
764
795
  attr_accessor :proration_behavior
765
- # 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.
796
+ # 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.
766
797
  attr_accessor :proration_date
767
798
  # 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.
768
799
  attr_accessor :transfer_data
769
- # 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`.
800
+ # 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`.
770
801
  attr_accessor :trial_end
771
802
  # 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.
772
803
  attr_accessor :trial_from_plan
@@ -778,6 +809,7 @@ module Stripe
778
809
  application_fee_percent: nil,
779
810
  automatic_tax: nil,
780
811
  billing_cycle_anchor: nil,
812
+ billing_thresholds: nil,
781
813
  cancel_at: nil,
782
814
  cancel_at_period_end: nil,
783
815
  cancellation_details: nil,
@@ -809,6 +841,7 @@ module Stripe
809
841
  @application_fee_percent = application_fee_percent
810
842
  @automatic_tax = automatic_tax
811
843
  @billing_cycle_anchor = billing_cycle_anchor
844
+ @billing_thresholds = billing_thresholds
812
845
  @cancel_at = cancel_at
813
846
  @cancel_at_period_end = cancel_at_period_end
814
847
  @cancellation_details = cancellation_details
@@ -838,8 +871,7 @@ module Stripe
838
871
  end
839
872
  end
840
873
 
841
- class DeleteDiscountParams < Stripe::RequestParams
842
- end
874
+ class DeleteDiscountParams < Stripe::RequestParams; end
843
875
 
844
876
  class ListParams < Stripe::RequestParams
845
877
  class AutomaticTax < Stripe::RequestParams
@@ -1073,6 +1105,18 @@ module Stripe
1073
1105
  end
1074
1106
  end
1075
1107
 
1108
+ class BillingThresholds < Stripe::RequestParams
1109
+ # Monetary threshold that triggers the subscription to advance to a new billing period
1110
+ attr_accessor :amount_gte
1111
+ # 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.
1112
+ attr_accessor :reset_billing_cycle_anchor
1113
+
1114
+ def initialize(amount_gte: nil, reset_billing_cycle_anchor: nil)
1115
+ @amount_gte = amount_gte
1116
+ @reset_billing_cycle_anchor = reset_billing_cycle_anchor
1117
+ end
1118
+ end
1119
+
1076
1120
  class Discount < Stripe::RequestParams
1077
1121
  # ID of the coupon to create a new discount for.
1078
1122
  attr_accessor :coupon
@@ -1112,6 +1156,15 @@ module Stripe
1112
1156
  end
1113
1157
 
1114
1158
  class Item < Stripe::RequestParams
1159
+ class BillingThresholds < Stripe::RequestParams
1160
+ # 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))
1161
+ attr_accessor :usage_gte
1162
+
1163
+ def initialize(usage_gte: nil)
1164
+ @usage_gte = usage_gte
1165
+ end
1166
+ end
1167
+
1115
1168
  class Discount < Stripe::RequestParams
1116
1169
  # ID of the coupon to create a new discount for.
1117
1170
  attr_accessor :coupon
@@ -1168,6 +1221,8 @@ module Stripe
1168
1221
  @unit_amount_decimal = unit_amount_decimal
1169
1222
  end
1170
1223
  end
1224
+ # 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.
1225
+ attr_accessor :billing_thresholds
1171
1226
  # The coupons to redeem into discounts for the subscription item.
1172
1227
  attr_accessor :discounts
1173
1228
  # 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`.
@@ -1184,6 +1239,7 @@ module Stripe
1184
1239
  attr_accessor :tax_rates
1185
1240
 
1186
1241
  def initialize(
1242
+ billing_thresholds: nil,
1187
1243
  discounts: nil,
1188
1244
  metadata: nil,
1189
1245
  plan: nil,
@@ -1192,6 +1248,7 @@ module Stripe
1192
1248
  quantity: nil,
1193
1249
  tax_rates: nil
1194
1250
  )
1251
+ @billing_thresholds = billing_thresholds
1195
1252
  @discounts = discounts
1196
1253
  @metadata = metadata
1197
1254
  @plan = plan
@@ -1293,11 +1350,8 @@ module Stripe
1293
1350
  end
1294
1351
  end
1295
1352
 
1296
- class Konbini < Stripe::RequestParams
1297
- end
1298
-
1299
- class SepaDebit < Stripe::RequestParams
1300
- end
1353
+ class Konbini < Stripe::RequestParams; end
1354
+ class SepaDebit < Stripe::RequestParams; end
1301
1355
 
1302
1356
  class UsBankAccount < Stripe::RequestParams
1303
1357
  class FinancialConnections < Stripe::RequestParams
@@ -1435,9 +1489,11 @@ module Stripe
1435
1489
  attr_accessor :billing_cycle_anchor
1436
1490
  # 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.
1437
1491
  attr_accessor :billing_cycle_anchor_config
1492
+ # 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.
1493
+ attr_accessor :billing_thresholds
1438
1494
  # 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.
1439
1495
  attr_accessor :cancel_at
1440
- # Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
1496
+ # 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.
1441
1497
  attr_accessor :cancel_at_period_end
1442
1498
  # 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`.
1443
1499
  attr_accessor :collection_method
@@ -1505,6 +1561,7 @@ module Stripe
1505
1561
  backdate_start_date: nil,
1506
1562
  billing_cycle_anchor: nil,
1507
1563
  billing_cycle_anchor_config: nil,
1564
+ billing_thresholds: nil,
1508
1565
  cancel_at: nil,
1509
1566
  cancel_at_period_end: nil,
1510
1567
  collection_method: nil,
@@ -1538,6 +1595,7 @@ module Stripe
1538
1595
  @backdate_start_date = backdate_start_date
1539
1596
  @billing_cycle_anchor = billing_cycle_anchor
1540
1597
  @billing_cycle_anchor_config = billing_cycle_anchor_config
1598
+ @billing_thresholds = billing_thresholds
1541
1599
  @cancel_at = cancel_at
1542
1600
  @cancel_at_period_end = cancel_at_period_end
1543
1601
  @collection_method = collection_method
@@ -1590,9 +1648,9 @@ module Stripe
1590
1648
  attr_accessor :billing_cycle_anchor
1591
1649
  # Specifies which fields in the response should be expanded.
1592
1650
  attr_accessor :expand
1593
- # 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`.
1651
+ # 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`.
1594
1652
  attr_accessor :proration_behavior
1595
- # 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.
1653
+ # 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.
1596
1654
  attr_accessor :proration_date
1597
1655
 
1598
1656
  def initialize(
@@ -1617,9 +1675,11 @@ module Stripe
1617
1675
  attr_reader :billing_cycle_anchor
1618
1676
  # The fixed values used to calculate the `billing_cycle_anchor`.
1619
1677
  attr_reader :billing_cycle_anchor_config
1678
+ # Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
1679
+ attr_reader :billing_thresholds
1620
1680
  # A date in the future at which the subscription will automatically get canceled
1621
1681
  attr_reader :cancel_at
1622
- # Whether this subscription will (if `status=active`) or did (if `status=canceled`) cancel at the end of the current billing period.
1682
+ # 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.
1623
1683
  attr_reader :cancel_at_period_end
1624
1684
  # 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.
1625
1685
  attr_reader :canceled_at
@@ -1699,12 +1759,12 @@ module Stripe
1699
1759
  attr_reader :trial_end
1700
1760
  # Settings related to subscription trials.
1701
1761
  attr_reader :trial_settings
1702
- # If the subscription has a trial, the beginning of that trial.
1762
+ # 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.
1703
1763
  attr_reader :trial_start
1704
1764
 
1705
- # 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).
1765
+ # 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).
1706
1766
  #
1707
- # 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.
1767
+ # 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.
1708
1768
  #
1709
1769
  # 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.
1710
1770
  def cancel(params = {}, opts = {})
@@ -1716,9 +1776,9 @@ module Stripe
1716
1776
  )
1717
1777
  end
1718
1778
 
1719
- # 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).
1779
+ # 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).
1720
1780
  #
1721
- # 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.
1781
+ # 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.
1722
1782
  #
1723
1783
  # 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.
1724
1784
  def self.cancel(subscription_exposed_id, params = {}, opts = {})
@@ -1735,7 +1795,7 @@ module Stripe
1735
1795
  # When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.
1736
1796
  # The payment_behavior parameter determines the exact behavior of the initial payment.
1737
1797
  #
1738
- # 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.
1798
+ # 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.
1739
1799
  # Schedules provide the flexibility to model more complex billing configurations that change over time.
1740
1800
  def self.create(params = {}, opts = {})
1741
1801
  request_stripe_object(method: :post, path: "/v1/subscriptions", params: params, opts: opts)
@@ -1801,7 +1861,7 @@ module Stripe
1801
1861
 
1802
1862
  # Updates an existing subscription to match the specified parameters.
1803
1863
  # When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes.
1804
- # To preview how the proration is calculated, use the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint.
1864
+ # To preview how the proration is calculated, use the [create preview](https://docs.stripe.com/docs/api/invoices/create_preview) endpoint.
1805
1865
  #
1806
1866
  # 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.
1807
1867
  #
@@ -1813,13 +1873,13 @@ module Stripe
1813
1873
  # A trial starts or ends.
1814
1874
  #
1815
1875
  #
1816
- # 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).
1876
+ # 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).
1817
1877
  #
1818
- # 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).
1878
+ # 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).
1819
1879
  #
1820
1880
  # 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.
1821
1881
  #
1822
- # 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.
1882
+ # 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.
1823
1883
  def self.update(subscription_exposed_id, params = {}, opts = {})
1824
1884
  request_stripe_object(
1825
1885
  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 DeleteParams < Stripe::RequestParams
19
24
  # Delete all usage for the given subscription item. Allowed only when the current plan's `usage_type` is `metered`.
20
25
  attr_accessor :clear_usage
@@ -31,6 +36,15 @@ module Stripe
31
36
  end
32
37
 
33
38
  class UpdateParams < Stripe::RequestParams
39
+ class BillingThresholds < Stripe::RequestParams
40
+ # 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))
41
+ attr_accessor :usage_gte
42
+
43
+ def initialize(usage_gte: nil)
44
+ @usage_gte = usage_gte
45
+ end
46
+ end
47
+
34
48
  class Discount < Stripe::RequestParams
35
49
  # ID of the coupon to create a new discount for.
36
50
  attr_accessor :coupon
@@ -87,6 +101,8 @@ module Stripe
87
101
  @unit_amount_decimal = unit_amount_decimal
88
102
  end
89
103
  end
104
+ # 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.
105
+ attr_accessor :billing_thresholds
90
106
  # The coupons to redeem into discounts for the subscription item.
91
107
  attr_accessor :discounts
92
108
  # Specifies which fields in the response should be expanded.
@@ -119,6 +135,7 @@ module Stripe
119
135
  attr_accessor :tax_rates
120
136
 
121
137
  def initialize(
138
+ billing_thresholds: nil,
122
139
  discounts: nil,
123
140
  expand: nil,
124
141
  metadata: nil,
@@ -132,6 +149,7 @@ module Stripe
132
149
  quantity: nil,
133
150
  tax_rates: nil
134
151
  )
152
+ @billing_thresholds = billing_thresholds
135
153
  @discounts = discounts
136
154
  @expand = expand
137
155
  @metadata = metadata
@@ -175,6 +193,15 @@ module Stripe
175
193
  end
176
194
 
177
195
  class CreateParams < Stripe::RequestParams
196
+ class BillingThresholds < Stripe::RequestParams
197
+ # 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))
198
+ attr_accessor :usage_gte
199
+
200
+ def initialize(usage_gte: nil)
201
+ @usage_gte = usage_gte
202
+ end
203
+ end
204
+
178
205
  class Discount < Stripe::RequestParams
179
206
  # ID of the coupon to create a new discount for.
180
207
  attr_accessor :coupon
@@ -231,6 +258,8 @@ module Stripe
231
258
  @unit_amount_decimal = unit_amount_decimal
232
259
  end
233
260
  end
261
+ # 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.
262
+ attr_accessor :billing_thresholds
234
263
  # The coupons to redeem into discounts for the subscription item.
235
264
  attr_accessor :discounts
236
265
  # Specifies which fields in the response should be expanded.
@@ -263,6 +292,7 @@ module Stripe
263
292
  attr_accessor :tax_rates
264
293
 
265
294
  def initialize(
295
+ billing_thresholds: nil,
266
296
  discounts: nil,
267
297
  expand: nil,
268
298
  metadata: nil,
@@ -276,6 +306,7 @@ module Stripe
276
306
  subscription: nil,
277
307
  tax_rates: nil
278
308
  )
309
+ @billing_thresholds = billing_thresholds
279
310
  @discounts = discounts
280
311
  @expand = expand
281
312
  @metadata = metadata
@@ -290,6 +321,8 @@ module Stripe
290
321
  @tax_rates = tax_rates
291
322
  end
292
323
  end
324
+ # Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
325
+ attr_reader :billing_thresholds
293
326
  # Time at which the object was created. Measured in seconds since the Unix epoch.
294
327
  attr_reader :created
295
328
  # The end time of this subscription item's current billing period.