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
@@ -38,56 +38,89 @@ module Stripe
38
38
  extend Stripe::APIOperations::Create
39
39
  include Stripe::APIOperations::Delete
40
40
  extend Stripe::APIOperations::List
41
+ extend Stripe::APIOperations::NestedResource
41
42
  extend Stripe::APIOperations::Search
42
43
  include Stripe::APIOperations::Save
43
44
 
44
45
  OBJECT_NAME = "invoice"
46
+ def self.object_name
47
+ "invoice"
48
+ end
45
49
 
46
- def finalize_invoice(params = {}, opts = {})
50
+ nested_resource_class_methods :line, operations: %i[list]
51
+
52
+ # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft.
53
+ def add_lines(params = {}, opts = {})
47
54
  request_stripe_object(
48
55
  method: :post,
49
- path: format("/v1/invoices/%<invoice>s/finalize", { invoice: CGI.escape(self["id"]) }),
56
+ path: format("/v1/invoices/%<invoice>s/add_lines", { invoice: CGI.escape(self["id"]) }),
50
57
  params: params,
51
58
  opts: opts
52
59
  )
53
60
  end
54
61
 
55
- def mark_uncollectible(params = {}, opts = {})
62
+ # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft.
63
+ def self.add_lines(invoice, params = {}, opts = {})
56
64
  request_stripe_object(
57
65
  method: :post,
58
- path: format("/v1/invoices/%<invoice>s/mark_uncollectible", { invoice: CGI.escape(self["id"]) }),
66
+ path: format("/v1/invoices/%<invoice>s/add_lines", { invoice: CGI.escape(invoice) }),
59
67
  params: params,
60
68
  opts: opts
61
69
  )
62
70
  end
63
71
 
64
- def pay(params = {}, opts = {})
72
+ # This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or <a href="#send_invoice">send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers.
73
+ def self.create(params = {}, opts = {})
74
+ request_stripe_object(method: :post, path: "/v1/invoices", params: params, opts: opts)
75
+ end
76
+
77
+ # At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.
78
+ #
79
+ # Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount.
80
+ #
81
+ # You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the subscription_details.proration_date parameter when doing the actual subscription update. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_details.proration_date value passed in the request.
82
+ #
83
+ # Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions)
84
+ def self.create_preview(params = {}, opts = {})
65
85
  request_stripe_object(
66
86
  method: :post,
67
- path: format("/v1/invoices/%<invoice>s/pay", { invoice: CGI.escape(self["id"]) }),
87
+ path: "/v1/invoices/create_preview",
68
88
  params: params,
69
89
  opts: opts
70
90
  )
71
91
  end
72
92
 
73
- def send_invoice(params = {}, opts = {})
93
+ # Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice).
94
+ def self.delete(id, params = {}, opts = {})
74
95
  request_stripe_object(
75
- method: :post,
76
- path: format("/v1/invoices/%<invoice>s/send", { invoice: CGI.escape(self["id"]) }),
96
+ method: :delete,
97
+ path: format("/v1/invoices/%<id>s", { id: CGI.escape(id) }),
77
98
  params: params,
78
99
  opts: opts
79
100
  )
80
101
  end
81
102
 
82
- def void_invoice(params = {}, opts = {})
103
+ # Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice).
104
+ def delete(params = {}, opts = {})
105
+ request_stripe_object(
106
+ method: :delete,
107
+ path: format("/v1/invoices/%<invoice>s", { invoice: CGI.escape(self["id"]) }),
108
+ params: params,
109
+ opts: opts
110
+ )
111
+ end
112
+
113
+ # Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method.
114
+ def finalize_invoice(params = {}, opts = {})
83
115
  request_stripe_object(
84
116
  method: :post,
85
- path: format("/v1/invoices/%<invoice>s/void", { invoice: CGI.escape(self["id"]) }),
117
+ path: format("/v1/invoices/%<invoice>s/finalize", { invoice: CGI.escape(self["id"]) }),
86
118
  params: params,
87
119
  opts: opts
88
120
  )
89
121
  end
90
122
 
123
+ # Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method.
91
124
  def self.finalize_invoice(invoice, params = {}, opts = {})
