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 | 29 |
1 files changed, 16 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 dce2a30ed..0097f5bcc 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -532,21 +532,23 @@ async function processDownloadProposal( h: contractTermsHash, contractTermsRaw: proposalResp.contract_terms, }); - if ( + const isResourceFulfillmentUrl = fulfillmentUrl && (fulfillmentUrl.startsWith("http://") || - fulfillmentUrl.startsWith("https://")) - ) { - const differentPurchase = - await tx.purchases.indexes.byFulfillmentUrl.get(fulfillmentUrl); - // FIXME: Adjust this to account for refunds, don't count as repurchase - // if original order is refunded. - if (differentPurchase) { - logger.warn("repurchase detected"); - p.purchaseStatus = PurchaseStatus.RepurchaseDetected; - p.repurchaseProposalId = differentPurchase.proposalId; - await tx.purchases.put(p); - } + fulfillmentUrl.startsWith("https://")); + let otherPurchase: PurchaseRecord | undefined; + if (isResourceFulfillmentUrl) { + otherPurchase = await tx.purchases.indexes.byFulfillmentUrl.get( + fulfillmentUrl, + ); + } + // FIXME: Adjust this to account for refunds, don't count as repurchase + // if original order is refunded. + if (otherPurchase) { + logger.warn("repurchase detected"); + p.purchaseStatus = PurchaseStatus.RepurchaseDetected; + p.repurchaseProposalId = otherPurchase.proposalId; + await tx.purchases.put(p); } else { p.purchaseStatus = PurchaseStatus.DialogProposed; await tx.purchases.put(p); @@ -602,6 +604,7 @@ async function createPurchase( (!noncePriv || oldProposal.noncePriv === noncePriv) && oldProposal.claimToken === claimToken ) { + // FIXME: This lacks proper error handling await processDownloadProposal(ws, oldProposal.proposalId); return oldProposal.proposalId; } |