stripe 10.1.0 → 12.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +215 -21
  3. data/Gemfile +6 -5
  4. data/Makefile +8 -1
  5. data/OPENAPI_VERSION +1 -1
  6. data/README.md +46 -14
  7. data/Rakefile +7 -5
  8. data/VERSION +1 -1
  9. data/{bin → exe}/stripe-console +1 -1
  10. data/lib/stripe/api_operations/nested_resource.rb +22 -2
  11. data/lib/stripe/api_operations/request.rb +22 -18
  12. data/lib/stripe/api_operations/save.rb +7 -9
  13. data/lib/stripe/api_operations/search.rb +5 -0
  14. data/lib/stripe/api_operations/singleton_save.rb +86 -0
  15. data/lib/stripe/api_resource.rb +13 -4
  16. data/lib/stripe/api_resource_test_helpers.rb +7 -3
  17. data/lib/stripe/api_version.rb +1 -1
  18. data/lib/stripe/connection_manager.rb +4 -6
  19. data/lib/stripe/errors.rb +3 -11
  20. data/lib/stripe/instrumentation.rb +5 -21
  21. data/lib/stripe/list_object.rb +3 -0
  22. data/lib/stripe/multipart_encoder.rb +7 -7
  23. data/lib/stripe/oauth.rb +6 -6
  24. data/lib/stripe/object_types.rb +135 -116
  25. data/lib/stripe/resources/account.rb +103 -25
  26. data/lib/stripe/resources/account_link.rb +8 -0
  27. data/lib/stripe/resources/account_session.rb +8 -0
  28. data/lib/stripe/resources/alipay_account.rb +1 -1
  29. data/lib/stripe/resources/apple_pay_domain.rb +43 -0
  30. data/lib/stripe/resources/application_fee.rb +8 -0
  31. data/lib/stripe/resources/application_fee_refund.rb +4 -2
  32. data/lib/stripe/resources/apps/secret.rb +15 -0
  33. data/lib/stripe/resources/balance.rb +3 -0
  34. data/lib/stripe/resources/balance_transaction.rb +15 -0
  35. data/lib/stripe/resources/bank_account.rb +49 -7
  36. data/lib/stripe/resources/billing/alert.rb +87 -0
  37. data/lib/stripe/resources/billing/meter.rb +83 -0
  38. data/lib/stripe/resources/billing/meter_event.rb +27 -0
  39. data/lib/stripe/resources/billing/meter_event_adjustment.rb +26 -0
  40. data/lib/stripe/resources/billing/meter_event_summary.rb +15 -0
  41. data/lib/stripe/resources/billing_portal/configuration.rb +33 -0
  42. data/lib/stripe/resources/billing_portal/session.rb +14 -1
  43. data/lib/stripe/resources/capability.rb +4 -2
  44. data/lib/stripe/resources/card.rb +28 -0
  45. data/lib/stripe/resources/cash_balance.rb +3 -0
  46. data/lib/stripe/resources/charge.rb +39 -1
  47. data/lib/stripe/resources/checkout/session.rb +47 -5
  48. data/lib/stripe/resources/climate/order.rb +67 -0
  49. data/lib/stripe/resources/climate/product.rb +27 -0
  50. data/lib/stripe/resources/climate/supplier.rb +26 -0
  51. data/lib/stripe/resources/confirmation_token.rb +39 -0
  52. data/lib/stripe/resources/country_spec.rb +8 -0
  53. data/lib/stripe/resources/coupon.rb +45 -0
  54. data/lib/stripe/resources/credit_note.rb +47 -7
  55. data/lib/stripe/resources/credit_note_line_item.rb +3 -0
  56. data/lib/stripe/resources/customer.rb +89 -26
  57. data/lib/stripe/resources/customer_balance_transaction.rb +3 -1
  58. data/lib/stripe/resources/customer_cash_balance_transaction.rb +3 -2
  59. data/lib/stripe/resources/customer_session.rb +29 -0
  60. data/lib/stripe/resources/discount.rb +3 -0
  61. data/lib/stripe/resources/dispute.rb +26 -0
  62. data/lib/stripe/resources/entitlements/active_entitlement.rb +26 -0
  63. data/lib/stripe/resources/entitlements/feature.rb +49 -0
  64. data/lib/stripe/resources/ephemeral_key.rb +23 -0
  65. data/lib/stripe/resources/event.rb +11 -3
  66. data/lib/stripe/resources/exchange_rate.rb +8 -0
  67. data/lib/stripe/resources/file.rb +29 -16
  68. data/lib/stripe/resources/file_link.rb +23 -0
  69. data/lib/stripe/resources/financial_connections/account.rb +66 -7
  70. data/lib/stripe/resources/financial_connections/account_owner.rb +3 -0
  71. data/lib/stripe/resources/financial_connections/account_ownership.rb +3 -0
  72. data/lib/stripe/resources/financial_connections/session.rb +13 -0
  73. data/lib/stripe/resources/financial_connections/transaction.rb +26 -0
  74. data/lib/stripe/resources/forwarding/request.rb +52 -0
  75. data/lib/stripe/resources/funding_instructions.rb +3 -0
  76. data/lib/stripe/resources/identity/verification_report.rb +14 -1
  77. data/lib/stripe/resources/identity/verification_session.rb +90 -4
  78. data/lib/stripe/resources/invoice.rb +170 -17
  79. data/lib/stripe/resources/invoice_item.rb +43 -0
  80. data/lib/stripe/resources/invoice_line_item.rb +21 -0
  81. data/lib/stripe/resources/invoice_rendering_template.rb +63 -0
  82. data/lib/stripe/resources/issuing/authorization.rb +88 -14
  83. data/lib/stripe/resources/issuing/card.rb +50 -16
  84. data/lib/stripe/resources/issuing/cardholder.rb +33 -0
  85. data/lib/stripe/resources/issuing/dispute.rb +35 -0
  86. data/lib/stripe/resources/issuing/personalization_design.rb +119 -0
  87. data/lib/stripe/resources/issuing/physical_bundle.rb +26 -0
  88. data/lib/stripe/resources/issuing/token.rb +18 -0
  89. data/lib/stripe/resources/issuing/transaction.rb +30 -0
  90. data/lib/stripe/resources/line_item.rb +3 -0
  91. data/lib/stripe/resources/login_link.rb +4 -1
  92. data/lib/stripe/resources/mandate.rb +3 -0
  93. data/lib/stripe/resources/payment_intent.rb +190 -25
  94. data/lib/stripe/resources/payment_link.rb +25 -0
  95. data/lib/stripe/resources/payment_method.rb +57 -4
  96. data/lib/stripe/resources/payment_method_configuration.rb +33 -0
  97. data/lib/stripe/resources/payment_method_domain.rb +46 -1
  98. data/lib/stripe/resources/payout.rb +39 -4
  99. data/lib/stripe/resources/person.rb +5 -4
  100. data/lib/stripe/resources/plan.rb +43 -0
  101. data/lib/stripe/resources/price.rb +24 -1
  102. data/lib/stripe/resources/product.rb +47 -1
  103. data/lib/stripe/resources/product_feature.rb +13 -0
  104. data/lib/stripe/resources/promotion_code.rb +23 -0
  105. data/lib/stripe/resources/quote.rb +67 -32
  106. data/lib/stripe/resources/radar/early_fraud_warning.rb +13 -0
  107. data/lib/stripe/resources/radar/value_list.rb +53 -0
  108. data/lib/stripe/resources/radar/value_list_item.rb +43 -0
  109. data/lib/stripe/resources/refund.rb +46 -0
  110. data/lib/stripe/resources/reporting/report_run.rb +23 -0
  111. data/lib/stripe/resources/reporting/report_type.rb +13 -0
  112. data/lib/stripe/resources/reversal.rb +5 -3
  113. data/lib/stripe/resources/review.rb +10 -0
  114. data/lib/stripe/resources/setup_attempt.rb +8 -0
  115. data/lib/stripe/resources/setup_intent.rb +72 -10
  116. data/lib/stripe/resources/shipping_rate.rb +23 -0
  117. data/lib/stripe/resources/sigma/scheduled_query_run.rb +13 -0
  118. data/lib/stripe/resources/source.rb +23 -1
  119. data/lib/stripe/resources/source_transaction.rb +3 -0
  120. data/lib/stripe/resources/subscription.rb +81 -13
  121. data/lib/stripe/resources/subscription_item.rb +54 -1
  122. data/lib/stripe/resources/subscription_schedule.rb +41 -4
  123. data/lib/stripe/resources/tax/calculation.rb +15 -0
  124. data/lib/stripe/resources/tax/calculation_line_item.rb +3 -0
  125. data/lib/stripe/resources/tax/registration.rb +35 -0
  126. data/lib/stripe/resources/tax/settings.rb +4 -2
  127. data/lib/stripe/resources/tax/transaction.rb +15 -8
  128. data/lib/stripe/resources/tax/transaction_line_item.rb +3 -0
  129. data/lib/stripe/resources/tax_code.rb +8 -0
  130. data/lib/stripe/resources/tax_id.rb +30 -12
  131. data/lib/stripe/resources/tax_rate.rb +23 -0
  132. data/lib/stripe/resources/terminal/configuration.rb +53 -0
  133. data/lib/stripe/resources/terminal/connection_token.rb +13 -0
  134. data/lib/stripe/resources/terminal/location.rb +54 -0
  135. data/lib/stripe/resources/terminal/reader.rb +80 -12
  136. data/lib/stripe/resources/test_helpers/test_clock.rb +45 -0
  137. data/lib/stripe/resources/token.rb +10 -1
  138. data/lib/stripe/resources/topup.rb +25 -0
  139. data/lib/stripe/resources/transfer.rb +26 -1
  140. data/lib/stripe/resources/treasury/credit_reversal.rb +23 -0
  141. data/lib/stripe/resources/treasury/debit_reversal.rb +23 -0
  142. data/lib/stripe/resources/treasury/financial_account.rb +42 -5
  143. data/lib/stripe/resources/treasury/financial_account_features.rb +3 -0
  144. data/lib/stripe/resources/treasury/inbound_transfer.rb +47 -11
  145. data/lib/stripe/resources/treasury/outbound_payment.rb +64 -8
  146. data/lib/stripe/resources/treasury/outbound_transfer.rb +64 -8
  147. data/lib/stripe/resources/treasury/received_credit.rb +17 -0
  148. data/lib/stripe/resources/treasury/received_debit.rb +17 -0
  149. data/lib/stripe/resources/treasury/transaction.rb +13 -0
  150. data/lib/stripe/resources/treasury/transaction_entry.rb +13 -0
  151. data/lib/stripe/resources/usage_record.rb +5 -0
  152. data/lib/stripe/resources/usage_record_summary.rb +3 -0
  153. data/lib/stripe/resources/webhook_endpoint.rb +55 -2
  154. data/lib/stripe/resources.rb +18 -0
  155. data/lib/stripe/search_result_object.rb +4 -1
  156. data/lib/stripe/singleton_api_resource.rb +20 -3
  157. data/lib/stripe/stripe_client.rb +61 -63
  158. data/lib/stripe/stripe_configuration.rb +13 -29
  159. data/lib/stripe/stripe_object.rb +23 -21
  160. data/lib/stripe/stripe_response.rb +1 -3
  161. data/lib/stripe/util.rb +13 -15
  162. data/lib/stripe/version.rb +1 -1
  163. data/lib/stripe.rb +26 -0
  164. data/stripe.gemspec +7 -4
  165. metadata +25 -5
