diff options
author | Sebastian <sebasjm@gmail.com> | 2024-06-03 13:11:07 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-06-03 13:11:07 -0300 |
commit | aac3878f5915d4742d253ad13b076a20f011e403 (patch) | |
tree | 54938dc4300eab5146fef17e7ca82fa7e59f5f75 /packages/merchant-backoffice-ui/src/paths/instance/accounts/create | |
parent | 228324bb4411515675930e68eece2045dcafe12a (diff) | |
download | wallet-core-aac3878f5915d4742d253ad13b076a20f011e403.tar.xz |
check account info match
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/accounts/create')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx | 1 | ||||
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx | 36 |
2 files changed, 27 insertions, 10 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx index 63ed01565..d0e7a83cd 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx @@ -117,7 +117,6 @@ export function CreatePage({ onCreate, onBack }: Props): VNode { credit_facade_url, }); }; - // {"accountURI":"payto://x-taler-bank/bank-fir.taler.test:1180/sebasjm?receiver-name=Sebastian%20Javier","infoURL":"http://sebasjm:secret-token%3AM4XNDC6HMD0Z3N3S74G5W64H3PNM4XCYHE0CHQE7DG29GAH2NYMG@bank-fir.taler.test:1180/accounts/sebasjm/taler-revenue/"} return ( <div> {importing && <ImportingAccountModal onCancel={()=> {setImporting(false)}} onConfirm={(ac) => { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx index 4849d1d6c..aa1481a2e 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx @@ -24,6 +24,7 @@ import { HttpStatusCode, OperationFail, OperationOk, + PaytoString, TalerError, TalerMerchantApi, TalerRevenueHttpClient, @@ -67,10 +68,11 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { const resp = await testRevenueAPI( revenueAPI, request.credit_facade_credentials, + request.payto_uri, ); if (resp instanceof TalerError) { setNotif({ - message: i18n.str`Could not create account`, + message: i18n.str`Could not add bank account`, type: "ERROR", description: i18n.str`The request to check the revenue API failed.`, details: JSON.stringify(resp.errorDetail, undefined, 2), @@ -81,7 +83,7 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { switch (resp.case) { case HttpStatusCode.BadRequest: { setNotif({ - message: i18n.str`Could not create account`, + message: i18n.str`Could not add bank account`, type: "ERROR", description: i18n.str`Server replied with "bad request".`, }); @@ -90,7 +92,7 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { } case HttpStatusCode.Unauthorized: { setNotif({ - message: i18n.str`Could not create account`, + message: i18n.str`Could not add bank account`, type: "ERROR", description: i18n.str`Unauthorized, try with another credentials.`, }); @@ -99,12 +101,20 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { } case HttpStatusCode.NotFound: { setNotif({ - message: i18n.str`Could not create account`, + message: i18n.str`Could not add bank account`, type: "ERROR", description: i18n.str`The endpoint doesn't seems to be a Taler Revenue API`, }); return; } + case TestRevenueErrorType.ANOTHER_ACCOUNT: { + setNotif({ + message: i18n.str`Could not add bank account`, + type: "ERROR", + description: i18n.str`The account info URL returned information from an account which is not the same in the account form: ${resp.detail.hint}`, + }); + return; + } default: { assertUnreachable(resp); } @@ -131,19 +141,17 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { } export enum TestRevenueErrorType { - NO_CONFIG, - CLIENT_BAD_REQUEST, - UNAUTHORIZED, - NOT_FOUND, - GENERIC_ERROR, + ANOTHER_ACCOUNT, } export async function testRevenueAPI( revenueAPI: URL, creds: FacadeCredentials | undefined, + account: PaytoString, ): Promise<OperationOk<void> | OperationFail<HttpStatusCode.NotFound> | OperationFail<HttpStatusCode.Unauthorized> | OperationFail<HttpStatusCode.BadRequest> +| OperationFail<TestRevenueErrorType.ANOTHER_ACCOUNT> | TalerError> { const api = new TalerRevenueHttpClient( revenueAPI.href, @@ -173,6 +181,16 @@ export async function testRevenueAPI( if (history.type === "fail") { return history; } + if (history.body.credit_account !== account) { + return { + type: "fail", + case: TestRevenueErrorType.ANOTHER_ACCOUNT, + detail: { + code: 1, + hint: history.body.credit_account + }, + }; + } } catch (err) { if (err instanceof TalerError) { return err; |