From dcddc4c53a59b087c5e48b6b20ed740514257bc8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 25 Nov 2022 12:18:52 -0300 Subject: revert the Lost payment result --- .../src/operations/backup/index.ts | 21 ++++++++------------- .../src/operations/pay-merchant.ts | 5 +---- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'packages/taler-wallet-core') diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts b/packages/taler-wallet-core/src/operations/backup/index.ts index eef838b0c..a44e8f55a 100644 --- a/packages/taler-wallet-core/src/operations/backup/index.ts +++ b/packages/taler-wallet-core/src/operations/backup/index.ts @@ -368,10 +368,7 @@ async function runBackupCycleForProvider( } } - if ( - res === undefined || - res.status === PreparePayResultType.AlreadyConfirmed - ) { + if (res === undefined) { //claimed await ws.db @@ -400,10 +397,6 @@ async function runBackupCycleForProvider( } const result = res; - if (result.status === PreparePayResultType.Lost) { - throw Error("invalid state, could not get proposal for backup"); - } - await ws.db .mktx((x) => [x.backupProviders, x.operationRetries]) .runReadWrite(async (tx) => { @@ -890,7 +883,13 @@ async function getProviderPaymentInfo( const status = await checkPaymentByProposalId( ws, provider.currentPaymentProposalId, - ); + ).catch(() => undefined); + + if (!status) { + return { + type: ProviderPaymentType.Unpaid, + }; + } switch (status.status) { case PreparePayResultType.InsufficientBalance: @@ -903,10 +902,6 @@ async function getProviderPaymentInfo( type: ProviderPaymentType.Pending, talerUri: status.talerUri, }; - case PreparePayResultType.Lost: - return { - type: ProviderPaymentType.Unpaid, - }; case PreparePayResultType.AlreadyConfirmed: if (status.paid) { return { diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index d3d0a12bd..ed7f17a18 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -1291,10 +1291,7 @@ export async function checkPaymentByProposalId( return tx.purchases.get(proposalId); }); if (!proposal) { - // throw Error(`could not get proposal ${proposalId}`); - return { - status: PreparePayResultType.Lost, - }; + throw Error(`could not get proposal ${proposalId}`); } if (proposal.purchaseStatus === PurchaseStatus.RepurchaseDetected) { const existingProposalId = proposal.repurchaseProposalId; -- cgit v1.2.3