@@ -10,7 +10,11 @@ module Stripe
10
10
  extend Stripe::APIOperations::List
11
11
 
12
12
  OBJECT_NAME = "review"
13
+ def self.object_name
14
+ "review"
15
+ end
13
16
 
17
+ # Approves a Review object, closing it and removing it from the list of reviews.
14
18
  def approve(params = {}, opts = {})
15
19
  request_stripe_object(
16
20
  method: :post,
@@ -20,6 +24,7 @@ module Stripe
20
24
  )
21
25
  end
22
26
 
27
+ # Approves a Review object, closing it and removing it from the list of reviews.
23
28
  def self.approve(review, params = {}, opts = {})
24
29
  request_stripe_object(
25
30
  method: :post,
@@ -28,5 +33,10 @@ module Stripe
28
33
  opts: opts
29
34
  )
30
35
  end
36
+
37
+ # Returns a list of Review objects that have open set to true. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
38
+ def self.list(filters = {}, opts = {})
39
+ request_stripe_object(method: :get, path: "/v1/reviews", params: filters, opts: opts)
40
+ end
31
41
  end
32
42
  end
@@ -10,5 +10,13 @@ module Stripe
10
10
  extend Stripe::APIOperations::List
11
11
 
12
12
  OBJECT_NAME = "setup_attempt"
