feat(checkout): one-time annual payment with Swish, no auto-renewal #99

Sammanfogat
supernaut sammanfogade 2 incheckningar från feat/95-one-time-swish in i main 2026-10-06 08:29:57 +00:00
Ägare

Two ways to buy the personal plan at the same price: auto-renew by card, or a one-time annual payment with Swish that does not renew.

  • startCheckout takes renewal: "auto" | "none", default "auto". "none" needs interval: "annual" and sends method: ["swish"] with no customer, no mandate and no sequenceType. New provider method beginOneOffCheckout.
  • Schema: enum renewal and column subscription.renewal (default auto). charge_subscription_id_period_unique becomes a partial unique index WHERE status <> 'failed', so a failed early renewal does not block its period. Migration 0007.
  • Activation for "none" runs the same transaction (charge, period, tier grant, gapless invoice) without createSubscription, and sets cancelAtPeriodEnd so the sweep ends it at period end. The no-mandate refund from #82 runs only for "auto".
  • Early renewal extends from the current periodEnd, and the invoice covers the new period from that date.
  • Withdrawal: same rules. The window is anchored to the charge that started the current continuous period, so a purchase after a lapse gets a fresh 14 days. An early-paid future period is refunded in full on withdrawal. A one-time payment that lands after a withdrawal is refunded.
  • Refusals: a second checkout while an auto-renew subscription is live, and an auto checkout during a running one-time period (already_subscribed); monthly with "none" (one_time_needs_annual); one early renewal at a time (payment_pending, also on a concurrent insert race).
  • If the Mollie create call throws during an early renewal, the pending charge is marked failed.
  • subscriptionStatus adds renewal and paidUntil. Contract 0.6.0, service 0.5.0.

Known limit: a pending early renewal whose failure webhook is lost blocks further early renewals until the period ends (marked in code).

Tests: 335 passed with Postgres, including one-time activation without refund, an auto payment without a mandate still refunded, early renewal, lapse then repurchase, withdrawal amounts and the concurrent-checkout race.

To check on staging: buy with Swish, withdraw, buy again, renew early, let a period lapse. Confirm Mollie test mode takes method: ["swish"] for SEK and how long an open Swish payment takes to expire.

Closes #95.

Two ways to buy the personal plan at the same price: auto-renew by card, or a one-time annual payment with Swish that does not renew. - `startCheckout` takes `renewal: "auto" | "none"`, default `"auto"`. `"none"` needs `interval: "annual"` and sends `method: ["swish"]` with no customer, no mandate and no `sequenceType`. New provider method `beginOneOffCheckout`. - Schema: enum `renewal` and column `subscription.renewal` (default `auto`). `charge_subscription_id_period_unique` becomes a partial unique index `WHERE status <> 'failed'`, so a failed early renewal does not block its period. Migration `0007`. - Activation for `"none"` runs the same transaction (charge, period, tier grant, gapless invoice) without `createSubscription`, and sets `cancelAtPeriodEnd` so the sweep ends it at period end. The no-mandate refund from #82 runs only for `"auto"`. - Early renewal extends from the current `periodEnd`, and the invoice covers the new period from that date. - Withdrawal: same rules. The window is anchored to the charge that started the current continuous period, so a purchase after a lapse gets a fresh 14 days. An early-paid future period is refunded in full on withdrawal. A one-time payment that lands after a withdrawal is refunded. - Refusals: a second checkout while an auto-renew subscription is live, and an auto checkout during a running one-time period (`already_subscribed`); monthly with `"none"` (`one_time_needs_annual`); one early renewal at a time (`payment_pending`, also on a concurrent insert race). - If the Mollie create call throws during an early renewal, the pending charge is marked `failed`. - `subscriptionStatus` adds `renewal` and `paidUntil`. Contract 0.6.0, service 0.5.0. Known limit: a pending early renewal whose failure webhook is lost blocks further early renewals until the period ends (marked in code). Tests: 335 passed with Postgres, including one-time activation without refund, an auto payment without a mandate still refunded, early renewal, lapse then repurchase, withdrawal amounts and the concurrent-checkout race. To check on staging: buy with Swish, withdraw, buy again, renew early, let a period lapse. Confirm Mollie test mode takes `method: ["swish"]` for SEK and how long an open Swish payment takes to expire. Closes #95.
supernaut lade till 2 incheckningar 2026-10-06 08:26:58 +00:00
supernaut sammanfogade incheckning ef5b344031 till main 2026-10-06 08:29:57 +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!99
Ingen beskrivning angiven.