When to use it
For every subscription business. Cards expire and get replaced; a failed renewal is often not a decision to leave, and a customer who does not know their payment failed cannot fix it. Dunning recovers revenue that would otherwise churn without anyone choosing to.
How it works
- 1A
payment_failedevent starts it, unless the reason is a test charge (the payloadwhere). - 2At once: a transactional email with the amount and currency from the event.
- 3Three days later: a push and a reminder email.
- 4Four days after that: a final notice, and a Slack message to billing with the unpaid amount.
- 5A
payment_succeededevent is the goal and stops the sequence. If the subscription is gone,exitWhenends it uncounted.
Why it's built this way
Transactional, every message
These are about the account, not marketing, so they are sent whatever the user’s topic preferences. A user who opted out of tips still needs to know their card was declined.
A goal and an exit condition
Two different endings: the payment going through is a recovery and counts as a conversion (the goal); the subscription being canceled makes the reminders pointless and ends the journey without counting (exitWhen).
Test charges never start it
notInArray(p.reason, ['test_charge']) keeps charges made from the billing dashboard out, before any instance exists.
Make it yours
- Align the delays with your payment provider’s retry schedule, so each reminder follows a failed retry.
- Branch on
failed.payload.reason: an expired card needs different words from insufficient funds. - Send the Slack alert only above an amount:
branch([gte(failed.payload.amount, 500), ...]).
What to measure
Recovered payments: the goal conversion rate, and revenue recovered per month.