Class: Stripe::Invoice

Inherits:
APIResource show all
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: AddLinesParams, AmountsDue, AttachPaymentIntentParams, AttachPaymentParams, AutomaticTax, CreateParams, CreatePreviewParams, CustomField, CustomerAddress, CustomerShipping, CustomerTaxId, DeleteParams, FinalizeInvoiceParams, FromInvoice, Issuer, LastFinalizationError, ListParams, ListUpcomingLineItemsParams, MarkUncollectibleParams, PayParams, PaymentSettings, RemoveLinesParams, Rendering, RetrieveParams, SearchParams, SendInvoiceParams, ShippingCost, ShippingDetails, StatusTransitions, SubscriptionDetails, ThresholdReason, TotalDiscountAmount, TotalMarginAmount, TotalPretaxCreditAmount, TotalTaxAmount, TransferData, UpcomingParams, UpdateLinesParams, UpdateParams, VoidInvoiceParams

Constant Summary collapse

OBJECT_NAME =
"invoice"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::NestedResource

nested_resource_class_methods

Methods included from APIOperations::Search

_search

Methods included from APIOperations::Save

included, #save

Methods included from APIOperations::Delete

included

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

included

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_countryObject (readonly)

The country of the business associated with this invoice, most often the business creating the invoice.



9043
9044
9045
# File 'lib/stripe/resources/invoice.rb', line 9043

def 
  @account_country
end

#account_nameObject (readonly)

The public name of the business associated with this invoice, most often the business creating the invoice.



9046
9047
9048
# File 'lib/stripe/resources/invoice.rb', line 9046

def 
  @account_name
end

#account_tax_idsObject (readonly)

The account tax IDs associated with the invoice. Only editable when the invoice is a draft.



9049
9050
9051
# File 'lib/stripe/resources/invoice.rb', line 9049

def 
  @account_tax_ids
end

#amount_dueObject (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`.



9052
9053
9054
# File 'lib/stripe/resources/invoice.rb', line 9052

def amount_due
  @amount_due
end

#amount_overpaidObject (readonly)

Amount that was overpaid on the invoice. Overpayments are debited to the customer’s credit balance.



9055
9056
9057
# File 'lib/stripe/resources/invoice.rb', line 9055

def amount_overpaid
  @amount_overpaid
end

#amount_paidObject (readonly)

The amount, in cents (or local equivalent), that was paid.



9058
9059
9060
# File 'lib/stripe/resources/invoice.rb', line 9058

def amount_paid
  @amount_paid
end

#amount_remainingObject (readonly)

The difference between amount_due and amount_paid, in cents (or local equivalent).



9061
9062
9063
# File 'lib/stripe/resources/invoice.rb', line 9061

def amount_remaining
  @amount_remaining
end

#amount_shippingObject (readonly)

This is the sum of all the shipping amounts.



9064
9065
9066
# File 'lib/stripe/resources/invoice.rb', line 9064

def amount_shipping
  @amount_shipping
end

#amounts_dueObject (readonly)

List of expected payments and corresponding due dates. This value will be null for invoices where collection_method=charge_automatically.



9067
9068
9069
# File 'lib/stripe/resources/invoice.rb', line 9067

def amounts_due
  @amounts_due
end

#applicationObject (readonly)

ID of the Connect Application that created the invoice.



9070
9071
9072
# File 'lib/stripe/resources/invoice.rb', line 9070

def application
  @application
end

#application_fee_amountObject (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.



9073
9074
9075
# File 'lib/stripe/resources/invoice.rb', line 9073

def application_fee_amount
  @application_fee_amount
end

#attempt_countObject (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.



9076
9077
9078
# File 'lib/stripe/resources/invoice.rb', line 9076

def attempt_count
  @attempt_count
end

#attemptedObject (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.



9079
9080
9081
# File 'lib/stripe/resources/invoice.rb', line 9079

def attempted
  @attempted
end

#auto_advanceObject (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.



9082
9083
9084
# File 'lib/stripe/resources/invoice.rb', line 9082

def auto_advance
  @auto_advance
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



9085
9086
9087
# File 'lib/stripe/resources/invoice.rb', line 9085

def automatic_tax
  @automatic_tax
end

#automatically_finalizes_atObject (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.



9088
9089
9090
# File 'lib/stripe/resources/invoice.rb', line 9088

def automatically_finalizes_at
  @automatically_finalizes_at
end

#billing_reasonObject (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.



