New subscription invoices

When you subscribe a customer to a plan, the API call immediately:

Creates an invoice

Finalizes the invoice

Attempts to pay the invoice, updating the invoice status to paid if successful

If the payment succeeds on a subscription’s first invoice, or if no payment is required, the invoice is marked as status=paid, and the subscription is created.
If the payment fails, the subscription attempt fails as well, and no invoice or subscription is created.

Any API call that results in a new subscription, such as upgrading or downgrading the plan, also creates a new invoice that is set to auto_advance=false from the outset.

With a finalized invoice, you cannot add invoice items or make other modifications that affect the amount due.
(However, you can still add invoice items to the customer, and these will apply to the next invoice.)

Subscription renewal invoices

When a subscription is updated automatically, instead of via the API, the invoice behavior is a bit different.
In these cases, Stripe:

Creates an invoice

Leaves the invoice in a draft state for about an hour

Attempts to finalize and pay the invoice

Changes the invoice status to paid if payment succeeds

When the invoice is created, you’ll receive (via configured webhooks) an invoice.created event.
This time, the invoice’s status attribute will be draft, which means that its invoice items are open for modification.

Adding extra invoice items to to a future invoice

In the middle of a billing period, you might want to add more invoice items to the next invoice.

You can optionally use an subscription parameter to apply the invoice item to a specific subscription.

Adding an extra charge or discount on a subscription’s first invoice

Should you need to include a one-time charge or discount to the first subscription invoice, you can do so by adding an invoice item to the customer before creating the subscription. (The above code would work, as it doesn’t specify an invoice.) The resulting invoice item will be attached to the customer and automatically included in the first invoice created.

Adding invoice items to a draft subscription invoice

When a subscription renews and creates an invoice, Stripe sends the invoice.createdwebhook event.
Stripe waits approximately one hour before attempting to finalize the invoice and automatically collect payment for it.

During that delay, the invoice is a draft and is editable.
It’s possible to create invoice items on that invoice. Be certain to provide the invoice parameter when creating these invoice items, otherwise they will be added to the next subscription period.

If you have generated invoice items for a subscription, these invoice items behave slightly differently than invoice items automatically generated by Stripe:

User-generated invoice items are always charged when the billing period ends, even if the subscription is canceled. Canceling a customer’s subscription means only that the customer isn’t billed again if no invoice items exist.

User-generated invoice items are not prorated when a customer’s subscription is changed.

If there are pending invoice items that remain even after a subscription is canceled, Stripe will generate an invoice and will attempt to bill the customer for these items at the end of the next billing period. These invoice items are (similarly) not prorated when a subscription is changed.

Previewing upcoming invoices

The Retrieve an invoice API call provides a mechanism for viewing an existing invoice, but Stripe also provides an endpoint for previewing the next upcoming invoice.
This preview reflects the base plan cost, pending invoice items, discounts, and any existing customer balance.

When fetching the preview, you can also model what the invoice would look like if you changed the subscription in one of these ways:

Swapping the underlying plan

Altering the quantity

Applying a trial period

Adding a coupon

Generating an invoice for subscription items outside the billing cycle

At the end of a billing cycle, Stripe automatically creates an invoice containing both a line item for the customer’s subscription (future charges) and any invoice items that have been left pending on the customer.
When the customer has pending invoice items, you can also request that an invoice be generated at any time.
Generating a one-off invoice does not affect the customer’s standard billing schedule, but it does pull in any pending invoice items that would have been added to the regularly scheduled invoice.

When you manually generate an invoice, Stripe does not apply the taxes that you might have established on the subscription.
If taxes should apply, you must manually add the tax on the invoice itself (as a flat amount or percentage).

Manually generating invoices can be helpful when you want to request immediate payment of prorations created when you upgraded your customer’s subscription. For example, upgrading a user from a $10-per-month plan to a $20-per-month plan, mid-month, triggers proration invoice items for approximately a net $5.

However, by default, these prorations simply remain pending on the customer until the end of the month.
If you’d like the customer to be billed immediately, you can always create a one-off invoice after upgrading.

You manually generate an invoice from the Dashboard’s Customers section, using the Pending invoice items pane’s Invoice Now button; or from the API, using the Create an invoice method:

Remember that manually creating an invoice does not lead to a synchronous attempt to pay the invoice. Finalizing an invoice, then attempting automatic collection on it, occurs roughly one hour after the invoice is created.

Holding a subscription invoice for review

Rather than automatically attempting payment at the end of a billing period, you can hold the invoice for review or corrections. To hold an invoice:

Pause automatic collection within one hour of receiving the invoice.created event. You can do this by setting auto_advance=false in the API, or by pressing the Dashboard’s Turn off automatic billing button. This prevents Stripe from automatically attempting payment from your customer for the invoice amount, and from sending the invoice via email.

Review the invoice.

Once you are ready to attempt payment, resume automatic collection. You can do so either by setting auto_advance=truethrough the API, or by clicking the Dashboard’s Turn on automatic billing button.