[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: wallet-core: return pending s
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: wallet-core: return pending status instead of error |
Date: |
Fri, 13 Jan 2023 00:31:59 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new cbf848dd2 wallet-core: return pending status instead of error
cbf848dd2 is described below
commit cbf848dd2a1b24bb30ab10155c235c13edea575d
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Jan 13 00:31:29 2023 +0100
wallet-core: return pending status instead of error
This allows clients to get the transaction ID of the confirmed payment.
---
.../src/integrationtests/test-denom-unoffered.ts | 27 +++++++++++-----------
.../src/operations/pay-merchant.ts | 27 ++++------------------
2 files changed, 18 insertions(+), 36 deletions(-)
diff --git
a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
index b5ecbee4a..5b3aec551 100644
--- a/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
+++ b/packages/taler-harness/src/integrationtests/test-denom-unoffered.ts
@@ -18,7 +18,7 @@
* Imports.
*/
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
-import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
+import { Wallet, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { GlobalTestState, MerchantPrivateApi } from "../harness/harness.js";
import {
createSimpleTestkudosEnvironment,
@@ -55,7 +55,6 @@ export async function runDenomUnofferedTest(t:
GlobalTestState) {
fulfillment_url: "taler://fulfillment-success/thx",
};
- {
const orderResp = await MerchantPrivateApi.createOrder(
merchant,
"default",
@@ -86,34 +85,34 @@ export async function runDenomUnofferedTest(t:
GlobalTestState) {
preparePayResult.status === PreparePayResultType.PaymentPossible,
);
- const exc = await t.assertThrowsTalerErrorAsync(async () => {
- await wallet.client.call(WalletApiOperation.ConfirmPay, {
- proposalId: preparePayResult.proposalId,
- });
+ const confirmResp = await
wallet.client.call(WalletApiOperation.ConfirmPay, {
+ proposalId: preparePayResult.proposalId,
+ });
+
+ const tx = await wallet.client.call(WalletApiOperation.GetTransactionById,
{
+ transactionId: confirmResp.transactionId,
});
t.assertTrue(
- exc.hasErrorCode(TalerErrorCode.WALLET_PENDING_OPERATION_FAILED),
+ tx.error?.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR
);
- // FIXME: We might want a more specific error code here!
- t.assertDeepEqual(
- exc.errorDetail.innerError.code,
- TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR,
- );
- const merchantErrorCode = (exc.errorDetail.innerError.errorResponse as any)
+ const merchantErrorCode = ((tx.error as any).errorResponse as any)
.code;
t.assertDeepEqual(
merchantErrorCode,
TalerErrorCode.MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND,
);
- }
await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
forceUpdate: true,
});
+ await wallet.client.call(WalletApiOperation.DeleteTransaction, {
+ transactionId: confirmResp.transactionId,
+ });
+
// Now withdrawal should work again.
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:20" });
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");
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: wallet-core: return pending status instead of error,
gnunet <=