92
125
  request_stripe_object(
93
126
  method: :post,
@@ -97,6 +130,12 @@ module Stripe
97
130
  )
98
131
  end
99
132
 
133
+ # You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first.
134
+ def self.list(filters = {}, opts = {})
135
+ request_stripe_object(method: :get, path: "/v1/invoices", params: filters, opts: opts)
136
+ end
137
+
138
+ # When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
100
139
  def self.list_upcoming_line_items(params = {}, opts = {})
101
140
  request_stripe_object(
102
141
  method: :get,
@@ -106,6 +145,17 @@ module Stripe
106
145
  )
107
146
  end
108
147
 
148
+ # Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
149
+ def mark_uncollectible(params = {}, opts = {})
150
+ request_stripe_object(
151
+ method: :post,
152
+ path: format("/v1/invoices/%<invoice>s/mark_uncollectible", { invoice: CGI.escape(self["id"]) }),
153
+ params: params,
154
+ opts: opts
155
+ )
156
+ end
157
+
158
+ # Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
109
159
  def self.mark_uncollectible(invoice, params = {}, opts = {})
110
160
  request_stripe_object(
111
161
  method: :post,
@@ -115,6 +165,17 @@ module Stripe
115
165
  )
116
166
  end
117
167
 
168
+ # Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so.
169
+ def pay(params = {}, opts = {})
170
+ request_stripe_object(
171
+ method: :post,
172
+ path: format("/v1/invoices/%<invoice>s/pay", { invoice: CGI.escape(self["id"]) }),
173
+ params: params,
174
+ opts: opts
175
+ )
176
+ end
177
+
178
+ # Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so.
118
179
  def self.pay(invoice, params = {}, opts = {})
119
180
  request_stripe_object(
120
181
  method: :post,
@@ -124,6 +185,49 @@ module Stripe
124
185
  )
125
186
  end
126
187
 
188
+ # Removes multiple line items from an invoice. This is only possible when an invoice is still a draft.
189
+ def remove_lines(params = {}, opts = {})
190
+ request_stripe_object(
191
+ method: :post,
192
+ path: format("/v1/invoices/%<invoice>s/remove_lines", { invoice: CGI.escape(self["id"]) }),
193
+ params: params,
194
+ opts: opts
195
+ )
196
+ end
197
+
198
+ # Removes multiple line items from an invoice. This is only possible when an invoice is still a draft.
199
+ def self.remove_lines(invoice, params = {}, opts = {})
200
+ request_stripe_object(
201
+ method: :post,
202
+ path: format("/v1/invoices/%<invoice>s/remove_lines", { invoice: CGI.escape(invoice) }),
203
+ params: params,
204
+ opts: opts
205
+ )
206
+ end
207
+
208
+ def self.search(params = {}, opts = {})
209
+ request_stripe_object(method: :get, path: "/v1/invoices/search", params: params, opts: opts)
210
+ end
211
+
212
+ def self.search_auto_paging_each(params = {}, opts = {}, &blk)
213
+ search(params, opts).auto_paging_each(&blk)
214
+ end
215
+
216
+ # Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email.
217
+ #
218
+ # Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.
219
+ def send_invoice(params = {}, opts = {})
220
+ request_stripe_object(
221
+ method: :post,
222
+ path: format("/v1/invoices/%<invoice>s/send", { invoice: CGI.escape(self["id"]) }),
223
+ params: params,
224
+ opts: opts
225
+ )
226
+ end
227
+
228
+ # Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email.
229
+ #
230
+ # Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.
127
231
  def self.send_invoice(invoice, params = {}, opts = {})
128
232
  request_stripe_object(
129
233
  method: :post,
@@ -133,25 +237,74 @@ module Stripe
133
237
  )
134
238
  end
135
239
 
240
+ # At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.
241
+ #
242
+ # Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount.
243
+ #
244
+ # You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the subscription_details.proration_date parameter when doing the actual subscription update. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_details.proration_date value passed in the request.
245
+ #
246
+ # Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions)
136
247
  def self.upcoming(params = {}, opts = {})
137
248
  request_stripe_object(method: :get, path: "/v1/invoices/upcoming", params: params, opts: opts)
138
249
  end
139
250
 
