[Bug] normalizeSwishNumber does not strip leading '+', breaking Swish payment for +46 numbers #24
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Identified during advisory review of #17 (guest checkout).
Problem
normalizeSwishNumberinpayment.ts:52does not strip a leading+. Ifapp.payment.swish-numberis stored as+46..., the+leaks into theswparam (URL-encoded as%2B), which Swish rejects - the entire Swish payment link breaks.This bug is pre-existing in
payment.ts(not introduced by the guest PR) but is now exercised by the guest flow.Severity
Warning (payment-link generation failure)
Suggested fix
Before the prefix checks, add:
trimmed.replace(/^\+/, '')so the normalized number is always digits only.References
Already fixed on master in commit
573153b(fix(payment): make Swish QR code scannable by the Swish app).The
normalizeSwishNumberfunction inpayment.tsnow strips a leading+via/[\s+]/gbefore any prefix checks, so+46...numbers normalize correctly to46....Verified by the existing test
buildSwishPaymentUrl('+467****4567', 49, 'test')inpayment.spec.ts(8/8 tests pass). The shared helper is used by bothPaymentRedirect.vueandGuestPaymentRedirect.vue, so both auth and guest paths are covered.