A retry loop that sends four reminders about a €4 invoice costs more than the invoice. I kept seeing the same shape in failed-payment handling: one schedule applied to every failure, because writing down the exceptions felt like more work than letting the schedule run.
So I wrote the exceptions down.
The engine is one Python file. It reads a JSON event on stdin and writes one JSON decision on stdout. No network calls, no database, no secrets in the output. The whole policy fits on a screen, which is the point.
Timing is the least interesting part
The obvious dunning question is "when do we retry?" The more expensive question is "should we retry at all?"
Three ordinary declines get three increasing gaps:
first failure: retry in 24 hours, friendly reminder
second: retry in 72 hours, firmer reminder
third: retry in 168 hours, final notice, and escalate to a person
That is a schedule.…