9099
9100
9101
# File 'lib/stripe/resources/invoice.rb', line 9099

def billing_reason
  @billing_reason
end

#chargeObject (readonly)

ID of the latest charge generated for this invoice, if any.



9102
9103
9104
# File 'lib/stripe/resources/invoice.rb', line 9102

def charge
  @charge
end

#collection_methodObject (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.



9105
9106
9107
# File 'lib/stripe/resources/invoice.rb', line 9105

def collection_method
  @collection_method
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



9108
9109
9110
# File 'lib/stripe/resources/invoice.rb', line 9108

def created
  @created
end

#currencyObject (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).



9111
9112
9113
# File 'lib/stripe/resources/invoice.rb', line 9111

def currency
  @currency
end

#custom_fieldsObject (readonly)

Custom fields displayed on the invoice.



9114
9115
9116
# File 'lib/stripe/resources/invoice.rb', line 9114

def custom_fields
  @custom_fields
end

#customerObject (readonly)

The ID of the customer who will be billed.



9117
9118
9119
# File 'lib/stripe/resources/invoice.rb', line 9117

def customer
  @customer
end

#customer_addressObject (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.



9120
9121
9122
# File 'lib/stripe/resources/invoice.rb', line 9120

def customer_address
  @customer_address
end

#customer_emailObject (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.



9123
9124
9125
# File 'lib/stripe/resources/invoice.rb', line 9123

def customer_email
  @customer_email
end

#customer_nameObject (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.



9126
9127
9128
# File 'lib/stripe/resources/invoice.rb', line 9126

def customer_name
  @customer_name
end

#customer_phoneObject (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.



9129
9130
9131
# File 'lib/stripe/resources/invoice.rb', line 9129

def customer_phone
  @customer_phone
end

#customer_shippingObject (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.



9132
9133
9134
# File 'lib/stripe/resources/invoice.rb', line 9132

def customer_shipping
  @customer_shipping
end

#customer_tax_exemptObject (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.



9135
9136
9137
# File 'lib/stripe/resources/invoice.rb', line 9135

def customer_tax_exempt
  @customer_tax_exempt
end

#customer_tax_idsObject (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.



9138
9139
9140
# File 'lib/stripe/resources/invoice.rb', line 9138

def customer_tax_ids
  @customer_tax_ids
end

#default_marginsObject (readonly)

The margins applied to the invoice. Can be overridden by line item ‘margins`. Use `expand[]=default_margins` to expand each margin.



9141
9142
9143
# File 'lib/stripe/resources/invoice.rb', line 9141

def default_margins
  @default_margins
end

#default_payment_methodObject (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.



9144
9145
9146
# File 'lib/stripe/resources/invoice.rb', line 9144

def default_payment_method
  @default_payment_method
end

#default_sourceObject (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.



9147
9148
9149
# File 'lib/stripe/resources/invoice.rb', line 9147

def default_source
  @default_source
end

#default_tax_ratesObject (readonly)

The tax rates applied to this invoice, if any.



9150
9151
9152
# File 'lib/stripe/resources/invoice.rb', line 9150

def default_tax_rates
  @default_tax_rates
end

#deletedObject (readonly)

Always true for a deleted object



9318
9319
9320
# File 'lib/stripe/resources/invoice.rb', line 9318

def deleted
  @deleted
end

#descriptionObject (readonly)

An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard.



9153
9154
9155
# File 'lib/stripe/resources/invoice.rb', line 9153

def description
  @description
end

#discountObject (readonly)

Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.



9156
9157
9158
# File 'lib/stripe/resources/invoice.rb', line 9156

def discount
  @discount
end

#discountsObject (readonly)

The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use ‘expand[]=discounts` to expand each discount.



9159
9160
9161
# File 'lib/stripe/resources/invoice.rb', line 9159

def discounts
  @discounts
end

#due_dateObject (readonly)

