fix(billing): report a failed checkout for a returning customer #152

Sammanfogat
supernaut sammanfogade 2 incheckningar från fix/143-failed-checkout-returning in i main 2026-10-12 14:41:13 +00:00
Ägare

What changed

subscriptionStatus now looks at the newest subscription of any status first. If it is incomplete and its latest charge is failed, canceled or expired, it reports that. Otherwise it falls back to latestSubscription, as before.

A running (active or past_due) subscription always wins over a newer incomplete checkout. The extra query only runs when the newest row is incomplete.

A returning customer whose earlier subscription was canceled now sees the failed checkout and the retry button.

Tests

  • New test: old canceled subscription, new checkout that expires. It fails without the fix.
  • New tests: running subscription with a newer expired checkout, and canceled subscription with a newer pending checkout.
  • pnpm lint, pnpm typecheck and pnpm test pass, with TEST_DATABASE_URL set (439 tests).

Closes #143

## What changed `subscriptionStatus` now looks at the newest subscription of any status first. If it is `incomplete` and its latest charge is `failed`, `canceled` or `expired`, it reports that. Otherwise it falls back to `latestSubscription`, as before. A running (`active` or `past_due`) subscription always wins over a newer incomplete checkout. The extra query only runs when the newest row is `incomplete`. A returning customer whose earlier subscription was `canceled` now sees the failed checkout and the retry button. ## Tests - New test: old `canceled` subscription, new checkout that expires. It fails without the fix. - New tests: running subscription with a newer expired checkout, and canceled subscription with a newer pending checkout. - `pnpm lint`, `pnpm typecheck` and `pnpm test` pass, with `TEST_DATABASE_URL` set (439 tests). Closes #143
supernaut lade till 2 incheckningar 2026-10-12 14:10:18 +00:00
subscriptionStatus skipped incomplete rows when any other subscription
existed. A returning customer with a canceled subscription never saw
the failed or expired payment. Check the newest subscription first.

Closes #143
fix(billing): keep a running subscription over a newer failed checkout
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m14s
c425b3a5f4
Skip the second query when the newest subscription is not incomplete.

Closes #143
supernaut tvångsskickade fix/143-failed-checkout-returning från c425b3a5f4
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m14s
till aa79d3f739
En del kontroller misslyckades
ci / ci (pull_request) Failing after 1m18s
2026-10-12 14:25:09 +00:00
Jämför
supernaut schemalade den här ändringsförfrågan för automatisk sammanfogning när alla kontroller lyckas 2026-10-12 14:25:12 +00:00
supernaut tvångsskickade fix/143-failed-checkout-returning från aa79d3f739
En del kontroller misslyckades
ci / ci (pull_request) Failing after 1m18s
till a78765eadd
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m7s
2026-10-12 14:38:28 +00:00
Jämför
supernaut sammanfogade incheckning 5a7de99ffa till main 2026-10-12 14:41:13 +00:00
supernaut tog bort grenen fix/143-failed-checkout-returning 2026-10-12 14:41:13 +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-payment!152
Ingen beskrivning angiven.