Reliable HTTP cron and delayed-job scheduling with automatic retries and full run logs — delay.run
A subscription renewal fails. The card was declined: insufficient funds, expired card, the bank's fraud check, or a vague "do not honour". Somebody has to decide when to try again, how many times, and what to tell the customer in between.
Most payment providers will do this for you. They offer automatic retries, often marketed as "smart" because a model picks the retry time based on patterns across many merchants' card data. Or you can turn that off and run your own schedule: a job that retries on day 1, 3, 5 and 7, emails the customer, and downgrades the account at the end.
Both approaches have real defenders. Our most-discussed post so far was a case study about a retry schedule that went wrong, so I suspect there are opinions out there. Let's argue about it.
The case for letting the provider retry
They have more data than you. A provider sees millions of declines across many merchants and banks. They know that certain decline codes almost never succeed on retry, that some banks reset limits on particular days, and that some hours recover better than others. Your own schedule is based on maybe a few hundred failures and a guess.
It's less code, and less risk. Retry logic for payments has sharp edges: double charges, retrying a card the customer just replaced, retrying after a cancellation, charging during a dispute. The provider's implementation has had years of bugs fixed in it already.
It's integrated with the rest of their dunning. Card updater services, hosted "update your card" pages, automatic emails, and subscription status changes all work together. When you replace one piece, you have to recreate how it talks to the others.
Decline codes are messy. Interpreting hundreds of issuer response codes correctly (which ones mean "never retry", which ones mean "try later") is specialist knowledge. Getting it wrong can mean breaking card network rules on excessive retries.
The case for owning the retry schedule
You know your customers. A provider's model doesn't know that most of your customers are small businesses in one country who get paid on the 25th, or that your renewals cluster on the 1st. A schedule designed around that, such as "retry on the next business day morning in the customer's timezone, and once more after payday", can beat a generic model for your specific base.
You control the experience. When to email, what to say, when to show an in-app banner, when to restrict features, whether to give a grace period to long-time customers. Provider automations offer some of this, but your product often needs more nuance, for example not locking out a team in the middle of their busiest week.
You can coordinate with the rest of your system. Your own retry job can check whether the customer opened the "update your card" email, whether they logged in yesterday, or whether there's an open support ticket, and adjust. A provider's retry engine can't see any of that.
It's portable. If you ever run more than one payment provider, or switch providers, your dunning logic comes with you instead of being rebuilt from scratch.
You can see and test it. A schedule in your own code can be reviewed, unit tested, and simulated against past failures. A black-box model's choices are harder to reason about when the finance team asks why recovery dropped last month.
Want a retry schedule you control, without running a worker? delay.run delays and retries the HTTP callback on your terms, and keeps a log of every attempt.
Where I've landed
For most small and mid-sized subscription businesses, I'd start with the provider's retries plus your own communication layer:
- Let the provider decide when to retry the card. Their data advantage on timing and decline codes is real, and the risk of getting card network rules wrong is not worth taking early.
-
Own everything around the retries. Emails, in-app banners, grace periods and access changes are driven by your code, from the provider's webhooks (
invoice.payment_failed, subscription status changes), on a schedule you control. - Measure recovery yourself. Track what share of failed renewals are recovered within 7, 14 and 30 days, by decline reason. Without that number you can't tell whether any change helped.
- Switch to your own retry schedule only with evidence. If you have enough volume to run a fair comparison and your customer base has patterns a generic model can't know, test your own schedule against the provider's on a split of customers. Keep it if it wins.
Owning the communication layer is mostly scheduled work: "email on day 1, banner from day 3, restrict on day 10, unless the invoice is paid first". That's the kind of cancellable delayed job delay.run and similar schedulers are designed for, but it can live in any durable job queue.
The cases that start arguments
- Hard declines. Should you ever retry "card reported stolen" or "account closed"? (No, but some systems do.)
- Annual plans. A failed $1,200 annual renewal is a very different conversation from a failed $12 monthly one. Same retry logic?
- Retrying at the exact renewal time. Many systems renew everyone at 00:00 UTC. Is spreading renewals across the day a retry strategy, a reliability strategy, or both?
- Telling the customer before the first retry. Some argue a silent first retry recovers more; others say customers deserve to know immediately.
Related reading
- Why '0 9 1 * 1' runs every Monday AND on the 1st: how cron combines day-of-month and day-of-week (and how to schedule 'the first Monday')
- Case study: redesigning a failed-payment retry schedule that retried every card at 00:00 UTC
- Retries and backoff FAQ: 11 questions about retrying failed jobs without making things worse
- 6 myths about calling rate-limited APIs from background jobs
So who decides when your failed payments get retried: the provider, your code, or a mix? And has anyone actually measured one against the other?
Top comments (0)