Class: Stripe::Invoice
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Invoice
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::NestedResource, APIOperations::Search
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/stripe/resources/invoice.rb
Overview
Invoices are statements of amounts owed by a customer, and are either generated one-off, or generated periodically from a subscription.
They contain [invoice items](stripe.com/docs/api#invoiceitems), and proration adjustments that may be caused by subscription upgrades/downgrades (if necessary).
If your invoice is configured to be billed through automatic charges, Stripe automatically finalizes your invoice and attempts payment. Note that finalizing the invoice, [when automatic](stripe.com/docs/invoicing/integration/automatic-advancement-collection), does not happen immediately as the invoice is created. Stripe waits until one hour after the last webhook was successfully sent (or the last webhook timed out after failing). If you (and the platforms you may have connected to) have no webhooks configured, Stripe waits one hour after creation to finalize the invoice.
If your invoice is configured to be billed by sending an email, then based on your [email settings](dashboard.stripe.com/account/billing/automatic), Stripe will email the invoice to your customer and await payment. These emails can contain a link to a hosted page to pay the invoice.
Stripe applies any customer credit on the account before determining the amount due for the invoice (i.e., the amount that will be actually charged). If the amount due for the invoice is less than Stripe’s [minimum allowed charge per currency](stripe.com/docs/currencies#minimum-and-maximum-charge-amounts), the invoice is automatically marked paid, and we add the amount due to the customer’s credit balance which is applied to the next invoice.
More details on the customer’s credit balance are [here](stripe.com/docs/billing/customer/balance).
Related guide: [Send invoices to customers](stripe.com/docs/billing/invoices/sending)
Defined Under Namespace
Classes: AmountsDue, AutomaticTax, CustomField, CustomerAddress, CustomerShipping, CustomerTaxId, FromInvoice, Issuer, LastFinalizationError, PaymentSettings, Rendering, ShippingCost, ShippingDetails, StatusTransitions, SubscriptionDetails, ThresholdReason, TotalDiscountAmount, TotalMarginAmount, TotalPretaxCreditAmount, TotalTaxAmount, TransferData
Constant Summary collapse
- OBJECT_NAME =
"invoice"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#account_country ⇒ Object
readonly
The country of the business associated with this invoice, most often the business creating the invoice.
-
#account_name ⇒ Object
readonly
The public name of the business associated with this invoice, most often the business creating the invoice.
-
#account_tax_ids ⇒ Object
readonly
The account tax IDs associated with the invoice.
-
#amount_due ⇒ Object
readonly
Final amount due at this time for this invoice.
-
#amount_overpaid ⇒ Object
readonly
Amount that was overpaid on the invoice.
-
#amount_paid ⇒ Object
readonly
The amount, in cents (or local equivalent), that was paid.
-
#amount_remaining ⇒ Object
readonly
The difference between amount_due and amount_paid, in cents (or local equivalent).
-
#amount_shipping ⇒ Object
readonly
This is the sum of all the shipping amounts.
-
#amounts_due ⇒ Object
readonly
List of expected payments and corresponding due dates.
-
#application ⇒ Object
readonly
ID of the Connect Application that created the invoice.
-
#application_fee_amount ⇒ Object
readonly
The fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner’s Stripe account when the invoice is paid.
-
#attempt_count ⇒ Object
readonly
Number of payment attempts made for this invoice, from the perspective of the payment retry schedule.
-
#attempted ⇒ Object
readonly
Whether an attempt has been made to pay the invoice.
-
#auto_advance ⇒ Object
readonly
Controls whether Stripe performs [automatic collection](stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice.
-
#automatic_tax ⇒ Object
readonly
Attribute for field automatic_tax.
-
#automatically_finalizes_at ⇒ Object
readonly
The time when this invoice is currently scheduled to be automatically finalized.
-
#billing_reason ⇒ Object
readonly
Indicates the reason why the invoice was created.
-
#charge ⇒ Object
readonly
ID of the latest charge generated for this invoice, if any.
-
#collection_method ⇒ Object
readonly
Either ‘charge_automatically`, or `send_invoice`.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#currency ⇒ Object
readonly
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase.
-
#custom_fields ⇒ Object
readonly
Custom fields displayed on the invoice.
-
#customer ⇒ Object
readonly
The ID of the customer who will be billed.
-
#customer_address ⇒ Object
readonly
The customer’s address.
-
#customer_email ⇒ Object
readonly
The customer’s email.
-
#customer_name ⇒ Object
readonly
The customer’s name.
-
#customer_phone ⇒ Object
readonly
The customer’s phone number.
-
#customer_shipping ⇒ Object
readonly
The customer’s shipping information.
-
#customer_tax_exempt ⇒ Object
readonly
The customer’s tax exempt status.
-
#customer_tax_ids ⇒ Object
readonly
The customer’s tax IDs.
-
#default_margins ⇒ Object
readonly
The margins applied to the invoice.
-
#default_payment_method ⇒ Object
readonly
ID of the default payment method for the invoice.
-
#default_source ⇒ Object
readonly
ID of the default payment source for the invoice.
-
#default_tax_rates ⇒ Object
readonly
The tax rates applied to this invoice, if any.
-
#deleted ⇒ Object
readonly
Always true for a deleted object.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#discount ⇒ Object
readonly
Describes the current discount applied to this invoice, if there is one.
-
#discounts ⇒ Object
readonly
The discounts applied to the invoice.
-
#due_date ⇒ Object
readonly
The date on which payment for this invoice is due.
-
#effective_at ⇒ Object
readonly
The date when this invoice is in effect.
-
#ending_balance ⇒ Object
readonly
Ending customer balance after the invoice is finalized.
-
#footer ⇒ Object
readonly
Footer displayed on the invoice.
-
#from_invoice ⇒ Object
readonly
Details of the invoice that was cloned.
-
#hosted_invoice_url ⇒ Object
readonly
The URL for the hosted invoice page, which allows customers to view and pay an invoice.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#invoice_pdf ⇒ Object
readonly
The link to download the PDF for the invoice.
-
#issuer ⇒ Object
readonly
Attribute for field issuer.
-
#last_finalization_error ⇒ Object
readonly
The error encountered during the previous attempt to finalize the invoice.
-
#latest_revision ⇒ Object
readonly
The ID of the most recent non-draft revision of this invoice.
-
#lines ⇒ Object
readonly
The individual line items that make up the invoice.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#next_payment_attempt ⇒ Object
readonly
The time at which payment will next be attempted.
-
#number ⇒ Object
readonly
A unique, identifying string that appears on emails sent to the customer for this invoice.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#on_behalf_of ⇒ Object
readonly
The account (if any) for which the funds of the invoice payment are intended.
-
#paid ⇒ Object
readonly
Whether payment was successfully collected for this invoice.
-
#paid_out_of_band ⇒ Object
readonly
Returns true if the invoice was manually marked paid, returns false if the invoice hasn’t been paid yet or was paid on Stripe.
-
#payment_intent ⇒ Object
readonly
The PaymentIntent associated with this invoice.
-
#payment_settings ⇒ Object
readonly
Attribute for field payment_settings.
-
#payments ⇒ Object
readonly
Payments for this invoice.
-
#period_end ⇒ Object
readonly
End of the usage period during which invoice items were added to this invoice.
-
#period_start ⇒ Object
readonly
Start of the usage period during which invoice items were added to this invoice.
-
#post_payment_credit_notes_amount ⇒ Object
readonly
Total amount of all post-payment credit notes issued for this invoice.
-
#pre_payment_credit_notes_amount ⇒ Object
readonly
Total amount of all pre-payment credit notes issued for this invoice.
-
#quote ⇒ Object
readonly
The quote this invoice was generated from.
-
#receipt_number ⇒ Object
readonly
This is the transaction number that appears on email receipts sent for this invoice.
-
#rendering ⇒ Object
readonly
The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
-
#shipping_cost ⇒ Object
readonly
The details of the cost of shipping, including the ShippingRate applied on the invoice.
-
#shipping_details ⇒ Object
readonly
Shipping details for the invoice.
-
#starting_balance ⇒ Object
readonly
Starting customer balance before the invoice is finalized.
-
#statement_descriptor ⇒ Object
readonly
Extra information about an invoice for the customer’s credit card statement.
-
#status ⇒ Object
readonly
The status of the invoice, one of ‘draft`, `open`, `paid`, `uncollectible`, or `void`.
-
#status_transitions ⇒ Object
readonly
Attribute for field status_transitions.
-
#subscription ⇒ Object
readonly
The subscription that this invoice was prepared for, if any.
-
#subscription_details ⇒ Object
readonly
Details about the subscription that created this invoice.
-
#subscription_proration_date ⇒ Object
readonly
Only set for upcoming invoices that preview prorations.
-
#subtotal ⇒ Object
readonly
Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied.
-
#subtotal_excluding_tax ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the subtotal of the invoice before any invoice level discount or tax is applied.
-
#tax ⇒ Object
readonly
The amount of tax on this invoice.
-
#test_clock ⇒ Object
readonly
ID of the test clock this invoice belongs to.
-
#threshold_reason ⇒ Object
readonly
Attribute for field threshold_reason.
-
#total ⇒ Object
readonly
Total after discounts and taxes.
-
#total_discount_amounts ⇒ Object
readonly
The aggregate amounts calculated per discount across all line items.
-
#total_excluding_tax ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax.
-
#total_margin_amounts ⇒ Object
readonly
The aggregate amounts calculated per margin across all line items.
-
#total_pretax_credit_amounts ⇒ Object
readonly
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this invoice.
-
#total_tax_amounts ⇒ Object
readonly
The aggregate amounts calculated per tax rate for all line items.
-
#transfer_data ⇒ Object
readonly
The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
-
#webhooks_delivered_at ⇒ Object
readonly
Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have [been exhausted](stripe.com/docs/billing/webhooks#understand).
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.add_lines(invoice, params = {}, opts = {}) ⇒ Object
Adds multiple line items to an invoice.
-
.attach_payment(invoice, params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent or an Out of Band Payment to the invoice, adding it to the list of payments.
-
.attach_payment_intent(invoice, params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent to the invoice, adding it to the list of payments.
-
.create(params = {}, opts = {}) ⇒ Object
This endpoint creates a draft invoice for a given customer.
-
.create_preview(params = {}, opts = {}) ⇒ Object
At any time, you can preview the upcoming invoice for a customer.
-
.delete(id, params = {}, opts = {}) ⇒ Object
Permanently deletes a one-off invoice draft.
-
.finalize_invoice(invoice, params = {}, opts = {}) ⇒ Object
Stripe automatically finalizes drafts before sending and attempting payment on invoices.
-
.list(filters = {}, opts = {}) ⇒ Object
You can list all invoices, or list the invoices for a specific customer.
-
.list_upcoming_line_items(params = {}, opts = {}) ⇒ Object
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.
-
.mark_uncollectible(invoice, params = {}, opts = {}) ⇒ Object
Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
- .object_name ⇒ Object
-
.pay(invoice, params = {}, opts = {}) ⇒ Object
Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](dashboard.stripe.com/account/billing/automatic).
-
.remove_lines(invoice, params = {}, opts = {}) ⇒ Object
Removes multiple line items from an invoice.
- .search(params = {}, opts = {}) ⇒ Object
- .search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
-
.send_invoice(invoice, params = {}, opts = {}) ⇒ Object
Stripe will automatically send invoices to customers according to your [subscriptions settings](dashboard.stripe.com/account/billing/automatic).
-
.upcoming(params = {}, opts = {}) ⇒ Object
At any time, you can preview the upcoming invoice for a customer.
-
.update(id, params = {}, opts = {}) ⇒ Object
Draft invoices are fully editable.
-
.update_lines(invoice, params = {}, opts = {}) ⇒ Object
Updates multiple line items on an invoice.
-
.void_invoice(invoice, params = {}, opts = {}) ⇒ Object
Mark a finalized invoice as void.
Instance Method Summary collapse
-
#add_lines(params = {}, opts = {}) ⇒ Object
Adds multiple line items to an invoice.
-
#attach_payment(params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent or an Out of Band Payment to the invoice, adding it to the list of payments.
-
#attach_payment_intent(params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent to the invoice, adding it to the list of payments.
-
#delete(params = {}, opts = {}) ⇒ Object
Permanently deletes a one-off invoice draft.
-
#finalize_invoice(params = {}, opts = {}) ⇒ Object
Stripe automatically finalizes drafts before sending and attempting payment on invoices.
-
#mark_uncollectible(params = {}, opts = {}) ⇒ Object
Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
-
#pay(params = {}, opts = {}) ⇒ Object
Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](dashboard.stripe.com/account/billing/automatic).
-
#remove_lines(params = {}, opts = {}) ⇒ Object
Removes multiple line items from an invoice.
-
#send_invoice(params = {}, opts = {}) ⇒ Object
Stripe will automatically send invoices to customers according to your [subscriptions settings](dashboard.stripe.com/account/billing/automatic).
-
#update_lines(params = {}, opts = {}) ⇒ Object
Updates multiple line items on an invoice.
-
#void_invoice(params = {}, opts = {}) ⇒ Object
Mark a finalized invoice as void.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::NestedResource
Methods included from APIOperations::Search
Methods included from APIOperations::Save
Methods included from APIOperations::Delete
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#account_country ⇒ Object (readonly)
The country of the business associated with this invoice, most often the business creating the invoice.
202 203 204 |
# File 'lib/stripe/resources/invoice.rb', line 202 def account_country @account_country end |
#account_name ⇒ Object (readonly)
The public name of the business associated with this invoice, most often the business creating the invoice.
204 205 206 |
# File 'lib/stripe/resources/invoice.rb', line 204 def account_name @account_name end |
#account_tax_ids ⇒ Object (readonly)
The account tax IDs associated with the invoice. Only editable when the invoice is a draft.
206 207 208 |
# File 'lib/stripe/resources/invoice.rb', line 206 def account_tax_ids @account_tax_ids end |
#amount_due ⇒ Object (readonly)
Final amount due at this time for this invoice. If the invoice’s total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the ‘amount_due` may be 0. If there is a positive `starting_balance` for the invoice (the customer owes money), the `amount_due` will also take that into account. The charge that gets generated for the invoice will be for the amount specified in `amount_due`.
208 209 210 |
# File 'lib/stripe/resources/invoice.rb', line 208 def amount_due @amount_due end |
#amount_overpaid ⇒ Object (readonly)
Amount that was overpaid on the invoice. Overpayments are debited to the customer’s credit balance.
210 211 212 |
# File 'lib/stripe/resources/invoice.rb', line 210 def amount_overpaid @amount_overpaid end |
#amount_paid ⇒ Object (readonly)
The amount, in cents (or local equivalent), that was paid.
212 213 214 |
# File 'lib/stripe/resources/invoice.rb', line 212 def amount_paid @amount_paid end |
#amount_remaining ⇒ Object (readonly)
The difference between amount_due and amount_paid, in cents (or local equivalent).
214 215 216 |
# File 'lib/stripe/resources/invoice.rb', line 214 def amount_remaining @amount_remaining end |
#amount_shipping ⇒ Object (readonly)
This is the sum of all the shipping amounts.
216 217 218 |
# File 'lib/stripe/resources/invoice.rb', line 216 def amount_shipping @amount_shipping end |
#amounts_due ⇒ Object (readonly)
List of expected payments and corresponding due dates. This value will be null for invoices where collection_method=charge_automatically.
218 219 220 |
# File 'lib/stripe/resources/invoice.rb', line 218 def amounts_due @amounts_due end |
#application ⇒ Object (readonly)
ID of the Connect Application that created the invoice.
220 221 222 |
# File 'lib/stripe/resources/invoice.rb', line 220 def application @application end |
#application_fee_amount ⇒ Object (readonly)
The fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner’s Stripe account when the invoice is paid.
222 223 224 |
# File 'lib/stripe/resources/invoice.rb', line 222 def application_fee_amount @application_fee_amount end |
#attempt_count ⇒ Object (readonly)
Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule. If a failure is returned with a non-retryable return code, the invoice can no longer be retried unless a new payment method is obtained. Retries will continue to be scheduled, and attempt_count will continue to increment, but retries will only be executed if a new payment method is obtained.
224 225 226 |
# File 'lib/stripe/resources/invoice.rb', line 224 def attempt_count @attempt_count end |
#attempted ⇒ Object (readonly)
Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the ‘invoice.created` webhook, for example, so you might not want to display that invoice as unpaid to your users.
226 227 228 |
# File 'lib/stripe/resources/invoice.rb', line 226 def attempted @attempted end |
#auto_advance ⇒ Object (readonly)
Controls whether Stripe performs [automatic collection](stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If ‘false`, the invoice’s state doesn’t automatically advance without an explicit action.
228 229 230 |
# File 'lib/stripe/resources/invoice.rb', line 228 def auto_advance @auto_advance end |
#automatic_tax ⇒ Object (readonly)
Attribute for field automatic_tax
230 231 232 |
# File 'lib/stripe/resources/invoice.rb', line 230 def automatic_tax @automatic_tax end |
#automatically_finalizes_at ⇒ Object (readonly)
The time when this invoice is currently scheduled to be automatically finalized. The field will be ‘null` if the invoice is not scheduled to finalize in the future. If the invoice is not in the draft state, this field will always be `null` - see `finalized_at` for the time when an already-finalized invoice was finalized.
232 233 234 |
# File 'lib/stripe/resources/invoice.rb', line 232 def automatically_finalizes_at @automatically_finalizes_at end |
#billing_reason ⇒ Object (readonly)
Indicates the reason why the invoice was created.
-
‘manual`: Unrelated to a subscription, for example, created via the invoice editor.
-
‘subscription`: No longer in use. Applies to subscriptions from before May 2018 where no distinction was made between updates, cycles, and thresholds.
-
‘subscription_create`: A new subscription was created.
-
‘subscription_cycle`: A subscription advanced into a new period.
-
‘subscription_threshold`: A subscription reached a billing threshold.
-
‘subscription_update`: A subscription was updated.
-
‘upcoming`: Reserved for simulated invoices, per the upcoming invoice endpoint.
242 243 244 |
# File 'lib/stripe/resources/invoice.rb', line 242 def billing_reason @billing_reason end |
#charge ⇒ Object (readonly)
ID of the latest charge generated for this invoice, if any.
244 245 246 |
# File 'lib/stripe/resources/invoice.rb', line 244 def charge @charge end |
#collection_method ⇒ Object (readonly)
Either ‘charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
246 247 248 |
# File 'lib/stripe/resources/invoice.rb', line 246 def collection_method @collection_method end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
248 249 250 |
# File 'lib/stripe/resources/invoice.rb', line 248 def created @created end |
#currency ⇒ Object (readonly)
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).
250 251 252 |
# File 'lib/stripe/resources/invoice.rb', line 250 def currency @currency end |
#custom_fields ⇒ Object (readonly)
Custom fields displayed on the invoice.
252 253 254 |
# File 'lib/stripe/resources/invoice.rb', line 252 def custom_fields @custom_fields end |
#customer ⇒ Object (readonly)
The ID of the customer who will be billed.
254 255 256 |
# File 'lib/stripe/resources/invoice.rb', line 254 def customer @customer end |
#customer_address ⇒ Object (readonly)
The customer’s address. Until the invoice is finalized, this field will equal ‘customer.address`. Once the invoice is finalized, this field will no longer be updated.
256 257 258 |
# File 'lib/stripe/resources/invoice.rb', line 256 def customer_address @customer_address end |
#customer_email ⇒ Object (readonly)
The customer’s email. Until the invoice is finalized, this field will equal ‘customer.email`. Once the invoice is finalized, this field will no longer be updated.
258 259 260 |
# File 'lib/stripe/resources/invoice.rb', line 258 def customer_email @customer_email end |
#customer_name ⇒ Object (readonly)
The customer’s name. Until the invoice is finalized, this field will equal ‘customer.name`. Once the invoice is finalized, this field will no longer be updated.
260 261 262 |
# File 'lib/stripe/resources/invoice.rb', line 260 def customer_name @customer_name end |
#customer_phone ⇒ Object (readonly)
The customer’s phone number. Until the invoice is finalized, this field will equal ‘customer.phone`. Once the invoice is finalized, this field will no longer be updated.
262 263 264 |
# File 'lib/stripe/resources/invoice.rb', line 262 def customer_phone @customer_phone end |
#customer_shipping ⇒ Object (readonly)
The customer’s shipping information. Until the invoice is finalized, this field will equal ‘customer.shipping`. Once the invoice is finalized, this field will no longer be updated.
264 265 266 |
# File 'lib/stripe/resources/invoice.rb', line 264 def customer_shipping @customer_shipping end |
#customer_tax_exempt ⇒ Object (readonly)
The customer’s tax exempt status. Until the invoice is finalized, this field will equal ‘customer.tax_exempt`. Once the invoice is finalized, this field will no longer be updated.
266 267 268 |
# File 'lib/stripe/resources/invoice.rb', line 266 def customer_tax_exempt @customer_tax_exempt end |
#customer_tax_ids ⇒ Object (readonly)
The customer’s tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as ‘customer.tax_ids`. Once the invoice is finalized, this field will no longer be updated.
268 269 270 |
# File 'lib/stripe/resources/invoice.rb', line 268 def customer_tax_ids @customer_tax_ids end |
#default_margins ⇒ Object (readonly)
The margins applied to the invoice. Can be overridden by line item ‘margins`. Use `expand[]=default_margins` to expand each margin.
270 271 272 |
# File 'lib/stripe/resources/invoice.rb', line 270 def default_margins @default_margins end |
#default_payment_method ⇒ Object (readonly)
ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription’s default payment method, if any, or to the default payment method in the customer’s invoice settings.
272 273 274 |
# File 'lib/stripe/resources/invoice.rb', line 272 def default_payment_method @default_payment_method end |
#default_source ⇒ Object (readonly)
ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription’s default source, if any, or to the customer’s default source.
274 275 276 |
# File 'lib/stripe/resources/invoice.rb', line 274 def default_source @default_source end |
#default_tax_rates ⇒ Object (readonly)
The tax rates applied to this invoice, if any.
276 277 278 |
# File 'lib/stripe/resources/invoice.rb', line 276 def default_tax_rates @default_tax_rates end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
388 389 390 |
# File 'lib/stripe/resources/invoice.rb', line 388 def deleted @deleted end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard.
278 279 280 |
# File 'lib/stripe/resources/invoice.rb', line 278 def description @description end |
#discount ⇒ Object (readonly)
Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.
280 281 282 |
# File 'lib/stripe/resources/invoice.rb', line 280 def discount @discount end |
#discounts ⇒ Object (readonly)
The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use ‘expand[]=discounts` to expand each discount.
282 283 284 |
# File 'lib/stripe/resources/invoice.rb', line 282 def discounts @discounts end |
#due_date ⇒ Object (readonly)
The date on which payment for this invoice is due. This value will be ‘null` for invoices where `collection_method=charge_automatically`.
284 285 286 |
# File 'lib/stripe/resources/invoice.rb', line 284 def due_date @due_date end |
#effective_at ⇒ Object (readonly)
The date when this invoice is in effect. Same as ‘finalized_at` unless overwritten. When defined, this value replaces the system-generated ’Date of issue’ printed on the invoice PDF and receipt.
286 287 288 |
# File 'lib/stripe/resources/invoice.rb', line 286 def effective_at @effective_at end |
#ending_balance ⇒ Object (readonly)
Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
288 289 290 |
# File 'lib/stripe/resources/invoice.rb', line 288 def ending_balance @ending_balance end |
#footer ⇒ Object (readonly)
Footer displayed on the invoice.
290 291 292 |
# File 'lib/stripe/resources/invoice.rb', line 290 def @footer end |
#from_invoice ⇒ Object (readonly)
Details of the invoice that was cloned. See the [revision documentation](stripe.com/docs/invoicing/invoice-revisions) for more details.
292 293 294 |
# File 'lib/stripe/resources/invoice.rb', line 292 def from_invoice @from_invoice end |
#hosted_invoice_url ⇒ Object (readonly)
The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null.
294 295 296 |
# File 'lib/stripe/resources/invoice.rb', line 294 def hosted_invoice_url @hosted_invoice_url end |
#id ⇒ Object (readonly)
Unique identifier for the object. This property is always present unless the invoice is an upcoming invoice. See [Retrieve an upcoming invoice](stripe.com/docs/api/invoices/upcoming) for more details.
296 297 298 |
# File 'lib/stripe/resources/invoice.rb', line 296 def id @id end |
#invoice_pdf ⇒ Object (readonly)
The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.
298 299 300 |
# File 'lib/stripe/resources/invoice.rb', line 298 def invoice_pdf @invoice_pdf end |
#issuer ⇒ Object (readonly)
Attribute for field issuer
300 301 302 |
# File 'lib/stripe/resources/invoice.rb', line 300 def issuer @issuer end |
#last_finalization_error ⇒ Object (readonly)
The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.
302 303 304 |
# File 'lib/stripe/resources/invoice.rb', line 302 def last_finalization_error @last_finalization_error end |
#latest_revision ⇒ Object (readonly)
The ID of the most recent non-draft revision of this invoice
304 305 306 |
# File 'lib/stripe/resources/invoice.rb', line 304 def latest_revision @latest_revision end |
#lines ⇒ Object (readonly)
The individual line items that make up the invoice. ‘lines` is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order.
306 307 308 |
# File 'lib/stripe/resources/invoice.rb', line 306 def lines @lines end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
308 309 310 |
# File 'lib/stripe/resources/invoice.rb', line 308 def livemode @livemode end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](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.
310 311 312 |
# File 'lib/stripe/resources/invoice.rb', line 310 def @metadata end |
#next_payment_attempt ⇒ Object (readonly)
The time at which payment will next be attempted. This value will be ‘null` for invoices where `collection_method=send_invoice`.
312 313 314 |
# File 'lib/stripe/resources/invoice.rb', line 312 def next_payment_attempt @next_payment_attempt end |
#number ⇒ Object (readonly)
A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer’s unique invoice_prefix if it is specified.
314 315 316 |
# File 'lib/stripe/resources/invoice.rb', line 314 def number @number end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
316 317 318 |
# File 'lib/stripe/resources/invoice.rb', line 316 def object @object end |
#on_behalf_of ⇒ Object (readonly)
The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](stripe.com/docs/billing/invoices/connect) documentation for details.
318 319 320 |
# File 'lib/stripe/resources/invoice.rb', line 318 def on_behalf_of @on_behalf_of end |
#paid ⇒ Object (readonly)
Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer’s account balance.
320 321 322 |
# File 'lib/stripe/resources/invoice.rb', line 320 def paid @paid end |
#paid_out_of_band ⇒ Object (readonly)
Returns true if the invoice was manually marked paid, returns false if the invoice hasn’t been paid yet or was paid on Stripe.
322 323 324 |
# File 'lib/stripe/resources/invoice.rb', line 322 def paid_out_of_band @paid_out_of_band end |
#payment_intent ⇒ Object (readonly)
The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent.
324 325 326 |
# File 'lib/stripe/resources/invoice.rb', line 324 def payment_intent @payment_intent end |
#payment_settings ⇒ Object (readonly)
Attribute for field payment_settings
326 327 328 |
# File 'lib/stripe/resources/invoice.rb', line 326 def payment_settings @payment_settings end |
#payments ⇒ Object (readonly)
Payments for this invoice
328 329 330 |
# File 'lib/stripe/resources/invoice.rb', line 328 def payments @payments end |
#period_end ⇒ Object (readonly)
End of the usage period during which invoice items were added to this invoice. This looks back one period for a subscription invoice. Use the [line item period](/api/invoices/line_item#invoice_line_item_object-period) to get the service period for each price.
330 331 332 |
# File 'lib/stripe/resources/invoice.rb', line 330 def period_end @period_end end |
#period_start ⇒ Object (readonly)
Start of the usage period during which invoice items were added to this invoice. This looks back one period for a subscription invoice. Use the [line item period](/api/invoices/line_item#invoice_line_item_object-period) to get the service period for each price.
332 333 334 |
# File 'lib/stripe/resources/invoice.rb', line 332 def period_start @period_start end |
#post_payment_credit_notes_amount ⇒ Object (readonly)
Total amount of all post-payment credit notes issued for this invoice.
334 335 336 |
# File 'lib/stripe/resources/invoice.rb', line 334 def post_payment_credit_notes_amount @post_payment_credit_notes_amount end |
#pre_payment_credit_notes_amount ⇒ Object (readonly)
Total amount of all pre-payment credit notes issued for this invoice.
336 337 338 |
# File 'lib/stripe/resources/invoice.rb', line 336 def pre_payment_credit_notes_amount @pre_payment_credit_notes_amount end |
#quote ⇒ Object (readonly)
The quote this invoice was generated from.
338 339 340 |
# File 'lib/stripe/resources/invoice.rb', line 338 def quote @quote end |
#receipt_number ⇒ Object (readonly)
This is the transaction number that appears on email receipts sent for this invoice.
340 341 342 |
# File 'lib/stripe/resources/invoice.rb', line 340 def receipt_number @receipt_number end |
#rendering ⇒ Object (readonly)
The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
342 343 344 |
# File 'lib/stripe/resources/invoice.rb', line 342 def rendering @rendering end |
#shipping_cost ⇒ Object (readonly)
The details of the cost of shipping, including the ShippingRate applied on the invoice.
344 345 346 |
# File 'lib/stripe/resources/invoice.rb', line 344 def shipping_cost @shipping_cost end |
#shipping_details ⇒ Object (readonly)
Shipping details for the invoice. The Invoice PDF will use the ‘shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.
346 347 348 |
# File 'lib/stripe/resources/invoice.rb', line 346 def shipping_details @shipping_details end |
#starting_balance ⇒ Object (readonly)
Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. For revision invoices, this also includes any customer balance that was applied to the original invoice.
348 349 350 |
# File 'lib/stripe/resources/invoice.rb', line 348 def starting_balance @starting_balance end |
#statement_descriptor ⇒ Object (readonly)
Extra information about an invoice for the customer’s credit card statement.
350 351 352 |
# File 'lib/stripe/resources/invoice.rb', line 350 def statement_descriptor @statement_descriptor end |
#status ⇒ Object (readonly)
The status of the invoice, one of ‘draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](stripe.com/docs/billing/invoices/workflow#workflow-overview)
352 353 354 |
# File 'lib/stripe/resources/invoice.rb', line 352 def status @status end |
#status_transitions ⇒ Object (readonly)
Attribute for field status_transitions
354 355 356 |
# File 'lib/stripe/resources/invoice.rb', line 354 def status_transitions @status_transitions end |
#subscription ⇒ Object (readonly)
The subscription that this invoice was prepared for, if any.
356 357 358 |
# File 'lib/stripe/resources/invoice.rb', line 356 def subscription @subscription end |
#subscription_details ⇒ Object (readonly)
Details about the subscription that created this invoice.
358 359 360 |
# File 'lib/stripe/resources/invoice.rb', line 358 def subscription_details @subscription_details end |
#subscription_proration_date ⇒ Object (readonly)
Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
360 361 362 |
# File 'lib/stripe/resources/invoice.rb', line 360 def subscription_proration_date @subscription_proration_date end |
#subtotal ⇒ Object (readonly)
Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied. Item discounts are already incorporated
362 363 364 |
# File 'lib/stripe/resources/invoice.rb', line 362 def subtotal @subtotal end |
#subtotal_excluding_tax ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
364 365 366 |
# File 'lib/stripe/resources/invoice.rb', line 364 def subtotal_excluding_tax @subtotal_excluding_tax end |
#tax ⇒ Object (readonly)
The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
366 367 368 |
# File 'lib/stripe/resources/invoice.rb', line 366 def tax @tax end |
#test_clock ⇒ Object (readonly)
ID of the test clock this invoice belongs to.
368 369 370 |
# File 'lib/stripe/resources/invoice.rb', line 368 def test_clock @test_clock end |
#threshold_reason ⇒ Object (readonly)
Attribute for field threshold_reason
370 371 372 |
# File 'lib/stripe/resources/invoice.rb', line 370 def threshold_reason @threshold_reason end |
#total ⇒ Object (readonly)
Total after discounts and taxes.
372 373 374 |
# File 'lib/stripe/resources/invoice.rb', line 372 def total @total end |
#total_discount_amounts ⇒ Object (readonly)
The aggregate amounts calculated per discount across all line items.
374 375 376 |
# File 'lib/stripe/resources/invoice.rb', line 374 def total_discount_amounts @total_discount_amounts end |
#total_excluding_tax ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax.
376 377 378 |
# File 'lib/stripe/resources/invoice.rb', line 376 def total_excluding_tax @total_excluding_tax end |
#total_margin_amounts ⇒ Object (readonly)
The aggregate amounts calculated per margin across all line items.
378 379 380 |
# File 'lib/stripe/resources/invoice.rb', line 378 def total_margin_amounts @total_margin_amounts end |
#total_pretax_credit_amounts ⇒ Object (readonly)
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this invoice. This is a combined list of total_pretax_credit_amounts across all invoice line items.
380 381 382 |
# File 'lib/stripe/resources/invoice.rb', line 380 def total_pretax_credit_amounts @total_pretax_credit_amounts end |
#total_tax_amounts ⇒ Object (readonly)
The aggregate amounts calculated per tax rate for all line items.
382 383 384 |
# File 'lib/stripe/resources/invoice.rb', line 382 def total_tax_amounts @total_tax_amounts end |
#transfer_data ⇒ Object (readonly)
The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
384 385 386 |
# File 'lib/stripe/resources/invoice.rb', line 384 def transfer_data @transfer_data end |
#webhooks_delivered_at ⇒ Object (readonly)
Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have [been exhausted](stripe.com/docs/billing/webhooks#understand). This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
386 387 388 |
# File 'lib/stripe/resources/invoice.rb', line 386 def webhooks_delivered_at @webhooks_delivered_at end |
Class Method Details
.add_lines(invoice, params = {}, opts = {}) ⇒ Object
Adds multiple line items to an invoice. This is only possible when an invoice is still a draft.
401 402 403 404 405 406 407 408 |
# File 'lib/stripe/resources/invoice.rb', line 401 def self.add_lines(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/add_lines", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.attach_payment(invoice, params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent or an Out of Band Payment to the invoice, adding it to the list of payments.
For Out of Band Payment, the payment is credited to the invoice immediately, increasing the amount_paid of the invoice and subsequently transitioning the status of the invoice to paid if necessary.
For the PaymentIntent, when the PaymentIntent’s status changes to succeeded, the payment is credited to the invoice, increasing its amount_paid. When the invoice is fully paid, the invoice’s status becomes paid.
If the PaymentIntent’s status is already succeeded when it’s attached, it’s credited to the invoice immediately.
See: [Create an invoice payment](stripe.com/docs/invoicing/payments/create) to learn more.
445 446 447 448 449 450 451 452 |
# File 'lib/stripe/resources/invoice.rb', line 445 def self.attach_payment(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/attach_payment", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.attach_payment_intent(invoice, params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent to the invoice, adding it to the list of payments. When the PaymentIntent’s status changes to succeeded, the payment is credited to the invoice, increasing its amount_paid. When the invoice is fully paid, the invoice’s status becomes paid.
If the PaymentIntent’s status is already succeeded when it is attached, it is credited to the invoice immediately.
Related guide: [Create an invoice payment](stripe.com/docs/invoicing/payments/create)
481 482 483 484 485 486 487 488 |
# File 'lib/stripe/resources/invoice.rb', line 481 def self.attach_payment_intent(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/attach_payment_intent", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
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](stripe.com/docs/api#finalize_invoice) the invoice to your customers.
491 492 493 |
# File 'lib/stripe/resources/invoice.rb', line 491 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/invoices", params: params, opts: opts) end |
.create_preview(params = {}, opts = {}) ⇒ Object
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.
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.
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 is equal to the subscription_details.proration_date value passed in the request.
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](docs.stripe.com/currencies/conversions)
502 503 504 505 506 507 508 509 |
# File 'lib/stripe/resources/invoice.rb', line 502 def self.create_preview(params = {}, opts = {}) request_stripe_object( method: :post, path: "/v1/invoices/create_preview", params: params, opts: opts ) end |
.delete(id, params = {}, opts = {}) ⇒ Object
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](stripe.com/docs/api#void_invoice).
512 513 514 515 516 517 518 519 |
# File 'lib/stripe/resources/invoice.rb', line 512 def self.delete(id, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/invoices/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.finalize_invoice(invoice, params = {}, opts = {}) ⇒ Object
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.
542 543 544 545 546 547 548 549 |
# File 'lib/stripe/resources/invoice.rb', line 542 def self.finalize_invoice(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/finalize", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.list(filters = {}, opts = {}) ⇒ Object
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.
552 553 554 |
# File 'lib/stripe/resources/invoice.rb', line 552 def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoices", params: filters, opts: opts) end |
.list_upcoming_line_items(params = {}, opts = {}) ⇒ Object
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.
557 558 559 560 561 562 563 564 |
# File 'lib/stripe/resources/invoice.rb', line 557 def self.list_upcoming_line_items(params = {}, opts = {}) request_stripe_object( method: :get, path: "/v1/invoices/upcoming/lines", params: params, opts: opts ) end |
.mark_uncollectible(invoice, params = {}, opts = {}) ⇒ Object
Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
577 578 579 580 581 582 583 584 |
# File 'lib/stripe/resources/invoice.rb', line 577 def self.mark_uncollectible(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/mark_uncollectible", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.object_name ⇒ Object
46 47 48 |
# File 'lib/stripe/resources/invoice.rb', line 46 def self.object_name "invoice" end |
.pay(invoice, params = {}, opts = {}) ⇒ Object
Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](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.
597 598 599 600 601 602 603 604 |
# File 'lib/stripe/resources/invoice.rb', line 597 def self.pay(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/pay", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.remove_lines(invoice, params = {}, opts = {}) ⇒ Object
Removes multiple line items from an invoice. This is only possible when an invoice is still a draft.
617 618 619 620 621 622 623 624 |
# File 'lib/stripe/resources/invoice.rb', line 617 def self.remove_lines(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/remove_lines", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.search(params = {}, opts = {}) ⇒ Object
626 627 628 |
# File 'lib/stripe/resources/invoice.rb', line 626 def self.search(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoices/search", params: params, opts: opts) end |
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
630 631 632 |
# File 'lib/stripe/resources/invoice.rb', line 630 def self.search_auto_paging_each(params = {}, opts = {}, &blk) search(params, opts).auto_paging_each(&blk) end |
.send_invoice(invoice, params = {}, opts = {}) ⇒ Object
Stripe will automatically send invoices to customers according to your [subscriptions settings](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.
Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.
649 650 651 652 653 654 655 656 |
# File 'lib/stripe/resources/invoice.rb', line 649 def self.send_invoice(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/send", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.upcoming(params = {}, opts = {}) ⇒ Object
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.
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.
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 is equal to the subscription_details.proration_date value passed in the request.
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](docs.stripe.com/currencies/conversions)
665 666 667 |
# File 'lib/stripe/resources/invoice.rb', line 665 def self.upcoming(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoices/upcoming", params: params, opts: opts) end |
.update(id, params = {}, opts = {}) ⇒ Object
Draft invoices are fully editable. Once an invoice is [finalized](stripe.com/docs/billing/invoices/workflow#finalized), monetary values, as well as collection_method, become uneditable.
If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, sending reminders for, or [automatically reconciling](stripe.com/docs/billing/invoices/reconciliation) invoices, pass auto_advance=false.
675 676 677 678 679 680 681 682 |
# File 'lib/stripe/resources/invoice.rb', line 675 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.update_lines(invoice, params = {}, opts = {}) ⇒ Object
Updates multiple line items on an invoice. This is only possible when an invoice is still a draft.
695 696 697 698 699 700 701 702 |
# File 'lib/stripe/resources/invoice.rb', line 695 def self.update_lines(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/update_lines", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
.void_invoice(invoice, params = {}, opts = {}) ⇒ Object
Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.
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](stripe.com/docs/api#create_invoice) instead. Stripe recommends that you consult with your legal counsel for advice specific to your business.
719 720 721 722 723 724 725 726 |
# File 'lib/stripe/resources/invoice.rb', line 719 def self.void_invoice(invoice, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/void", { invoice: CGI.escape(invoice) }), params: params, opts: opts ) end |
Instance Method Details
#add_lines(params = {}, opts = {}) ⇒ Object
Adds multiple line items to an invoice. This is only possible when an invoice is still a draft.
391 392 393 394 395 396 397 398 |
# File 'lib/stripe/resources/invoice.rb', line 391 def add_lines(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/add_lines", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#attach_payment(params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent or an Out of Band Payment to the invoice, adding it to the list of payments.
For Out of Band Payment, the payment is credited to the invoice immediately, increasing the amount_paid of the invoice and subsequently transitioning the status of the invoice to paid if necessary.
For the PaymentIntent, when the PaymentIntent’s status changes to succeeded, the payment is credited to the invoice, increasing its amount_paid. When the invoice is fully paid, the invoice’s status becomes paid.
If the PaymentIntent’s status is already succeeded when it’s attached, it’s credited to the invoice immediately.
See: [Create an invoice payment](stripe.com/docs/invoicing/payments/create) to learn more.
423 424 425 426 427 428 429 430 |
# File 'lib/stripe/resources/invoice.rb', line 423 def attach_payment(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/attach_payment", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#attach_payment_intent(params = {}, opts = {}) ⇒ Object
Attaches a PaymentIntent to the invoice, adding it to the list of payments. When the PaymentIntent’s status changes to succeeded, the payment is credited to the invoice, increasing its amount_paid. When the invoice is fully paid, the invoice’s status becomes paid.
If the PaymentIntent’s status is already succeeded when it is attached, it is credited to the invoice immediately.
Related guide: [Create an invoice payment](stripe.com/docs/invoicing/payments/create)
463 464 465 466 467 468 469 470 |
# File 'lib/stripe/resources/invoice.rb', line 463 def attach_payment_intent(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/attach_payment_intent", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#delete(params = {}, opts = {}) ⇒ Object
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](stripe.com/docs/api#void_invoice).
522 523 524 525 526 527 528 529 |
# File 'lib/stripe/resources/invoice.rb', line 522 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/invoices/%<invoice>s", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#finalize_invoice(params = {}, opts = {}) ⇒ Object
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.
532 533 534 535 536 537 538 539 |
# File 'lib/stripe/resources/invoice.rb', line 532 def finalize_invoice(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/finalize", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#mark_uncollectible(params = {}, opts = {}) ⇒ Object
Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
567 568 569 570 571 572 573 574 |
# File 'lib/stripe/resources/invoice.rb', line 567 def mark_uncollectible(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/mark_uncollectible", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#pay(params = {}, opts = {}) ⇒ Object
Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](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.
587 588 589 590 591 592 593 594 |
# File 'lib/stripe/resources/invoice.rb', line 587 def pay(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/pay", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#remove_lines(params = {}, opts = {}) ⇒ Object
Removes multiple line items from an invoice. This is only possible when an invoice is still a draft.
607 608 609 610 611 612 613 614 |
# File 'lib/stripe/resources/invoice.rb', line 607 def remove_lines(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/remove_lines", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#send_invoice(params = {}, opts = {}) ⇒ Object
Stripe will automatically send invoices to customers according to your [subscriptions settings](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.
Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.
637 638 639 640 641 642 643 644 |
# File 'lib/stripe/resources/invoice.rb', line 637 def send_invoice(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/send", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#update_lines(params = {}, opts = {}) ⇒ Object
Updates multiple line items on an invoice. This is only possible when an invoice is still a draft.
685 686 687 688 689 690 691 692 |
# File 'lib/stripe/resources/invoice.rb', line 685 def update_lines(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/update_lines", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#void_invoice(params = {}, opts = {}) ⇒ Object
Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.
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](stripe.com/docs/api#create_invoice) instead. Stripe recommends that you consult with your legal counsel for advice specific to your business.
707 708 709 710 711 712 713 714 |
# File 'lib/stripe/resources/invoice.rb', line 707 def void_invoice(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoices/%<invoice>s/void", { invoice: CGI.escape(self["id"]) }), params: params, opts: opts ) end |