fix(checkout): restrict the first payment to mandate-creating methods #98

Sammanfogat
supernaut sammanfogade 1 incheckning från fix/82-mandate-methods in i main 2026-10-06 08:05:41 +00:00
Ägare

The first payment set sequenceType: first but no method, so a customer could pay with a method that creates no mandate. The payment was then paid with an empty mandate, createSubscription failed, and the customer paid without getting the plan.

  • The first payment sends method: ["creditcard", "applepay"]. Per the Mollie docs, an array limits the hosted checkout to those methods, Google Pay runs inside creditcard, and cards, Apple Pay and Google Pay all create a creditcard mandate.
  • The adapter reports no payment method when a completed payment has no mandate or customer.
  • applyFirstPayment refunds such a payment in full through the existing claimRefund path and never creates a subscription, grants the tier or writes an invoice. The subscription stays incomplete, so the customer can check out again.
  • Replay safety: a succeeded charge returns early on a replayed webhook, the reconcile sweep treats it as settled, and the refund row's idempotency key stops a second refund.

Tests: four new, failing before the fix. The billing test forces a webhook replay plus a reconcile pass and asserts exactly one refund. Full suite 315 passed against Postgres 17.

To confirm on staging: Mollie accepts the method array on a first payment, and the hosted checkout shows only card and Apple Pay. Card and Apple Pay must be active on the profile.

Version 0.4.1.

Closes #82.

The first payment set `sequenceType: first` but no `method`, so a customer could pay with a method that creates no mandate. The payment was then `paid` with an empty mandate, `createSubscription` failed, and the customer paid without getting the plan. - The first payment sends `method: ["creditcard", "applepay"]`. Per the Mollie docs, an array limits the hosted checkout to those methods, Google Pay runs inside `creditcard`, and cards, Apple Pay and Google Pay all create a `creditcard` mandate. - The adapter reports no payment method when a completed payment has no mandate or customer. - `applyFirstPayment` refunds such a payment in full through the existing `claimRefund` path and never creates a subscription, grants the tier or writes an invoice. The subscription stays `incomplete`, so the customer can check out again. - Replay safety: a `succeeded` charge returns early on a replayed webhook, the reconcile sweep treats it as settled, and the refund row's idempotency key stops a second refund. Tests: four new, failing before the fix. The billing test forces a webhook replay plus a reconcile pass and asserts exactly one refund. Full suite 315 passed against Postgres 17. To confirm on staging: Mollie accepts the method array on a `first` payment, and the hosted checkout shows only card and Apple Pay. Card and Apple Pay must be active on the profile. Version 0.4.1. Closes #82.
supernaut lade till 1 incheckning 2026-10-06 08:03:01 +00:00
fix(checkout): restrict the first payment to mandate-creating methods
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m2s
52632a21fe
Closes #82.
supernaut sammanfogade incheckning 1d6d228535 till main 2026-10-06 08:05:41 +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!98
Ingen beskrivning angiven.