First period end is one day before the first provider charge #163

Stängd
öppnade 2026-10-12 18:23:57 +00:00 av supernaut · 0 kommentarer
Ägare

The first period of an auto-renewing subscription ends one day before the provider's first charge.

Seen on staging, 2026-10-12. Monthly card checkout paid at 18:19 UTC.

  • Our period end: addInterval(paidAt) = 2026-11-12 18:19 UTC (src/billing.ts, the paid-checkout path).
  • Mollie subscription: startDate and nextPaymentDate 2026-11-13, from renewalStartDate(periodEnd).
  • The portal shows "Your plan renews on 12 November 2026". The charge happens on 13 November.

Renewals after the first are aligned: renewalPeriodEnd ends the period 1 ms before Amsterdam midnight of the charge day. Only the first period breaks that rule, which the web portal relies on (src/lib/renewal.ts in bitborg-web: "1 ms before the next charge day").

Impact: no access loss, because auto-renewing rows get the 8-day grace. The shown renewal date and any reminder dated from the period end are one day early.

Fix: for renewal = "auto", end the first period at amsterdamMidnight(renewalStartDate(addInterval(paid))) - 1, the same rule as renewalPeriodEnd. Add a test that the first period end plus 1 ms falls on the subscription's startDate in Amsterdam time.

The first period of an auto-renewing subscription ends one day before the provider's first charge. Seen on staging, 2026-10-12. Monthly card checkout paid at 18:19 UTC. - Our period end: `addInterval(paidAt)` = 2026-11-12 18:19 UTC (`src/billing.ts`, the paid-checkout path). - Mollie subscription: `startDate` and `nextPaymentDate` 2026-11-13, from `renewalStartDate(periodEnd)`. - The portal shows "Your plan renews on 12 November 2026". The charge happens on 13 November. Renewals after the first are aligned: `renewalPeriodEnd` ends the period 1 ms before Amsterdam midnight of the charge day. Only the first period breaks that rule, which the web portal relies on (`src/lib/renewal.ts` in bitborg-web: "1 ms before the next charge day"). Impact: no access loss, because auto-renewing rows get the 8-day grace. The shown renewal date and any reminder dated from the period end are one day early. Fix: for `renewal = "auto"`, end the first period at `amsterdamMidnight(renewalStartDate(addInterval(paid))) - 1`, the same rule as `renewalPeriodEnd`. Add a test that the first period end plus 1 ms falls on the subscription's `startDate` in Amsterdam time.
supernaut lade till detta till projektet Bitborg Payment 2026-10-12 18:24:05 +00:00
Logga in för att delta i denna konversation.
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#163
Ingen beskrivning angiven.