diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-06 00:56:31 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-06 00:56:31 +0100 |
commit | c8c84911ce4f69900ffbbf5accff827c78d9e13b (patch) | |
tree | f47d7e020c2bf64673ae2afa1652d18a0075bab9 /src/wallet-impl/pay.ts | |
parent | 65bccbd139c53a2baccec442a680373125488102 (diff) | |
download | wallet-core-c8c84911ce4f69900ffbbf5accff827c78d9e13b.tar.xz |
fix re-purchase detection
Diffstat (limited to 'src/wallet-impl/pay.ts')
-rw-r--r-- | src/wallet-impl/pay.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wallet-impl/pay.ts b/src/wallet-impl/pay.ts index cec1b6bc5..1375a22ca 100644 --- a/src/wallet-impl/pay.ts +++ b/src/wallet-impl/pay.ts @@ -593,6 +593,7 @@ async function processDownloadProposalImpl( fulfillmentUrl, ); if (differentPurchase) { + console.log("repurchase detected"); p.proposalStatus = ProposalStatus.REPURCHASE; p.repurchaseProposalId = differentPurchase.proposalId; await tx.put(Stores.proposals, p); @@ -756,7 +757,7 @@ export async function preparePay( }; } - const proposalId = await startDownloadProposal( + let proposalId = await startDownloadProposal( ws, uriResult.downloadUrl, uriResult.sessionId, @@ -771,6 +772,7 @@ export async function preparePay( if (!existingProposalId) { throw Error("invalid proposal state"); } + console.log("using existing purchase for same product"); proposal = await oneShotGet(ws.db, Stores.proposals, existingProposalId); if (!proposal) { throw Error("existing proposal is in wrong state"); @@ -787,7 +789,7 @@ export async function preparePay( throw Error("BUG: proposal is in invalid state"); } - console.log("proposal", proposal); + proposalId = proposal.proposalId; // First check if we already payed for it. const purchase = await oneShotGet(ws.db, Stores.purchases, proposalId); |