13
+ def self.object_name
14
+ "setup_attempt"
15
+ end
16
+
17
+ # Returns a list of SetupAttempts that associate with a provided SetupIntent.
18
+ def self.list(filters = {}, opts = {})
19
+ request_stripe_object(method: :get, path: "/v1/setup_attempts", params: filters, opts: opts)
20
+ end
13
21
  end
14
22
  end
@@ -8,13 +8,13 @@ module Stripe
8
8
  #
9
9
  # Create a SetupIntent when you're ready to collect your customer's payment credentials.
10
10
  # Don't maintain long-lived, unconfirmed SetupIntents because they might not be valid.
11
- # The SetupIntent transitions through multiple [statuses](https://stripe.com/docs/payments/intents#intent-statuses) as it guides
11
+ # The SetupIntent transitions through multiple [statuses](https://docs.stripe.com/payments/intents#intent-statuses) as it guides
12
12
  # you through the setup process.
13
13
  #
14
14
  # Successful SetupIntents result in payment credentials that are optimized for future payments.
15
15
  # For example, cardholders in [certain regions](https://stripe.com/guides/strong-customer-authentication) might need to be run through
16
- # [Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) during payment method collection
17
- # to streamline later [off-session payments](https://stripe.com/docs/payments/setup-intents).
16
+ # [Strong Customer Authentication](https://docs.stripe.com/strong-customer-authentication) during payment method collection
17
+ # to streamline later [off-session payments](https://docs.stripe.com/payments/setup-intents).
18
18
  # If you use the SetupIntent with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer),
