How to automate invoices and returns in online sales.
To automate invoices and returns in online sales, create the invoice from the payment event — on Stripe, a Checkout Session with invoice_creation enabled produces a paid invoice after each successful payment — and, when a returned parcel is checked, let one job restock the item, refund the payment and issue a credit note that refers to that original invoice. Below: the chain step by step, the published rules for invoices and credit notes, which document fits each return outcome, one return followed through both ledgers, and the pitfalls.
Invoices and returns
- Sale
- Paid invoice created from the payment event
- Return
- Restock, refund and credit note in one job
- Credit note
- Refers to the original invoice and the lines amended
- EU refund
- Within 14 days, may wait for the goods
- Keep human
- Damage, disputes, country-specific tax cases
One chain, two ledgers
An online sale moves two things: goods out of stock and money into the account. The invoice is the accounting record of both. A return reverses them, and needs its own records: the item back in inventory, the money back to the customer, and a credit note that cancels the returned part of the invoice. Most shops automate the first half and leave the second to someone copying numbers into the accounting software.
The way to automate both is to give every step an event and a key. The payment event creates the invoice; the invoice ID is stored on the order; the return is recorded against order lines; and the warehouse scan that confirms the parcel triggers restock, refund and credit note together, so the three can never disagree. The returns half on its own — request, eligibility, label, inspection — is covered in e-commerce returns automation with APIs.
Six steps, from checkout to the books
- 01
1. Create the invoice when the payment succeeds
On Stripe Checkout or Payment Links, turn on post-payment invoice creation (invoice_creation[enabled] set to true on the Checkout Session). Stripe creates a paid invoice and, with automatic receipts on, e-mails the customer links to the invoice and receipt PDFs. Listen for invoice.paid to pick it up in your own system.
- 02
2. Put the order and invoice on each other
Pass your order reference in invoice_creation.invoice_data.metadata, and store the invoice ID on the order in your shop or database. Every later credit note starts from that ID, so a missing link here is what forces manual work later.
- 03
3. Record the return against order lines
The return request names the lines and quantities coming back, not a free-text amount. On Shopify, returnCreate opens a return that is already approved and creates the sales records that reverse the returned items; a customer request goes through approval first.
- 04
4. Restock when the parcel is checked
The warehouse scan is the trigger. On Shopify, returnProcess can issue the refund for the return and set a disposition per returned line, such as restocking the item into inventory. Damaged items get a different disposition and go to a person.
- 05
5. Refund and credit note in the same job
Create a credit note on the original invoice for the returned lines and quantities, with a refund amount, or link the refund already made for that charge. One job, one set of lines: the refund, the credit note and the restock all describe the same items.
- 06
6. Sync and reconcile
Send the invoice and the credit note to your accounting software, and check daily that every refund has a credit note and every credit note a refund, a balance credit or an out-of-band entry. The same data can feed an automatic sales report that shows sales net of returns.
The rules your automation has to respect
Stripe and Shopify as examples; other platforms have equivalents, so check their own documentation. Tax rules vary by country: the EU basics below are the floor, national rules can add to them.
| Topic | What the official source says | What it means for the workflow |
|---|---|---|
| Invoice for one-time payments | Stripe: post-payment invoice creation is available for one-time payments made with Payment Links or Checkout, configured on the payment link or Checkout Session; it is priced separately from Stripe Invoicing | Turn it on per session in code, not as an afterthought in the Dashboard |
| What a credit note does | Stripe: credit notes decrease the amount of an open or paid invoice and do not void and replace the original invoice | The original invoice stays in the books; the credit note sits next to it |
| Ceiling | Stripe: the sum of all credit notes issued for an invoice can't exceed the total amount of the invoice | Several partial returns on one order are fine, up to the invoice total |
| Credit note on a paid invoice | Stripe: create a refund, link an existing refund, credit the customer credit balance, or credit outside of Stripe | Map each return outcome to one of these four (see the next table) |
| Refund is a separate choice | Stripe: issuing a credit note doesn't automatically refund the customer's payment method | Set the refund amount explicitly, or link the refund you made |
| Credit note content (EU) | European Commission: a correcting document must carry a specific, unambiguous reference to the initial invoice and the details being amended | Credit the invoice's own lines, not a generic discount line |
| Full invoice content (EU) | European Commission: issue date, unique sequential number, both parties' names and addresses, description and quantity, unit price excluding tax, VAT rate and amount by rate | Number credit notes and invoices from a sequence your system cannot skip |
| Invoices to consumers (EU) | European Commission: required for distance sales taxable in another Member State when the One Stop Shop is not used; some Member States require invoices for other sales to private individuals | Check the rule of each country you ship to before deciding B2C invoices are optional |
| Refund deadline (EU) | Directive 2011/83/EU: all payments, including delivery costs, refunded within 14 days of being informed of the withdrawal; the trader may withhold the refund until the goods are back or proof of sending is supplied | Trigger refund and credit note on the warehouse or carrier event, and alert someone before the deadline |
| E-invoicing (EU) | European Commission: Digital Reporting Requirements, based on e-invoicing, apply to cross-border B2B transactions from 1 July 2030 | Keep invoice data structured now, not only as PDFs |
Which document for which return outcome
Using Stripe's credit note options on a paid invoice as the example.
| Return outcome | Stock | Money | Accounting document |
|---|---|---|---|
| Whole order returned, money back | All lines restocked | Refund to the original payment method | Credit note on every line, with the refund amount |
| Part of the order returned | Returned lines restocked | Partial refund | Credit note on the returned lines and quantities only |
| Refunded earlier, before the credit note existed | As received | Refund already made | Credit note that links the existing refund |
| Store credit instead of money | Returned lines restocked | None to the card | Credit note to the customer credit balance, applied to future invoices |
| Paid back another way (cash, bank transfer) | Returned lines restocked | Outside the payment provider | Credit note with an amount credited outside of Stripe |
| Item arrives damaged or not as described | Not restocked | On hold | None yet: a person decides first |
One return, followed through both ledgers
A customer buys two shirts on a shop that takes payment through Stripe Checkout. The payment succeeds; Stripe creates the paid invoice and e-mails it; the invoice.paid event writes the invoice ID onto the order. Later, the customer asks, on the shop's WhatsApp number, to send one shirt back. The agent looks up the order, checks the return window and opens a return for one unit of that line.
When the warehouse scans the parcel and marks the shirt as resellable, one job runs: the shirt goes back into stock, a credit note is created on the original invoice for a quantity of one on the shirt line, with a refund amount equal to that line, and the customer receives: “Your shirt has arrived. Your refund is on its way to the card you paid with, and the credit note is attached.” The accounting software receives the credit note with its link to the invoice. If the shirt had arrived damaged, nothing would be refunded or credited automatically: the case goes to a person with the photos and the order.
This is the kind of workflow we build behind shops and agents — see AI agents and automation and the custom shop with Stripe checkout we run for a sports equipment brand in France, under retail and e-commerce.
Pitfalls to avoid
- Refunding from the payment screen only. The money goes back, but the invoice still shows the full sale. Stripe lets a credit note link an existing refund: make that link part of the job, or reconcile daily.
- Crediting a lump sum instead of lines. Stripe recommends discounting invoice line items, because a custom discount line is not associated with a real invoice line and makes reporting difficult; with automatic tax enabled, Stripe does not allow a custom line item on a credit note at all.
- Mixing quantity and amount on the same line. Once a line has been credited by quantity, Stripe only lets later credit notes on that line credit by quantity, and the same for amount. Decide one rule per product type: quantity for goods, amount for price adjustments.
- Forgetting the discount maths. Stripe applies invoice discounts proportionally to every line, so crediting one line of a discounted order credits the discounted price, not the list price. Your refund message should quote the same figure.
- Treating every country the same. EU rules set the basics, but invoice obligations for consumers and e-invoicing timelines differ by Member State; let an accountant confirm the rule for each market before switching it on.
Sources
- Stripe Docs — Receipts and paid invoices — post-payment invoices for Checkout and Payment Links, invoice_creation, invoice.paid, separate pricing — checked 25 November 2026
- Stripe Docs — Issue credit notes — open or paid invoices, no voiding of the original, ceiling, no automatic refund, line items, discounts, automatic tax — checked 25 November 2026
- Stripe Docs — Generate credit notes programmatically — refund, linked refund, customer credit balance, credit outside Stripe — checked 25 November 2026
- Shopify Developers — Build return management — returnCreate, returnProcess, dispositions and restocking — checked 25 November 2026
- European Commission — VAT invoicing rules — when an invoice is required, invoice contents, reference to the initial invoice — checked 25 November 2026
- European Commission — VAT in the Digital Age — Digital Reporting Requirements for cross-border B2B from 1 July 2030 — checked 25 November 2026
- EUR-Lex — Directive 2011/83/EU on consumer rights — refund deadline and withholding until the goods are back — checked 25 November 2026
Related
Frequently asked questions
How do I automate invoices and returns in online sales?
Create the invoice from the payment event and store its ID on the order. When a returned parcel is checked, run one job that restocks the item, refunds the payment and issues a credit note on the original invoice for the returned lines. A person handles damaged items and disputes.
Does Stripe create an invoice for a one-time Checkout payment?
Only if you turn it on. Post-payment invoice creation is available for one-time payments made with Payment Links or Checkout; on a Checkout Session, set invoice_creation[enabled] to true. Stripe prices it separately from Stripe Invoicing.
Does a Stripe credit note refund the customer automatically?
No. Stripe says issuing a credit note doesn't automatically refund the customer's payment method. On a paid invoice you choose to create a refund, link an existing refund, credit the customer credit balance or credit outside of Stripe.
What must a credit note contain in the EU?
According to the European Commission, a document that corrects an invoice, such as a credit note, must carry a specific, unambiguous reference to the initial invoice and the details being amended. National rules can add requirements.
Returns and invoices out of sync?
We connect your shop, payment provider and accounting so a return updates stock, money and books in one go.