From cbf848dd2a1b24bb30ab10155c235c13edea575d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 13 Jan 2023 00:31:29 +0100 Subject: wallet-core: return pending status instead of error This allows clients to get the transaction ID of the confirmed payment. --- .../src/operations/pay-merchant.ts | 27 ++++------------------ 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index cb17f16eb..83c6b74d3 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -1625,28 +1625,11 @@ export async function runPayForConfirmPay( .runReadOnly(async (tx) => tx.operationRetries.get(RetryTags.byPaymentProposalId(proposalId)), ); - const maxRetry = 3; - const numRetry = opRetry?.retryInfo.retryCounter ?? 0; - if ( - res.errorDetail.code === - TalerErrorCode.WALLET_PAY_MERCHANT_SERVER_ERROR && - numRetry < maxRetry - ) { - logger.trace("hiding transient error from caller"); - // Pretend the operation is pending instead of reporting - // an error, but only up to maxRetry attempts. - await storeOperationPending( - ws, - RetryTags.byPaymentProposalId(proposalId), - ); - return { - type: ConfirmPayResultType.Pending, - lastError: opRetry?.lastError, - transactionId: makeTransactionId(TransactionType.Payment, proposalId), - }; - } else { - throw Error("payment failed"); - } + return { + type: ConfirmPayResultType.Pending, + lastError: opRetry?.lastError, + transactionId: makeTransactionId(TransactionType.Payment, proposalId), + }; } case OperationAttemptResultType.Pending: logger.trace("reporting pending as confirmPay response"); -- cgit v1.2.3