taler-typescript-core

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

commit 261f43eae8b53d4d5290d922f5b6ca50b96af3b4
parent 8d1c1482e0714f31c1c0f0e04ee9c053e00ecccc
Author: Florian Dold <florian@dold.me>
Date:   Sat,  2 Aug 2025 11:44:12 +0200

wallet-core: fix matching of existing purchase transactions

Should fix https://bugs.taler.net/9966

Diffstat:
Mpackages/taler-util/src/taleruri.ts | 4++++
Mpackages/taler-wallet-core/src/pay-merchant.ts | 12+++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts @@ -72,6 +72,10 @@ export interface PayUriResult { orderId: string; sessionId: string; claimToken?: string; + /** + * Nonce priv, only present in the + * "continue on mobile" payment flow. + */ noncePriv?: string; } diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -1427,11 +1427,21 @@ async function createOrReusePurchase( }, ); - const oldProposal = oldProposals.find((p) => { + if (oldProposals.length > 1) { + logger.error( + "BUG: more than one existing purchase transaction for same order ID and merchant base URL, this should never happen", + ); + } + + let oldProposal = oldProposals.find((p) => { return ( (!noncePriv || p.noncePriv === noncePriv) && p.claimToken === claimToken ); }); + if (!oldProposal && oldProposals.length > 0) { + // Should never happen, except for backwards compat. + oldProposal = oldProposals[0]; + } // If we have already claimed this proposal with the same // nonce and claim token, reuse it. if (oldProposal) {