diff options
author | Sebastian <sebasjm@gmail.com> | 2023-07-10 14:08:05 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-07-10 14:09:18 -0300 |
commit | d759f08225a85858b0de7d98b5c50d410360ee8d (patch) | |
tree | 26c26c3d73922cd3d52a8a9a25fe3c4396fcb526 | |
parent | 742b00028eb9cffcc013e1b126aae2fe7cefe8f6 (diff) | |
download | wallet-core-d759f08225a85858b0de7d98b5c50d410360ee8d.tar.xz |
repurchase detection
- check that the old transaction is not refunded
- if the old purchase was deleted fallback to no-repurchase detected
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 23 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/Transaction.tsx | 2 |
2 files changed, 12 insertions, 13 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); diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index e164a28c5..8d564a275 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -1497,7 +1497,7 @@ export function PurchaseDetails({ {Amounts.isNonZero(price.fee) && ( <tr> <td> - <i18n.Translate>Transaction fees</i18n.Translate> + <i18n.Translate>Fees</i18n.Translate> </td> <td> <Amount value={price.fee} /> |