feat: dunning for failed renewals with an 8-day grace #74
Inga granskare
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
priority
high
priority
low
priority
medium
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-payment!74
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "feat/53-dunning"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
feat: dunning for failed renewals with an 8-day grace
What
Dunning for failed subscription renewals, built on Mollie's own retries. Renewal periods now line up with Mollie's charge days. Refs #53.
Design
subscriptionId. There is no webhook for subscription status changes. Source: docs.mollie.com "Recurring payments". So we build no retry scheduler.past_dueand keepstier_pro. A failure 3 or more days before the period end is a stale delivery and is ignored.activeagain and extends the period.tier_proand cancels the Mollie subscription. This happens once, and the cancel is a no-op if Mollie already cancelled. A renewal paid after that is refunded, and the customer can check out again.SubscriptionStatus.graceEndsAtis set while the subscription ispast_dueand not cancelled. Otherwise it is null. A subscription cancelled while past due ends at the next sweep.@bitborg/payment-contractgoes to 0.4.0. The root version is left to the release PR.How tested
The tests were written first and each new behaviour failed before its fix. Recovery and the post-grace refund pin behaviour that already existed. The tests cover:
An offline sweep of 75,090 derived periods (start dates every 7 h over 2 years) found 0 that miss Mollie's charge day.
Results with Postgres 17:
pnpm test --coverage: 277/277 passed, 16 files.drizzle-kit check: all pass.Follow-ups and open questions
graceEndsAton the account page, and send the reminder email. The portal owns mail. Deploy this service before the portal moves to contract 0.4.0, because the field is required in the output.currentPeriodEndis now the last instant before the charge day, so the portal should show the renewal date ascurrentPeriodEnd + 1 ms(the charge day), or say "paid until" forcurrentPeriodEnd.already_subscribed). Mollie's retries do not fix an expired card, so that customer loses access after the grace and then checks out again. A "replace card" flow needs a new first payment and a mandate update. Is it needed before monthly plans launch?6f8a2346adb0d4d887ae