feat(billing): renewal reminders for one-time yearly payments #302

Sammanfogat
supernaut sammanfogade 3 incheckningar från feat/297-renewal-reminders in i main 2026-10-06 10:27:23 +00:00
Ägare

Customers on a one-time yearly payment get reminded before their plan ends, so they never lose access by surprise.

  • Runs in-process, like the hourly purge job: scripts/server.mjs sets a random per-process INTERNAL_JOB_TOKEN, and scripts/renewal-reminders.mjs POSTs to 127.0.0.1:$PORT/api/internal/renewal-reminders 60 s after start and then hourly. The route answers 404 without the token. No new env and no infra timer; with billing or Kanidm unconfigured it does nothing.
  • Accounts: every distinct sub in checkout_consents. Name and email come from Kanidm, the plan from subscriptionStatus. Only renewal === "none" with a future paidUntil qualifies, so auto-renew customers never get a reminder.
  • Thresholds 30, 7 and 1 days before paidUntil, plus one on the last day, counted in Stockholm calendar days. A run that missed a threshold sends only the latest one due.
  • Once only: a claim row in renewal_reminders (primary key sub, paid_until, threshold) is inserted with ON CONFLICT DO NOTHING before each send, and deleted if the send fails so the next run retries. A new paidUntil starts a fresh series.
  • Language: new checkout_consents.lang, recorded at checkout; old rows read as Swedish.
  • Account page banner from 30 days before paidUntil, using the same rule as the emails.
  • Migration 0010 is additive.

Tests: 599 passed, including the DB tests and two parallel claims against Postgres. Build passes. Version 1.22.0.

Closes #297.

Customers on a one-time yearly payment get reminded before their plan ends, so they never lose access by surprise. - Runs in-process, like the hourly purge job: `scripts/server.mjs` sets a random per-process `INTERNAL_JOB_TOKEN`, and `scripts/renewal-reminders.mjs` POSTs to `127.0.0.1:$PORT/api/internal/renewal-reminders` 60 s after start and then hourly. The route answers 404 without the token. No new env and no infra timer; with billing or Kanidm unconfigured it does nothing. - Accounts: every distinct `sub` in `checkout_consents`. Name and email come from Kanidm, the plan from `subscriptionStatus`. Only `renewal === "none"` with a future `paidUntil` qualifies, so auto-renew customers never get a reminder. - Thresholds 30, 7 and 1 days before `paidUntil`, plus one on the last day, counted in Stockholm calendar days. A run that missed a threshold sends only the latest one due. - Once only: a claim row in `renewal_reminders` (primary key sub, paid_until, threshold) is inserted with `ON CONFLICT DO NOTHING` before each send, and deleted if the send fails so the next run retries. A new `paidUntil` starts a fresh series. - Language: new `checkout_consents.lang`, recorded at checkout; old rows read as Swedish. - Account page banner from 30 days before `paidUntil`, using the same rule as the emails. - Migration `0010` is additive. Tests: 599 passed, including the DB tests and two parallel claims against Postgres. Build passes. Version 1.22.0. Closes #297.
supernaut lade till 3 incheckningar 2026-10-06 10:21:40 +00:00
feat(checkout): choose automatic renewal or a one-time yearly Swish payment
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m45s
58dfd52c4e
Closes #296.
Closes #297.
Merge remote-tracking branch 'origin/main' into feat/297-renewal-reminders
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m3s
947e5e4dee
# Conflicts:
#	package.json
#	src/components/account-panel.astro
supernaut sammanfogade incheckning fc2c9021c2 till main 2026-10-06 10:27:23 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-web!302
Ingen beskrivning angiven.