When should you use it?
- Your app emits billing events and you handle the paperwork by hand
- You've been bitten by double-sent invoices or receipts
- You want billing logic you can read in one place
Not for: Replacing your payment processor or accounting system of record; High-volume billing where a spreadsheet store won't scale
What do you need, and what do you get?
You need
- A webhook endpoint protected by an API key
- A sheet or database for invoices and transactions
- A PDF generator, file storage and an email service
You get
- Stored invoices with PDF links and send timestamps
- Updated balances and payment status per invoice
- Refund records and confirmation emails
How does it work, step by step?
- Validate firstReject any webhook call without the right API key before touching data.
- Route by event typeGive each of the three event kinds its own branch so each stays simple.
- Check for duplicatesLook up the invoice, payment or refund ID before creating anything new.
- Do the branch's workCreate and email the invoice PDF, or apply the payment to the balance, or record the refund against its invoice.
- Write status backUpdate the record with result, links and timestamps, and return the outcome to the calling app.
The prompt
Our own prompt, inspired by u/cuebicai on r/n8n_ai_agents and written to work in n8n, ChatGPT and Claude. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
Design an n8n workflow for billing events from {app_name}. Event types: invoice.created, payment.received, refund.issued, with fields {fields}. Requirements: validate an API key header; route by type; before creating any record, check whether its ID already exists and stop if so; for invoices generate a PDF, store it, email the customer and save the link; for payments update the invoice balance and send either a receipt or a paid-in-full email; for refunds record the refund and confirm it. Return the node list in order with what each node checks or writes, plus test cases for duplicate and out-of-order events.
Inspired by u/cuebicai on r/n8n_ai_agents: n8n workflow that handles invoices, payments, and refunds automatically. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- Webhooks are often retried; without the duplicate checks you will send the same invoice twice.
- Spreadsheets are fine to start but get slow and fragile as volume grows.
Our take
We include this because it shows the boring engineering that most agent demos skip. Billing events arrive more than once, out of order, or from a misconfigured client, and a workflow that doesn't check before acting will email customers duplicate invoices or apply a payment twice. The author's design handles that with three habits worth copying anywhere: authenticate the call, branch by event type, and look up the ID before creating a record. Writing the final status back gives you an audit trail you can reconcile. If you add a model to a flow like this, keep it at the edges, for example to draft a friendlier receipt or summarize a dispute, and leave balances and records to deterministic steps. Plan the move off Google Sheets before you need it; a small database with unique keys enforces the duplicate rule for you. Test with replayed events, including the same payment sent twice, before pointing real customers at it.
Where the time goes back: Billing paperwork happens on the event instead of in a weekly catch-up, and duplicates are blocked automatically.
FAQ
Where is AI used here?
What did the author focus on?
Source and credit
Inspired by u/cuebicai on r/n8n_ai_agents. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- n8n workflow that handles invoices, payments, and refunds automatically
- Creator
- u/cuebicai on r/n8n_ai_agents
- Published on
- Original date
- Sep 8, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- n8n
- AI dry run
- Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS (desk check, not a live run in the vendor's app). Replaces an earlier templated dry-run note.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.