The date on which payment for this invoice is due. This value will be ‘null` for invoices where `collection_method=charge_automatically`.



9162
9163
9164
# File 'lib/stripe/resources/invoice.rb', line 9162

def due_date
  @due_date
end

#effective_atObject (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.



9165
9166
9167
# File 'lib/stripe/resources/invoice.rb', line 9165

def effective_at
  @effective_at
end

#ending_balanceObject (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.



9168
9169
9170
# File 'lib/stripe/resources/invoice.rb', line 9168

def ending_balance
  @ending_balance
end

Footer displayed on the invoice.



9171
9172
9173
# File 'lib/stripe/resources/invoice.rb', line 9171

def footer
  @footer
end

#from_invoiceObject (readonly)

Details of the invoice that was cloned. See the [revision documentation](stripe.com/docs/invoicing/invoice-revisions) for more details.



9174
9175
9176
# File 'lib/stripe/resources/invoice.rb', line 9174

def from_invoice
  @from_invoice
end

#hosted_invoice_urlObject (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.



9177
9178
9179
# File 'lib/stripe/resources/invoice.rb', line 9177

def hosted_invoice_url
  @hosted_invoice_url
end

#idObject (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.



9180
9181
9182
# File 'lib/stripe/resources/invoice.rb', line 9180

def id
  @id
end

#invoice_pdfObject (readonly)

The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.



9183
9184
9185
# File 'lib/stripe/resources/invoice.rb', line 9183

def invoice_pdf
  @invoice_pdf
end

#issuerObject (readonly)

Attribute for field issuer



9186
9187
9188
# File 'lib/stripe/resources/invoice.rb', line 9186

def issuer
  @issuer
end

#last_finalization_errorObject (readonly)

The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.



9189
9190
9191
# File 'lib/stripe/resources/invoice.rb', line 9189

def last_finalization_error
  @last_finalization_error
end

#latest_revisionObject (readonly)

The ID of the most recent non-draft revision of this invoice



9192
9193
9194
# File 'lib/stripe/resources/invoice.rb', line 9192

def latest_revision
  @latest_revision
end

#linesObject (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.



9195
9196
9197
# File 'lib/stripe/resources/invoice.rb', line 9195

def lines
  @lines
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



9198
9199
9200
# File 'lib/stripe/resources/invoice.rb', line 9198

def livemode
  @livemode
end

#metadataObject (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.



9201
9202
9203
# File 'lib/stripe/resources/invoice.rb', line 9201

def 
  @metadata
end

#next_payment_attemptObject (readonly)

The time at which payment will next be attempted. This value will be ‘null` for invoices where `collection_method=send_invoice`.



9204
9205
9206
# File 'lib/stripe/resources/invoice.rb', line 9204

def next_payment_attempt
  @next_payment_attempt
end

#numberObject (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.



9207
9208
9209
# File 'lib/stripe/resources/invoice.rb', line 9207

def number
  @number
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



9210
9211
9212
# File 'lib/stripe/resources/invoice.rb', line 9210

def object
  @object
end

#on_behalf_ofObject (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.



9213
9214
9215
# File 'lib/stripe/resources/invoice.rb', line 9213

def on_behalf_of
  @on_behalf_of
end

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.



9216
9217
9218
# File 'lib/stripe/resources/invoice.rb', line 9216

def paid
  @paid
end

Returns true if the invoice was manually marked paid, returns false if the invoice hasn’t been paid yet or was paid on Stripe.



9219
9220
9221
# File 'lib/stripe/resources/invoice.rb', line 9219

def paid_out_of_band
  @paid_out_of_band
end

#payment_intentObject (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.



9222
9223
9224
# File 'lib/stripe/resources/invoice.rb', line 9222

def payment_intent
  @payment_intent
end

#payment_settingsObject (readonly)

Attribute for field payment_settings



9225
9226
9227
# File 'lib/stripe/resources/invoice.rb', line 9225

def payment_settings
  @payment_settings
end

#paymentsObject (readonly)

Payments for this invoice



9228
9229
9230
# File 'lib/stripe/resources/invoice.rb', line 9228

def payments
  @payments
end

#period_endObject (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.



9231
9232
9233
# File 'lib/stripe/resources/invoice.rb', line 9231

def period_end
  @period_end
end

#period_startObject (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.



9234
9235
9236
# File 'lib/stripe/resources/invoice.rb', line 9234

def period_start
  @period_start
end

#post_payment_credit_notes_amountObject (readonly)

Total amount of all post-payment credit notes issued for this invoice.



9237
9238
9239
# File 'lib/stripe/resources/invoice.rb', line 9237

def post_payment_credit_notes_amount
  @post_payment_credit_notes_amount
end

#pre_payment_credit_notes_amountObject (readonly)

Total amount of all pre-payment credit notes issued for this invoice.



9240
9241
9242
# File 'lib/stripe/resources/invoice.rb', line 9240

def pre_payment_credit_notes_amount
  @pre_payment_credit_notes_amount