140
- def self.void_invoice(invoice, params = {}, opts = {})
251
+ # Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized),
252
+ # monetary values, as well as collection_method, become uneditable.
253
+ #
254
+ # If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on,
255
+ # sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass
256
+ # auto_advance=false.
257
+ def self.update(id, params = {}, opts = {})
141
258
  request_stripe_object(
142
259
  method: :post,
143
- path: format("/v1/invoices/%<invoice>s/void", { invoice: CGI.escape(invoice) }),
260
+ path: format("/v1/invoices/%<id>s", { id: CGI.escape(id) }),
144
261
  params: params,
145
262
  opts: opts
146
263
  )
147
264
  end
148
265
 
149
- def self.search(params = {}, opts = {})
150
- _search("/v1/invoices/search", params, opts)
266
+ # Updates multiple line items on an invoice. This is only possible when an invoice is still a draft.
267
+ def update_lines(params = {}, opts = {})
268
+ request_stripe_object(
269
+ method: :post,
270
+ path: format("/v1/invoices/%<invoice>s/update_lines", { invoice: CGI.escape(self["id"]) }),
271
+ params: params,
272
+ opts: opts
273
+ )
151
274
  end
152
275
 
153
- def self.search_auto_paging_each(params = {}, opts = {}, &blk)
154
- search(params, opts).auto_paging_each(&blk)
276
+ # Updates multiple line items on an invoice. This is only possible when an invoice is still a draft.
277
+ def self.update_lines(invoice, params = {}, opts = {})
278
+ request_stripe_object(
279
+ method: :post,
280
+ path: format("/v1/invoices/%<invoice>s/update_lines", { invoice: CGI.escape(invoice) }),
281
+ params: params,
282
+ opts: opts
283
+ )
284
+ end
285
+
286
+ # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.
287
+ #
288
+ # Consult with local regulations to determine whether and how an invoice might be amended, canceled, or voided in the jurisdiction you're doing business in. You might need to [issue another invoice or <a href="#create_credit_note">credit note](https://stripe.com/docs/api#create_invoice) instead. Stripe recommends that you consult with your legal counsel for advice specific to your business.
289
+ def void_invoice(params = {}, opts = {})
290
+ request_stripe_object(
291
+ method: :post,
292
+ path: format("/v1/invoices/%<invoice>s/void", { invoice: CGI.escape(self["id"]) }),
293
+ params: params,
294
+ opts: opts
295
+ )
296
+ end
297
+
298
+ # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.
299
+ #
300
+ # Consult with local regulations to determine whether and how an invoice might be amended, canceled, or voided in the jurisdiction you're doing business in. You might need to [issue another invoice or <a href="#create_credit_note">credit note](https://stripe.com/docs/api#create_invoice) instead. Stripe recommends that you consult with your legal counsel for advice specific to your business.
301
+ def self.void_invoice(invoice, params = {}, opts = {})
302
+ request_stripe_object(
303
+ method: :post,
304
+ path: format("/v1/invoices/%<invoice>s/void", { invoice: CGI.escape(invoice) }),
305
+ params: params,
306
+ opts: opts
307
+ )
155
308
  end
156
309
  end
157
310
  end
@@ -20,5 +20,48 @@ module Stripe
20
20
  include Stripe::APIOperations::Save
21
21
 
22
22
  OBJECT_NAME = "invoiceitem"
23
+ def self.object_name
24
+ "invoiceitem"
25
+ end
26
+
27
+ # Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.
28
+ def self.create(params = {}, opts = {})
29
+ request_stripe_object(method: :post, path: "/v1/invoiceitems", params: params, opts: opts)
30
+ end
31
+
32
+ # Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice.
33
+ def self.delete(id, params = {}, opts = {})
34
+ request_stripe_object(
35
+ method: :delete,
36
+ path: format("/v1/invoiceitems/%<id>s", { id: CGI.escape(id) }),
37
+ params: params,
38
+ opts: opts
39
+ )
40
+ end
41
+
42
+ # Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice.
43
+ def delete(params = {}, opts = {})
44
+ request_stripe_object(
45
+ method: :delete,
46
+ path: format("/v1/invoiceitems/%<invoiceitem>s", { invoiceitem: CGI.escape(self["id"]) }),
47
+ params: params,
48
+ opts: opts
49
+ )
50
+ end
51
+
52
+ # Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
53
+ def self.list(filters = {}, opts = {})
54
+ request_stripe_object(method: :get, path: "/v1/invoiceitems", params: filters, opts: opts)
55
+ end
56
+
57
+ # Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it's attached to is closed.
58
+ def self.update(id, params = {}, opts = {})
59
+ request_stripe_object(
60
+ method: :post,
61
+ path: format("/v1/invoiceitems/%<id>s", { id: CGI.escape(id) }),
62
+ params: params,
63
+ opts: opts
64
+ )
65
+ end
23
66
  end