19
19
  # it automatically attaches the resulting payment method to that Customer after successful setup.
20
20
  # We recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on
@@ -22,14 +22,20 @@ module Stripe
22
22
  #
23
23
  # By using SetupIntents, you can reduce friction for your customers, even as regulations change over time.
24
24
  #
25
- # Related guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents)
25
+ # Related guide: [Setup Intents API](https://docs.stripe.com/payments/setup-intents)
26
26
  class SetupIntent < APIResource
27
27
  extend Stripe::APIOperations::Create
28
28
  extend Stripe::APIOperations::List
29
29
  include Stripe::APIOperations::Save
30
30
 
31
31
  OBJECT_NAME = "setup_intent"
32
+ def self.object_name
33
+ "setup_intent"
34
+ end
32
35
 
36
+ # You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
37
+ #
38
+ # After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. You can't cancel the SetupIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead.
33
39
  def cancel(params = {}, opts = {})
34
40
  request_stripe_object(
35
41
  method: :post,
@@ -39,6 +45,32 @@ module Stripe
39
45
  )
40
46
  end
41
47
 
48
+ # You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
49
+ #
50
+ # After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. You can't cancel the SetupIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead.
51
+ def self.cancel(intent, params = {}, opts = {})
52
+ request_stripe_object(
53
+ method: :post,
54
+ path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }),
55
+ params: params,
56
+ opts: opts
57
+ )
58
+ end
59
+
60
+ # Confirm that your customer intends to set up the current or
61
+ # provided payment method. For example, you would confirm a SetupIntent
62
+ # when a customer hits the “Save” button on a payment method management
63
+ # page on your website.
64
+ #
65
+ # If the selected payment method does not require any additional
66
+ # steps from the customer, the SetupIntent will transition to the
67
+ # succeeded status.
68
+ #
69
+ # Otherwise, it will transition to the requires_action status and
70
+ # suggest additional actions via next_action. If setup fails,
71
+ # the SetupIntent will transition to the
72
+ # requires_payment_method status or the canceled status if the
73
+ # confirmation limit is reached.
42
74
  def confirm(params = {}, opts = {})
43
75
  request_stripe_object(
44
76
  method: :post,
@@ -48,33 +80,63 @@ module Stripe
48
80
  )
49
81
  end
50
82
 
51
- def verify_microdeposits(params = {}, opts = {})
83
+ # Confirm that your customer intends to set up the current or
84
+ # provided payment method. For example, you would confirm a SetupIntent
85
+ # when a customer hits the “Save” button on a payment method management
86
+ # page on your website.
87
+ #
88
+ # If the selected payment method does not require any additional
89
+ # steps from the customer, the SetupIntent will transition to the
90
+ # succeeded status.
91
+ #
92
+ # Otherwise, it will transition to the requires_action status and
93
+ # suggest additional actions via next_action. If setup fails,
94
+ # the SetupIntent will transition to the
95
+ # requires_payment_method status or the canceled status if the
96
+ # confirmation limit is reached.
97
+ def self.confirm(intent, params = {}, opts = {})
52
98
  request_stripe_object(
53
99
  method: :post,
54
- path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }),
100
+ path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }),
55
101
  params: params,
56
102
  opts: opts
57
103
  )
58
104
  end
59
105
 