end

#quoteObject (readonly)

The quote this invoice was generated from.



9243
9244
9245
# File 'lib/stripe/resources/invoice.rb', line 9243

def quote
  @quote
end

#receipt_numberObject (readonly)

This is the transaction number that appears on email receipts sent for this invoice.



9246
9247
9248
# File 'lib/stripe/resources/invoice.rb', line 9246

def receipt_number
  @receipt_number
end

#renderingObject (readonly)

The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.



9249
9250
9251
# File 'lib/stripe/resources/invoice.rb', line 9249

def rendering
  @rendering
end

#shipping_costObject (readonly)

The details of the cost of shipping, including the ShippingRate applied on the invoice.



9252
9253
9254
# File 'lib/stripe/resources/invoice.rb', line 9252

def shipping_cost
  @shipping_cost
end

#shipping_detailsObject (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.



9255
9256
9257
# File 'lib/stripe/resources/invoice.rb', line 9255

def shipping_details
  @shipping_details
end

#starting_balanceObject (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.



9258
9259
9260
# File 'lib/stripe/resources/invoice.rb', line 9258

def starting_balance
  @starting_balance
end

#statement_descriptorObject (readonly)

Extra information about an invoice for the customer’s credit card statement.



9261
9262
9263
# File 'lib/stripe/resources/invoice.rb', line 9261

def statement_descriptor
  @statement_descriptor
end

#statusObject (readonly)

The status of the invoice, one of ‘draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](stripe.com/docs/billing/invoices/workflow#workflow-overview)



9264
9265
9266
# File 'lib/stripe/resources/invoice.rb', line 9264

def status
  @status
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



9267
9268
9269
# File 'lib/stripe/resources/invoice.rb', line 9267

def status_transitions
  @status_transitions
end

#subscriptionObject (readonly)

The subscription that this invoice was prepared for, if any.



9270
9271
9272
# File 'lib/stripe/resources/invoice.rb', line 9270

def subscription
  @subscription
end

#subscription_detailsObject (readonly)

Details about the subscription that created this invoice.



9273
9274
9275
# File 'lib/stripe/resources/invoice.rb', line 9273

def subscription_details
  @subscription_details
end

#subscription_proration_dateObject (readonly)

Only set for upcoming invoices that preview prorations. The time used to calculate prorations.



9276
9277
9278
# File 'lib/stripe/resources/invoice.rb', line 9276

def subscription_proration_date
  @subscription_proration_date
end

#subtotalObject (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



9279
9280
9281
# File 'lib/stripe/resources/invoice.rb', line 9279

def subtotal
  @subtotal
end

#subtotal_excluding_taxObject (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



9282
9283
9284
# File 'lib/stripe/resources/invoice.rb', line 9282

def subtotal_excluding_tax
  @subtotal_excluding_tax
end

#taxObject (readonly)

The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.



9285
9286
9287
# File 'lib/stripe/resources/invoice.rb', line 9285

def tax
  @tax
end

#test_clockObject (readonly)

ID of the test clock this invoice belongs to.



9288
9289
9290
# File 'lib/stripe/resources/invoice.rb', line 9288

def test_clock
  @test_clock
end

#threshold_reasonObject (readonly)

Attribute for field threshold_reason



9291
9292
9293
# File 'lib/stripe/resources/invoice.rb', line 9291

def threshold_reason
  @threshold_reason
end

#totalObject (readonly)

Total after discounts and taxes.



9294
9295
9296
# File 'lib/stripe/resources/invoice.rb', line 9294

def total
  @total
end

#total_discount_amountsObject (readonly)

The aggregate amounts calculated per discount across all line items.



9297
9298
9299
# File 'lib/stripe/resources/invoice.rb', line 9297

def total_discount_amounts
  @total_discount_amounts
end

#total_excluding_taxObject (readonly)

The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax.



9300
9301
9302
# File 'lib/stripe/resources/invoice.rb', line 9300

def total_excluding_tax
  @total_excluding_tax
end

#total_margin_amountsObject (readonly)

The aggregate amounts calculated per margin across all line items.



9303
9304
9305
# File 'lib/stripe/resources/invoice.rb', line 9303

def total_margin_amounts
  @total_margin_amounts
end

#total_pretax_credit_amountsObject (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.



9306
9307
9308
# File 'lib/stripe/resources/invoice.rb', line 9306

def total_pretax_credit_amounts
  @total_pretax_credit_amounts
end

#total_tax_amountsObject (readonly)

The aggregate amounts calculated per tax rate for all line items.



9309
9310
9311
# File 'lib/stripe/resources/invoice.rb', line 9309

def total_tax_amounts
  @total_tax_amounts
end

#transfer_dataObject (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.



9312
9313
9314
# File 'lib/stripe/resources/invoice.rb', line 9312

def transfer_data
  @transfer_data
end

#webhooks_delivered_atObject (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.



9315
9316
9317
# File 'lib/stripe/resources/invoice.rb', line 9315

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.



9331
9332
9333
9334
9335
9336
9337
9338
# File 'lib/stripe/resources/invoice.rb', line 9331

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.



9375
9376
9377
9378
9379
9380
9381
9382
# File 'lib/stripe/resources/invoice.rb', line 9375

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)



