Guides / Payments
Dunning is the process of recovering failed subscription payments: retrying the charge, sending reminder emails, and eventually cancelling if payment can't be recovered. Logging each step gives you a real-time funnel.
// 1. Initial payment failure
await logit.now("dunning", {
event: "Dunning started",
description: `${customerEmail} — payment failed, dunning initiated`,
icon: "⚠️",
notify: false,
tags: { step: "start", plan: customer.plan },
metadata: { customerId, email: customerEmail, amount, subscriptionId },
});
// 2. Dunning email sent
await logit.now("dunning", {
event: "Dunning email sent",
description: `Reminder ${attemptNumber} sent to ${customerEmail}`,
icon: "✉️",
notify: false,
tags: { step: "email", attempt: attemptNumber.toString() },
metadata: { customerId, email: customerEmail, attemptNumber },
});
// 3. Retry succeeded — recovery
await logit.now("dunning", {
event: "Payment recovered",
description: `${customerEmail} paid after ${daysSinceFailure} days`,
icon: "✅",
notify: true,
tags: { step: "recovered", plan: customer.plan },
metadata: { customerId, email: customerEmail, amount, daysSinceFailure },
});
// 4. Subscription cancelled after failed dunning
await logit.now("dunning", {
event: "Dunning failed — subscription cancelled",
description: `${customerEmail} could not be recovered`,
icon: "❌",
notify: true,
tags: { step: "cancelled", plan: customer.plan },
metadata: { customerId, email: customerEmail, subscriptionId },
});
| Field | Value |
|---|---|
| Name | Dunning failure cluster |
| Channel | dunning |
| Event name | Dunning failed — subscription cancelled |
| Threshold | 3 |
| Window | 24 hours |
| Cooldown | 24 hours |
| Action | Push notification + Slack webhook |
attempt: "1", "2", "3") so you can see which retry email drives the most recoveries.daysSinceFailure in metadata to understand how long your dunning window should be.dunning channel gives you a complete funnel: start → emails → recovered or cancelled.Try LogIt free
7-day trial. No credit card required.