60
- def self.cancel(intent, params = {}, opts = {})
106
+ # Creates a SetupIntent object.
107
+ #
108
+ # After you create the SetupIntent, attach a payment method and [confirm](https://stripe.com/docs/api/setup_intents/confirm)
109
+ # it to collect any required permissions to charge the payment method later.
110
+ def self.create(params = {}, opts = {})
111
+ request_stripe_object(method: :post, path: "/v1/setup_intents", params: params, opts: opts)
112
+ end
113
+
114
+ # Returns a list of SetupIntents.
115
+ def self.list(filters = {}, opts = {})
116
+ request_stripe_object(method: :get, path: "/v1/setup_intents", params: filters, opts: opts)
117
+ end
118
+
119
+ # Updates a SetupIntent object.
120
+ def self.update(id, params = {}, opts = {})
61
121
  request_stripe_object(
62
122
  method: :post,
63
- path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }),
123
+ path: format("/v1/setup_intents/%<id>s", { id: CGI.escape(id) }),
64
124
  params: params,
65
125
  opts: opts
66
126
  )
67
127
  end
68
128
 
69
- def self.confirm(intent, params = {}, opts = {})
129
+ # Verifies microdeposits on a SetupIntent object.
130
+ def verify_microdeposits(params = {}, opts = {})
70
131
  request_stripe_object(
71
132
  method: :post,
72
- path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }),
133
+ path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }),
73
134
  params: params,
74
135
  opts: opts
75
136
  )
76
137
  end
77
138
 
139
+ # Verifies microdeposits on a SetupIntent object.
78
140
  def self.verify_microdeposits(intent, params = {}, opts = {})
