Recovery

Failed payment dunning email sequence

After a failed charge: an email with the amount at once, a push and a reminder after three days, a final notice after a week, then an alert to billing in Slack. A successful payment ends it.

EmailPushSlacktrigger.eventpayload wherepayload refsdelayperformedgoalexitWhenreentry: after_exitSlack
import { eq, notInArray, performed, trigger, workflow } from 'sendwend';
import { e, u } from './contract';
import { email, push, slack } from './templates';

/**
 * A real failed charge: test charges from the billing dashboard do not
 * start dunning.
 */
const failed = trigger.event(e.payment_failed, (p) =>
  notInArray(p.reason, ['test_charge'])
);

/**
 * Failed payment dunning: an email right away with the amount, a push
 * and a reminder three days later, a final notice after a week, and
 * then billing hears about it in Slack. A successful payment is the
 * goal and stops everything.
 *
 * Every message is transactional: it is about the account, so it is
 * sent whatever the user's marketing preferences. `exitWhen` ends the
 * journey, uncounted, if the subscription is gone (the billing system
 * canceled it, or the user did): there is no card to fix any more.
 */
export const failedPaymentDunning = workflow({
  id: 'failed_payment_dunning',
  name: 'Failed payment dunning',
  trigger: failed,
  reentry: { mode: 'after_exit' },
  goal: performed(e.payment_succeeded),
  exitWhen: eq(u.subscription_status, 'none'),
})
  .email(email.paymentFailed, {
    name: u.name,
    amount: failed.payload.amount,
    currency: failed.payload.currency,
  })
  .delay('3 days')
  .push(push.paymentFailed, {})
  .email(email.paymentReminder, { name: u.name })
  .delay('4 days')
  .email(email.paymentFinalNotice, { name: u.name })
  .slack(slack.billingAtRisk, {
    email: u.email,
    amount: failed.payload.amount,
    currency: failed.payload.currency,
  });
Compiled canvasDrag to pan

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

  1. 1A payment_failed event starts it, unless the reason is a test charge (the payload where).
  2. 2At once: a transactional email with the amount and currency from the event.
  3. 3Three days later: a push and a reminder email.
  4. 4Four days after that: a final notice, and a Slack message to billing with the unpaid amount.
  5. 5A payment_succeeded event is the goal and stops the sequence. If the subscription is gone, exitWhen ends 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.

Also see Abandoned checkout recovery email workflow.