9411
9412
9413
9414
9415
9416
9417
9418
# File 'lib/stripe/resources/invoice.rb', line 9411

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.



9421
9422
9423
# File 'lib/stripe/resources/invoice.rb', line 9421

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)



9432
9433
9434
9435
9436
9437
9438
9439
# File 'lib/stripe/resources/invoice.rb', line 9432

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).



9442
9443
9444
9445
9446
9447
9448
9449
# File 'lib/stripe/resources/invoice.rb', line 9442

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.



9472
9473
9474
9475
9476
9477
9478
9479
# File 'lib/stripe/resources/invoice.rb', line 9472

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(params = {}, 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.



9482
9483
9484
# File 'lib/stripe/resources/invoice.rb', line 9482

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/invoices", params: params, 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.



9487
9488
9489
9490
9491
9492
9493
9494
# File 'lib/stripe/resources/invoice.rb', line 9487

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.



9507
9508
9509
9510
9511
9512
9513
9514
# File 'lib/stripe/resources/invoice.rb', line 9507

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_nameObject



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.



9527
9528
9529
9530
9531
9532
9533
9534
# File 'lib/stripe/resources/invoice.rb', line 9527

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.



9547
9548
9549
9550
9551
9552
9553
9554
# File 'lib/stripe/resources/invoice.rb', line 9547

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



9556
9557
9558
# File 'lib/stripe/resources/invoice.rb', line 9556

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



9560
9561
9562
# File 'lib/stripe/resources/invoice.rb', line 9560

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.



9579
9580
9581
9582
9583
9584
9585
9586
# File 'lib/stripe/resources/invoice.rb', line 9579

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)



9595
9596
9597
# File 'lib/stripe/resources/invoice.rb', line 9595

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.



9605
9606
9607
9608
9609
9610
9611
9612
# File 'lib/stripe/resources/invoice.rb', line 9605

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.



9625
9626
9627
9628
9629
9630
9631
9632
# File 'lib/stripe/resources/invoice.rb', line 9625

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.



9649
9650
9651
9652
9653
9654
9655
9656
# File 'lib/stripe/resources/invoice.rb', line 9649

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.



9321
9322
9323
9324
9325
9326
9327
9328
# File 'lib/stripe/resources/invoice.rb', line 9321

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.



9353
9354
9355
9356
9357
9358
9359
9360
# File 'lib/stripe/resources/invoice.rb', line 9353

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)



9393
9394
9395
9396
9397
9398
9399
9400
# File 'lib/stripe/resources/invoice.rb', line 9393

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).



9452
9453
9454
9455
9456
9457
9458
9459
# File 'lib/stripe/resources/invoice.rb', line 9452

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.



9462
9463
9464
9465
9466
9467
9468
9469
# File 'lib/stripe/resources/invoice.rb', line 9462

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.



9497
9498
9499
9500
9501
9502
9503
9504
# File 'lib/stripe/resources/invoice.rb', line 9497

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.



9517
9518
9519
9520
9521
9522
9523
9524
# File 'lib/stripe/resources/invoice.rb', line 9517

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.



9537
9538
9539
9540
9541
9542
9543
9544
# File 'lib/stripe/resources/invoice.rb', line 9537

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.



9567
9568
9569
9570
9571
9572
9573
9574
# File 'lib/stripe/resources/invoice.rb', line 9567

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.



9615
9616
9617
9618
9619
9620
9621
9622
# File 'lib/stripe/resources/invoice.rb', line 9615

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.



9637
9638
9639
9640
9641
9642
9643
9644
# File 'lib/stripe/resources/invoice.rb', line 9637

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