@adyen/kyc-components
Version:
This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.
1,161 lines • 181 kB
JavaScript
try {
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "6b2488f3-6fd9-4cdd-8da7-070b970b1878", e._sentryDebugIdIdentifier = "sentry-dbid-6b2488f3-6fd9-4cdd-8da7-070b970b1878");
} catch (e) {}
import { a as Icon, i as Typography, o as createLogger, r as useTranslation, t as Trans } from "./translation-BFxyJ1c5.js";
import { t as Button } from "./Button-oj6H8OrC.js";
import { n as httpGet, r as httpPost, s as useApiContext } from "./http-D1NDkBxF.js";
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js";
import { t as useAccountHolder } from "./useAccountHolder-ClppK4-L.js";
import { t as useSettingsContext } from "./useSettingsContext-DzwVt0W0.js";
import { c as objectsDeepEqual, d as keysOf, r as cloneObject, t as useAnalyticsContext } from "./useAnalyticsContext-BVFDMrVE.js";
import { t as useToggleContext } from "./useToggleContext-DaQUBF8O.js";
import { a as translateTranslatable } from "./utils-B807QaDx.js";
import { d as extractFieldName, m as hasEmptyFields, u as concatenateFieldNames, v as isAccountIdentifierObscured, y as isEmpty } from "./validatorUtils-DRapRJ6z.js";
import { t as StackLayout } from "./StackLayout-Bhbj68nx.js";
import { t as Header } from "./Header-CPmJyuoP.js";
import { t as CountryCodes } from "./country-code-CX5KqMBr.js";
import { t as useDataset } from "./useDataset-ZHrWhmsh.js";
import { n as datasetUtilities, t as datasetIdentifier } from "./datasetUtil-Zd4TCTDn.js";
import { t as Alert } from "./Alert-C6gL3JIt.js";
import { n as getCapabilityProblems } from "./processCapabilities-DlZY9-Jc.js";
import { d as hasOwnEntityAssociationOfType, p as TaskTypes } from "./entityAssociationUtil-BEzUdPbm.js";
import { t as EEA_Countries } from "./countries-BuZ6_X95.js";
import { t as Card } from "./Card-vYndix5Y.js";
import { t as SettingNames } from "./types-CNZsK2dZ.js";
import { t as useToastContext } from "./useToastContext-CYgfHjSb.js";
import { t as EndStateLayout } from "./EndStateLayout-ChS-vdMt.js";
import { t as useInvalidateRootLegalEntity } from "./invalidateRootLegalEntity-CZr0iiji.js";
import { t as LoaderWrapper } from "./LoaderWrapper-Dq8TNJCi.js";
import { t as Modal } from "./Modal-CioQJ7Q7.js";
import { t as Confirm } from "./Confirm-B6TWSuab.js";
import { n as FeatureNames, t as ExperimentNames } from "./types-8S6KTD2W.js";
import { t as Image } from "./Image-BEzOZ1tt.js";
import { n as getLegalEntityNameBasedOnType, r as getPayoutAccountHolderName } from "./getName-Bdwp_hkV.js";
import { r as getPropsFromConfigurations, t as augmentWithCountryConfigs } from "./process-field-configurations-C7MuEj5q.js";
import { i as useFormComposer, n as getRequiredForms, t as addValidityToForms } from "./dropinUtils-IdasFZCU.js";
import { t as ErrorPanel } from "./ErrorPanel-B536hgSc.js";
import { t as trackNavigation } from "./trackNavigation-LvCP5Vyc.js";
import { n as mergeFieldMetadataIntoProps, t as createFormUtils } from "./formUtils-DCvL3uZG.js";
import { n as summaryStep } from "./Summary-B5IkOGJV.js";
import { r as summaryItem } from "./summaryItem-Dehjwp8D.js";
import { t as isNotEmptyValidator } from "./commonValidators-DCdet-gH.js";
import { a as useScenarioConfiguration, i as uppercase, o as useUnifyLoadingStatus, r as getPageName, s as payoutAccountFormat, t as mapExistingFile } from "./mapExistingFile-wp3Nf1-m.js";
import { t as useTaskLandedEvent } from "./useTaskLandedEvent-DInxWeqN.js";
import { a as alphanumericInputs, c as nonInputs, i as alphaInputs, l as numericInputs, o as customInputs, s as makeMask, t as MaskedInput, u as spacer } from "./MaskedInput-BFPSwRto.js";
import { a as mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable, i as isValidationError, o as processValidationErrors, r as isIdDocumentUploadError, s as isMaintenanceModeError, t as isBankStatementUploadError } from "./validationError-BzQCrJPn.js";
import { a as StateContextSetter, c as getDocument, i as bytesToSize, n as fileValidationRules, o as createDocumentRequest, r as DropzoneFile, s as documentApiUtils, t as defaultFileValidationOptions, u as getFileExtention } from "./validate-DDKy88ac.js";
import { t as omitObscuredFieldsIfUnchanged } from "./omitObscuredFieldsIfUnchanged-Cx1OCZuB.js";
import { o as validatePatternOnBlur } from "./patternValidators-BaQxw3ki.js";
import { t as bankStatementDescriptionPattern } from "./basePatterns-VqSYMnkh.js";
import { t as resolveFieldMetadata } from "./fieldConfigurations-m7oWP1DZ.js";
import { t as Field } from "./Field-pcJkjIG_.js";
import { t as Select } from "./Select-CcSRI-H0.js";
import { t as TextArea } from "./TextArea-CRLeP4x6.js";
import { t as useForm } from "./useForm-pUkvCLc9.js";
import { n as getFormProps, t as getFieldProps } from "./getProps-CkZCnNxW.js";
import { t as Link } from "./Link-6M1PZnz2.js";
import { t as InputText } from "./InputText-C30dZxS4.js";
import { n as CountryField } from "./CountryField-Dh4DfjBf.js";
import { t as createFormRules } from "./form-rules-ZiRm6ke_.js";
import { t as ContextGuidance } from "./ContextGuidance-DdoORtLt.js";
import { t as Tag } from "./Tag-BhU73i1R.js";
import { n as useTransferInstrument, t as mapTransferInstrumentToPayoutAccount } from "./mapTransferInstrumentToPayoutAccount--CQmg2ha.js";
import { a as useStateContext, i as FormWrapper, n as useGlobalDataSlice, r as useResetGlobalData, t as useGlobalData } from "./useGlobalData-DD00rA9R.js";
import { t as Currencies } from "./currency-CfIDpZh9.js";
import { t as currencyByCountry } from "./types-qnPNJzLh.js";
import { t as useUnincorporatedPartnershipMembers } from "./useUnincorporatedPartnershipMembers-BfE3lulH.js";
import { t as Divider } from "./Divider-DMwncntz.js";
import { lazy, memo, useEffect, useMemo, useRef, useState } from "preact/compat";
import { useCallback as useCallback$1, useContext as useContext$1, useEffect as useEffect$1, useMemo as useMemo$1, useRef as useRef$1, useState as useState$1 } from "preact/hooks";
import cx from "classnames";
import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime";
import { signal } from "@preact/signals";
import { skipToken, useMutation, useQuery, useQueryClient } from "@tanstack/preact-query";
import { createContext as createContext$1 } from "preact";
import { Show } from "@preact/signals/utils";
import OpenBankingSDK from "@adyen/openbankingsdk";
//#region src/api/check/useCheck.ts
var getCheck = async (legalEntityId, baseUrl, data) => {
return httpPost({
baseUrl,
path: `legalEntities/${legalEntityId}/checks/bankAccount`
}, data);
};
/**
*
* @param data CheckAsAService request
* @param options additional options passed to Tanstack Query, eg; refetchInterval for polling
*/
var useCheck = (data, options) => {
const { rootLegalEntityId, baseUrl: url } = useApiContext();
return useQuery({
queryKey: ["checkAsAService", data],
queryFn: () => getCheck(rootLegalEntityId.value, url.value, data),
...options
});
};
//#endregion
//#region src/api/transferInstruments/useBankVerificationProviders.ts
var getBankVerificationProviders = async (legalEntityId, baseUrl, queryParams) => {
const { country, locale, configId } = queryParams;
return httpGet({
baseUrl,
path: `legalEntities/${legalEntityId}/transferInstruments/trusted/providers?${new URLSearchParams({
country,
locale,
...configId && { configId }
})}`
});
};
/**
* Retrieves the list of bank verification providers and their respective urls.
* Bank verification providers are used to instantly verify payout accounts.
* @param queryParams the relevant country, locale, and configId
* @param options additional options passed to Tanstack Query, eg; onSuccess
*/
var useBankVerificationProviders = (queryParams, options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useQuery({
queryKey: ["bankVerificationProviders", queryParams],
queryFn: () => getBankVerificationProviders(rootLegalEntityId.value, baseUrl.value, queryParams),
...options
});
};
//#endregion
//#region src/api/transferInstruments/useCreateTransferInstrument.ts
var createTransferInstrument = async (rootLegalEntityId, baseUrl, transferInstrument) => {
return httpPost({
baseUrl,
path: `legalEntities/${rootLegalEntityId}/transferInstruments`
}, transferInstrument);
};
//#endregion
//#region src/api/transferInstruments/useCreateTrustedTransferInstrument.ts
var createTrustedTransferInstrument = async (legalEntityId, baseUrl, data) => {
return httpPost({
baseUrl,
path: `legalEntities/${legalEntityId}/transferInstruments/trusted`
}, data);
};
/**
* Creates a trusted transfer instrument in LEM using the information provided by Open Banking
* @param options additional options passed to Tanstack Query, eg; onSuccess
*/
var useCreateTrustedTransferInstrument = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useMutation({
mutationFn: (data) => createTrustedTransferInstrument(rootLegalEntityId.value, baseUrl.value, data),
...options
});
};
//#endregion
//#region src/api/transferInstruments/useUpdateTransferInstrument.ts
var updateTransferInstrument = async (legalEntityId, baseUrl, transferInstrument, transferInstrumentId) => {
return httpPost({
baseUrl,
path: `legalEntities/${legalEntityId}/transferInstruments/${transferInstrumentId}`
}, transferInstrument);
};
/**
* Updates a transfer instrument associated with a legal entity
* When update is successful, updates the transfer instrument query and invalidates transfer instruments
* @param options additional options passed to Tanstack Query
*/
var useUpdateTransferInstrument = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ transferInstrument, transferInstrumentId }) => updateTransferInstrument(rootLegalEntityId.value, baseUrl.value, transferInstrument, transferInstrumentId),
onSuccess: async (transferInstrument) => {
queryClient.setQueryData(["transferInstrument", transferInstrument.id], transferInstrument);
await queryClient.invalidateQueries({ queryKey: ["transferInstruments"] });
},
...options
});
};
//#endregion
//#region src/api/transferInstruments/useUpdateTrustedTransferInstrument.ts
var updateTrustedTransferInstrument = async (legalEntityId, baseUrl, preferredCurrencyCode, transferInstrumentId) => {
return httpPost({
baseUrl,
path: `legalEntities/${legalEntityId}/transferInstruments/trusted/${transferInstrumentId}`
}, { preferredCurrencyCode });
};
/**
* Updates a trusted transfer instrument associated with a legal entity
* When update is successful, updates the transfer instrument query and invalidates transfer instruments
* @param options additional options passed to Tanstack Query
*/
var useUpdateTrustedTransferInstrument = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useMutation({
mutationFn: ({ preferredCurrencyCode, transferInstrumentId }) => updateTrustedTransferInstrument(rootLegalEntityId.value, baseUrl.value, preferredCurrencyCode, transferInstrumentId),
...options
});
};
//#endregion
//#region src/datasets/generators/getAccountFormatForCountry.ts
var accountFormatsImports = /* @__PURE__ */ Object.assign({
"../accountFormats/AD.json": () => import("./AD-DB5nr9tP.js"),
"../accountFormats/AE.json": () => import("./AE-CJ7TIjDy.js"),
"../accountFormats/AI.json": () => import("./AI-BQpw7rma.js"),
"../accountFormats/AL.json": () => import("./AL-PjHuPrbQ.js"),
"../accountFormats/AR.json": () => import("./AR-CU2ICtA_.js"),
"../accountFormats/AS.json": () => import("./AS-DfgHV8yp.js"),
"../accountFormats/AT.json": () => import("./AT-CE6zBm8a.js"),
"../accountFormats/AU.json": () => import("./AU-CVPrMt74.js"),
"../accountFormats/AX.json": () => import("./AX-DVfSmWhN.js"),
"../accountFormats/AZ.json": () => import("./AZ-DIcvAsVy.js"),
"../accountFormats/BA.json": () => import("./BA-DFu8JCnF.js"),
"../accountFormats/BE.json": () => import("./BE-pkvQ7-pO.js"),
"../accountFormats/BG.json": () => import("./BG-zaw09oBT.js"),
"../accountFormats/BH.json": () => import("./BH-ByuC-_Cy.js"),
"../accountFormats/BM.json": () => import("./BM-FrOgBeTW.js"),
"../accountFormats/BR.json": () => import("./BR-BEePczcO.js"),
"../accountFormats/BS.json": () => import("./BS-BLCF5IzE.js"),
"../accountFormats/BV.json": () => import("./BV-Ball_EvD.js"),
"../accountFormats/BY.json": () => import("./BY-CYE3ET2j.js"),
"../accountFormats/CA.json": () => import("./CA-DjE9yebq.js"),
"../accountFormats/CH.json": () => import("./CH-B5P_iJIO.js"),
"../accountFormats/CN.json": () => import("./CN-CP7sf7YS.js"),
"../accountFormats/CR.json": () => import("./CR-QbBCoLqW.js"),
"../accountFormats/CY.json": () => import("./CY-C80hVF0V.js"),
"../accountFormats/CZ.json": () => import("./CZ-B4eytKxE.js"),
"../accountFormats/DE.json": () => import("./DE-w2hYM5oM.js"),
"../accountFormats/DK.json": () => import("./DK-BCGM05gZ.js"),
"../accountFormats/DO.json": () => import("./DO-DtMkGZOf.js"),
"../accountFormats/EC.json": () => import("./EC-BXvXPzDj.js"),
"../accountFormats/EE.json": () => import("./EE-CVByoRMi.js"),
"../accountFormats/ES.json": () => import("./ES-CUnZIEd0.js"),
"../accountFormats/FI.json": () => import("./FI-E_ZyfJ7t.js"),
"../accountFormats/FJ.json": () => import("./FJ-dwvq-g41.js"),
"../accountFormats/FO.json": () => import("./FO-CWQ0W1H6.js"),
"../accountFormats/FR.json": () => import("./FR-O_hbmwJW.js"),
"../accountFormats/GB.json": () => import("./GB-nAqfhFIu.js"),
"../accountFormats/GE.json": () => import("./GE-DI1v7mo0.js"),
"../accountFormats/GF.json": () => import("./GF-B610wYeJ.js"),
"../accountFormats/GG.json": () => import("./GG-CilWz47C.js"),
"../accountFormats/GI.json": () => import("./GI-DFtvvGTY.js"),
"../accountFormats/GL.json": () => import("./GL-D36pp53C.js"),
"../accountFormats/GP.json": () => import("./GP-yyCziKB4.js"),
"../accountFormats/GR.json": () => import("./GR-BxzVHYz8.js"),
"../accountFormats/GT.json": () => import("./GT-QLXEWmtP.js"),
"../accountFormats/GU.json": () => import("./GU-jrvpoyb9.js"),
"../accountFormats/HK.json": () => import("./HK-Bds0tONE.js"),
"../accountFormats/HR.json": () => import("./HR-CSBA8yzB.js"),
"../accountFormats/HU.json": () => import("./HU-CzYTCtjV.js"),
"../accountFormats/ID.json": () => import("./ID-Dl7g2Ppa.js"),
"../accountFormats/IE.json": () => import("./IE-CmK-C0yz.js"),
"../accountFormats/IL.json": () => import("./IL-Cfpmk1v7.js"),
"../accountFormats/IM.json": () => import("./IM-C2sXmVTc.js"),
"../accountFormats/IN.json": () => import("./IN-DilwgNAy.js"),
"../accountFormats/IS.json": () => import("./IS-CFtJpGcN.js"),
"../accountFormats/IT.json": () => import("./IT-BlfPdNZf.js"),
"../accountFormats/JE.json": () => import("./JE-X57q_Fdk.js"),
"../accountFormats/JM.json": () => import("./JM-Bx2hppi2.js"),
"../accountFormats/JO.json": () => import("./JO-DhBlXP2F.js"),
"../accountFormats/JP.json": () => import("./JP-UnxSZuO9.js"),
"../accountFormats/KR.json": () => import("./KR-D3U_AtZT.js"),
"../accountFormats/KW.json": () => import("./KW-m7bxO2Xa.js"),
"../accountFormats/KY.json": () => import("./KY-CpUXfGcI.js"),
"../accountFormats/KZ.json": () => import("./KZ-C8RUkmV6.js"),
"../accountFormats/LB.json": () => import("./LB-BRrDvnrf.js"),
"../accountFormats/LI.json": () => import("./LI-BN5PGW_H.js"),
"../accountFormats/LT.json": () => import("./LT-CmyEYM7z.js"),
"../accountFormats/LU.json": () => import("./LU-Bi4L1b9z.js"),
"../accountFormats/LV.json": () => import("./LV-ukOdBuwo.js"),
"../accountFormats/MC.json": () => import("./MC-EQ1jmHjl.js"),
"../accountFormats/MD.json": () => import("./MD-DxAeNcG8.js"),
"../accountFormats/ME.json": () => import("./ME-CvndvtiG.js"),
"../accountFormats/MK.json": () => import("./MK-sohc7De9.js"),
"../accountFormats/MP.json": () => import("./MP-CCltX7ag.js"),
"../accountFormats/MQ.json": () => import("./MQ-DonPA9tN.js"),
"../accountFormats/MR.json": () => import("./MR-Bh6ZCghL.js"),
"../accountFormats/MT.json": () => import("./MT-LIvGhW6j.js"),
"../accountFormats/MU.json": () => import("./MU-kys50fwN.js"),
"../accountFormats/MX.json": () => import("./MX-UvvHVHCC.js"),
"../accountFormats/MY.json": () => import("./MY-B6EJ4miK.js"),
"../accountFormats/NC.json": () => import("./NC-D78ykfoF.js"),
"../accountFormats/NL.json": () => import("./NL-Cq2QKj_R.js"),
"../accountFormats/NO.json": () => import("./NO-Pyh5_V7y.js"),
"../accountFormats/NZ.json": () => import("./NZ-7A0F7nHF.js"),
"../accountFormats/PE.json": () => import("./PE-DHm86V9n.js"),
"../accountFormats/PF.json": () => import("./PF-CPMgKxu3.js"),
"../accountFormats/PH.json": () => import("./PH-B_NakBgs.js"),
"../accountFormats/PK.json": () => import("./PK-CcdXkTsY.js"),
"../accountFormats/PL.json": () => import("./PL-D9Kpjom5.js"),
"../accountFormats/PM.json": () => import("./PM-C-GliGAO.js"),
"../accountFormats/PR.json": () => import("./PR-JCXbpE0b.js"),
"../accountFormats/PS.json": () => import("./PS-D62VdZaN.js"),
"../accountFormats/PT.json": () => import("./PT-D9big47n.js"),
"../accountFormats/QA.json": () => import("./QA-CeWT26tF.js"),
"../accountFormats/RE.json": () => import("./RE-DSGfn_pm.js"),
"../accountFormats/RO.json": () => import("./RO-BX6cRBo0.js"),
"../accountFormats/RS.json": () => import("./RS-B2iIit5I.js"),
"../accountFormats/RU.json": () => import("./RU-dSs63sUC.js"),
"../accountFormats/SA.json": () => import("./SA-D2c21Lvo.js"),
"../accountFormats/SE.json": () => import("./SE-P9xbQO4o.js"),
"../accountFormats/SG.json": () => import("./SG-BgkMHf8k.js"),
"../accountFormats/SI.json": () => import("./SI-BLo3mGXB.js"),
"../accountFormats/SJ.json": () => import("./SJ-yb3-jDZT.js"),
"../accountFormats/SK.json": () => import("./SK-D8pAx-Kv.js"),
"../accountFormats/SM.json": () => import("./SM-BBKV-_UA.js"),
"../accountFormats/TF.json": () => import("./TF-B0dgTCfm.js"),
"../accountFormats/TH.json": () => import("./TH-CmVSlUuX.js"),
"../accountFormats/TL.json": () => import("./TL-nRB_lM2i.js"),
"../accountFormats/TN.json": () => import("./TN-CGwMdeBx.js"),
"../accountFormats/TR.json": () => import("./TR-B-J7KAnx.js"),
"../accountFormats/TT.json": () => import("./TT-Cd6NBPP1.js"),
"../accountFormats/TW.json": () => import("./TW-BQVlyIhq.js"),
"../accountFormats/UA.json": () => import("./UA-BAfANYki.js"),
"../accountFormats/US.json": () => import("./US-DqDIO6Fs.js"),
"../accountFormats/UY.json": () => import("./UY-CqTNFGkq.js"),
"../accountFormats/VA.json": () => import("./VA-BOTo9AUe.js"),
"../accountFormats/VG.json": () => import("./VG-DGXnBmqr.js"),
"../accountFormats/VI.json": () => import("./VI-D8j8IzJs.js"),
"../accountFormats/VN.json": () => import("./VN-wC6sHs21.js"),
"../accountFormats/WF.json": () => import("./WF-Cv-zZiEX.js"),
"../accountFormats/YT.json": () => import("./YT-BJrZCXu7.js"),
"../accountFormats/ZA.json": () => import("./ZA-BU2vcyD6.js")
});
var getAccountFormatsForCountry = async (country) => {
const importForCountry = accountFormatsImports[`../accountFormats/${country}.json`];
if (!importForCountry) throw Error(`No account formats available for ${country}`);
return {
...(await importForCountry()).default,
numberAndBic: {
bankStatementRequirement: "OPTIONAL",
fields: ["bankAccountNumber", "swiftCode"]
}
};
};
//#endregion
//#region src/api/validation/useValidateAccountIdentification.ts
var validateAccountIdentification = async (baseUrl, data) => {
return httpPost({
baseUrl,
path: `validations/accountidentification`
}, { accountIdentification: { ...data } });
};
var useValidateAccountIdentification = (options) => {
const { baseUrl } = useApiContext();
return useMutation({
mutationFn: (data) => validateAccountIdentification(baseUrl.value, data),
...options
});
};
//#endregion
//#region src/components/BankAccount/hooks/useAsyncAccountDetailsValidationRules.ts
var useAsyncAccountDetailsValidationRules = (payload, hasEmptyFields, isAccountNumberMasked) => {
const [timeoutId, setTimeoutId] = useState$1(null);
const [accountValidationData, setAccountValidationData] = useState$1({
invalidFields: [],
valid: false
});
const { mutateAsync } = useValidateAccountIdentification();
useEffect$1(() => {
const fetchAccountDetails = async (accountIdentificationPayload) => {
try {
setAccountValidationData(await mutateAsync(accountIdentificationPayload));
} catch (error) {
console.error("Error fetching account details:", error);
}
};
if (payload && !hasEmptyFields && !isAccountNumberMasked) {
if (timeoutId !== null) clearTimeout(timeoutId);
setTimeoutId(setTimeout(() => {
fetchAccountDetails(payload);
setTimeoutId(null);
}, 500));
}
}, [
mutateAsync,
hasEmptyFields,
payload
]);
return accountValidationData;
};
//#endregion
//#region src/components/BankAccount/mapping/mapPayoutAccountSchemaToApiBankAccount.ts
var logger = createLogger();
var getAccountIdentificationFromPayoutAccountSchema = (payoutAccount, bankCountry, enabledCrossBorderPayouts) => {
if ("iban" in payoutAccount && payoutAccount.iban) return {
type: "iban",
iban: payoutAccount.iban
};
if (enabledCrossBorderPayouts && "bankAccountNumber" in payoutAccount && payoutAccount.bankAccountNumber && "swiftCode" in payoutAccount && payoutAccount.swiftCode) return {
type: "numberAndBic",
bic: payoutAccount.swiftCode,
accountNumber: payoutAccount.bankAccountNumber
};
/**
* Although we are switching on country, the "type" refers to a region within the API.
* This means multiple countries can be apart of a single region.
*
* see 'com.adyen.bankaccountidentification.types.BankAccountIdentificationType' for current mappings
*/
switch (bankCountry) {
case CountryCodes.Australia: return {
type: "auLocal",
accountNumber: payoutAccount.bankAccountNumber,
bsbCode: payoutAccount.branchCode
};
case CountryCodes.Brazil: return {
type: "brLocal",
accountNumber: payoutAccount.bankAccountNumber,
ispb: payoutAccount.bankCode,
bankCode: payoutAccount.bankName,
branchNumber: payoutAccount.branchCode
};
case CountryCodes.Canada: return {
type: "caLocal",
accountNumber: payoutAccount.bankAccountNumber,
institutionNumber: payoutAccount.bankCode,
transitNumber: payoutAccount.branchCode
};
case CountryCodes.CzechRepublic: return {
type: "czLocal",
accountNumber: payoutAccount.bankAccountNumber,
bankCode: payoutAccount.bankCode
};
case CountryCodes.Denmark: return {
type: "dkLocal",
accountNumber: payoutAccount.bankAccountNumber,
bankCode: payoutAccount.bankCode
};
case CountryCodes.HongKong: return {
type: "hkLocal",
accountNumber: payoutAccount.bankAccountNumber,
clearingCode: payoutAccount.bankCode
};
case CountryCodes.NewZealand: return {
type: "nzLocal",
accountNumber: payoutAccount.bankAccountNumber?.replaceAll("-", "")
};
case CountryCodes.Sweden: return {
type: "seLocal",
accountNumber: payoutAccount.bankAccountNumber,
clearingNumber: payoutAccount.branchCode
};
case CountryCodes.Singapore: return {
type: "sgLocal",
accountNumber: payoutAccount.bankAccountNumber,
bic: payoutAccount.swiftCode
};
case CountryCodes.IsleOfMan:
case CountryCodes.Guernsey:
case CountryCodes.Gibraltar:
case CountryCodes.Jersey:
case CountryCodes.UnitedKingdom: return {
type: "ukLocal",
accountNumber: payoutAccount.bankAccountNumber,
sortCode: payoutAccount.branchCode
};
case CountryCodes.NorthernMarianaIslands:
case CountryCodes.Guam:
case CountryCodes.VirginIslandsUS:
case CountryCodes.AmericanSamoa:
case CountryCodes.PuertoRico:
case CountryCodes.UnitedStates: return {
type: "usLocal",
accountNumber: payoutAccount.bankAccountNumber,
routingNumber: payoutAccount.branchCode
};
default:
logger.log(`${bankCountry.toLowerCase()}Local is not a configured region`);
return {
type: `${bankCountry.toLowerCase()}Local`,
accountNumber: payoutAccount.bankAccountNumber
};
}
};
var mapPayoutAccountSchemaToApiBankAccount = (payoutAccount, bankCountry, preferredCurrency, enabledCrossBorderPayouts) => ({
accountIdentification: getAccountIdentificationFromPayoutAccountSchema(payoutAccount, bankCountry, enabledCrossBorderPayouts),
preferredCurrencyCode: preferredCurrency,
countryCode: bankCountry,
bankName: payoutAccount.bankName
});
//#endregion
//#region src/components/BankAccount/tasks/PayoutDetailsDropin/store.ts
var showInstantVerificationPayoutModal = signal(false);
var isUsingManualFlow = signal(true);
var resetPayoutSignals = () => {
showInstantVerificationPayoutModal.value = false;
isUsingManualFlow.value = true;
};
//#endregion
//#region src/api/documentValidation/useDocumentMultipartValidate.ts
var validateDocumentMultipart = async (context, request) => {
const { baseUrl, rootLegalEntityId } = context;
const formData = new FormData();
formData.append("file", request.file, request.fileName);
formData.append("fileName", request.fileName);
formData.append("documentType", request.documentType);
formData.append("sessionId", request.sessionId);
return httpPost({
baseUrl,
path: `legalEntities/${rootLegalEntityId}/genai/classifyDocument`
}, formData);
};
var useValidateDocumentMultipart = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useMutation({
mutationFn: (payload) => validateDocumentMultipart({
rootLegalEntityId: rootLegalEntityId.value,
baseUrl: baseUrl.value
}, payload),
retry: 0,
...options
});
};
//#endregion
//#region src/components/ui/molecules/Dropzone/FilePicker.tsx
function FilePicker({ files, setFiles, isValid, errorMessage, multiple = false, label, name, iconPrefix = "generic-document", enableTracking = false, id, loading, allowedFileTypes, maxSize, isOptional, maxNumberOfFiles, "aria-describedby": ariaDescribedBy, "aria-labelledby": ariaLabelledBy }) {
const { t } = useTranslation("ui");
const userEvents = useAnalyticsContext();
const fileInput = useRef$1(null);
const [dragged, setDragged] = useState$1(false);
const hasRequiredError = errorMessage === "fieldIsRequired";
const showDropzone = files.length < maxNumberOfFiles;
const openFilePicker = () => fileInput.current?.click();
const handleFileDelete = (fileToDelete) => {
setFiles(files.filter((file) => file !== fileToDelete));
};
const handleDragEnter = (e) => {
e.preventDefault();
e.stopPropagation();
};
const handleDragLeave = (e) => {
e.preventDefault();
e.stopPropagation();
setDragged(false);
};
const handleDragOver = (e) => {
e.preventDefault();
e.stopPropagation();
setDragged(true);
};
const handleDrop = (e) => {
e.preventDefault();
e.stopPropagation();
if (e.dataTransfer) addFiles(e.dataTransfer.files);
setDragged(false);
};
const handleFilesChosen = (e) => {
const fileInput = e.currentTarget;
if (fileInput.files) addFiles(fileInput.files);
};
const addFiles = (newFiles) => {
if (enableTracking) userEvents.addFieldEvent("Interacted with form field", {
actionType: "change",
field: name || "dropzone"
});
setFiles([...newFiles, ...files]);
};
const allowedFileTypesString = allowedFileTypes.join(", ");
return /* @__PURE__ */ jsxs("div", { children: [
label && /* @__PURE__ */ jsx("div", {
className: cx("adyen-kyc-label__text", { "adyen-kyc-label__text--error": hasRequiredError }),
children: label
}),
files.map((file) => /* @__PURE__ */ jsx(DropzoneFile, {
file,
onDelete: () => {
handleFileDelete(file);
},
errorMessage,
iconPrefix,
loading
}, file)),
showDropzone && /* @__PURE__ */ jsxs("div", {
role: "region",
className: cx("adyen-kyc-dropzone", {
"adyen-kyc-dropzone--dragged": dragged,
"adyen-kyc-dropzone--error": !dragged && hasRequiredError
}),
onDrop: handleDrop,
onDragOver: handleDragOver,
onDragEnter: handleDragEnter,
onDragLeave: handleDragLeave,
children: [
/* @__PURE__ */ jsx("div", {
className: "adyen-kyc-dropzone__icon",
children: /* @__PURE__ */ jsx(Icon, { name: "upload" })
}),
/* @__PURE__ */ jsxs("div", {
className: "adyen-kyc-dropzone__labels",
children: [
/* @__PURE__ */ jsx(Typography, {
el: "h4",
variant: "body-strongest",
children: t(($) => $["dropFileToUpload"])
}),
/* @__PURE__ */ jsx(Typography, {
color: "secondary",
children: t(($) => $["supportedFileTypes"], { fileTypes: allowedFileTypesString })
}),
/* @__PURE__ */ jsx(Typography, {
color: "secondary",
children: t(($) => $["maxFileSize"], { maxSize: bytesToSize(maxSize) })
}),
/* @__PURE__ */ jsx(Typography, {
color: "secondary",
children: t(($) => $["upToFiles"], { maxFiles: maxNumberOfFiles })
})
]
}),
/* @__PURE__ */ jsx("div", {
className: "adyen-kyc-dropzone__button",
children: /* @__PURE__ */ jsx(Button, {
onClick: openFilePicker,
variant: "secondary",
children: t(($) => $["browseFiles"])
})
}),
/* @__PURE__ */ jsx("input", {
id,
className: "adyen-kyc-dropzone__input",
ref: fileInput,
multiple,
accept: allowedFileTypesString,
onChange: handleFilesChosen,
type: "file",
"aria-required": !isOptional,
"aria-describedby": ariaDescribedBy,
"aria-labelledby": ariaLabelledBy,
"data-testid": "hidden-file-input",
"aria-invalid": !isValid
})
]
}),
hasRequiredError && /* @__PURE__ */ jsx("div", {
className: "adyen-kyc-error-text",
children: t(($) => $["fieldIsRequired"])
})
] });
}
var BankDocumentClassification_module_default = {
"bank-document-classification": "adyen-kyc-bank-document-classification",
bankDocumentClassification: "adyen-kyc-bank-document-classification",
"requirements-list": "adyen-kyc-requirements-list",
requirementsList: "adyen-kyc-requirements-list",
"file-picker-disabled": "adyen-kyc-file-picker-disabled",
filePickerDisabled: "adyen-kyc-file-picker-disabled",
"review-modal": "adyen-kyc-review-modal",
reviewModal: "adyen-kyc-review-modal",
preview: "adyen-kyc-preview",
"preview-image": "adyen-kyc-preview-image",
previewImage: "adyen-kyc-preview-image",
content: "adyen-kyc-content",
actions: "adyen-kyc-actions",
title: "adyen-kyc-title",
description: "adyen-kyc-description",
issues: "adyen-kyc-issues",
"confirmation-modal": "adyen-kyc-confirmation-modal",
confirmationModal: "adyen-kyc-confirmation-modal"
};
//#endregion
//#region src/components/BankAccount/forms/BankDocument/validate.ts
var bankDocumentValidationRules = { description: {
modes: ["blur"],
validate: (description) => description ? bankStatementDescriptionPattern.test(description) : true,
errorMessage: "invalidFormatBankStatementDescription"
} };
var getValidationIssuesKeys = (validationResponse) => {
const issues = [];
const { blurryOrLowQuality, documentType } = validationResponse;
if (blurryOrLowQuality) issues.push("documentIsntReadable");
if (documentType === "other" || documentType !== "bankDocument") issues.push("documentIsNotBankDocument");
if (!documentType || documentType === "other") issues.push("documentNameMissing");
return issues;
};
//#endregion
//#region src/components/BankAccount/forms/BankDocument/BankDocumentClassification.tsx
var CHARACTERS_LIMIT = 200;
var bankStatementValidationOptions = {
...defaultFileValidationOptions,
isOptional: false
};
var bankDocumentClassificationFields = ["bankStatementDocument", "description"];
function BankDocumentClassification(props) {
const { legalEntity, validators, data: bankData, id, fieldValidationErrors, formVerificationErrors, shouldValidate, country, handleFieldChange, valid: propValid, errors: propErrors } = props;
const { t } = useTranslation("banking");
const { t: commonT } = useTranslation("common");
const stateRef = useRef({ setState: null });
const [showReviewModal, setShowReviewModal] = useState(false);
const [showConfirmationModal, setShowConfirmationModal] = useState(false);
const [validationResponse, setValidationResponse] = useState(null);
const [showEndState, setShowEndState] = useState(false);
const inputRef = useRef(null);
const logger = createLogger();
const userEvents = useAnalyticsContext();
const formUtils = createFormUtils(props, commonT);
const { isFeatureEnabled } = useToggleContext();
const enableBankDocumentClassification = isFeatureEnabled(FeatureNames.EnableBankDocumentClassification);
const isShadowMode = isFeatureEnabled(FeatureNames.EnableBankDocumentClassificationShadowMode);
const rules = useMemo(() => ({
...validators || bankDocumentValidationRules,
bankStatementDocument: fileValidationRules(bankStatementValidationOptions)
}), [validators]);
const localForm = useForm({
...props,
schema: bankDocumentClassificationFields,
defaultData: bankData,
rules,
fieldProblems: fieldValidationErrors,
shouldValidate
});
const useMultiFormMode = !!handleFieldChange;
const data = useMultiFormMode ? bankData : localForm.data;
const valid = useMultiFormMode ? propValid : localForm.valid;
const errors = useMultiFormMode ? propErrors : localForm.errors;
const fieldProblems = useMultiFormMode ? fieldValidationErrors : localForm.fieldProblems;
const handleChange = useMultiFormMode ? handleFieldChange : localForm.handleChangeFor;
const { triggerValidation, setData } = localForm;
const validateDocumentMutation = useValidateDocumentMultipart({
onSuccess: (response) => {
userEvents.addEvent("Success", {
actionType: "upload",
actionLevel: "journey",
label: isShadowMode ? "bankDocumentClassificationShadowMode" : "bankDocumentClassification",
additionalData: {
documentType: response?.documentType,
subDocumentType: response?.subDocumentType,
blurryOrLowQuality: response?.blurryOrLowQuality
}
});
if (isShadowMode) return;
setValidationResponse(response);
if (response?.blurryOrLowQuality || response?.documentType !== "bankDocument") {
userEvents.addEvent("Opened modal", {
actionType: "open",
actionLevel: "journey",
label: "bankDocumentClassification"
});
setShowReviewModal(true);
} else {
setShowEndState(true);
setTimeout(() => {
setShowEndState(false);
setShowReviewModal(false);
}, 2e3);
}
},
onError: (error) => {
userEvents.addEvent("Encountered error", {
actionType: "upload",
actionLevel: "journey",
label: isShadowMode ? "bankDocumentClassificationShadowMode" : "bankDocumentClassification"
});
if (isShadowMode) return;
logger.error("Document validation failed:", error);
setShowReviewModal(false);
setValidationResponse(null);
}
});
const handleDocumentUpload = async (files) => {
handleChange("bankStatementDocument")(files);
if (!useMultiFormMode) triggerValidation();
if (!(enableBankDocumentClassification && [
"US",
"FR",
"GB",
"AU"
].includes(country || "") || isShadowMode)) return;
if (files.length > 0) {
const file = files[0];
if (file && file instanceof File) try {
const document = {
file,
documentType: "bankStatement",
fileName: file.name,
sessionId: legalEntity.id
};
validateDocumentMutation.mutate(document);
} catch (error) {
logger.error("Error processing document:", error);
}
}
};
const alreadyUploadedDocuments = useMemo(() => bankData?.bankStatementDocument ?? [], [bankData?.bankStatementDocument]);
useEffect(() => {
if (!useMultiFormMode && alreadyUploadedDocuments.length > 0) {
setData("bankStatementDocument", alreadyUploadedDocuments);
if (bankData?.description) setData("description", bankData.description);
triggerValidation();
}
}, [
alreadyUploadedDocuments,
bankData?.description,
setData,
triggerValidation,
useMultiFormMode
]);
useEffect(() => {
if (!useMultiFormMode) stateRef.current?.setState?.({
type: "addToState",
value: {
data,
valid,
errors,
fieldProblems,
dataStoreId: id,
schema: bankDocumentClassificationFields
}
});
}, [
data,
valid,
errors,
fieldProblems,
id,
useMultiFormMode
]);
const handleUploadNewDocument = () => {
userEvents.addEvent("Clicked button", {
actionType: "next",
actionLevel: "journey",
label: "bankDocumentClassificationUploadNewDocument"
});
inputRef.current?.click();
};
const handleContinueAnyway = () => {
setShowConfirmationModal(true);
};
const handleConfirmationCancel = () => {
setShowConfirmationModal(false);
};
const handleUseDocument = () => {
setShowConfirmationModal(false);
setShowReviewModal(false);
userEvents.addEvent("Clicked button", {
actionType: "next",
actionLevel: "journey",
label: "bankDocumentClassificationContinueAnyway"
});
};
const documentPreview = useMemo(() => {
if (!data?.bankStatementDocument?.[0] || !showReviewModal) return null;
const file = data.bankStatementDocument?.[0];
return file.type === "application/pdf" || file.name.toLowerCase().endsWith(".pdf") ? /* @__PURE__ */ jsx("object", {
width: "100%",
height: "100%",
data: URL.createObjectURL(file),
type: "application/pdf",
"aria-label": t(($) => $["reviewDocument"]),
"data-testid": "pdf-preview"
}) : /* @__PURE__ */ jsx("img", {
src: URL.createObjectURL(file),
alt: t(($) => $["reviewDocument"])
});
}, [
data?.bankStatementDocument,
showReviewModal,
t
]);
return /* @__PURE__ */ jsxs("div", {
className: BankDocumentClassification_module_default.bankDocumentPage,
children: [
/* @__PURE__ */ jsxs("form", {
className: BankDocumentClassification_module_default.bankDocumentClassification,
children: [
!useMultiFormMode && /* @__PURE__ */ jsx(StateContextSetter, {
owner: id,
stateRef
}),
/* @__PURE__ */ jsx(Header, {
title: t(($) => $["uploadABankDocument"]),
description: t(($) => $["toVerifyYourBankAccountDetails"])
}),
/* @__PURE__ */ jsx(ErrorPanel, {
verificationErrors: formVerificationErrors,
validationErrors: fieldValidationErrors,
formUtils,
id: "ariaErrorField"
}),
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
className: BankDocumentClassification_module_default.requirementsList,
children: t(($) => $["makeSureYourDocumentIncludes"])
}), /* @__PURE__ */ jsxs("ul", {
className: BankDocumentClassification_module_default.requirementsList,
children: [
/* @__PURE__ */ jsx("li", { children: t(($) => $["documentRequirementNameOrBusiness"]) }),
/* @__PURE__ */ jsx("li", { children: t(($) => $[`documentRequirementAccountNumber${country === "US" ? "Partial" : ""}`]) }),
/* @__PURE__ */ jsx("li", { children: t(($) => $["documentRequirementBankInfo"]) }),
/* @__PURE__ */ jsx("li", { children: t(($) => $["documentRequirementReadableText"]) })
]
})] }),
/* @__PURE__ */ jsx(Field, {
className: cx("adyen-kyc-upload-field"),
name: "bankStatementDocument",
isValid: valid?.bankStatementDocument ?? true,
children: (childProps) => /* @__PURE__ */ jsx("div", {
className: validateDocumentMutation.isPending && !isShadowMode ? BankDocumentClassification_module_default.filePickerDisabled : "",
children: /* @__PURE__ */ jsx(FilePicker, {
...childProps,
name: "bankStatementDocument",
files: data?.bankStatementDocument ?? [],
setFiles: handleDocumentUpload,
isValid: valid?.bankStatementDocument ?? true,
errorMessage: errors?.bankStatementDocument?.errorMessage,
loading: validateDocumentMutation.isPending && !isShadowMode,
...bankStatementValidationOptions
})
})
}),
data?.bankStatementDocument?.length ? /* @__PURE__ */ jsx(Field, {
className: "adyen-kyc-document-description",
name: "description",
label: formUtils.getLabel("bankDocumentFileDescription"),
errorMessage: formUtils.getErrorMessage("description", errors, fieldProblems),
isValid: valid?.description,
children: (childProps) => /* @__PURE__ */ jsx(TextArea, {
...childProps,
name: "description",
value: data?.description,
maxLength: CHARACTERS_LIMIT,
onInput: handleChange("description"),
"aria-invalid": valid?.description === false
})
}) : void 0
]
}),
showReviewModal && /* @__PURE__ */ jsx(Modal, {
ariaLabel: t(($) => $["reviewDocument"]),
size: showEndState ? "small" : "medium",
inset: showEndState,
showCloseButton: !showEndState,
onClose: !showEndState ? handleContinueAnyway : void 0,
children: showEndState ? /* @__PURE__ */ jsx(EndStateLayout, { title: t(($) => $["documentUploaded"]) }) : /* @__PURE__ */ jsxs("div", {
className: BankDocumentClassification_module_default.reviewModal,
children: [/* @__PURE__ */ jsx("div", {
className: BankDocumentClassification_module_default.preview,
children: /* @__PURE__ */ jsx("div", {
className: BankDocumentClassification_module_default.previewImage,
children: documentPreview
})
}), /* @__PURE__ */ jsxs("div", {
className: BankDocumentClassification_module_default.content,
children: [
/* @__PURE__ */ jsx("h2", {
className: BankDocumentClassification_module_default.title,
children: t(($) => $["reviewDocument"])
}),
/* @__PURE__ */ jsx("p", {
className: BankDocumentClassification_module_default.description,
children: t(($) => $["reviewDocumentDescription"])
}),
/* @__PURE__ */ jsx("ul", {
className: BankDocumentClassification_module_default.issues,
children: validationResponse && getValidationIssuesKeys(validationResponse).map((issue, index) => /* @__PURE__ */ jsx("li", { children: t(($) => $[issue]) }, index))
}),
/* @__PURE__ */ jsxs("div", {
className: BankDocumentClassification_module_default.actions,
children: [/* @__PURE__ */ jsx(Button, {
variant: "secondary",
disabled: validateDocumentMutation.isPending,
onClick: handleContinueAnyway,
children: commonT(($) => $["continue"])
}), /* @__PURE__ */ jsx(Button, {
loading: validateDocumentMutation.isPending,
variant: "primary",
onClick: handleUploadNewDocument,
children: t(($) => $["uploadNewDocument"])
})]
})
]
})]
})
}),
showConfirmationModal && /* @__PURE__ */ jsx(Modal, {
ariaLabel: t(($) => $["useThisDocument"]),
size: "small",
onClose: handleConfirmationCancel,
children: /* @__PURE__ */ jsxs("div", {
className: BankDocumentClassification_module_default.confirmationModal,
children: [
/* @__PURE__ */ jsx("h2", {
className: BankDocumentClassification_module_default.title,
children: t(($) => $["useThisDocument"])
}),
/* @__PURE__ */ jsx("p", {
className: BankDocumentClassification_module_default.description,
children: t(($) => $["thisDocumentNeedstoBeReviewedManually"])
}),
/* @__PURE__ */ jsxs("div", {
className: BankDocumentClassification_module_default.actions,
children: [/* @__PURE__ */ jsx(Button, {
variant: "secondary",
onClick: handleConfirmationCancel,
children: commonT(($) => $["cancel"])
}), /* @__PURE__ */ jsx(Button, {
variant: "primary",
onClick: handleUseDocument,
children: t(($) => $["useDocument"])
})]
})
]
})
}),
/* @__PURE__ */ jsx("input", {
id,
ref: inputRef,
className: "adyen-kyc-dropzone__input",
onChange: (e) => {
const fileInput = e.currentTarget;
if (fileInput?.files?.length) handleDocumentUpload([...fileInput.files]);
},
type: "file",
accept: defaultFileValidationOptions.allowedFileTypes.join(", ")
})
]
});
}
var MemoizedBankDocumentClassification = memo(BankDocumentClassification, (prevProps, nextProps) => objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.country === nextProps.country && prevProps.shouldValidate === nextProps.shouldValidate);
//#endregion
//#region src/components/BankAccount/forms/BankVerification/validate.ts
var bankVerificationValidationRules = {
verifiedAccountHolder: {
modes: ["blur"],
validate: (verifiedAccountHolder) => !isEmpty(verifiedAccountHolder),
errorMessage: "fieldIsRequired"
},
verifiedBankCountry: {
modes: ["blur"],
validate: (verifiedBankCountry) => !isEmpty(verifiedBankCountry),
errorMessage: "fieldIsRequired"
},
verifiedBankName: {
modes: ["blur"],
validate: (verifiedBankName) => !isEmpty(verifiedBankName),
errorMessage: "fieldIsRequired"
},
verifiedCurrencyCode: {
modes: ["blur"],
validate: (verifiedCurrencyCode) => !isEmpty(verifiedCurrencyCode),
errorMessage: "fieldIsRequired"
},
verifiedBankAccountNumber: {
modes: ["blur"],
validate: (verifiedBankAccountNumber) => !isEmpty(verifiedBankAccountNumber),
errorMessage: "fieldIsRequired"
}
};
//#endregion
//#region src/api/transferInstruments/useHandleBankVerificationError.ts
var handleBankVerificationError = async (legalEntityId, baseUrl, bankVerificationErrorParams) => {
return httpPost({
baseUrl,
path: `legalEntities/${legalEntityId}/transferInstruments/trusted/error`
}, bankVerificationErrorParams);
};
/**
* Receives an error code and message from a banking verification provider and translates it to a known, standardized error
* @param options additional mutation options
*/
var useHandleBankVerificationError = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useMutation({
mutationFn: (params) => handleBankVerificationError(rootLegalEntityId.value, baseUrl.value, params),
...options
});
};
//#endregion
//#region src/components/BankAccount/forms/BankVerification/verification/overlay/types.ts
var VerificationWidgetCallbackActions = {
HANDLE_EXCEPTION: "handle_exception",
VERIFICATION_SUCCESS: "verification_success",
RETRY_VERIFICATION: "retry_verification",
HANDLE_EVENT: "handle_event"
};
//#endregion
//#region src/components/BankAccount/forms/BankVerification/verification/overlay/BankVerificationOverlay.tsx
var WIDGET_CONTAINER_CLASS = `adyen-kyc-bank-verification-widget-container`;
function BankVerificationOverlay({ url, setBankVerificationError, onBack, retrieveBankAccountInfo, createTrustedTransferInstrument, providerName }) {
const { t } = useTranslation("banking");
const userEvents = useAnalyticsContext();
const widgetContainerRef = useRef$1(null);
const { mutateAsync: handleBankVerificationError } = useHandleBankVerificationError();
const trackVerificationError = (returnValue) => {
userEvents.addPageEvent("Encountered error", {
actionType: "add",
returnType: "sdk error",
returnValue,
additionalData: { providerName }
});
};
const DEFAULT_ERROR = {
error: "UNKNOWN_ERROR",
message: t(($) => $["weCouldntCompleteTheAccountCheck"])
};
useEffect$1(() => {
setBankVerificationError(null);
}, [setBankVerificationError]);
const widgetCallback = useCallback$1((payload) => {
const errorContent = t(($) => $["tryAgainOrManualAccountDetails"]);
switch (payload.action) {
case VerificationWidgetCallbackActions.HANDLE_EXCEPTION: {
let errorTitle;
const { err } = payload;
switch (!(err instanceof Error) && err?.error) {
case "USER_CANCELLED":
errorTitle = "";
break;
case "CONNECTION_ERROR":
errorTitle = t(($) => $["couldNotEstablishBankConnection"]);
break;
case "GENERIC_ERROR":
errorTitle = t(($) => $["ranIntoTechnicalError"]);
break;
default:
errorTitle = t(($) => $["couldNotCompleteAccountCheck"]);
break;
}
if (errorTitle) setBankVerificationError({
title: errorTitle,
content: errorContent
});
isUsingManualFlow.value = true;
showInstantVerificationPayoutModal.value = false;
onBack?.();
break;
}
case VerificationWidgetCallbackActions.RETRY_VERIFICATION:
setBankVerificationError({
title: t(($) => $["failedInitializeInstantVerification"]),
content: errorContent
});
onBack?.();
break;
case VerificationWidgetCallbackActions.HANDLE_EVENT: {
const { name, provider } = payload.event;
if (name === "institution_selected" && provider === "plaid") widgetContainerRef.current?.classList.add(`${WIDGET_CONTAINER_CLASS}--plaid-modal`);
break;
}
case VerificationWidgetCallbackActions.VERIFICATION_SUCCESS: {
const { accounts } = payload.result;
if (accounts) retrieveBankAccountInfo(accounts[0]);
}
}
}, [
t,
retrieveBankAccountInfo,
onBack,
setBankVerificationError
]);
useEffect$1(() => {
const container = widgetContainerRef.current;
if (!container) return;
const openBanking = OpenBankingSDK.create({
divElement: container,
link: url,
successHandler: (code, state) => {
createTrustedTransferInstrument?.(code, state).then((res) => {
userEvents.addPageEvent("Success", {
actionType: "add",
additionalData: { providerName }
});
if (res) widgetCallback({
action: Verifi