Create an invoice
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 or send the invoice to your customers.
Parameters
- auto_
advanceboolean Controls whether Stripe performs automatic collection of the invoice. If
false
, the invoice’s state doesn’t automatically advance without an explicit action. - collection_
methodenum Either
charge_automatically
, orsend_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. Defaults tocharge_automatically
. - customerstring
The ID of the customer who will be billed.
- descriptionstring
An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard.
- metadataobject
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata
. - subscriptionstring
The ID of the subscription to invoice, if any. If set, the created invoice will only include pending invoice items for that subscription. The subscription’s billing cycle and regular subscription events won’t be affected.
More parameters
- account_
tax_ idsarray of strings - application_
fee_ amountintegerConnect only - automatic_
taxobject - currencyenum
- custom_
fieldsarray of objects - days_
until_ dueinteger - default_
payment_ methodstring - default_
sourcestring - default_
tax_ ratesarray of strings - discountsarray of objects
- due_
datetimestamp - effective_
attimestamp - footerstring
- from_
invoiceobject - issuerobjectConnect only
- numberstring
- on_
behalf_ ofstringConnect only - payment_
settingsobject - pending_
invoice_ items_ behaviorenum - renderingobject
- shipping_
costobject - shipping_
detailsobject - statement_
descriptorstring - transfer_
dataobjectConnect only
Returns
Returns the invoice object. Raises an error if the customer ID provided is invalid.
Update an invoice
Draft invoices are fully editable. Once an invoice is 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 invoices, pass auto_advance=false
.
Parameters
- auto_
advanceboolean Controls whether Stripe performs automatic collection of the invoice.
- collection_
methodenum Either
charge_automatically
orsend_invoice
. This field can be updated only ondraft
invoices. - descriptionstring
An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard.
- metadataobject
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata
.
More parameters
- account_
tax_ idsarray of strings - application_
fee_ amountintegerConnect only - automatic_
taxobject - custom_
fieldsarray of objects - days_
until_ dueinteger - default_
payment_ methodstring - default_
sourcestring - default_
tax_ ratesarray of strings - discountsarray of objects
- due_
datetimestamp - effective_
attimestamp - footerstring
- issuerobjectConnect only
- numberstring
- on_
behalf_ ofstringConnect only - payment_
settingsobject - renderingobject
- shipping_
costobject - shipping_
detailsobject - statement_
descriptorstring - transfer_
dataobjectConnect only
Returns
Returns the invoice object.
Update an invoice's line item
Updates an invoice’s line item. Some fields, such as tax_amounts
, only live on the invoice line item, so they can only be updated through this endpoint. Other fields, such as amount
, live on both the invoice item and the invoice line item, so updates on this endpoint will propagate to the invoice item as well. Updating an invoice’s line item is only possible before the invoice is finalized.
Parameters
- invoicestringRequired
Invoice ID of line item
- line_
item_ idstringRequired Invoice line item ID
- amountinteger
The integer amount in cents of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer’s account, pass a negative amount.
- descriptionstring
An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.
- metadataobject
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata
. - periodobject
The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have Stripe Revenue Recognition enabled, the period will be used to recognize and defer revenue. See the Revenue Recognition documentation for details.
- pricestring
The ID of the price object.
- quantityinteger
Non-negative integer. The quantity of units for the line item.
More parameters
- discountableboolean
- discountsarray of objects
- price_
dataobject - tax_
amountsarray of objects - tax_
ratesarray of strings
Returns
The updated invoice’s line item object is returned upon success. Otherwise, this call raises an error.
Retrieve an invoice
Retrieves the invoice with the given ID.
Parameters
No parameters.
Returns
Returns an invoice object if a valid invoice ID was provided. Raises an error otherwise.
The invoice object contains a lines
hash that contains information about the subscriptions and invoice items that have been applied to the invoice, as well as any prorations that Stripe has automatically calculated. Each line on the invoice has an amount
attribute that represents the amount actually contributed to the invoice’s total. For invoice items and prorations, the amount attribute is the same as for the invoice item or proration respectively. For subscriptions, the amount may be different from the plan’s regular price depending on whether the invoice covers a trial period or the invoice period differs from the plan’s usual interval.
The invoice object has both a subtotal
and a total
. The subtotal represents the total before any discounts, while the total is the final amount to be charged to the customer after all coupons have been applied.
The invoice also has a next_payment_attempt
attribute that tells you the next time (as a Unix timestamp) payment for the invoice will be automatically attempted. For invoices with manual payment collection, that have been closed, or that have reached the maximum number of retries (specified in your subscriptions settings), the next_payment_attempt
will be null.
Retrieve an upcoming invoice
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 a proration_date
parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date
returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start]
is equal to the subscription_proration_date
on the upcoming invoice resource.
Parameters
- customerstring
The identifier of the customer whose upcoming invoice you’d like to retrieve. If
automatic_tax
is enabled then one ofcustomer
,customer_details
,subscription
, orschedule
must be set. - subscriptionstring
The identifier of the subscription for which you’d like to retrieve the upcoming invoice. If not provided, but a
subscription_items
is provided, you will preview creating a subscription with those items. If neithersubscription
norsubscription_items
is provided, you will retrieve the next upcoming invoice from among the customer’s subscriptions.
More parameters
- automatic_
taxobject - couponstring
- currencyenum
- customer_
detailsobject - discountsarray of objects
- invoice_
itemsarray of objects - issuerobjectConnect only
- on_
behalf_ ofstringConnect only - schedulestring
- subscription_
billing_ cycle_ anchorstring | timestamp - subscription_
cancel_ attimestamp - subscription_
cancel_ at_ period_ endboolean - subscription_
cancel_ nowboolean - subscription_
default_ tax_ ratesarray of strings - subscription_
itemsarray of objects - subscription_
proration_ behaviorenum - subscription_
proration_ datetimestamp - subscription_
resume_ atstring - subscription_
start_ datetimestamp - subscription_
trial_ endstring | timestamp - subscription_
trial_ from_ planboolean
Returns
Returns an invoice if valid customer information is provided. Raises an error otherwise.