aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-06-03 13:11:07 -0300
committerSebastian <sebasjm@gmail.com>2024-06-03 13:11:07 -0300
commitaac3878f5915d4742d253ad13b076a20f011e403 (patch)
tree54938dc4300eab5146fef17e7ca82fa7e59f5f75 /packages
parent228324bb4411515675930e68eece2045dcafe12a (diff)
downloadwallet-core-aac3878f5915d4742d253ad13b076a20f011e403.tar.xz
check account info match
Diffstat (limited to 'packages')
-rw-r--r--packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx35
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx1
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx36
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx2
-rw-r--r--packages/web-util/src/components/CopyButton.tsx2
5 files changed, 33 insertions, 43 deletions
diff --git a/packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx b/packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx
index 3fc4fcbf1..994850b75 100644
--- a/packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx
+++ b/packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx
@@ -221,6 +221,10 @@ export function InputPaytoForm<T>({
const nv = parsePaytoUri(initialValueStr ?? "");
const paths = !initialPayto ? [] : initialPayto.targetPath.split("/");
if (nv !== undefined && nv.isKnown) {
+ if (nv.targetType === "iban" && paths.length >= 2) {
+ //FIXME: workaround EBIC not supported
+ paths[0] = paths[1]
+ }
setValue({
target: nv.targetType,
params: nv.params,
@@ -279,37 +283,6 @@ export function InputPaytoForm<T>({
onChange(str as any);
}, [str]);
- // const submit = useCallback((): void => {
- // // const accounts: TalerMerchantApi.AccountAddDetails[] = paytos;
- // // const alreadyExists =
- // // accounts.findIndex((x) => x.payto_uri === paytoURL) !== -1;
- // // if (!alreadyExists) {
- // const newValue: TalerMerchantApi.AccountAddDetails = {
- // payto_uri: paytoURL,
- // };
- // if (value.auth) {
- // if (value.auth.url) {
- // newValue.credit_facade_url = value.auth.url;
- // }
- // if (value.auth.type === "none") {
- // newValue.credit_facade_credentials = {
- // type: "none",
- // };
- // }
- // if (value.auth.type === "basic") {
- // newValue.credit_facade_credentials = {
- // type: "basic",
- // username: value.auth.username ?? "",
- // password: value.auth.password ?? "",
- // };
- // }
- // }
- // onChange(newValue as any);
- // // }
- // // valueHandler(defaultTarget);
- // }, [value]);
-
- //FIXME: translating plural singular
return (
<InputGroup name="payto" label={label} fixed tooltip={tooltip}>
<FormProvider<Entity>
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;
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
index d1a0c9ba4..fb6819b5b 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
@@ -94,7 +94,7 @@ export default function UpdateValidator({
message: i18n.str`Could not create account`,
type: "ERROR",
description: i18n.str`The request to check the revenue API failed.`,
- details: resp.errorDetail
+ details: JSON.stringify(resp.errorDetail, undefined, 2),
});
return;
}
diff --git a/packages/web-util/src/components/CopyButton.tsx b/packages/web-util/src/components/CopyButton.tsx
index 3ca3e4078..4351da018 100644
--- a/packages/web-util/src/components/CopyButton.tsx
+++ b/packages/web-util/src/components/CopyButton.tsx
@@ -21,7 +21,7 @@ export function CopyButton({ class: clazz, children, getContent }: { children?:
const [copied, setCopied] = useState(false);
function copyText(): void {
if (!navigator.clipboard && !window.isSecureContext) {
- alert(`clipboard is not available on insecure context (http), the content is:\n${getContent()}`)
+ prompt("Clipboard is not available on insecure context (http).", getContent());
}
if (navigator.clipboard) {
navigator.clipboard.writeText(getContent() || "");