diff options
author | Sebastian <sebasjm@gmail.com> | 2024-05-17 17:29:37 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-05-17 17:29:37 -0300 |
commit | 184c3bcd2d7aabbc033b035fda34e86b3df2f98a (patch) | |
tree | 6492e3e865cd555d6fb2b16578c954b2f159b382 /packages/taler-wallet-webextension/src | |
parent | 9381ac6d1031ac16882023c617dc82b53df7a961 (diff) | |
download | wallet-core-184c3bcd2d7aabbc033b035fda34e86b3df2f98a.tar.xz |
fix #8856
Diffstat (limited to 'packages/taler-wallet-webextension/src')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw/state.ts | 30 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw/test.ts | 42 |
2 files changed, 33 insertions, 39 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts index 0b36be1fd..65c000741 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts @@ -16,6 +16,7 @@ import { AmountJson, + AmountString, Amounts, ExchangeFullDetails, ExchangeListItem, @@ -156,6 +157,7 @@ export function useComponentStateFromParams({ async function doManualWithdraw( exchange: string, ageRestricted: number | undefined, + amount: AmountString, ): Promise<{ transactionId: string; confirmTransferUrl: string | undefined; @@ -164,7 +166,7 @@ export function useComponentStateFromParams({ WalletApiOperation.AcceptManualWithdrawal, { exchangeBaseUrl: exchange, - amount: Amounts.stringify(chosenAmount), + amount, restrictAge: ageRestricted, }, ); @@ -203,10 +205,9 @@ export function useComponentStateFromURI({ : maybeTalerUri; const uriInfo = await api.wallet.call( - WalletApiOperation.GetWithdrawalDetailsForUri, + WalletApiOperation.PrepareBankIntegratedWithdrawal, { talerWithdrawUri, - // notifyChangeFromPendingTimeoutMs: 30 * 1000, }, ); const { @@ -216,16 +217,12 @@ export function useComponentStateFromURI({ operationId, confirmTransferUrl, status, - } = uriInfo; - const transaction = await api.wallet.call( - WalletApiOperation.GetWithdrawalTransactionByUri, - { talerWithdrawUri }, - ); + } = uriInfo.info; return { talerWithdrawUri, operationId, status, - transaction, + transactionId: uriInfo.transactionId, confirmTransferUrl, amount: Amounts.parseOrThrow(amount), thisExchange: defaultExchangeBaseUrl, @@ -259,6 +256,7 @@ export function useComponentStateFromURI({ } const uri = uriInfoHook.response.talerWithdrawUri; + const txId = uriInfoHook.response.transactionId; const chosenAmount = uriInfoHook.response.amount; const defaultExchange = uriInfoHook.response.thisExchange; const exchangeList = uriInfoHook.response.exchanges; @@ -266,16 +264,18 @@ export function useComponentStateFromURI({ async function doManagedWithdraw( exchange: string, ageRestricted: number | undefined, + amount: AmountString, ): Promise<{ transactionId: string; confirmTransferUrl: string | undefined; }> { const res = await api.wallet.call( - WalletApiOperation.AcceptBankIntegratedWithdrawal, + WalletApiOperation.ConfirmWithdrawal, { exchangeBaseUrl: exchange, - talerWithdrawUri: uri, + amount, restrictAge: ageRestricted, + transactionId: txId, }, ); return { @@ -285,9 +285,9 @@ export function useComponentStateFromURI({ } if (uriInfoHook.response.status !== "pending") { - if (uriInfoHook.response.transaction) { - onSuccess(uriInfoHook.response.transaction.transactionId); - } + // if (uriInfoHook.response.transactionId) { + // onSuccess(uriInfoHook.response.transactionId); + // } return { status: "already-completed", operationState: uriInfoHook.response.status, @@ -312,6 +312,7 @@ export function useComponentStateFromURI({ type ManualOrManagedWithdrawFunction = ( exchange: string, ageRestricted: number | undefined, + amount: AmountString, ) => Promise<{ transactionId: string; confirmTransferUrl: string | undefined }>; function exchangeSelectionState( @@ -380,6 +381,7 @@ function exchangeSelectionState( const res = await doWithdraw( currentExchange.exchangeBaseUrl, !ageRestricted ? undefined : ageRestricted, + Amounts.stringify(Amounts.zeroOfCurrency(selectedCurrency)), ); if (res.confirmTransferUrl) { document.location.href = res.confirmTransferUrl; diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts index f90f7bed7..70d40ec1c 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts @@ -108,22 +108,18 @@ describe("Withdraw CTA states", () => { }; handler.addWalletCallResponse( - WalletApiOperation.GetWithdrawalDetailsForUri, + WalletApiOperation.PrepareBankIntegratedWithdrawal, undefined, { - status: "pending", - operationId: "123", - amount: "EUR:2" as AmountString, - possibleExchanges: [], + transactionId: "123", + info: { + status: "pending", + operationId: "123", + amount: "EUR:2" as AmountString, + possibleExchanges: [], + } }, ); - handler.addWalletCallResponse( - WalletApiOperation.GetWithdrawalTransactionByUri, - undefined, - { - transactionId: "123" - } as any, - ); const hookBehavior = await tests.hookBehaveLikeThis( useComponentStateFromURI, @@ -153,24 +149,20 @@ describe("Withdraw CTA states", () => { }; handler.addWalletCallResponse( - WalletApiOperation.GetWithdrawalDetailsForUri, + WalletApiOperation.PrepareBankIntegratedWithdrawal, undefined, { - status: "pending", - operationId: "123", - amount: "ARS:2" as AmountString, - possibleExchanges: exchanges, - defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl, + transactionId: "123", + info: { + status: "pending", + operationId: "123", + amount: "ARS:2" as AmountString, + possibleExchanges: exchanges, + defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl, + } }, ); handler.addWalletCallResponse( - WalletApiOperation.GetWithdrawalTransactionByUri, - undefined, - { - transactionId: "123" - } as any, - ); - handler.addWalletCallResponse( WalletApiOperation.GetWithdrawalDetailsForAmount, undefined, { |