diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-merchant.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index e258a0994..2580c97f5 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -539,7 +539,7 @@ async function processDownloadProposal( } // FIXME: Adjust this to account for refunds, don't count as repurchase // if original order is refunded. - if (otherPurchase) { + if (otherPurchase && otherPurchase.refundAmountAwaiting === undefined) { logger.warn("repurchase detected"); p.purchaseStatus = PurchaseStatus.RepurchaseDetected; p.repurchaseProposalId = otherPurchase.proposalId; @@ -976,17 +976,16 @@ export async function checkPaymentByProposalId( } if (proposal.purchaseStatus === PurchaseStatus.RepurchaseDetected) { const existingProposalId = proposal.repurchaseProposalId; - if (!existingProposalId) { - throw Error("invalid proposal state"); - } - logger.trace("using existing purchase for same product"); - proposal = await ws.db - .mktx((x) => [x.purchases]) - .runReadOnly(async (tx) => { - return tx.purchases.get(existingProposalId); - }); - if (!proposal) { - throw Error("existing proposal is in wrong state"); + if (existingProposalId) { + logger.trace("using existing purchase for same product"); + const oldProposal = await ws.db + .mktx((x) => [x.purchases]) + .runReadOnly(async (tx) => { + return tx.purchases.get(existingProposalId); + }); + if (oldProposal) { + proposal = oldProposal; + } } } const d = await expectProposalDownload(ws, proposal); |