When should you use it?
- Subscription revenue billed through Stripe
- Failed payments are retried on a fixed schedule
- Customers churn because a card expired
Not for: Retrying cards reported lost or stolen; Businesses without someone to own the workflow
What do you need, and what do you get?
You need
- Stripe webhook for failed invoices
- A Stripe credential with read access
- Your retry and messaging policy
You get
- A routing decision per failed payment
- Suggested next action
- A flag for whether Stripe will retry
How does it work, step by step?
- Receive and dedupeWebhook in, drop event IDs you have already handled.
- Fetch the real reasonLook up the payment for its decline code.
- RouteHard declines stop; insufficient funds wait; authentication issues go to the customer.
- Avoid double retriesCheck Stripe's own retry settings before adding yours.
The prompt
Our own prompt, inspired by u/Beneficial-Toe-3492 on r/n8n and written to work in n8n. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
Help me design failed-payment handling for {business} (billing via Stripe; Smart Retries: {smart_retries_on}). 1) Build a table of common decline codes, including {extra_codes}: for each give a route (STOP, RETRY_AFTER_PAYDAY, RETRY_SOON, ASK_CUSTOMER), the reason, and how many retries at most. 2) Unknown codes or failed lookups: route to ALERT_STAFF, never to retry. 3) Explain how to avoid retrying twice if Stripe also retries. 4) Write a short, friendly customer email for ASK_CUSTOMER and one for a final notice before cancellation. No threats, no fees not in our terms: {terms}. Do not invent Stripe fields; mark anything I should confirm in the Stripe docs.
Inspired by u/Beneficial-Toe-3492 on r/n8n: Stripe's failed payment webhook doesn't give you the decline code, so I made a small workflow that does. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- If the lookup fails, your own errors look like customer declines; fail loudly instead of defaulting to retry.
- Stripe's newer API versions moved the payment reference on invoices; check your webhook's pinned version.
Our take
We like this post because it is honest and specific: a real snag in a real billing integration, a small fix, and the JSON to prove it. The comments made it better, and we folded their corrections into our version. Don't let a failed lookup default to a retry path, because your own outages will look like customer declines. Check which Stripe API version your webhook uses, since newer versions moved the payment reference. Make sure Stripe's built-in retries aren't doubling up with yours. The routing should stay deterministic code; AI earns its place in drafting the policy table and the customer emails for each route, where tone matters. In our dry run with eight sample decline codes, our prompt produced a routing table that stopped retries for lost, stolen and expired cards, scheduled insufficient-funds retries after typical paydays, sent authentication failures to a customer email, and treated unknown codes as an alert for a person.
Where the time goes back: Pointless retries stop, and the customers who need to update a card hear about it the same day instead of after the subscription lapses.
FAQ
Why does the decline code matter?
Where does AI come in?
Source and credit
Inspired by u/Beneficial-Toe-3492 on r/n8n. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- Stripe's failed payment webhook doesn't give you the decline code, so I made a small workflow that does
- Creator
- u/Beneficial-Toe-3492 on r/n8n
- Published on
- Original date
- Oct 4, 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 20, 2026: passed. Dry-run tested by our AI test agent on sample input. Unknown never retried; double-retry handled; no invented fees.
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 24, 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.