79
141
  request_stripe_object(
80
142
  method: :post,
@@ -10,5 +10,28 @@ module Stripe
10
10
  include Stripe::APIOperations::Save
11
11
 
12
12
  OBJECT_NAME = "shipping_rate"
13
+ def self.object_name
14
+ "shipping_rate"
15
+ end
16
+
17
+ # Creates a new shipping rate object.
18
+ def self.create(params = {}, opts = {})
19
+ request_stripe_object(method: :post, path: "/v1/shipping_rates", params: params, opts: opts)
20
+ end
21
+
22
+ # Returns a list of your shipping rates.
23
+ def self.list(filters = {}, opts = {})
24
+ request_stripe_object(method: :get, path: "/v1/shipping_rates", params: filters, opts: opts)
25
+ end
26
+
27
+ # Updates an existing shipping rate object.
28
+ def self.update(id, params = {}, opts = {})
29
+ request_stripe_object(
30
+ method: :post,
31
+ path: format("/v1/shipping_rates/%<id>s", { id: CGI.escape(id) }),
32
+ params: params,
33
+ opts: opts
34
+ )
35
+ end
13
36
  end
14
37
  end
@@ -11,6 +11,19 @@ module Stripe
11
11
  extend Stripe::APIOperations::List
12
12
 
13
13
  OBJECT_NAME = "scheduled_query_run"
14
+ def self.object_name
15
+ "scheduled_query_run"
16
+ end
17
+
18
+ # Returns a list of scheduled query runs.
19
+ def self.list(filters = {}, opts = {})
20
+ request_stripe_object(
21
+ method: :get,
22
+ path: "/v1/sigma/scheduled_query_runs",
23
+ params: filters,
24
+ opts: opts
25
+ )
26
+ end
14
27
 
15
28
  def self.resource_url
16
29
  "/v1/sigma/scheduled_query_runs"
@@ -14,13 +14,34 @@ module Stripe
14
14
  # Related guides: [Sources API](https://stripe.com/docs/sources) and [Sources & Customers](https://stripe.com/docs/sources/customers).
15
15
  class Source < APIResource
16
16
  extend Stripe::APIOperations::Create
17
- include Stripe::APIOperations::Save
18
17
  extend Stripe::APIOperations::NestedResource
18
+ include Stripe::APIOperations::Save
19
19
 
20
20
  OBJECT_NAME = "source"
21
+ def self.object_name
22
+ "source"
23
+ end
21
24
 
22
25
  nested_resource_class_methods :source_transaction, operations: %i[retrieve list]
23
26
 
27
+ # Creates a new source object.
28
+ def self.create(params = {}, opts = {})
29
+ request_stripe_object(method: :post, path: "/v1/sources", params: params, opts: opts)
30
+ end
31
+
32
+ # Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
33
+ #
34
+ # 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.
35
+ def self.update(id, params = {}, opts = {})
36
+ request_stripe_object(
37
+ method: :post,
38
+ path: format("/v1/sources/%<id>s", { id: CGI.escape(id) }),
39
+ params: params,
40
+ opts: opts
41
+ )
42
+ end
43
+
44
+ # Verify a given source.
24
45
  def verify(params = {}, opts = {})
25
46
  request_stripe_object(
26
47
  method: :post,
@@ -30,6 +51,7 @@ module Stripe
30
51
  )
31
52
  end
32
53
 
54
+ # Verify a given source.
33
55
  def self.verify(source, params = {}, opts = {})
34
56
  request_stripe_object(
35
57
  method: :post,
@@ -8,5 +8,8 @@ module Stripe
8
8
  # transactions.
9
9
  class SourceTransaction < StripeObject
10
10
  OBJECT_NAME = "source_transaction"
11
+ def self.object_name
12
+ "source_transaction"
13
+ end
11
14
  end
12
15
  end
@@ -12,7 +12,15 @@ module Stripe
12
12
  include Stripe::APIOperations::Save
13
13
 
14
14
  OBJECT_NAME = "subscription"
15
+ def self.object_name
16
+ "subscription"
17
+ end
15
18
 
19
+ # Cancels a customer's subscription immediately. The customer will not be charged again for the subscription.
20
+ #
21
+ # Note, however, that any pending invoice items that you've created will still be charged for 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 will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.
22
+ #
23
+ # By default, upon subscription cancellation, Stripe will stop 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.
16
24
  def cancel(params = {}, opts = {})
17
25
  request_stripe_object(
18
26
  method: :delete,
@@ -22,42 +30,67 @@ module Stripe
22
30
  )
23
31
  end
24
32
 
25
- def delete_discount(params = {}, opts = {})
33
+ # Cancels a customer's subscription immediately. The customer will not be charged again for the subscription.
34
+ #
35
+ # Note, however, that any pending invoice items that you've created will still be charged for 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 will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.
36
+ #
37
+ # By default, upon subscription cancellation, Stripe will stop 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.
38
+ def self.cancel(subscription_exposed_id, params = {}, opts = {})
26
39
  request_stripe_object(
27
40
  method: :delete,
28
- path: format("/v1/subscriptions/%<subscription_exposed_id>s/discount", { subscription_exposed_id: CGI.escape(self["id"]) }),
41
+ path: format("/v1/subscriptions/%<subscription_exposed_id>s", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }),
29
42
  params: params,
30
43
  opts: opts
31
44
  )
32
45
  end
33
46
 
34
- def resume(params = {}, opts = {})
47
+ # Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.
48
+ #
49
+ # When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.
50
+ # The payment_behavior parameter determines the exact behavior of the initial payment.
51
+ #
52
+ # 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.
53
+ # Schedules provide the flexibility to model more complex billing configurations that change over time.
54
+ def self.create(params = {}, opts = {})
55
+ request_stripe_object(method: :post, path: "/v1/subscriptions", params: params, opts: opts)
56
+ end
57
+
58
+ # Removes the currently applied discount on a subscription.
59
+ def delete_discount(params = {}, opts = {})
35
60
  request_stripe_object(
36
- method: :post,
37
- path: format("/v1/subscriptions/%<subscription>s/resume", { subscription: CGI.escape(self["id"]) }),
61
+ method: :delete,
62
+ path: format("/v1/subscriptions/%<subscription_exposed_id>s/discount", { subscription_exposed_id: CGI.escape(self["id"]) }),
38
63
  params: params,
39
64
  opts: opts
40
65
  )
41
66
  end
42
67
 
43
- def self.cancel(subscription_exposed_id, params = {}, opts = {})
68
+ # Removes the currently applied discount on a subscription.
69
+ def self.delete_discount(subscription_exposed_id, params = {}, opts = {})
44
70
  request_stripe_object(
45
71
  method: :delete,
46
- path: format("/v1/subscriptions/%<subscription_exposed_id>s", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }),
72
+ path: format("/v1/subscriptions/%<subscription_exposed_id>s/discount", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }),
47
73
  params: params,
48
74
  opts: opts
49
75
  )
50
76
  end
51
77
 
52
- def self.delete_discount(subscription_exposed_id, params = {}, opts = {})
78
+ # By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
79
+ def self.list(filters = {}, opts = {})
80
+ request_stripe_object(method: :get, path: "/v1/subscriptions", params: filters, opts: opts)
81
+ end
82
+
83
+ # 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.
84
+ def resume(params = {}, opts = {})
53
85
  request_stripe_object(
54
- method: :delete,
55
- path: format("/v1/subscriptions/%<subscription_exposed_id>s/discount", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }),
86
+ method: :post,
87
+ path: format("/v1/subscriptions/%<subscription>s/resume", { subscription: CGI.escape(self["id"]) }),
56
88
  params: params,
