taler-typescript-core

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

commit 6257e84ab59fbeb409ac74585b2fec6e6e9256f5
parent ac3a62fde6bae894ed842b1b013b134f8727737d
Author: Florian Dold <dold@taler.net>
Date:   Tue, 28 Jul 2026 19:56:54 +0200

wallet-core: use a proper error code when a refund URI has no purchase

Scanning a refund QR code for an order bought with a different wallet threw a
bare Error, which reached clients as WALLET_UNEXPECTED_EXCEPTION with a stack
trace and was indistinguishable from an internal failure.

Issue: https://bugs.taler.net/n/10692

Diffstat:
Mpackages/taler-wallet-core/src/pay-merchant.ts | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -4263,10 +4263,17 @@ export async function startRefundQueryForUri( ); }); if (!purchaseRecord) { - logger.error( - `no purchase for order ID "${parsedUri.orderId}" from merchant "${parsedUri.merchantBaseUrl}" when processing "${talerUri}"`, + // Scanning a refund QR code for an order that was paid with a different + // wallet is a normal user mistake, so the caller must be able to tell it + // apart from an internal failure. + throw TalerError.fromDetail( + TalerErrorCode.WALLET_PURCHASE_NOT_FOUND, + { + merchantBaseUrl: parsedUri.merchantBaseUrl, + orderId: parsedUri.orderId, + }, + "no purchase found for the refund", ); - throw Error("no purchase found, can't refund"); } const proposalId = purchaseRecord.proposalId; const transactionId = constructTransactionIdentifier({