fix(billing): reuse one Mollie customer per customer #144

Stängd
öppnade 2026-10-12 13:15:01 +00:00 av supernaut · 0 kommentarer
Ägare

customers.create runs on every beginCheckout with idempotency key ${chargeId}_c, and chargeId is a new UUID per checkout (src/provider/mollie.ts:343-354, src/billing.ts:568, :630). The comment at mollie.ts:350 says a retried checkout reuses the customer. It cannot. No Mollie customer id is stored on our customer row.

Mollie:

Create a unique customer using the Customers API… Save the customer's id in your database.

https://docs.mollie.com/docs/recurring-payments

Seen on staging: two Mollie customers with the same metadata.customerId and no payments. When payments.create is refused after the customer was created, that customer is orphaned too.

Failing case: every abandoned or repeated checkout leaves another Mollie customer with name and email. An erasure request has to find each one by metadata.

Fix: add a nullable provider_customer_ref to customer. Create the Mollie customer only when it is null, then store and reuse it. Fix the comment.

Also (folded in from #118). Related: #85, #112, #113.

  • Update name and email at the provider when they change on our side.
  • Backfill provider_customer_ref from payment_method.provider_data.customerId where present.
  • Keep subscription descriptions unique per customer (see #85).

Done when:

  • Two checkouts for one customer create one Mollie customer.
  • A changed name or email is sent to the provider.
  • The backfill sets the ref for customers with a stored payment method.
  • Tests cover each.
`customers.create` runs on every `beginCheckout` with idempotency key `${chargeId}_c`, and `chargeId` is a new UUID per checkout (`src/provider/mollie.ts:343-354`, `src/billing.ts:568`, `:630`). The comment at `mollie.ts:350` says a retried checkout reuses the customer. It cannot. No Mollie customer id is stored on our `customer` row. Mollie: > Create a unique customer using the Customers API… Save the customer's `id` in your database. https://docs.mollie.com/docs/recurring-payments Seen on staging: two Mollie customers with the same `metadata.customerId` and no payments. When `payments.create` is refused after the customer was created, that customer is orphaned too. Failing case: every abandoned or repeated checkout leaves another Mollie customer with name and email. An erasure request has to find each one by metadata. Fix: add a nullable `provider_customer_ref` to `customer`. Create the Mollie customer only when it is null, then store and reuse it. Fix the comment. Also (folded in from #118). Related: #85, #112, #113. - Update name and email at the provider when they change on our side. - Backfill `provider_customer_ref` from `payment_method.provider_data.customerId` where present. - Keep subscription descriptions unique per customer (see #85). Done when: - [ ] Two checkouts for one customer create one Mollie customer. - [ ] A changed name or email is sent to the provider. - [ ] The backfill sets the ref for customers with a stored payment method. - [ ] Tests cover each.
supernaut lade till detta till projektet Bitborg Payment 2026-10-12 13:16:13 +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#144
Ingen beskrivning angiven.