fix(billing): mollie hardening: mandates, chargebacks, customer reuse #172

Sammanfogat
supernaut sammanfogade 6 incheckningar från fix/mollie-hardening in i main 2026-10-13 08:30:54 +00:00
Ägare

Four Mollie hardening fixes, one commit each.

Small Mollie fixes (#149)

  • The card expiry is read from the mandate and stored in payment_method.exp (first payments only). A failed mandate read leaves it empty.
  • A renewal whose amount differs from the subscription's last charge, or has no readable SEK amount, is not applied. It goes to reconcile_orphan and is logged once.
  • Apple Pay is detected from details.wallet, as Mollie creates those payments as creditcard.
  • completeCheckout is removed. It had no caller.
  • Payment descriptions end in the first 8 characters of the charge id.
  • With payments enabled, the service checks at start that the key works and that creditcard, applepay and swish are enabled, and exits otherwise.
  • The start check lists methods with a SEK amount, as Mollie lists euro methods only by default. Test mode lists pending methods too, so a staging pass does not prove live activation.
  • The Google Pay comment is corrected: it is a creditcard payment and supports recurring, per the Mollie docs.

Revoke the mandate (#145)

  • A chargeback, a withdrawal or a full dashboard refund that ends a subscription queues its payment method as revoking in the same transaction. The mandate is revoked after commit, then marked invalid.
  • A failed revoke is logged as [mandate] <id> not revoked and retried by the sweep. A mandate already gone at Mollie counts as revoked.
  • A paid checkout that is refunded without activating (duplicate, after a withdrawal, card country mismatch) has its new mandate revoked too.
  • A mandate a live subscription of the same customer still uses is never revoked. This is re-checked just before each revoke call. Cancel at period end is left alone.

Open chargebacks past the window (#147)

  • Mollie sends no payment webhook on a reversal, so past the 180-day re-fetch window a reversal is not seen. The comment that said otherwise is corrected.
  • An open chargeback older than the window is flagged once with a review note, which fires the existing unreviewed-chargeback alert. This also reopens a review closed earlier.

One Mollie customer per customer (#144, folds in #118)

  • customer.provider_customer_ref (migration 0012) holds the Mollie customer. The first renewing checkout creates it. Later checkouts reuse it. One-time Swish checkouts still create none.
  • Name and email are sent to Mollie at each checkout and on a billing email change. A failed update on an email change is logged and does not fail the change. A customer recreated there is stored. A customer deleted at Mollie is created again.
  • The migration backfills the column from the newest payment_method.provider_data.customerId.
  • Mollie subscription descriptions end in a short subscription id, so they are unique per customer.
  • PaymentProvider gains ensureCustomer, revokeMethod and verifySetup. beginCheckout takes customerRef and no longer creates a customer.

Closes #149
Closes #145
Closes #147
Closes #144

Version 0.13.0.

Four Mollie hardening fixes, one commit each. ## Small Mollie fixes (#149) - The card expiry is read from the mandate and stored in `payment_method.exp` (first payments only). A failed mandate read leaves it empty. - A renewal whose amount differs from the subscription's last charge, or has no readable SEK amount, is not applied. It goes to `reconcile_orphan` and is logged once. - Apple Pay is detected from `details.wallet`, as Mollie creates those payments as `creditcard`. - `completeCheckout` is removed. It had no caller. - Payment descriptions end in the first 8 characters of the charge id. - With payments enabled, the service checks at start that the key works and that `creditcard`, `applepay` and `swish` are enabled, and exits otherwise. - The start check lists methods with a SEK amount, as Mollie lists euro methods only by default. Test mode lists pending methods too, so a staging pass does not prove live activation. - The Google Pay comment is corrected: it is a `creditcard` payment and supports recurring, per the Mollie docs. ## Revoke the mandate (#145) - A chargeback, a withdrawal or a full dashboard refund that ends a subscription queues its payment method as `revoking` in the same transaction. The mandate is revoked after commit, then marked `invalid`. - A failed revoke is logged as `[mandate] <id> not revoked` and retried by the sweep. A mandate already gone at Mollie counts as revoked. - A paid checkout that is refunded without activating (duplicate, after a withdrawal, card country mismatch) has its new mandate revoked too. - A mandate a live subscription of the same customer still uses is never revoked. This is re-checked just before each revoke call. Cancel at period end is left alone. ## Open chargebacks past the window (#147) - Mollie sends no payment webhook on a reversal, so past the 180-day re-fetch window a reversal is not seen. The comment that said otherwise is corrected. - An open chargeback older than the window is flagged once with a review note, which fires the existing unreviewed-chargeback alert. This also reopens a review closed earlier. ## One Mollie customer per customer (#144, folds in #118) - `customer.provider_customer_ref` (migration 0012) holds the Mollie customer. The first renewing checkout creates it. Later checkouts reuse it. One-time Swish checkouts still create none. - Name and email are sent to Mollie at each checkout and on a billing email change. A failed update on an email change is logged and does not fail the change. A customer recreated there is stored. A customer deleted at Mollie is created again. - The migration backfills the column from the newest `payment_method.provider_data.customerId`. - Mollie subscription descriptions end in a short subscription id, so they are unique per customer. - `PaymentProvider` gains `ensureCustomer`, `revokeMethod` and `verifySetup`. `beginCheckout` takes `customerRef` and no longer creates a customer. Closes #149 Closes #145 Closes #147 Closes #144 Version 0.13.0.
supernaut lade till 6 incheckningar 2026-10-13 06:39:03 +00:00
Store the card expiry from the mandate. Check the renewal amount against
the subscription and send a mismatch to reconcile_orphan. Read the Apple
Pay wallet instead of a brand that never occurs. Drop completeCheckout.
Add a charge tag to payment descriptions. Verify the key and enabled
methods at start. Correct the Google Pay comment.
Queue the card mandate of an ended subscription for revocation in the
same transaction that ends it, and revoke it after commit. A failed call
stays queued and the sweep retries it. The mandate of a refused paid
checkout is revoked too, unless a live subscription still uses it.
Mollie sends no payment webhook on a reversal, so past the 180-day
re-fetch window a reversal is never seen. Flag such a chargeback once
for review, which fires the unreviewed-chargeback alert, and correct the
comment that said the webhook would catch it.
Store the provider customer on the customer row. The first renewing
checkout creates it, later ones reuse it and send the current name and
email, and a billing email change does too. Migration 0012 backfills the
column from the newest stored payment method. Subscription descriptions
now end in a short subscription id so they stay unique per customer.
List methods with a SEK amount at start, so Swish is seen. Re-check the
mandate before a queued revoke. Store a customer recreated by a billing
email change. Document the renewal amount mismatch.
chore(release): 0.13.0
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m16s
972989a06a
supernaut tvångsskickade fix/mollie-hardening från 972989a06a
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m16s
till 9b75062b60
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m16s
2026-10-13 08:28:07 +00:00
Jämför
supernaut schemalade den här ändringsförfrågan för automatisk sammanfogning när alla kontroller lyckas 2026-10-13 08:28:10 +00:00
supernaut sammanfogade incheckning 249202a2ad till main 2026-10-13 08:30:54 +00:00
supernaut tog bort grenen fix/mollie-hardening 2026-10-13 08:30:55 +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!172
Ingen beskrivning angiven.