fix(billing): follow mollie's next charge date after a retried renewal #159

Sammanfogat
supernaut sammanfogade 3 incheckningar från fix/138-follow-next-payment-date in i main 2026-10-12 16:58:38 +00:00
Ägare

What

Period end and nextCharge.on came from a fixed anchor. After a successful retry Mollie dates the next charge from that payment. Monthly, anchor day 2: the 2 November renewal fails and the retry is paid on 5 November. Our period ended 1 December while Mollie charged on 5 December. The reminder named the wrong day, and a retry 8 or more days late let the sweep end access before Mollie charged.

  • After applying a renewal, the Mollie subscription is read. periodEnd becomes the last millisecond before nextPaymentDate at Amsterdam midnight. nextCharge.on is derived from periodEnd, so it equals nextPaymentDate.
  • When the read fails or the date is missing, the period runs one interval from this renewal's charge day. It does not go back to the purchase anchor, since an earlier retry may have moved Mollie's schedule.
  • A date not after this charge day, or on or after the anchored charge day of the following period, is rejected. This keeps a late replay from taking a later cycle's date.
  • The read sits inside the renewal transaction, like the existing createSubscription and cancelSubscription calls. It is a GET and safe to repeat. A processed webhook replay never reaches it.
  • README corrected.

Version 0.11.2. This releases the batch #151 to #158.

Tests

  • A retry paid 9 days late: period end and nextCharge.on follow Mollie's date, and the sweep at the anchored grace end keeps access.
  • After the schedule moved, a failed read counts from that renewal's charge day, not the anchor.
  • A failed first read and a later-cycle date both keep the local period end.

Closes #138

## What Period end and `nextCharge.on` came from a fixed anchor. After a successful retry Mollie dates the next charge from that payment. Monthly, anchor day 2: the 2 November renewal fails and the retry is paid on 5 November. Our period ended 1 December while Mollie charged on 5 December. The reminder named the wrong day, and a retry 8 or more days late let the sweep end access before Mollie charged. - After applying a renewal, the Mollie subscription is read. `periodEnd` becomes the last millisecond before `nextPaymentDate` at Amsterdam midnight. `nextCharge.on` is derived from `periodEnd`, so it equals `nextPaymentDate`. - When the read fails or the date is missing, the period runs one interval from this renewal's charge day. It does not go back to the purchase anchor, since an earlier retry may have moved Mollie's schedule. - A date not after this charge day, or on or after the anchored charge day of the following period, is rejected. This keeps a late replay from taking a later cycle's date. - The read sits inside the renewal transaction, like the existing `createSubscription` and `cancelSubscription` calls. It is a GET and safe to repeat. A processed webhook replay never reaches it. - README corrected. Version 0.11.2. This releases the batch #151 to #158. ## Tests - A retry paid 9 days late: period end and `nextCharge.on` follow Mollie's date, and the sweep at the anchored grace end keeps access. - After the schedule moved, a failed read counts from that renewal's charge day, not the anchor. - A failed first read and a later-cycle date both keep the local period end. Closes #138
supernaut lade till 3 incheckningar 2026-10-12 16:56:07 +00:00
Period end and `nextCharge.on` came from a fixed anchor. After a successful retry Mollie counts the next charge from that payment. A renewal failed on the 2nd and paid on the 5th left our period ending on the 1st while Mollie charged on the 5th. The reminder named the wrong day, and a retry 8 or more days late let the sweep end access before Mollie charged.

- After applying a renewal, the Mollie subscription is read and `periodEnd` is set to the end of the day before `nextPaymentDate` (Amsterdam time). `nextCharge.on` follows from it.
- The anchored calculation stays as the fallback when the read fails, the date is missing, or the date belongs to a later cycle (a late replay).
- README corrected.

Closes #138
Once a retry has moved Mollie's schedule off the purchase anchor, a failed read fell back to the anchor. With anchor day 1 and a retry paid on 8 February, a failed read at the 8 March renewal ended the period on 31 March while Mollie charged on 8 April.

- The fallback now counts one interval from this renewal's charge day.
- The anchor still sets the upper bound that rejects a later cycle's date.

Refs #138
chore(release): 0.11.2
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m3s
7871636fe9
supernaut schemalade den här ändringsförfrågan för automatisk sammanfogning när alla kontroller lyckas 2026-10-12 16:57:46 +00:00
supernaut sammanfogade incheckning 0649cc4234 till main 2026-10-12 16:58:38 +00:00
supernaut tog bort grenen fix/138-follow-next-payment-date 2026-10-12 16:58:39 +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!159
Ingen beskrivning angiven.