From 10c2b877b16f8e933335b20b1689c0ed2e8e4e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Manciot?= Date: Wed, 17 Jun 2026 15:58:42 +0200 Subject: [PATCH] fix(testkit): create a fresh Stripe customer per test run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Stripe provider's createOrUpdateCustomer reuses an existing customer matched by email (Customer.list(email).headOption). With the fixed test email demo@softnetwork.fr, every run reattached pm_card_visa to the SAME persisted customer until Stripe rejected with customer_max_payment_methods, failing StripeLicenseIntegrationSpec.registerCard (and any card flow) — the in-memory journal means the account is recreated each run, so the email lookup is the actual reuse vector. Make `email` unique per JVM run (demo+@softnetwork.fr), evaluated once as a val so it stays a single source of truth within a run (every user/assertion referencing `email` still sees the same value) while differing across runs → Customer.list misses → a brand-new customer each run. This ships in the published payment-testkit artifact, so republish payment-testkit for downstream consumers (e.g. softclient4es-license-server) to pick it up. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../main/scala/app/softnetwork/payment/data/package.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testkit/src/main/scala/app/softnetwork/payment/data/package.scala b/testkit/src/main/scala/app/softnetwork/payment/data/package.scala index 865f3a0..36b1104 100644 --- a/testkit/src/main/scala/app/softnetwork/payment/data/package.scala +++ b/testkit/src/main/scala/app/softnetwork/payment/data/package.scala @@ -34,7 +34,13 @@ package object data { val lastName = "lastName" val name = "SoftNetwork" val birthday = "26/12/1972" - val email = "demo@softnetwork.fr" + // Unique per test run (per JVM): the Stripe provider's createOrUpdateCustomer reuses an existing + // customer matched by email (Customer.list(email=...).headOption), so a fixed email made every run + // attach another pm_card_visa to the SAME persisted customer until Stripe rejected with + // `customer_max_payment_methods`. A fresh suffix forces a brand-new customer each run while staying a + // single source of truth — it is evaluated ONCE (a val, not a def), so all users/assertions that + // reference `email` still see the same value within the run. (+subaddressing keeps it a valid address.) + val email = s"demo+${java.util.UUID.randomUUID().toString.take(8)}@softnetwork.fr" val phone = "+33102030405" val country = "FR" val address: Address = Address.defaultInstance