24
67
  end
@@ -2,7 +2,28 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Invoice Line Items represent the individual lines within an [invoice](https://stripe.com/docs/api/invoices) and only exist within the context of an invoice.
6
+ #
7
+ # Each line item is backed by either an [invoice item](https://stripe.com/docs/api/invoiceitems) or a [subscription item](https://stripe.com/docs/api/subscription_items).
5
8
  class InvoiceLineItem < StripeObject
9
+ include Stripe::APIOperations::Save
10
+
6
11
  OBJECT_NAME = "line_item"
12
+ def self.object_name
13
+ "line_item"
14
+ end
15
+
16
+ # Updates an invoice's line item. Some fields, such as tax_amounts, only live on the invoice line item,
17
+ # so they can only be updated through this endpoint. Other fields, such as amount, live on both the invoice
18
+ # item and the invoice line item, so updates on this endpoint will propagate to the invoice item as well.
19
+ # Updating an invoice's line item is only possible before the invoice is finalized.
20
+ def self.update(id, params = {}, opts = {})
21
+ request_stripe_object(
22
+ method: :post,
23
+ path: format("/v1/invoices/%<invoice>s/lines/%<id>s", { invoice: CGI.escape(invoice), id: CGI.escape(id) }),
24
+ params: params,
25
+ opts: opts
26
+ )
27
+ end
7
28
  end
8
29
  end
@@ -0,0 +1,63 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ class InvoiceRenderingTemplate < APIResource
6
+ extend Stripe::APIOperations::List
7
+
8
+ OBJECT_NAME = "invoice_rendering_template"
9
+ def self.object_name
10
+ "invoice_rendering_template"
11
+ end
12
+
13
+ # Updates the status of an invoice rendering template to ‘archived' so no new Stripe objects (customers, invoices, etc.) can reference it. The template can also no longer be updated. However, if the template is already set on a Stripe object, it will continue to be applied on invoices generated by it.
14
+ def archive(params = {}, opts = {})
15
+ request_stripe_object(
16
+ method: :post,
17
+ path: format("/v1/invoice_rendering_templates/%<template>s/archive", { template: CGI.escape(self["id"]) }),
18
+ params: params,
19
+ opts: opts
20
+ )
21
+ end
22
+
23
+ # Updates the status of an invoice rendering template to ‘archived' so no new Stripe objects (customers, invoices, etc.) can reference it. The template can also no longer be updated. However, if the template is already set on a Stripe object, it will continue to be applied on invoices generated by it.
24
+ def self.archive(template, params = {}, opts = {})
25
+ request_stripe_object(
26
+ method: :post,
27
+ path: format("/v1/invoice_rendering_templates/%<template>s/archive", { template: CGI.escape(template) }),
28
+ params: params,
29
+ opts: opts
30
+ )
31
+ end
32
+
33
+ # List all templates, ordered by creation date, with the most recently created template appearing first.
34
+ def self.list(filters = {}, opts = {})
35
+ request_stripe_object(
36
+ method: :get,
37
+ path: "/v1/invoice_rendering_templates",
38
+ params: filters,
39
+ opts: opts
40
+ )
41
+ end
42
+
43
+ # Unarchive an invoice rendering template so it can be used on new Stripe objects again.
44
+ def unarchive(params = {}, opts = {})
45
+ request_stripe_object(
46
+ method: :post,
47
+ path: format("/v1/invoice_rendering_templates/%<template>s/unarchive", { template: CGI.escape(self["id"]) }),
48
+ params: params,
49
+ opts: opts
50
+ )
51
+ end
52
+
53
+ # Unarchive an invoice rendering template so it can be used on new Stripe objects again.
54
+ def self.unarchive(template, params = {}, opts = {})
55
+ request_stripe_object(
56
+ method: :post,
57
+ path: format("/v1/invoice_rendering_templates/%<template>s/unarchive", { template: CGI.escape(template) }),
58
+ params: params,
59
+ opts: opts
60
+ )
61
+ end
62
+ end
63
+ end
@@ -9,11 +9,17 @@ module Stripe
9
9
  #
10
10
  # Related guide: [Issued card authorizations](https://stripe.com/docs/issuing/purchases/authorizations)
11
11
  class Authorization < APIResource
12
+ extend Gem::Deprecate
12
13
  extend Stripe::APIOperations::List
13
14
  include Stripe::APIOperations::Save
14
15
 
15
16
  OBJECT_NAME = "issuing.authorization"
17
+ def self.object_name
18
+ "issuing.authorization"
19
+ end
16
20
 
21
+ # [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow.
22
+ # This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling).
17
23
  def approve(params = {}, opts = {})
18
24
  request_stripe_object(
19
25
  method: :post,
@@ -22,25 +28,37 @@ module Stripe
22
28
  opts: opts
23
29
  )
24
30
  end
31
+ deprecate :approve, :none, 2024, 3
25
32
 
26
- def decline(params = {}, opts = {})
33
+ # [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow.
34
+ # This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling).
35
+ def self.approve(authorization, params = {}, opts = {})
27
36
  request_stripe_object(
28
37
  method: :post,
29
- path: format("/v1/issuing/authorizations/%<authorization>s/decline", { authorization: CGI.escape(self["id"]) }),
38
+ path: format("/v1/issuing/authorizations/%<authorization>s/approve", { authorization: CGI.escape(authorization) }),
30
39
  params: params,
31
40
  opts: opts
32
41
  )
33
42
  end
43
+ class << self
44
+ extend Gem::Deprecate
45
+ deprecate :approve, :none, 2024, 3
46
+ end
34
47
 
35
- def self.approve(authorization, params = {}, opts = {})
48
+ # [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow.
49
+ # This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling).
50
+ def decline(params = {}, opts = {})
36
51
  request_stripe_object(
37
52
  method: :post,
38
- path: format("/v1/issuing/authorizations/%<authorization>s/approve", { authorization: CGI.escape(authorization) }),
53
+ path: format("/v1/issuing/authorizations/%<authorization>s/decline", { authorization: CGI.escape(self["id"]) }),
39
54
  params: params,
40
55
  opts: opts
41
56
  )
42
57
  end
58
+ deprecate :decline, :none, 2024, 3
43
59
 
60
+ # [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow.
61
+ # This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling).
44
62
  def self.decline(authorization, params = {}, opts = {})
45
63
  request_stripe_object(
46
64
  method: :post,
@@ -49,6 +67,30 @@ module Stripe
49
67
  opts: opts
50
68
  )
51
69
  end
70
+ class << self
71
+ extend Gem::Deprecate
72
+ deprecate :decline, :none, 2024, 3
73
+ end
74
+
75
+ # Returns a list of Issuing Authorization objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
76
+ def self.list(filters = {}, opts = {})
77
+ request_stripe_object(
78
+ method: :get,
79
+ path: "/v1/issuing/authorizations",
80
+ params: filters,
81
+ opts: opts
82
+ )
83
+ end
84
+
85
+ # Updates the specified Issuing Authorization object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
86
+ def self.update(id, params = {}, opts = {})
87
+ request_stripe_object(
88
+ method: :post,
89
+ path: format("/v1/issuing/authorizations/%<id>s", { id: CGI.escape(id) }),
90
+ params: params,
91
+ opts: opts
92
+ )
93
+ end
52
94
 
53
95
  def test_helpers
54
96
  TestHelpers.new(self)
@@ -56,7 +98,11 @@ module Stripe
56
98
 
57
99
  class TestHelpers < APIResourceTestHelpers
58
100
  RESOURCE_CLASS = Authorization
101
+ def self.resource_class
102
+ "Authorization"
103
+ end
59
104
 
105
+ # Capture a test-mode authorization.
60
106
  def self.capture(authorization, params = {}, opts = {})
61
107
  request_stripe_object(
62
108
  method: :post,
@@ -66,6 +112,17 @@ module Stripe
66
112
  )
67
113
  end
68
114
 
115
+ # Capture a test-mode authorization.
116
+ def capture(params = {}, opts = {})
117
+ @resource.request_stripe_object(
118
+ method: :post,
119
+ path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/capture", { authorization: CGI.escape(@resource["id"]) }),
120
+ params: params,
121
+ opts: opts
122
+ )
123
+ end
124
+
125
+ # Create a test-mode authorization.
69
126
  def self.create(params = {}, opts = {})
70
127
  request_stripe_object(
71
128
  method: :post,
@@ -75,6 +132,7 @@ module Stripe
75
132
  )
76
133
  end
77
134
 
135
+ # Expire a test-mode Authorization.
78
136
  def self.expire(authorization, params = {}, opts = {})
79
137
  request_stripe_object(
80
138
  method: :post,
@@ -84,42 +142,47 @@ module Stripe
84
142
  )
85
143
  end
86
144
 
87
- def self.increment(authorization, params = {}, opts = {})
88
- request_stripe_object(
145
+ # Expire a test-mode Authorization.
146
+ def expire(params = {}, opts = {})
147
+ @resource.request_stripe_object(
89
148
  method: :post,
90
- path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/increment", { authorization: CGI.escape(authorization) }),
149
+ path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/expire", { authorization: CGI.escape(@resource["id"]) }),
91
150
  params: params,
92
151
  opts: opts
93
152
  )
94
153
  end
95
154
 
96
- def self.reverse(authorization, params = {}, opts = {})
155
+ # Finalize the amount on an Authorization prior to capture, when the initial authorization was for an estimated amount.
156
+ def self.finalize_amount(authorization, params = {}, opts = {})
97
157
  request_stripe_object(
98
158
  method: :post,
99
- path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/reverse", { authorization: CGI.escape(authorization) }),
159
+ path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/finalize_amount", { authorization: CGI.escape(authorization) }),
100
160
  params: params,
101
161
  opts: opts
102
162
  )
103
163
  end
104
164
 
105
- def capture(params = {}, opts = {})
165
+ # Finalize the amount on an Authorization prior to capture, when the initial authorization was for an estimated amount.
166
+ def finalize_amount(params = {}, opts = {})
106
167
  @resource.request_stripe_object(
107
168
  method: :post,
108
- path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/capture", { authorization: CGI.escape(@resource["id"]) }),
169
+ path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/finalize_amount", { authorization: CGI.escape(@resource["id"]) }),
109
170
  params: params,
110
171
  opts: opts
111
172
  )
112
173
  end
113
174
 
114
- def expire(params = {}, opts = {})
115
- @resource.request_stripe_object(
175
+ # Increment a test-mode Authorization.
176
+ def self.increment(authorization, params = {}, opts = {})
177
+ request_stripe_object(
116
178
  method: :post,
117
- path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/expire", { authorization: CGI.escape(@resource["id"]) }),
179
+ path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/increment", { authorization: CGI.escape(authorization) }),
118
180
  params: params,
119
181
  opts: opts
120
182
  )
121
183
  end
122
184
 
185
+ # Increment a test-mode Authorization.
123
186
  def increment(params = {}, opts = {})
124
187
  @resource.request_stripe_object(
125
188
  method: :post,
@@ -129,6 +192,17 @@ module Stripe
129
192
  )
130
193
  end
131
194
 
195
+ # Reverse a test-mode Authorization.
196
+ def self.reverse(authorization, params = {}, opts = {})
197
+ request_stripe_object(
198
+ method: :post,
199
+ path: format("/v1/test_helpers/issuing/authorizations/%<authorization>s/reverse", { authorization: CGI.escape(authorization) }),
200
+ params: params,
201
+ opts: opts
202
+ )
203
+ end
204
+
205
+ # Reverse a test-mode Authorization.
132
206
  def reverse(params = {}, opts = {})
133
207
  @resource.request_stripe_object(
134
208
  method: :post,