57
89
  opts: opts
58
90
  )
59
91
  end
60
92
 
93
+ # 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.
61
94
  def self.resume(subscription, params = {}, opts = {})
62
95
  request_stripe_object(
63
96
  method: :post,
@@ -67,14 +100,49 @@ module Stripe
67
100
  )
68
101
  end
69
102
 
70
- save_nested_resource :source
71
-
72
103
  def self.search(params = {}, opts = {})
73
- _search("/v1/subscriptions/search", params, opts)
104
+ request_stripe_object(
105
+ method: :get,
106
+ path: "/v1/subscriptions/search",
107
+ params: params,
108
+ opts: opts
109
+ )
74
110
  end
75
111
 
76
112
  def self.search_auto_paging_each(params = {}, opts = {}, &blk)
77
113
  search(params, opts).auto_paging_each(&blk)
78
114
  end
115
+
116
+ # Updates an existing subscription to match the specified parameters.
117
+ # When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes.
118
+ # To preview how the proration is calculated, use the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint.
119
+ #
120
+ # 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.
121
+ #
122
+ # Switching prices does not normally change the billing date or generate an immediate charge unless:
123
+ #
124
+ #
125
+ # The billing interval is changed (for example, from monthly to yearly).
126
+ # The subscription moves from free to paid.
127
+ # A trial starts or ends.
128
+ #
129
+ #
130
+ # 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/billing/subscriptions/upgrade-downgrade#immediate-payment).
131
+ #
132
+ # 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).
133
+ #
134
+ # 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.
135
+ #
136
+ # 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.
137
+ def self.update(id, params = {}, opts = {})
138
+ request_stripe_object(
139
+ method: :post,
140
+ path: format("/v1/subscriptions/%<id>s", { id: CGI.escape(id) }),
141
+ params: params,
142
+ opts: opts
143
+ )
144
+ end
145
+
146
+ save_nested_resource :source
79
147
  end
80
148
  end
@@ -8,14 +8,67 @@ module Stripe
8
8
  extend Stripe::APIOperations::Create
9
9
  include Stripe::APIOperations::Delete
10
10
  extend Stripe::APIOperations::List
11
- include Stripe::APIOperations::Save
12
11
  extend Stripe::APIOperations::NestedResource
12
+ include Stripe::APIOperations::Save
13
13
 
14
14
  OBJECT_NAME = "subscription_item"
15
+ def self.object_name
16
+ "subscription_item"
17
+ end
15
18
 
16
19
  nested_resource_class_methods :usage_record, operations: %i[create]
17
20
  nested_resource_class_methods :usage_record_summary,
18
21
  operations: %i[list],
19
22
  resource_plural: "usage_record_summaries"
23
+
24
+ # Adds a new item to an existing subscription. No existing items will be changed or replaced.
25
+ def self.create(params = {}, opts = {})
26
+ request_stripe_object(
27
+ method: :post,
28
+ path: "/v1/subscription_items",
29
+ params: params,
30
+ opts: opts
31
+ )
32
+ end
33
+
34
+ # Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.
35
+ def self.delete(id, params = {}, opts = {})
36
+ request_stripe_object(
37
+ method: :delete,
38
+ path: format("/v1/subscription_items/%<id>s", { id: CGI.escape(id) }),
39
+ params: params,
40
+ opts: opts
41
+ )
42
+ end
43
+
44
+ # Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.
45
+ def delete(params = {}, opts = {})
46
+ request_stripe_object(
47
+ method: :delete,
48
+ path: format("/v1/subscription_items/%<item>s", { item: CGI.escape(self["id"]) }),
49
+ params: params,
50
+ opts: opts
51
+ )
52
+ end
53
+
54
+ # Returns a list of your subscription items for a given subscription.
55
+ def self.list(filters = {}, opts = {})
56
+ request_stripe_object(
57
+ method: :get,
58
+ path: "/v1/subscription_items",
59
+ params: filters,
60
+ opts: opts
61
+ )
62
+ end
63
+
64
+ # Updates the plan or quantity of an item on a current subscription.
65
+ def self.update(id, params = {}, opts = {})
66
+ request_stripe_object(
67
+ method: :post,
68
+ path: format("/v1/subscription_items/%<id>s", { id: CGI.escape(id) }),
69
+ params: params,
70
+ opts: opts
71
+ )
72
+ end
20
73
  end
