diff options
author | Sebastian <sebasjm@gmail.com> | 2023-06-05 10:58:24 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-06-05 10:58:24 -0300 |
commit | 75fdf6137fb465d6c6c72b997bc899459f3de66e (patch) | |
tree | a239d9f0f0599a96f789b24173820f077f254b8b | |
parent | 16900104b57036ceb4eac61891d9ff5679b4737a (diff) | |
download | wallet-core-75fdf6137fb465d6c6c72b997bc899459f3de66e.tar.xz |
move kycurl to commons, make webex aware
3 files changed, 50 insertions, 57 deletions
diff --git a/packages/taler-util/src/transactions-types.ts b/packages/taler-util/src/transactions-types.ts index 82d847e80..3f3fe8ac0 100644 --- a/packages/taler-util/src/transactions-types.ts +++ b/packages/taler-util/src/transactions-types.ts @@ -50,7 +50,6 @@ import { TransactionIdStr, } from "./wallet-types.js"; - export interface TransactionsRequest { /** * return only transactions in the given currency @@ -174,6 +173,12 @@ export interface TransactionCommon { amountEffective: AmountString; error?: TalerErrorDetail; + + /** + * If the transaction minor state is in KycRequired this field is going to + * have the location where the user need to go to complete KYC information. + */ + kycUrl?: string; } export type Transaction = @@ -282,13 +287,13 @@ export interface TransactionWithdrawal extends TransactionCommon { /** * Internal withdrawal operation, only reported on request. - * + * * Some transactions (peer-*-credit) internally do a withdrawal, * but only the peer-*-credit transaction is reported. - * + * * The internal withdrawal transaction allows to access the details of * the underlying withdrawal for testing/debugging. - * + * * It is usually not reported, so that amounts of transactions properly * add up, since the amountEffecive of the withdrawal is already reported * in the peer-*-credit transaction. @@ -345,8 +350,6 @@ export interface TransactionPeerPullCredit extends TransactionCommon { * URI to send to the other party. */ talerUri: string; - - kycUrl: string | undefined; } /** @@ -415,8 +418,6 @@ export interface TransactionPeerPushCredit extends TransactionCommon { * Amount that actually was (or will be) added to the wallet's balance. */ amountEffective: AmountString; - - kycUrl: string | undefined; } export enum PaymentStatus { diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx index 046757ab0..ecea4afd0 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx @@ -232,14 +232,6 @@ const transactionError = { message: "Unexpected error code in response", }; -const kycError = { - code: 7025, - hint: "KYC check required for withdrawal", - kycUrl: - "http://localhost:6666/oauth/v2/login?client_id=taler-exchange&redirect_uri=http%3A%2F%2Flocalhost%3A8081%2F%2Fkyc-proof%2F59WFS5VXXY3CEE25BM45XPB7ZCDQZNZ46PJCMNXK05P65T9M1X90%2FKYC-PROVIDER-MYPROV%2F1", - when: AbsoluteTime.now(), -}; - export const Withdraw = tests.createExample(TestedComponent, { transaction: exampleData.withdraw, }); @@ -285,21 +277,10 @@ export const WithdrawErrorKYC = tests.createExample(TestedComponent, { major: TransactionMajorState.Pending, minor: TransactionMinorState.KycRequired, }, - - // error: kycError, + kycUrl: + "http://localhost:6666/oauth/v2/login?client_id=taler-exchange&redirect_uri=http%3A%2F%2Flocalhost%3A8081%2F%2Fkyc-proof%2F59WFS5VXXY3CEE25BM45XPB7ZCDQZNZ46PJCMNXK05P65T9M1X90%2FKYC-PROVIDER-MYPROV%2F1", }, }); -// export const WithdrawErrorInDevMode = tests.createExampleInCustomContext( -// TestedComponent, -// { -// transaction: { -// ...exampleData.withdraw, -// error: transactionError, -// }, -// }, -// DevContextProviderForTesting, -// { value: true }, -// ); export const WithdrawPendingManual = tests.createExample( TestedComponent, diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index d198893cd..f5ffe4221 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -25,12 +25,14 @@ import { parsePaytoUri, PaytoUri, stringifyPaytoUri, + TalerErrorCode, TalerPreciseTimestamp, TalerProtocolTimestamp, Transaction, TransactionDeposit, TransactionIdStr, TransactionMajorState, + TransactionMinorState, TransactionType, TranslatedString, WithdrawalType, @@ -259,35 +261,44 @@ function TransactionTemplate({ return ( <Fragment> <section style={{ padding: 8, textAlign: "center" }}> - {transaction?.error ? ( - transaction.error.code === 7025 ? ( - <AlertView - alert={{ - type: "warning", - message: i18n.str`KYC check required for the transaction to complete`, - description: - transaction.error.kycUrl && - typeof transaction.error.kycUrl === "string" ? ( - <div> - <i18n.Translate> - Follow this link to the{` `} - <a href={transaction.error.kycUrl}>KYC verifier</a> - </i18n.Translate> - </div> - ) : ( - i18n.str`No more information has been provided` - ), - }} - /> - ) : ( - <ErrorAlertView - error={alertFromError( - i18n.str`There was an error trying to complete the transaction`, - transaction.error, - )} - /> - ) + {transaction?.error && + // FIXME: wallet core should stop sending this error on KYC + transaction.error.code !== + TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED ? ( + <ErrorAlertView + error={alertFromError( + i18n.str`There was an error trying to complete the transaction`, + transaction.error, + )} + /> ) : undefined} + {transaction.txState.minor === TransactionMinorState.KycRequired && ( + <AlertView + alert={{ + type: "warning", + message: i18n.str`KYC check required for the transaction to complete`, + description: + transaction.kycUrl && typeof transaction.kycUrl === "string" ? ( + <div> + <i18n.Translate> + Follow this link to the{` `} + <a href={transaction.kycUrl}>KYC verifier</a> + </i18n.Translate> + </div> + ) : ( + i18n.str`No more information has been provided` + ), + }} + /> + )} + {transaction.txState.minor === TransactionMinorState.AmlRequired && ( + <WarningBox> + <i18n.Translate> + The transaction has been blocked since the account required an AML + check + </i18n.Translate> + </WarningBox> + )} {transaction.txState.major === TransactionMajorState.Pending && ( <WarningBox> <i18n.Translate>This transaction is not completed</i18n.Translate> |