← Back to library

Cover bills, settles and refunds in one workflow

u/cuebicai shared an n8n workflow that takes an app's billing events through one webhook. After an API key check, each event type gets its own branch: invoices are logged in Google Sheets, rendered to PDF, saved to Drive and emailed; payments update the balance and send a receipt; refunds are recorded and confirmed. Every branch checks for duplicates first.

  • OutcomeEach billing event your app sends (invoice, payment or refund) is handled exactly once, with records, PDFs and customer emails kept in step.
  • SetupAn afternoon+
  • LevelAdvanced
  • Creditu/cuebicai on r/n8n_ai_agents
View original
Works with
n8nChatGPTClaude

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 23, 2026

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?

  1. Validate firstReject any webhook call without the right API key before touching data.
  2. Route by event typeGive each of the three event kinds its own branch so each stays simple.
  3. Check for duplicatesLook up the invoice, payment or refund ID before creating anything new.
  4. Do the branch's workCreate and email the invoice PDF, or apply the payment to the balance, or record the refund against its invoice.
  5. 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)

Prompt2 variables
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?
Mostly nowhere; it's a deterministic workflow. That is part of why it's reliable.
What did the author focus on?
Reliability and state: separate paths, idempotency checks and status updates rather than many integrations.

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
Reddit
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.

More in Finance & Accounting

All 62 Finance & Accounting playbooks →

Related playbooks

Finance & AccountingWorkflow✓ AI dry run

Collect monthly vendor invoices for your accountant

Every SaaS and cloud invoice for the month reaches your accountant without you visiting each billing portal.

Credit: u/UltraFocusMe on r/AccountingDepartment

An afternoon+
Finance & AccountingWorkflow✓ AI dry run

Turn emailed invoices into rows on a finance sheet

Watch a mailbox for invoice PDFs, extract the key fields with OCR and an LLM, and append categorized rows to a spreadsheet that powers a simple dashboard.

Credit: u/alexsafari1 on r/n8n

An afternoon+
Finance & AccountingPrompt✓ AI dry run

Review each AI project on its own line before budget lock

Give each AI tool and pilot its own cost line, owner and payback date, write the cut rules before you look at results, and walk into budget review with a short list to keep, fix or end.

Credit: Glenn Hopper

Under an hour
Finance & AccountingWorkflow✓ AI dry run

Route failed card payments by the real decline reason

When a subscription payment fails, look up why and route it: retry after payday, ask the customer to update the card, or stop.

Credit: u/Beneficial-Toe-3492 on r/n8n

An afternoon+