21
74
  end
@@ -11,7 +11,11 @@ module Stripe
11
11
  include Stripe::APIOperations::Save
12
12
 
13
13
  OBJECT_NAME = "subscription_schedule"
14
+ def self.object_name
15
+ "subscription_schedule"
16
+ end
14
17
 
18
+ # Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.
15
19
  def cancel(params = {}, opts = {})
16
20
  request_stripe_object(
17
21
  method: :post,
@@ -21,24 +25,47 @@ module Stripe
21
25
  )
22
26
  end
23
27
 
24
- def release(params = {}, opts = {})
28
+ # Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.
29
+ def self.cancel(schedule, params = {}, opts = {})
25
30
  request_stripe_object(
26
31
  method: :post,
27
- path: format("/v1/subscription_schedules/%<schedule>s/release", { schedule: CGI.escape(self["id"]) }),
32
+ path: format("/v1/subscription_schedules/%<schedule>s/cancel", { schedule: CGI.escape(schedule) }),
28
33
  params: params,
29
34
  opts: opts
30
35
  )
31
36
  end
32
37
 
33
- def self.cancel(schedule, params = {}, opts = {})
38
+ # Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions.
39
+ def self.create(params = {}, opts = {})
34
40
  request_stripe_object(
35
41
  method: :post,
36
- path: format("/v1/subscription_schedules/%<schedule>s/cancel", { schedule: CGI.escape(schedule) }),
42
+ path: "/v1/subscription_schedules",
43
+ params: params,
44
+ opts: opts
45
+ )
46
+ end
47
+
48
+ # Retrieves the list of your subscription schedules.
49
+ def self.list(filters = {}, opts = {})
50
+ request_stripe_object(
51
+ method: :get,
52
+ path: "/v1/subscription_schedules",
53
+ params: filters,
54
+ opts: opts
55
+ )
56
+ end
57
+
58
+ # Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property.
59
+ def release(params = {}, opts = {})
60
+ request_stripe_object(
61
+ method: :post,
62
+ path: format("/v1/subscription_schedules/%<schedule>s/release", { schedule: CGI.escape(self["id"]) }),
37
63
  params: params,
38
64
  opts: opts
39
65
  )
40
66
  end
41
67
 
68
+ # Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property.
42
69
  def self.release(schedule, params = {}, opts = {})
43
70
  request_stripe_object(
44
71
  method: :post,
@@ -47,5 +74,15 @@ module Stripe
47
74
  opts: opts
48
75
  )
49
76
  end
77
+
78
+ # Updates an existing subscription schedule.
79
+ def self.update(id, params = {}, opts = {})
80
+ request_stripe_object(
81
+ method: :post,
82
+ path: format("/v1/subscription_schedules/%<id>s", { id: CGI.escape(id) }),
83
+ params: params,
84
+ opts: opts
85
+ )
86
+ end
50
87
  end
51
88
  end
@@ -10,7 +10,21 @@ module Stripe
10
10
  extend Stripe::APIOperations::Create
11
11
 
12
12
  OBJECT_NAME = "tax.calculation"
13
+ def self.object_name
14
+ "tax.calculation"
15
+ end
16
+
17
+ # Calculates tax based on the input and returns a Tax Calculation object.
18
+ def self.create(params = {}, opts = {})
19
+ request_stripe_object(
20
+ method: :post,
21
+ path: "/v1/tax/calculations",
22
+ params: params,
23
+ opts: opts
24
+ )
25
+ end
13
26
 
27
+ # Retrieves the line items of a tax calculation as a collection, if the calculation hasn't expired.
14
28
  def list_line_items(params = {}, opts = {})
15
29
  request_stripe_object(
16
30
  method: :get,
@@ -20,6 +34,7 @@ module Stripe
20
34
  )
21
35
  end
22
36
 
37
+ # Retrieves the line items of a tax calculation as a collection, if the calculation hasn't expired.
23
38
  def self.list_line_items(calculation, params = {}, opts = {})
24
39
  request_stripe_object(
25
40
  method: :get,
@@ -5,6 +5,9 @@ module Stripe
5
5
  module Tax
6
6
  class CalculationLineItem < APIResource
7
7
  OBJECT_NAME = "tax.calculation_line_item"
8
+ def self.object_name
9
+ "tax.calculation_line_item"
10
+ end
8
11
  end
9
12
  end
10
13
  end