fix(helcim): skip HelcimPay verify when a card is already on file
Some checks failed
Test / vitest (push) Successful in 11m5s
Test / playwright (push) Failing after 9m18s
Test / visual (push) Failing after 9m24s
Test / Notify on failure (push) Successful in 2s

Helcim refuses paymentType:'verify' for cards already saved on a
customer ("A new card must be entered for saving the payment method"),
breaking every "Complete Payment" retry after a partial-failed signup.

Add GET /api/helcim/existing-card and short-circuit HelcimPay verify in
useMemberPayment + payment-setup.vue when a saved card is found, going
straight to subscription creation. The two existence-check fetches run
in parallel with get-or-create-customer so no extra round-trip latency
in the common path.
This commit is contained in:
Jennie Robinson Faber 2026-04-26 17:27:40 +01:00
parent e3410c52a5
commit 0f841912e2
4 changed files with 201 additions and 42 deletions

View file

@ -0,0 +1,25 @@
// Returns the saved cardToken so callers can skip HelcimPay re-entry.
import { requireAuth } from '../../utils/auth.js'
import { listHelcimCustomerCards } from '../../utils/helcim.js'
export default defineEventHandler(async (event) => {
const member = await requireAuth(event)
if (!member.helcimCustomerId) {
return { cardToken: null }
}
const cardsResponse = await listHelcimCustomerCards(member.helcimCustomerId)
const cards = Array.isArray(cardsResponse)
? cardsResponse
: (cardsResponse?.cards || cardsResponse?.data || [])
if (!cards.length) {
return { cardToken: null }
}
const defaultCard =
cards.find((c) => c?.default === true || c?.isDefault === true) || cards[0]
return { cardToken: defaultCard?.cardToken || null }
})