Integrate with the Invoicing API
The Dashboard is the most common way to create invoices. If you’d like to automate this process, you can integrate with the API. Build a full, working Invoicing integration using our sample integration.
You don’t need to integrate with the Payments API to integrate with the Invoicing API.
Set up Stripe
Use our official libraries for access to the Stripe API:
Create a product
To create a product, enter its name:
Create a price
Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the billing interval (when the price is for a subscription). Like products, if you only have a few prices, it’s preferable to manage them in the Dashboard. Use the unit amount to express prices in the lowest unit of the currency—in this case, cents (10 USD is 1,000 cents, so the unit amount is 1000).
As an alternative, if you don’t need to create a price for your product, you can use the amount parameter during invoice item creation.
To create a price and assign it to the product, pass the product ID, unit amount, and currency. In the following example, the price for the “Gold Special” product is 10 USD:
Create a customer
The Customer object represents the customer purchasing your product. It’s required for creating an invoice. To create a customer with a name
, email
, and description
, add the following code replacing the values with your own:
After you create the customer, store the customer id
in your database so that you can use it later. The next step, for example, uses the customer ID to preview an invoice.
See Create a customer for additional parameters.
Create an invoice
Before you invoice a customer, create an invoice item by passing in the customer id
and product price
. Creating an invoice automatically adds all pending invoice items for that customer. Only add invoice items to a single customer at a time to avoid adding them to the wrong one.
The maximum number of invoice items is 250. Creating an invoice will add up to 250 pending invoice items with the remainder to be added on the next invoice. To see your customer’s pending invoice items, see the Customer details page or set the pending attribute to true
when you use the API to list all of the invoice items.
Set the collection_method attribute to send_invoice
. For Stripe to mark an invoice as past due, you must add the days_until_due parameter. When you send an invoice, Stripe emails the invoice to the customer with payment instructions.
If you set auto_advance
to false
, you can continue to modify the invoice until you finalize it. To finalize a draft invoice, use the Dashboard, send it to the customer, or pay it. You can also use the Finalize API:
If you created the invoice in error, void it. You can also mark an invoice as uncollectible.
Send an invoice
Send the invoice to the email address associated with the customer. As soon as the an invoice is sent, Stripe finalizes it. Many jurisdictions consider finalized invoices a legal document making certain fields unalterable. If you send invoices that have already been paid, there’s no reference to the payment in the email.
When you send invoices that have already been paid, the email doesn’t reference the payment. Stripe sends invoices to the email address associated with the customer.