taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 9ff4c77cfd93c13a35eb149e945fd96d5f80e6e5
parent 66ad8e8f38c4270995067c2f850eac3b38337ce7
Author: Florian Dold <florian@dold.me>
Date:   Sat, 19 Apr 2025 17:08:12 +0200

util: filter QR codes for CH/EU

Diffstat:
Mpackages/taler-util/src/qr.ts | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/packages/taler-util/src/qr.ts b/packages/taler-util/src/qr.ts @@ -39,7 +39,11 @@ function encodePaytoAsSwissQrBill(paytoUri: string): EncodeResult { } const targetPathParts = parsedPayto.targetPath.split("/"); const beneficiaryIban = targetPathParts[targetPathParts.length - 1]; - const countryCode = beneficiaryIban.slice(0, 2); + const countryCode = beneficiaryIban.slice(0, 2).toUpperCase(); + if (countryCode !== "CH") { + // We only show the Swiss payment QR code for Swiss IBANs + return { type: "skip" }; + } const lines = [ "SPC", // QRType "0200", // Version @@ -102,6 +106,12 @@ function encodePaytoAsEpcQr(paytoUri: string): EncodeResult { const amountStr = parsedPayto.params["amount"]; const targetPathParts = parsedPayto.targetPath.split("/"); const beneficiaryIban = targetPathParts[targetPathParts.length - 1]; + const countryCode = beneficiaryIban.slice(0, 2).toUpperCase(); + switch (countryCode) { + case "CH": + // Switzerland has its own QR code, do not generate EPC. + return { type: "skip" }; + } const amt = amountStr !== undefined ? `${Amounts.currencyOf(amountStr)}${Amounts.stringifyValue(