diff options
author | Sebastian <sebasjm@gmail.com> | 2024-04-12 15:50:03 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-04-12 15:50:03 -0300 |
commit | 2cfd76e76a837be511c668fa1f22564cb86c7990 (patch) | |
tree | 7d3f08f182b9529f2188ec1ffa0d5f7498e24865 /packages/bank-ui | |
parent | 9b0aef33399afa664646715eb4286e3bc0e38fdc (diff) | |
download | wallet-core-2cfd76e76a837be511c668fa1f22564cb86c7990.tar.xz |
fix #8093
Diffstat (limited to 'packages/bank-ui')
-rw-r--r-- | packages/bank-ui/src/pages/PaytoWireTransferForm.tsx | 28 | ||||
-rw-r--r-- | packages/bank-ui/src/pages/SolveChallengePage.tsx | 3 |
2 files changed, 24 insertions, 7 deletions
diff --git a/packages/bank-ui/src/pages/PaytoWireTransferForm.tsx b/packages/bank-ui/src/pages/PaytoWireTransferForm.tsx index 41956b84b..a3bb091c1 100644 --- a/packages/bank-ui/src/pages/PaytoWireTransferForm.tsx +++ b/packages/bank-ui/src/pages/PaytoWireTransferForm.tsx @@ -24,28 +24,30 @@ import { HttpStatusCode, PaytoString, PaytoUri, + TalerCorebankApi, TalerErrorCode, TranslatedString, assertUnreachable, buildPayto, parsePaytoUri, - stringifyPaytoUri, + stringifyPaytoUri } from "@gnu-taler/taler-util"; import { InternationalizationAPI, LocalNotificationBanner, + RouteDefinition, ShowInputErrorLabel, notifyInfo, + useBankCoreApiContext, useLocalNotification, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { ComponentChildren, Fragment, Ref, VNode, h } from "preact"; import { useState } from "preact/hooks"; import { mutate } from "swr"; -import { useBankCoreApiContext } from "@gnu-taler/web-util/browser"; +import { IdempotencyRetry } from "../../../taler-util/lib/http-client/utils.js"; import { useBankState } from "../hooks/bank-state.js"; import { useSessionState } from "../hooks/session.js"; -import { RouteDefinition } from "@gnu-taler/web-util/browser"; import { undefinedIfEmpty, validateIBAN, validateTalerBank } from "../utils.js"; interface Props { @@ -182,12 +184,17 @@ export function PaytoWireTransferForm({ const puri = payto_uri; const sAmount = sendingAmount; - await handleError(async () => { - const request = { + await handleError(async function createTransactionHandleError() { + const request: TalerCorebankApi.CreateTransactionRequest = { payto_uri: puri, amount: sAmount, }; - const resp = await api.createTransaction(credentials, request); + const check = IdempotencyRetry.tryFiveTimes(); + const resp = await api.createTransaction( + credentials, + request, + check, + ); mutate(() => true); if (resp.type === "fail") { switch (resp.case) { @@ -249,6 +256,15 @@ export function PaytoWireTransferForm({ debug: resp.detail, when: AbsoluteTime.now(), }); + case TalerErrorCode.BANK_TRANSFER_REQUEST_UID_REUSED: { + return notify({ + type: "error", + title: i18n.str`Tried to create the transaction ${check.maxTries} times with different UID but failed.`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + when: AbsoluteTime.now(), + }); + } case HttpStatusCode.Accepted: { updateBankState("currentChallenge", { operation: "create-transaction", diff --git a/packages/bank-ui/src/pages/SolveChallengePage.tsx b/packages/bank-ui/src/pages/SolveChallengePage.tsx index eae5bfb5f..624890468 100644 --- a/packages/bank-ui/src/pages/SolveChallengePage.tsx +++ b/packages/bank-ui/src/pages/SolveChallengePage.tsx @@ -48,6 +48,7 @@ import { RouteDefinition } from "@gnu-taler/web-util/browser"; import { undefinedIfEmpty } from "../utils.js"; import { RenderAmount } from "./PaytoWireTransferForm.js"; import { OperationNotFound } from "./WithdrawalQRCode.js"; +import { IdempotencyRetry } from "../../../taler-util/lib/http-client/utils.js"; const TAN_PREFIX = "T-"; const TAN_REGEX = /^([Tt](-)?)?[0-9]*$/; @@ -205,7 +206,7 @@ export function SolveChallengePage({ case "update-password": return await api.updatePassword(creds, ch.request, ch.id); case "create-transaction": - return await api.createTransaction(creds, ch.request, ch.id); + return await api.createTransaction(creds, ch.request, undefined, ch.id); case "confirm-withdrawal": return await api.confirmWithdrawalById(creds, ch.request, ch.id); case "create-cashout": |