@adyen/kyc-components 3.81.0 → 3.82.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AcceptTermsOfServiceComponent-PDXa81vb.js → AcceptTermsOfServiceComponent-Do0w4uTc.js} +36 -10
- package/dist/{AccountSetupRejected-Du83gH0_.js → AccountSetupRejected-C7bZBsjo.js} +6 -4
- package/dist/Address-CX1FM8LF.js +1076 -0
- package/dist/Alert-DCYc9VpX.js +231 -0
- package/dist/{Avatar-Cd_8eqbA.js → Avatar-BaxjEBNy.js} +2 -2
- package/dist/BusinessDetailsDropin-yG7M7i9-.js +5088 -0
- package/dist/BusinessFinancingComponent-CZZcn51m.js +45 -0
- package/dist/{BusinessFinancingDropin-DioEfiqH.js → BusinessFinancingDropin-EfA32nOP.js} +43 -20
- package/dist/BusinessFinancingPage-Bb1dPIJF.js +40 -0
- package/dist/{BusinessTypeSelectionPage-uk6eDO5O.js → BusinessTypeSelectionPage-CjEomufR.js} +9 -5
- package/dist/Card-DsB6bxW-.js +145 -0
- package/dist/Confirm-X9nR52Md.js +64 -0
- package/dist/{ContractViewer-B2LwC3wV.js → ContractViewer-Byp71k2e.js} +33 -38
- package/dist/CountryField-DxBBjy81.js +864 -0
- package/dist/CreateIndividualComponent-Dyn173AJ.js +72 -0
- package/dist/CreateTransferInstrumentComponent-BT78AU6Z.js +67 -0
- package/dist/Currency-wsIZH1_j.js +238 -0
- package/dist/{CustomerSupport-C4n96PMt.js → CustomerSupport-B7VbKM8X.js} +10 -6
- package/dist/{DebugModal-CYO8HZDV.js → DebugModal-CZwhc_eY.js} +8 -5
- package/dist/{DecisionMakerDetailsPage-IT7x1ZRJ.js → DecisionMakerDetailsPage-Y7E2RfUW.js} +11 -4
- package/dist/{DecisionMakers-DkXmcSK4.js → DecisionMakers-DNepilyq.js} +224 -96
- package/dist/Dropzone-nt4AXJ-H.js +218 -0
- package/dist/{EmbeddedStatus-BS-fmZSm.js → EmbeddedStatus-D0gkDJMZ.js} +4 -4
- package/dist/{EndStateLayout-qrS2Eh-G.js → EndStateLayout-C2whNAgv.js} +2 -2
- package/dist/{FormFlow-BjHYz5-l.js → FormFlow-CRhuooj2.js} +8 -2
- package/dist/FormNavigation-BdFqTFAy.js +162 -0
- package/dist/{IndividualOnfidoDropin-B-y2VRFi.js → IndividualOnfidoDropin-BWM9aKLs.js} +2796 -64
- package/dist/InputDate-DydMc18N.js +43 -0
- package/dist/InputGroup-WBfGDV5F.js +32 -0
- package/dist/InputText-BCNFl9Ni.js +161 -0
- package/dist/{Introduction-CVSG_NSh.js → Introduction-1ZBVqCrd.js} +58 -4
- package/dist/LegalRepresentativeDetailsPage-B2yyvDKF.js +61 -0
- package/dist/Link-BGc9wGrL.js +35 -0
- package/dist/ManageIndividualComponent-CFvL5A-c.js +47 -0
- package/dist/ManageTermsOfServiceComponent-DTrzRxr1.js +47 -0
- package/dist/{ManageTransferInstrumentComponent-Byi222QQ.js → ManageTransferInstrumentComponent-B2cBS1y1.js} +25 -4
- package/dist/MaskedInput-DOTRZoSO.js +799 -0
- package/dist/MaybeModal-SjCkh5yq.js +25 -0
- package/dist/Modal-t5jbmZJu.js +136 -0
- package/dist/{OnboardingDropinComponent-CDK7PYx0.js → OnboardingDropinComponent-DegbZ_o6.js} +200 -41
- package/dist/PayoutDetailsDropin-58zkMbID.js +3694 -0
- package/dist/RadioGroup-Dkwl1v8z.js +143 -0
- package/dist/RegistrationAddress-DOqLUQEe.js +2334 -0
- package/dist/{Review-BCxsmMlz.js → Review-8WTYj81b.js} +8 -4
- package/dist/{RootBusinessDetailsPage-CIWtTZ1z.js → RootBusinessDetailsPage-FDWyaMpG.js} +65 -44
- package/dist/RootIndividualDetailsPage-SFgbb5Bk.js +77 -0
- package/dist/{SignPCIComponent-DzKFISwc.js → SignPCIComponent-bl7LzPjE.js} +17 -8
- package/dist/{SingpassSelection-ChRvdPZF.js → SingpassSelection-DukeaL-T.js} +6 -6
- package/dist/SoleProprietorshipPage-C-XJc7Iq.js +50 -0
- package/dist/{SourceOfFundsPage-DuUOdcam.js → SourceOfFundsPage-D-xLHf2C.js} +46 -24
- package/dist/Spacer-BK3jDget.js +18 -0
- package/dist/StepProgressIndicator-DHei86A6.js +78 -0
- package/dist/StoreProvider-B6-mwoeD.js +7072 -0
- package/dist/StructuredList-DaepaiVE.js +38 -0
- package/dist/{TaskItemStatus-DDwHsmh8.js → TaskItemStatus-BxzVEGbJ.js} +4 -3
- package/dist/{TaskStatusIndicator-Bmm2PsCZ.js → TaskStatusIndicator-Dfp2GcbN.js} +2 -2
- package/dist/TaxInformationField-r8gB7YBi.js +3062 -0
- package/dist/{TaxReportingDropin-kPcT1Kxt.js → TaxReportingDropin-5Lp9F8Ab.js} +25 -9
- package/dist/{TileGroup-BC8PSahf.js → TileGroup-jIldfSJ7.js} +4 -2
- package/dist/{TrustDetailsPage-lnVmcLSH.js → TrustDetailsPage-CjCSvds-.js} +506 -19
- package/dist/TrustMemberCompanyPage-Z6YT-R_a.js +60 -0
- package/dist/TrustMemberIndividualPage-qDN9m9Dv.js +66 -0
- package/dist/UnincorporatedPartnershipIndividualPage-iRZOCq2z.js +66 -0
- package/dist/UnincorporatedPartnershipMemberCompanyPage-9FlDLivA.js +64 -0
- package/dist/{ViewVerificationStatusComponent-D2V-RY2M.js → ViewVerificationStatusComponent-7D-3OVVA.js} +4 -3
- package/dist/adyen-business-financing.js +33 -22
- package/dist/adyen-individual.js +36 -27
- package/dist/adyen-kyc-components.js +28 -15
- package/dist/adyen-manage-individual.js +25 -26
- package/dist/adyen-manage-terms-of-service.js +26 -27
- package/dist/adyen-manage-transfer-instruments.js +40 -42
- package/dist/adyen-onboarding.js +3 -3
- package/dist/adyen-terms-of-service.js +41 -38
- package/dist/adyen-transfer-instrument.js +38 -29
- package/dist/adyen-verification-status.js +44 -36
- package/dist/analytics-CYiivYhI.js +61 -0
- package/dist/{bafinUtils-T6TnU7m4.js → bafinUtils-DSQnsLeT.js} +164 -10
- package/dist/basePatterns-BwdnMQxI.js +15 -0
- package/dist/bg-BG-CW9c658c.js +13 -0
- package/dist/bg-BG-CZ8v3rdy.js +30 -0
- package/dist/{bg-BG-Dlzl9Szn.js → bg-BG-D5192UVe.js} +1 -2
- package/dist/{bg-BG-NMIts2sa.js → bg-BG-QC5irNEG.js} +2 -4
- package/dist/commonValidators-CwkyFFVz.js +24 -0
- package/dist/{cs-CZ-BkyFDlAU.js → cs-CZ-DOqH0WeT.js} +1 -2
- package/dist/cs-CZ-Dx6momCa.js +30 -0
- package/dist/cs-CZ-dU9fnQ1g.js +13 -0
- package/dist/{cs-CZ-Csr_35T-.js → cs-CZ-t297LwYw.js} +2 -4
- package/dist/currency-BGwQyxBo.js +36 -0
- package/dist/{da-DK-B5KNtXL8.js → da-DK-B45X2VaJ.js} +1 -2
- package/dist/da-DK-BJ7aTPir.js +13 -0
- package/dist/{da-DK-Dm8o1giq.js → da-DK-BoQic3Gy.js} +2 -4
- package/dist/da-DK-D4H69PX3.js +30 -0
- package/dist/de-DE-C78RLE2G.js +13 -0
- package/dist/{de-DE-BA9tcpNQ.js → de-DE-CWvgMDqU.js} +1 -2
- package/dist/{de-DE-DMFaycio.js → de-DE-Dwagawx1.js} +2 -4
- package/dist/de-DE-wp5-H-ov.js +30 -0
- package/dist/dropinUtils-CkJv8r-0.js +192 -0
- package/dist/el-GR-BZRKurtr.js +13 -0
- package/dist/{el-GR-DIhHT2q_.js → el-GR-C3rkK_oc.js} +1 -2
- package/dist/el-GR-CK2heqPJ.js +30 -0
- package/dist/{el-GR-CGeBAkDN.js → el-GR-CxwhV-TX.js} +2 -4
- package/dist/emitEvent-CzZf80Am.js +28 -0
- package/dist/{en-US-DX4NHkX-.js → en-US-BbAzROHT.js} +2 -4
- package/dist/{en-US-TrwIHFh-.js → en-US-CAm3meB1.js} +1 -2
- package/dist/{en-US-SbE0c1gn.js → en-US-DIdQJky-.js} +1 -2
- package/dist/en-US.instructions-Ddr7AO05.js +22 -0
- package/dist/{es-ES-pXHx3ODy.js → es-ES-Bsoco8Fj.js} +2 -4
- package/dist/es-ES-BtUSEzkE.js +13 -0
- package/dist/{es-ES-RXwbiHjS.js → es-ES-DKCCgVF8.js} +1 -2
- package/dist/es-ES-Ds3-DtqZ.js +30 -0
- package/dist/et-EE-BCnK305R.js +13 -0
- package/dist/{et-EE-ZssIqWkO.js → et-EE-Bc6ioJRG.js} +1 -2
- package/dist/et-EE-Co-8akjV.js +30 -0
- package/dist/{et-EE-QLVnr6Vl.js → et-EE-DdGlUpaQ.js} +2 -4
- package/dist/{fi-FI-DT351N-G.js → fi-FI-ClnsYt3L.js} +2 -4
- package/dist/fi-FI-Cvar63RH.js +13 -0
- package/dist/fi-FI-DPNeTsJS.js +30 -0
- package/dist/{fi-FI-DmiggQEL.js → fi-FI-Hhku9Lmc.js} +1 -2
- package/dist/fieldConfigurations-CzZ2B1fa.js +458 -0
- package/dist/form-rules-DhbF2mY4.js +13 -0
- package/dist/fr-FR-B5543Fe-.js +13 -0
- package/dist/{fr-FR-N5wYE2BZ.js → fr-FR-BYuKsZIb.js} +1 -2
- package/dist/{fr-FR-BNXXNUX_.js → fr-FR-CJI0bIig.js} +2 -4
- package/dist/fr-FR-ChmNQciP.js +30 -0
- package/dist/getName-BkvLQ7My.js +41 -0
- package/dist/{hasDataChanged-e2EDb7Ni.js → hasDataChanged-B7dryhBQ.js} +2 -2
- package/dist/{hr-HR-B8AZ4eHJ.js → hr-HR-C0yWizOX.js} +2 -4
- package/dist/{hr-HR-5iwKtfgh.js → hr-HR-CPO5Yw2B.js} +1 -2
- package/dist/hr-HR-DqC8Cgs6.js +30 -0
- package/dist/hr-HR-ZreFlbK9.js +13 -0
- package/dist/hu-HU-B3BihdGh.js +13 -0
- package/dist/hu-HU-BOanVlKb.js +30 -0
- package/dist/{hu-HU-Aq1LsWah.js → hu-HU-mo_0ULJG.js} +1 -2
- package/dist/{hu-HU-DRi6Dz9U.js → hu-HU-wnSie9tz.js} +2 -4
- package/dist/iframeWidget-BfmN5KKM.js +234 -0
- package/dist/{payout-verification-instant-BIcnFP-p.js → instant-verification-Dvvkyfmp.js} +3 -3
- package/dist/isEmpty-CJ2g18ZH.js +23 -0
- package/dist/{it-IT-BeYbInCQ.js → it-IT-BeC2Y1F8.js} +2 -4
- package/dist/it-IT-Dd6xGSe-.js +13 -0
- package/dist/{it-IT-8DEagvb2.js → it-IT-Nl57jui-.js} +1 -2
- package/dist/it-IT-eCrTB65E.js +30 -0
- package/dist/ja-JP-BJljbFIZ.js +30 -0
- package/dist/{ja-JP-BhS-_dIx.js → ja-JP-CbgaW99b.js} +2 -2
- package/dist/{ja-JP-BGAJQs1g.js → ja-JP-D3oQAH7z.js} +1 -2
- package/dist/{ja-JP-C1OQ16fo.js → ja-JP-YoU7mNrK.js} +2 -4
- package/dist/ja-JP-iTbqSPNL.js +13 -0
- package/dist/keys-BpNgnAsD.js +23 -0
- package/dist/{localizeDateString-VqxvPF9j.js → localizeDateString-C4IzMd3y.js} +2 -2
- package/dist/{lt-LT-HZOWQKZT.js → lt-LT-CVasDmF3.js} +1 -2
- package/dist/lt-LT-DE-4IXNG.js +13 -0
- package/dist/{lt-LT-_MzAcXJo.js → lt-LT-DIe4cKlu.js} +2 -4
- package/dist/lt-LT-DckQGgoT.js +30 -0
- package/dist/lv-LV-CeivEZms.js +13 -0
- package/dist/lv-LV-DP9oRTFv.js +30 -0
- package/dist/{lv-LV-CRhXAjn6.js → lv-LV-DXgW5zWl.js} +2 -4
- package/dist/{lv-LV-F-Z4lDCV.js → lv-LV-Sbsv8-nD.js} +1 -2
- package/dist/{payout-verification-manual-DH9-DdlZ.js → manual-verification-BvZWqA00.js} +3 -3
- package/dist/mapExistingFile-D8NcT-or.js +231 -0
- package/dist/mapScriptLocalization-DBcq31SQ.js +72 -0
- package/dist/mapTransferInstrumentToPayoutAccount-CijqOJMZ.js +30 -0
- package/dist/{nl-NL-C-xUU2N3.js → nl-NL-BHkRnVrj.js} +1 -2
- package/dist/{nl-NL-Dbx0ZmI7.js → nl-NL-Cysslsh2.js} +2 -4
- package/dist/nl-NL-D2QKudfh.js +30 -0
- package/dist/nl-NL-DVENFpd5.js +13 -0
- package/dist/no-NO-C_snYWBc.js +30 -0
- package/dist/no-NO-Dn2UkdoI.js +13 -0
- package/dist/{no-NO-47ncaBZY.js → no-NO-kaAdT9B8.js} +1 -2
- package/dist/{no-NO-C0sfkp82.js → no-NO-zSnPtrDi.js} +2 -4
- package/dist/pl-PL-CQ6c2Qz_.js +30 -0
- package/dist/{pl-PL-CZLzkboH.js → pl-PL-DD8JN4Qf.js} +1 -2
- package/dist/pl-PL-DFAzuceF.js +13 -0
- package/dist/{pl-PL-DAPGaxWi.js → pl-PL-UB5J5JcB.js} +2 -4
- package/dist/pt-PT-C-hbNnsB.js +30 -0
- package/dist/{pt-PT-BY9rcwcF.js → pt-PT-CjsyP_OK.js} +2 -4
- package/dist/{pt-PT-CN4ws8N7.js → pt-PT-Xm-pm3mb.js} +1 -2
- package/dist/pt-PT-_o5xgnxS.js +13 -0
- package/dist/{resolveEnvironment-CDg6ksvB.js → resolveEnvironment-94mV6qts.js} +3 -3
- package/dist/ro-RO-BrTWk1Ui.js +30 -0
- package/dist/{ro-RO-RylOvc5g.js → ro-RO-C3m6aJVP.js} +1 -2
- package/dist/{ro-RO-DJLWmWZ4.js → ro-RO-C8yYXQc_.js} +2 -4
- package/dist/ro-RO-D7c_Rj8V.js +13 -0
- package/dist/{rules-BnJSV_NR.js → rules-D9wLpDnS.js} +5 -2
- package/dist/sk-SK-BBSuh2fA.js +13 -0
- package/dist/sk-SK-BTFtoPmI.js +30 -0
- package/dist/{sk-SK-BfJKbtGy.js → sk-SK-BVc-vNQm.js} +1 -2
- package/dist/{sk-SK-B7o3L57C.js → sk-SK-DbOE9C6n.js} +2 -4
- package/dist/sl-SI-BLTuWNf5.js +13 -0
- package/dist/sl-SI-BhVTSmhQ.js +30 -0
- package/dist/{sl-SI-C8CMAkD0.js → sl-SI-Br0UEUPL.js} +2 -4
- package/dist/{sl-SI-DklUFzaY.js → sl-SI-D_rqR0D7.js} +1 -2
- package/dist/style.css +3272 -3254
- package/dist/styles-CLV89_hH.js +3272 -3254
- package/dist/sv-SE-66rqYTxi.js +30 -0
- package/dist/{sv-SE-qduyDIzY.js → sv-SE-B3zoXMuH.js} +1 -2
- package/dist/sv-SE-BUfESAQK.js +13 -0
- package/dist/{sv-SE-Bwh0wKFk.js → sv-SE-BtXmvxx4.js} +2 -4
- package/dist/translation-BxcrjuWb.js +472 -0
- package/dist/types/api/industryCodes/industryCodes.types.d.ts +2 -0
- package/dist/types/api/industryCodes/useIndustryCodes.d.ts +6 -0
- package/dist/types/api/queryKeys.d.ts +2 -1
- package/dist/types/components/BankAccount/forms/PayoutDetails/PayoutDetails.d.ts +1 -0
- package/dist/types/components/BankAccount/forms/PayoutVerificationMethod/payoutVerificationMethodMetadata.d.ts +3 -3
- package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/payoutDetailsFormConfig.d.ts +0 -9
- package/dist/types/components/Business/forms/BasicInformation/BasicInformationMultiform.d.ts +0 -1
- package/dist/types/components/Business/forms/BusinessDetails/forms.d.ts +6 -0
- package/dist/types/components/Business/forms/rules.d.ts +1 -3
- package/dist/types/components/Business/tasks/BusinessDetailsDropin/utils.d.ts +1 -2
- package/dist/types/components/Business/tasks/BusinessDetailsMultiformDropin/BusinessDetailsMultiform.d.ts +1 -1
- package/dist/types/components/Contract/tasks/ServiceAgreementDropin/ServiceAgreementDropin.d.ts +1 -1
- package/dist/types/components/Contract/tasks/ServiceAgreementDropin/types.d.ts +1 -0
- package/dist/types/components/EFP/tasks/SourceOfFundsDropin/utils.d.ts +0 -1
- package/dist/types/components/EmbeddedDropins/AcceptTermsOfServiceComponent/AcceptTermsOfServiceComponent.d.ts +4 -3
- package/dist/types/components/Individual/forms/Individual/Individual.d.ts +4 -0
- package/dist/types/components/Individual/forms/Individual/ProofOfRelationship/types.d.ts +0 -5
- package/dist/types/components/Shared/fields/IdFieldTypeSelector/countryIdNumberTypes.d.ts +1 -1
- package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
- package/dist/types/components/Trust/forms/Trust/Trust.d.ts +1 -0
- package/dist/types/components/Trust/forms/TrustRegistrationDetails/types.d.ts +1 -2
- package/dist/types/components/Trust/tasks/TrustMembers/TrustMembersOverview.d.ts +2 -1
- package/dist/types/components/UnincorporatedPartnership/pages/UnincorporatedPartnershipMemberCompanyPage.d.ts +2 -1
- package/dist/types/components/ui/atoms/ActionsMenu/ActionsMenu.d.ts +2 -1
- package/dist/types/components/ui/atoms/Button/Button.types.d.ts +3 -3
- package/dist/types/components/ui/atoms/ListItem/ListItem.d.ts +2 -1
- package/dist/types/components/ui/atoms/RadioGroupCard/RadioGroupCard.types.d.ts +0 -14
- package/dist/types/components/ui/atoms/RadioWithLabel/RadioWithLabel.d.ts +2 -1
- package/dist/types/components/ui/atoms/SelectList/SelectList.d.ts +1 -0
- package/dist/types/components/ui/atoms/StepProgressIndicator/StepProgressIndicator.d.ts +2 -1
- package/dist/types/components/ui/atoms/StructuredList/StructuredList.d.ts +2 -1
- package/dist/types/components/ui/atoms/Svg/svgs.d.ts +0 -12
- package/dist/types/components/ui/atoms/TaskStatusIndicator/TaskStatusIndicator.d.ts +3 -2
- package/dist/types/components/ui/layout/LandingLayout/LandingLayout.d.ts +1 -1
- package/dist/types/components/ui/layout/StackLayout/StackLayout.d.ts +2 -1
- package/dist/types/components/ui/molecules/InputCurrency/InputCurrency.d.ts +2 -1
- package/dist/types/components/ui/molecules/InputEmail/InputEmail.d.ts +2 -1
- package/dist/types/components/ui/molecules/InputGroup/InputGroup.d.ts +2 -1
- package/dist/types/components/ui/molecules/InputTelephone/InputTelephone.d.ts +2 -1
- package/dist/types/components/ui/molecules/InputText/InputText.d.ts +2 -0
- package/dist/types/components/ui/molecules/MaskedInput/MaskedInput.d.ts +0 -1
- package/dist/types/components/ui/molecules/Tabs/Tabs.d.ts +1 -1
- package/dist/types/context/StateContext/types.d.ts +1 -1
- package/dist/types/core/models/api/accountIdentification.d.ts +5 -4
- package/dist/types/core/models/api/contracts.d.ts +1 -1
- package/dist/types/core/process-field-configurations.d.ts +14 -3
- package/dist/types/embeds/business-financing/AdyenBusinessFinancing.d.ts +1 -1
- package/dist/types/embeds/business-financing/adyen-business-financing.types.d.ts +1 -5
- package/dist/types/embeds/emitEvent.d.ts +14 -0
- package/dist/types/embeds/individual/adyen-individual.types.d.ts +2 -2
- package/dist/types/embeds/manage-individual/AdyenManageIndividual.d.ts +1 -1
- package/dist/types/embeds/manage-individual/adyen-manage-individual.types.d.ts +1 -1
- package/dist/types/embeds/manage-terms-of-service/AdyenManageTermsOfService.d.ts +1 -1
- package/dist/types/embeds/manage-terms-of-service/adyen-manage-terms-of-service.types.d.ts +1 -1
- package/dist/types/embeds/manage-transfer-instruments/AdyenManageTransferInstrument.d.ts +3 -4
- package/dist/types/embeds/manage-transfer-instruments/adyen-manage-transfer-instruments.types.d.ts +3 -4
- package/dist/types/embeds/terms-of-service/adyen-terms-of-service.types.d.ts +4 -3
- package/dist/types/embeds/transfer-instrument/adyen-transfer-instrument.types.d.ts +2 -2
- package/dist/types/embeds/verification-status/adyen-verification-status.types.d.ts +3 -3
- package/dist/types/hooks/introduction/useIntroductionScreens.d.ts +2 -1
- package/dist/types/hooks/introduction/useShouldShowIntroduction.d.ts +2 -1
- package/dist/types/language/utils.d.ts +1 -1
- package/dist/types/utils/addLinkedFields.d.ts +7 -1
- package/dist/types/utils/entityStatusUtil.d.ts +1 -1
- package/dist/types/utils/formUtils.d.ts +1 -1
- package/dist/types/utils/getDisplayErrorMessage.d.ts +1 -1
- package/dist/types/utils/getName.d.ts +1 -1
- package/dist/types/utils/makeSelectItemForRole.d.ts +1 -1
- package/dist/types/utils/masking/masks/businessRegistrationNumberMasks.d.ts +5 -0
- package/dist/types/utils/translation.d.ts +6 -0
- package/dist/types-CAznNNSI.js +160 -0
- package/dist/types-DAyrP-xk.js +64 -0
- package/dist/types-Da02-5C7.js +74 -0
- package/dist/useAssociatedLegalEntity-Bw8j7jsT.js +33 -0
- package/dist/useDataset-BLJa9WLi.js +120 -0
- package/dist/useForm-CiqZ15MF.js +1694 -0
- package/dist/useFormContext-beqGS11A.js +23 -0
- package/dist/useGlobalData-DRn0XQ0c.js +205 -0
- package/dist/{useMultiForm-Cbf_MGdG.js → useMultiForm-B2RH71uE.js} +4 -2
- package/dist/{useOnboardingStatus-bmHIDRGr.js → useOnboardingStatus-D1idaeSA.js} +2 -2
- package/dist/useScenarios-MJLlpy2B.js +46 -0
- package/dist/{useTermsOfServiceStatus-CMtyaC84.js → useTermsOfServiceStatus-YnguYeSj.js} +2 -2
- package/dist/useToastContext-BBdhLX_K.js +51 -0
- package/dist/useUnincorporatedPartnershipMembers-TCYzsxr-.js +99 -0
- package/dist/utils-Bw6dVL0x.js +29 -0
- package/dist/{utils-B-s8erbM.js → utils-CMkU9dq6.js} +46 -4
- package/dist/utils-DNSfZiio.js +70 -0
- package/dist/utils-Drt88lUg.js +159 -0
- package/dist/validate-BacCnDiH.js +382 -0
- package/dist/{validate-CNlNB2Sq.js → validate-BlPEAs8d.js} +2 -2
- package/dist/validate-DQ_IsigQ.js +605 -0
- package/dist/validationError-eJqGwKE_.js +86 -0
- package/package.json +44 -45
- package/dist/BusinessDetailsDropin-DR8YA-wz.js +0 -2136
- package/dist/BusinessFinancingComponent-saZxipq7.js +0 -38
- package/dist/BusinessFinancingPage-D7NMT1SV.js +0 -35
- package/dist/CreateIndividualComponent-B_6j8j5H.js +0 -64
- package/dist/CreateTransferInstrumentComponent-DgZq6f2m.js +0 -55
- package/dist/LegalRepresentativeDetailsPage-R9h6n8e1.js +0 -55
- package/dist/ManageIndividualComponent-D3EZWpKz.js +0 -42
- package/dist/ManageTermsOfServiceComponent-C2BMpyzo.js +0 -40
- package/dist/RootIndividualDetailsPage-DGpYhDWo.js +0 -71
- package/dist/SoleProprietorshipPage-CF_TKUfD.js +0 -44
- package/dist/StoreProvider-pdSV8sgb.js +0 -31920
- package/dist/TrustMemberCompanyPage-6_h3PnmT.js +0 -54
- package/dist/TrustMemberIndividualPage-DPlQ6OnQ.js +0 -60
- package/dist/UnincorporatedPartnershipIndividualPage-Bgcip8u6.js +0 -60
- package/dist/UnincorporatedPartnershipMemberCompanyPage-k5Cc0TWw.js +0 -57
- package/dist/VerificationErrorAlert-BEgXW4gA.js +0 -77
- package/dist/bg-BG-BvSUDgGF.js +0 -13
- package/dist/cs-CZ-y4mvq4Lv.js +0 -13
- package/dist/da-DK-qgQOVjDp.js +0 -13
- package/dist/de-DE-pSdsxBpQ.js +0 -13
- package/dist/el-GR-Bvjk5Sw8.js +0 -13
- package/dist/en-US-Bq2Twy6x.js +0 -54
- package/dist/es-ES-Dy1uR2H_.js +0 -13
- package/dist/et-EE-d9V24rcf.js +0 -13
- package/dist/fi-FI-B0fnAFV2.js +0 -13
- package/dist/fr-FR-BoKzVp2q.js +0 -13
- package/dist/getFieldsWithExistingData-BPKk0HGd.js +0 -22
- package/dist/hr-HR-CF0AHQzi.js +0 -13
- package/dist/hu-HU-CSPhOvLC.js +0 -13
- package/dist/it-IT-BH-eqIKH.js +0 -13
- package/dist/ja-JP-B3yqM_FM.js +0 -13
- package/dist/lt-LT-Lzl_Cbw-.js +0 -13
- package/dist/lv-LV-y00wN1pj.js +0 -13
- package/dist/mapFinancialReportsToFinancialInformation-iVvcsDNu.js +0 -66
- package/dist/mapScriptLocalization-H2Re3k5X.js +0 -35
- package/dist/nl-NL-DmnFXAQC.js +0 -13
- package/dist/no-NO-DbvFfP96.js +0 -13
- package/dist/pl-PL--mmxopYA.js +0 -13
- package/dist/pt-PT-BVzXBFp7.js +0 -13
- package/dist/ro-RO-Cdmevo9A.js +0 -13
- package/dist/ru-RU-FZb2upqh.js +0 -13
- package/dist/sk-SK-nfeuTcY5.js +0 -13
- package/dist/sl-SI-DUTZDqkP.js +0 -13
- package/dist/sv-SE-BTx2XKAp.js +0 -13
- package/dist/useUpdateLegalEntity-D91nO-DU.js +0 -57
- package/dist/validate-DhvbSKV4.js +0 -40
- package/dist/zh-CN-wUb4MmTZ.js +0 -13
- package/dist/zh-TW-DNTXHLKa.js +0 -13
|
@@ -0,0 +1,3694 @@
|
|
|
1
|
+
;
|
|
2
|
+
{
|
|
3
|
+
try {
|
|
4
|
+
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
5
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e2aa344f-11a3-4a5a-94f8-9063179fcc86", e._sentryDebugIdIdentifier = "sentry-dbid-e2aa344f-11a3-4a5a-94f8-9063179fcc86");
|
|
6
|
+
} catch (e) {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
;
|
|
10
|
+
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
11
|
+
import { useState, useEffect, useRef, useMemo, useCallback, useContext } from "preact/hooks";
|
|
12
|
+
import { b as useApiContext, j as useQuery, k as httpPost, o as httpGet, aA as useMutation, aC as useQueryClient, N as createLogger, a8 as CountryCodes, a as useTranslation, c as useLegalEntity, R as ROOT_LE, y as LegalEntityTypes, L as Loader, J as EntityTypes, U as useAnalyticsContext, V as Icon, x as Typography, B as Button, u as useI18nContext, af as objectsDeepEqual, aG as doArraysMatch, a9 as isEmpty, bj as getSdkToken, G as hasOwnEntityAssociationOfType, m as useSettingsContext, bk as EEA_Countries, X as useExperimentsContext, bl as isAccountIdentifierObscured, bm as hasEmptyFields, bn as extractFieldName, bo as concatenateFieldNames, aD as keysOf, g as getLegalEntityCountry, am as getCapabilityProblems, M as TaskTypes, ay as cloneObject, q as skipToken } from "./StoreProvider-B6-mwoeD.js";
|
|
13
|
+
import { u as useTransferInstrument, m as mapTransferInstrumentToPayoutAccount } from "./mapTransferInstrumentToPayoutAccount-CijqOJMZ.js";
|
|
14
|
+
import { a as useForm, F as Field, c as Select, L as LoaderWrapper } from "./useForm-CiqZ15MF.js";
|
|
15
|
+
import { E as ExperimentNames } from "./types-CAznNNSI.js";
|
|
16
|
+
import { I as InputText, S as SettingNames } from "./InputText-BCNFl9Ni.js";
|
|
17
|
+
import { u as useGlobalDataSlice, a as useGlobalData, b as useResetGlobalData, c as useStateContext, F as FormWrapper } from "./useGlobalData-DRn0XQ0c.js";
|
|
18
|
+
import { a as useInvalidateRootLegalEntity, u as useToastContext } from "./useToastContext-BBdhLX_K.js";
|
|
19
|
+
import { D as DropzoneFile, h as bytesToSize, i as defaultFileValidationOptions, j as fileValidationRules, S as StateContextSetter, a as getDocument, c as createDocumentRequest, k as augmentWithCountryConfigs, d as documentApiUtils, b as getPropsFromConfigurations, f as getFileExtention } from "./validate-DQ_IsigQ.js";
|
|
20
|
+
import { g as getRequiredForms, a as addValidityToForms, u as useFormComposer } from "./dropinUtils-CkJv8r-0.js";
|
|
21
|
+
import { D as DocumentGuidance, A as AdyenKycSdkError, u as uppercase, p as payoutAccountFormat, m as mapExistingFile, g as getPageName, b as useScenarioConfiguration, c as useUnifyLoadingStatus } from "./mapExistingFile-D8NcT-or.js";
|
|
22
|
+
import { C as Confirm } from "./Confirm-X9nR52Md.js";
|
|
23
|
+
import { c as currencyByCountry } from "./types-DAyrP-xk.js";
|
|
24
|
+
import { i as isValidationError, p as processValidationErrors, b as isIdDocumentUploadError, c as isBankStatementUploadError, a as isMaintenanceModeError, m as mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable } from "./validationError-eJqGwKE_.js";
|
|
25
|
+
import { u as useDataset, d as datasetIdentifier, a as datasetUtilities } from "./useDataset-BLJa9WLi.js";
|
|
26
|
+
import { g as getLegalEntityNameBasedOnType, b as getPayoutAccountHolderName } from "./getName-BkvLQ7My.js";
|
|
27
|
+
import { I as IFrameWidget, o as omitObscuredFieldsIfUnchanged } from "./iframeWidget-BfmN5KKM.js";
|
|
28
|
+
import { Show } from "@preact/signals/utils";
|
|
29
|
+
import { c as createFormUtils, F as FormHeader, E as ErrorPanel, m as mergeFieldMetadataIntoProps, g as getFieldProps, C as CountryField, f as getFormProps, d as summaryStep, s as summaryItem } from "./CountryField-DxBBjy81.js";
|
|
30
|
+
import { a as addResourceBundles, _ as __variableDynamicImportRuntimeHelper, T as Trans } from "./translation-BxcrjuWb.js";
|
|
31
|
+
import { signal } from "@preact/signals";
|
|
32
|
+
import { u as useAssociatedLegalEntity } from "./useAssociatedLegalEntity-Bw8j7jsT.js";
|
|
33
|
+
import { b as useCapabilityProblems, g as getProblemsForEntity, T as TextArea, f as validatePatternOnBlur, r as resolveFieldMetadata, a as useAccountHolder, I as Image, R as RadioGroupCard, C as ContextGuidance } from "./fieldConfigurations-CzZ2B1fa.js";
|
|
34
|
+
import { c as createFormRules } from "./form-rules-DhbF2mY4.js";
|
|
35
|
+
import { memo, lazy } from "preact/compat";
|
|
36
|
+
import { u as useUnincorporatedPartnershipMembers } from "./useUnincorporatedPartnershipMembers-TCYzsxr-.js";
|
|
37
|
+
import cx from "classnames";
|
|
38
|
+
import { b as bankStatementDescriptionPattern } from "./basePatterns-BwdnMQxI.js";
|
|
39
|
+
import { createContext } from "preact";
|
|
40
|
+
import { a as Alert } from "./Alert-DCYc9VpX.js";
|
|
41
|
+
import { A as ActionBar } from "./FormNavigation-BdFqTFAy.js";
|
|
42
|
+
import OpenBankingSDK from "@adyen/openbankingsdk";
|
|
43
|
+
import { m as makeMask, n as numericInputs, a as nonInputs, s as spacer, c as customInputs, M as MaskedInput, d as alphanumericInputs, b as alphaInputs } from "./MaskedInput-DOTRZoSO.js";
|
|
44
|
+
import { a as isNotEmptyValidator } from "./commonValidators-CwkyFFVz.js";
|
|
45
|
+
import { C as Currencies } from "./currency-BGwQyxBo.js";
|
|
46
|
+
import { L as Link } from "./Link-BGc9wGrL.js";
|
|
47
|
+
const getCheck = async (legalEntityId, baseUrl, data) => {
|
|
48
|
+
return httpPost(
|
|
49
|
+
{
|
|
50
|
+
baseUrl,
|
|
51
|
+
path: `legalEntities/${legalEntityId}/checks/bankAccount`
|
|
52
|
+
},
|
|
53
|
+
data
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
const useCheck = (data, options) => {
|
|
57
|
+
const { rootLegalEntityId, baseUrl: url } = useApiContext();
|
|
58
|
+
return useQuery({
|
|
59
|
+
queryKey: ["checkAsAService", data],
|
|
60
|
+
queryFn: () => getCheck(rootLegalEntityId.value, url.value, data),
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const getBankVerificationProviders = async (legalEntityId, baseUrl, queryParams) => {
|
|
65
|
+
const { country, locale, configId } = queryParams;
|
|
66
|
+
const providerParams = new URLSearchParams({
|
|
67
|
+
country,
|
|
68
|
+
locale,
|
|
69
|
+
...configId && { configId }
|
|
70
|
+
});
|
|
71
|
+
return httpGet({
|
|
72
|
+
baseUrl,
|
|
73
|
+
path: `legalEntities/${legalEntityId}/transferInstruments/trusted/providers?${providerParams}`
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const useBankVerificationProviders = (queryParams, options) => {
|
|
77
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
78
|
+
return useQuery({
|
|
79
|
+
queryKey: ["bankVerificationProviders", queryParams],
|
|
80
|
+
queryFn: () => getBankVerificationProviders(rootLegalEntityId.value, baseUrl.value, queryParams),
|
|
81
|
+
...options
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const createTransferInstrument = async (rootLegalEntityId, baseUrl, transferInstrument) => {
|
|
85
|
+
return httpPost(
|
|
86
|
+
{
|
|
87
|
+
baseUrl,
|
|
88
|
+
path: `legalEntities/${rootLegalEntityId}/transferInstruments`
|
|
89
|
+
},
|
|
90
|
+
transferInstrument
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
const createTrustedTransferInstrument = async (legalEntityId, baseUrl, data) => {
|
|
94
|
+
return httpPost(
|
|
95
|
+
{
|
|
96
|
+
baseUrl,
|
|
97
|
+
path: `legalEntities/${legalEntityId}/transferInstruments/trusted`
|
|
98
|
+
},
|
|
99
|
+
data
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
const useCreateTrustedTransferInstrument = (options) => {
|
|
103
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
104
|
+
return useMutation({
|
|
105
|
+
mutationFn: (data) => createTrustedTransferInstrument(rootLegalEntityId.value, baseUrl.value, data),
|
|
106
|
+
...options
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const updateTransferInstrument = async (legalEntityId, baseUrl, transferInstrument, transferInstrumentId) => {
|
|
110
|
+
return httpPost(
|
|
111
|
+
{
|
|
112
|
+
baseUrl,
|
|
113
|
+
path: `legalEntities/${legalEntityId}/transferInstruments/${transferInstrumentId}`
|
|
114
|
+
},
|
|
115
|
+
transferInstrument
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
const useUpdateTransferInstrument = (options) => {
|
|
119
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
120
|
+
const queryClient = useQueryClient();
|
|
121
|
+
return useMutation({
|
|
122
|
+
mutationFn: ({ transferInstrument, transferInstrumentId }) => updateTransferInstrument(
|
|
123
|
+
rootLegalEntityId.value,
|
|
124
|
+
baseUrl.value,
|
|
125
|
+
transferInstrument,
|
|
126
|
+
transferInstrumentId
|
|
127
|
+
),
|
|
128
|
+
onSuccess: async (transferInstrument) => {
|
|
129
|
+
queryClient.setQueryData(["transferInstrument", transferInstrument.id], transferInstrument);
|
|
130
|
+
await queryClient.invalidateQueries({
|
|
131
|
+
// Invalidate transfer instruments on root LE
|
|
132
|
+
queryKey: ["transferInstruments"]
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
...options
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const accountFormatsImports = /* @__PURE__ */ Object.assign({ "../accountFormats/AD.json": () => import("./AD-CyP5INSp.js"), "../accountFormats/AE.json": () => import("./AE-mIZ12t47.js"), "../accountFormats/AI.json": () => import("./AI-CYOqGKk2.js"), "../accountFormats/AL.json": () => import("./AL-BX1fEo1A.js"), "../accountFormats/AR.json": () => import("./AR-C9kMRnHG.js"), "../accountFormats/AS.json": () => import("./AS-B0TMZQ6o.js"), "../accountFormats/AT.json": () => import("./AT-DJLlevck.js"), "../accountFormats/AU.json": () => import("./AU-B5LSe4bo.js"), "../accountFormats/AX.json": () => import("./AX-Z6f6EnJc.js"), "../accountFormats/AZ.json": () => import("./AZ-BqrKjWMH.js"), "../accountFormats/BA.json": () => import("./BA-BbP72Tn6.js"), "../accountFormats/BE.json": () => import("./BE-B-m_4F41.js"), "../accountFormats/BG.json": () => import("./BG-BVR5ytc-.js"), "../accountFormats/BH.json": () => import("./BH-Ded1Eyrc.js"), "../accountFormats/BM.json": () => import("./BM-CBl-UQUl.js"), "../accountFormats/BR.json": () => import("./BR-DsY9PZVZ.js"), "../accountFormats/BS.json": () => import("./BS-dBfArxRw.js"), "../accountFormats/BV.json": () => import("./BV-D0QBsH7-.js"), "../accountFormats/BY.json": () => import("./BY-BsQUo3fM.js"), "../accountFormats/CA.json": () => import("./CA-DT4cmOOe.js"), "../accountFormats/CH.json": () => import("./CH-CesIKOYy.js"), "../accountFormats/CN.json": () => import("./CN-BV-5PSpq.js"), "../accountFormats/CR.json": () => import("./CR-Dtv-rXg9.js"), "../accountFormats/CY.json": () => import("./CY-BnJ7k_mN.js"), "../accountFormats/CZ.json": () => import("./CZ-BiPeoA9G.js"), "../accountFormats/DE.json": () => import("./DE-DdcbG-CC.js"), "../accountFormats/DK.json": () => import("./DK-DA8qRrzq.js"), "../accountFormats/DO.json": () => import("./DO-B1BWc3Iy.js"), "../accountFormats/EC.json": () => import("./EC-DbNXe71-.js"), "../accountFormats/EE.json": () => import("./EE-CaXoPgZz.js"), "../accountFormats/ES.json": () => import("./ES-Bt_oaIaf.js"), "../accountFormats/FI.json": () => import("./FI-C5V3lLuN.js"), "../accountFormats/FJ.json": () => import("./FJ-CBdbPf5l.js"), "../accountFormats/FO.json": () => import("./FO-1pD1p939.js"), "../accountFormats/FR.json": () => import("./FR-Bc1tLIC4.js"), "../accountFormats/GB.json": () => import("./GB-CCYHTagl.js"), "../accountFormats/GE.json": () => import("./GE-Deog1a3Z.js"), "../accountFormats/GF.json": () => import("./GF-Cda8N7A4.js"), "../accountFormats/GG.json": () => import("./GG-BGuqxplU.js"), "../accountFormats/GI.json": () => import("./GI-CROkpYrU.js"), "../accountFormats/GL.json": () => import("./GL-0vO9Of9c.js"), "../accountFormats/GP.json": () => import("./GP-za-3opp-.js"), "../accountFormats/GR.json": () => import("./GR-B9c2boG8.js"), "../accountFormats/GT.json": () => import("./GT-C1jhs-Dx.js"), "../accountFormats/GU.json": () => import("./GU-CALV5vh1.js"), "../accountFormats/HK.json": () => import("./HK-BB3PIq-Z.js"), "../accountFormats/HR.json": () => import("./HR-p4luVYpu.js"), "../accountFormats/HU.json": () => import("./HU-D8vJYkDH.js"), "../accountFormats/ID.json": () => import("./ID-BcOv4SXj.js"), "../accountFormats/IE.json": () => import("./IE-Cli_j7Al.js"), "../accountFormats/IL.json": () => import("./IL-CQ0yHRRe.js"), "../accountFormats/IM.json": () => import("./IM-mpIyBn16.js"), "../accountFormats/IN.json": () => import("./IN-BhEI9o7G.js"), "../accountFormats/IS.json": () => import("./IS-02zCAdvq.js"), "../accountFormats/IT.json": () => import("./IT-CzURFhrK.js"), "../accountFormats/JE.json": () => import("./JE-MFwIYti7.js"), "../accountFormats/JM.json": () => import("./JM-BMGgBK6y.js"), "../accountFormats/JO.json": () => import("./JO-rY8A8f9C.js"), "../accountFormats/JP.json": () => import("./JP-BQG5dF1Y.js"), "../accountFormats/KR.json": () => import("./KR-74SwXHka.js"), "../accountFormats/KW.json": () => import("./KW-CcVPOJ8B.js"), "../accountFormats/KY.json": () => import("./KY-DXCeltYA.js"), "../accountFormats/KZ.json": () => import("./KZ-CZNjdp22.js"), "../accountFormats/LB.json": () => import("./LB-DZ5YfAsO.js"), "../accountFormats/LI.json": () => import("./LI-DA06W10W.js"), "../accountFormats/LT.json": () => import("./LT-DuU6E2Ct.js"), "../accountFormats/LU.json": () => import("./LU-BQHhNpDy.js"), "../accountFormats/LV.json": () => import("./LV-DN7wckbP.js"), "../accountFormats/MC.json": () => import("./MC-DtSWC4jS.js"), "../accountFormats/MD.json": () => import("./MD-DVc0183a.js"), "../accountFormats/ME.json": () => import("./ME-DiJhSuli.js"), "../accountFormats/MK.json": () => import("./MK-BZxslBTS.js"), "../accountFormats/MP.json": () => import("./MP-7IpnbfCj.js"), "../accountFormats/MQ.json": () => import("./MQ-DusG_no1.js"), "../accountFormats/MR.json": () => import("./MR-DaBVNHqN.js"), "../accountFormats/MT.json": () => import("./MT-DeDMQ1f_.js"), "../accountFormats/MU.json": () => import("./MU-D3gGVu1R.js"), "../accountFormats/MX.json": () => import("./MX-CZVOFg3D.js"), "../accountFormats/MY.json": () => import("./MY-ym71svTa.js"), "../accountFormats/NC.json": () => import("./NC-xzMvjp9-.js"), "../accountFormats/NL.json": () => import("./NL-aVL0NAp-.js"), "../accountFormats/NO.json": () => import("./NO-D7EOiQA1.js"), "../accountFormats/NZ.json": () => import("./NZ-BP7_Q9Om.js"), "../accountFormats/PE.json": () => import("./PE-CdxgPh3v.js"), "../accountFormats/PF.json": () => import("./PF-CstaOd9Z.js"), "../accountFormats/PH.json": () => import("./PH-BYgMDYIH.js"), "../accountFormats/PK.json": () => import("./PK-bLhtgsEk.js"), "../accountFormats/PL.json": () => import("./PL-Bg7axKQA.js"), "../accountFormats/PM.json": () => import("./PM-BWbxAh4u.js"), "../accountFormats/PR.json": () => import("./PR-CFPKXEXp.js"), "../accountFormats/PS.json": () => import("./PS-B8obOOWY.js"), "../accountFormats/PT.json": () => import("./PT-hB1HnBM2.js"), "../accountFormats/QA.json": () => import("./QA-CSfx-mvb.js"), "../accountFormats/RE.json": () => import("./RE-BApq1FJ6.js"), "../accountFormats/RO.json": () => import("./RO-BLlC4CKq.js"), "../accountFormats/RS.json": () => import("./RS-BCenke-W.js"), "../accountFormats/RU.json": () => import("./RU-D27RC7dq.js"), "../accountFormats/SA.json": () => import("./SA-C9VgxCgm.js"), "../accountFormats/SE.json": () => import("./SE-q25Qt85B.js"), "../accountFormats/SG.json": () => import("./SG-DoCqjlFi.js"), "../accountFormats/SI.json": () => import("./SI-BzA-ozn6.js"), "../accountFormats/SJ.json": () => import("./SJ-Z9jwQQlz.js"), "../accountFormats/SK.json": () => import("./SK-DOTdLJPw.js"), "../accountFormats/SM.json": () => import("./SM-B4BIgmhk.js"), "../accountFormats/TF.json": () => import("./TF-BOWng-Dz.js"), "../accountFormats/TH.json": () => import("./TH-CvyXLcZK.js"), "../accountFormats/TL.json": () => import("./TL-BWslydRz.js"), "../accountFormats/TN.json": () => import("./TN-Cjd3bM_V.js"), "../accountFormats/TR.json": () => import("./TR-BBx5CuWS.js"), "../accountFormats/TT.json": () => import("./TT-D4-z5BA-.js"), "../accountFormats/TW.json": () => import("./TW-BC8YpnMr.js"), "../accountFormats/UA.json": () => import("./UA-DrXUnAe6.js"), "../accountFormats/US.json": () => import("./US-D8dI5_i1.js"), "../accountFormats/UY.json": () => import("./UY-DEHqLXhX.js"), "../accountFormats/VA.json": () => import("./VA-bPXdCnwD.js"), "../accountFormats/VG.json": () => import("./VG-DnKAVCsi.js"), "../accountFormats/VI.json": () => import("./VI-CU9MA9ux.js"), "../accountFormats/VN.json": () => import("./VN-CTSqsmB6.js"), "../accountFormats/WF.json": () => import("./WF-CwHbsjtJ.js"), "../accountFormats/YT.json": () => import("./YT-BCyAAbo7.js"), "../accountFormats/ZA.json": () => import("./ZA-NU7slima.js") });
|
|
139
|
+
const getAccountFormatsForCountry = async (country) => {
|
|
140
|
+
const importForCountry = accountFormatsImports[`../accountFormats/${country}.json`];
|
|
141
|
+
if (!importForCountry) {
|
|
142
|
+
throw Error(`No account formats available for ${country}`);
|
|
143
|
+
}
|
|
144
|
+
return (await importForCountry()).default;
|
|
145
|
+
};
|
|
146
|
+
const validateAccountIdentification = async (baseUrl, data) => {
|
|
147
|
+
return httpPost(
|
|
148
|
+
{
|
|
149
|
+
baseUrl,
|
|
150
|
+
path: `validations/accountidentification`
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
accountIdentification: {
|
|
154
|
+
...data
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
const useValidateAccountIdentification = (options) => {
|
|
160
|
+
const { baseUrl } = useApiContext();
|
|
161
|
+
return useMutation({
|
|
162
|
+
mutationFn: (data) => validateAccountIdentification(baseUrl.value, data),
|
|
163
|
+
...options
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
const useAsyncAccountDetailsValidationRules = (payload, hasEmptyFields2, isAccountNumberMasked) => {
|
|
167
|
+
const [timeoutId, setTimeoutId] = useState(null);
|
|
168
|
+
const [accountValidationData, setAccountValidationData] = useState({
|
|
169
|
+
invalidFields: [],
|
|
170
|
+
valid: false
|
|
171
|
+
});
|
|
172
|
+
const { mutateAsync } = useValidateAccountIdentification();
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
const fetchAccountDetails = async (accountIdentificationPayload) => {
|
|
175
|
+
try {
|
|
176
|
+
const accountIdentificationResponse = await mutateAsync(accountIdentificationPayload);
|
|
177
|
+
setAccountValidationData(accountIdentificationResponse);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error("Error fetching account details:", error);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
if (payload && !hasEmptyFields2 && !isAccountNumberMasked) {
|
|
183
|
+
if (timeoutId !== null) {
|
|
184
|
+
clearTimeout(timeoutId);
|
|
185
|
+
}
|
|
186
|
+
setTimeoutId(
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
fetchAccountDetails(payload);
|
|
189
|
+
setTimeoutId(null);
|
|
190
|
+
}, 500)
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}, [mutateAsync, hasEmptyFields2, payload]);
|
|
194
|
+
return accountValidationData;
|
|
195
|
+
};
|
|
196
|
+
const logger = createLogger();
|
|
197
|
+
const getAccountIdentificationFromPayoutAccountSchema = (payoutAccount, bankCountry) => {
|
|
198
|
+
if ("iban" in payoutAccount && payoutAccount.iban)
|
|
199
|
+
return {
|
|
200
|
+
type: "iban",
|
|
201
|
+
iban: payoutAccount.iban
|
|
202
|
+
};
|
|
203
|
+
switch (bankCountry) {
|
|
204
|
+
case CountryCodes.Australia:
|
|
205
|
+
return {
|
|
206
|
+
type: "auLocal",
|
|
207
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
208
|
+
bsbCode: payoutAccount.branchCode
|
|
209
|
+
};
|
|
210
|
+
case CountryCodes.Brazil:
|
|
211
|
+
return {
|
|
212
|
+
type: "brLocal",
|
|
213
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
214
|
+
ispb: payoutAccount.bankCode,
|
|
215
|
+
bankCode: payoutAccount.bankName,
|
|
216
|
+
branchNumber: payoutAccount.branchCode
|
|
217
|
+
};
|
|
218
|
+
case CountryCodes.Canada:
|
|
219
|
+
return {
|
|
220
|
+
type: "caLocal",
|
|
221
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
222
|
+
institutionNumber: payoutAccount.bankCode,
|
|
223
|
+
transitNumber: payoutAccount.branchCode
|
|
224
|
+
};
|
|
225
|
+
case CountryCodes.CzechRepublic:
|
|
226
|
+
return {
|
|
227
|
+
type: "czLocal",
|
|
228
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
229
|
+
bankCode: payoutAccount.bankCode
|
|
230
|
+
};
|
|
231
|
+
case CountryCodes.Denmark:
|
|
232
|
+
return {
|
|
233
|
+
type: "dkLocal",
|
|
234
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
235
|
+
bankCode: payoutAccount.bankCode
|
|
236
|
+
};
|
|
237
|
+
case CountryCodes.HongKong:
|
|
238
|
+
return {
|
|
239
|
+
type: "hkLocal",
|
|
240
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
241
|
+
clearingCode: payoutAccount.bankCode
|
|
242
|
+
};
|
|
243
|
+
case CountryCodes.NewZealand:
|
|
244
|
+
return {
|
|
245
|
+
type: "nzLocal",
|
|
246
|
+
accountNumber: payoutAccount.bankAccountNumber?.replaceAll("-", "")
|
|
247
|
+
};
|
|
248
|
+
case CountryCodes.Sweden:
|
|
249
|
+
return {
|
|
250
|
+
type: "seLocal",
|
|
251
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
252
|
+
clearingNumber: payoutAccount.branchCode
|
|
253
|
+
};
|
|
254
|
+
case CountryCodes.Singapore:
|
|
255
|
+
return {
|
|
256
|
+
type: "sgLocal",
|
|
257
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
258
|
+
bic: payoutAccount.swiftCode
|
|
259
|
+
};
|
|
260
|
+
case CountryCodes.IsleOfMan:
|
|
261
|
+
case CountryCodes.Guernsey:
|
|
262
|
+
case CountryCodes.Gibraltar:
|
|
263
|
+
case CountryCodes.Jersey:
|
|
264
|
+
case CountryCodes.UnitedKingdom:
|
|
265
|
+
return {
|
|
266
|
+
type: "ukLocal",
|
|
267
|
+
// for some reason GB's account identification is called `ukLocalAccountIdentification`
|
|
268
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
269
|
+
sortCode: payoutAccount.branchCode
|
|
270
|
+
};
|
|
271
|
+
case CountryCodes.NorthernMarianaIslands:
|
|
272
|
+
case CountryCodes.Guam:
|
|
273
|
+
case CountryCodes.VirginIslandsUS:
|
|
274
|
+
case CountryCodes.AmericanSamoa:
|
|
275
|
+
case CountryCodes.PuertoRico:
|
|
276
|
+
case CountryCodes.UnitedStates:
|
|
277
|
+
return {
|
|
278
|
+
type: "usLocal",
|
|
279
|
+
accountNumber: payoutAccount.bankAccountNumber,
|
|
280
|
+
routingNumber: payoutAccount.branchCode
|
|
281
|
+
};
|
|
282
|
+
default:
|
|
283
|
+
logger.log(`${bankCountry.toLowerCase()}Local is not a configured region`);
|
|
284
|
+
return {
|
|
285
|
+
type: `${bankCountry.toLowerCase()}Local`,
|
|
286
|
+
accountNumber: payoutAccount.bankAccountNumber
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const mapPayoutAccountSchemaToApiBankAccount = (payoutAccount, bankCountry) => ({
|
|
291
|
+
accountIdentification: getAccountIdentificationFromPayoutAccountSchema(
|
|
292
|
+
payoutAccount,
|
|
293
|
+
bankCountry
|
|
294
|
+
),
|
|
295
|
+
countryCode: bankCountry,
|
|
296
|
+
bankName: payoutAccount.bankName
|
|
297
|
+
});
|
|
298
|
+
const showPayoutVerificationMethodError = signal(false);
|
|
299
|
+
function PayoutDetailsPage({
|
|
300
|
+
transferInstrumentId,
|
|
301
|
+
setTransferInstrumentId,
|
|
302
|
+
taskType,
|
|
303
|
+
openBankingPartnerConfigId,
|
|
304
|
+
onSubmit,
|
|
305
|
+
handleHomeClick
|
|
306
|
+
}) {
|
|
307
|
+
const { i18n } = useTranslation();
|
|
308
|
+
const { data: rootLe } = useLegalEntity(ROOT_LE);
|
|
309
|
+
const { data: associatedLe, isLoading: associatedLeIsLoading } = useAssociatedLegalEntity(
|
|
310
|
+
rootLe,
|
|
311
|
+
[
|
|
312
|
+
LegalEntityTypes.SOLE_PROPRIETORSHIP,
|
|
313
|
+
LegalEntityTypes.TRUST,
|
|
314
|
+
LegalEntityTypes.UNINCORPORATED_PARTNERSHIP
|
|
315
|
+
]
|
|
316
|
+
);
|
|
317
|
+
const capabilityProblems = useCapabilityProblems();
|
|
318
|
+
addResourceBundles(i18n, i18n.language, [
|
|
319
|
+
{ ns: "banking", importFn: () => __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "../language/bg-BG.json": () => import("./bg-BG-CMomhopf.js"), "../language/cs-CZ.json": () => import("./cs-CZ-DMzortvO.js"), "../language/da-DK.json": () => import("./da-DK-q2b_1elr.js"), "../language/de-DE.json": () => import("./de-DE-D2ByeIZs.js"), "../language/el-GR.json": () => import("./el-GR-DGW388LZ.js"), "../language/en-US.json": () => import("./en-US-BQpgt41j.js"), "../language/es-ES.json": () => import("./es-ES-WWftn3JX.js"), "../language/et-EE.json": () => import("./et-EE-D5lRJbMZ.js"), "../language/fi-FI.json": () => import("./fi-FI-D9E_KaJi.js"), "../language/fr-FR.json": () => import("./fr-FR-Cv0k-3Xc.js"), "../language/hr-HR.json": () => import("./hr-HR-CzSrqEFA.js"), "../language/hu-HU.json": () => import("./hu-HU-zK6nUqWr.js"), "../language/it-IT.json": () => import("./it-IT-C_fNHhjE.js"), "../language/ja-JP.json": () => import("./ja-JP-weDU8GLW.js"), "../language/lt-LT.json": () => import("./lt-LT-BUYY0LaT.js"), "../language/lv-LV.json": () => import("./lv-LV-B9js9VoA.js"), "../language/nl-NL.json": () => import("./nl-NL-DLedC3mO.js"), "../language/no-NO.json": () => import("./no-NO-CpVal4cV.js"), "../language/pl-PL.json": () => import("./pl-PL-1ylK-_FE.js"), "../language/pt-PT.json": () => import("./pt-PT-BkvMsoK4.js"), "../language/ro-RO.json": () => import("./ro-RO-Dfx0g3bU.js"), "../language/sk-SK.json": () => import("./sk-SK-iO863_t2.js"), "../language/sl-SI.json": () => import("./sl-SI-Cth2Qa5T.js"), "../language/sv-SE.json": () => import("./sv-SE-OPOHtqtP.js") }), `../language/${i18n.language}.json`, 3) }
|
|
320
|
+
]);
|
|
321
|
+
if (!rootLe || associatedLeIsLoading) {
|
|
322
|
+
return /* @__PURE__ */ jsx(Loader, {});
|
|
323
|
+
}
|
|
324
|
+
const problems = capabilityProblems && transferInstrumentId ? getProblemsForEntity(capabilityProblems, EntityTypes.BANK_ACCOUNT, transferInstrumentId) : void 0;
|
|
325
|
+
return /* @__PURE__ */ jsx(
|
|
326
|
+
PayoutDetailsDropin,
|
|
327
|
+
{
|
|
328
|
+
taskType,
|
|
329
|
+
currentTransferInstrumentId: transferInstrumentId,
|
|
330
|
+
setCurrentTransferInstrumentId: setTransferInstrumentId,
|
|
331
|
+
legalEntityResponse: rootLe,
|
|
332
|
+
associatedLegalArrangement: associatedLe,
|
|
333
|
+
problems,
|
|
334
|
+
onSubmit,
|
|
335
|
+
handleHomeClick,
|
|
336
|
+
navigateBackToTaskList: handleHomeClick,
|
|
337
|
+
openBankingPartnerConfigId
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
const PayoutDetailsPage$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
342
|
+
__proto__: null,
|
|
343
|
+
PayoutDetailsPage,
|
|
344
|
+
showPayoutVerificationMethodError
|
|
345
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
346
|
+
function FilePicker({
|
|
347
|
+
files,
|
|
348
|
+
setFiles,
|
|
349
|
+
isValid,
|
|
350
|
+
errorMessage,
|
|
351
|
+
multiple = false,
|
|
352
|
+
label,
|
|
353
|
+
name,
|
|
354
|
+
iconPrefix = "generic-document",
|
|
355
|
+
enableTracking = false,
|
|
356
|
+
id,
|
|
357
|
+
// file validation options
|
|
358
|
+
allowedFileTypes,
|
|
359
|
+
maxSize,
|
|
360
|
+
isOptional,
|
|
361
|
+
maxNumberOfFiles,
|
|
362
|
+
// a11y
|
|
363
|
+
"aria-describedby": ariaDescribedBy,
|
|
364
|
+
"aria-labelledby": ariaLabelledBy
|
|
365
|
+
}) {
|
|
366
|
+
const { t } = useTranslation("common");
|
|
367
|
+
const userEvents = useAnalyticsContext();
|
|
368
|
+
const fileInput = useRef(null);
|
|
369
|
+
const [dragged, setDragged] = useState(false);
|
|
370
|
+
const hasRequiredError = errorMessage === "fieldIsRequired";
|
|
371
|
+
const showDropzone = files.length < maxNumberOfFiles;
|
|
372
|
+
const openFilePicker = () => fileInput.current?.click();
|
|
373
|
+
const handleFileDelete = (fileToDelete) => setFiles(files.filter((file) => file !== fileToDelete));
|
|
374
|
+
const handleDragEnter = (e) => {
|
|
375
|
+
e.preventDefault();
|
|
376
|
+
e.stopPropagation();
|
|
377
|
+
};
|
|
378
|
+
const handleDragLeave = (e) => {
|
|
379
|
+
e.preventDefault();
|
|
380
|
+
e.stopPropagation();
|
|
381
|
+
setDragged(false);
|
|
382
|
+
};
|
|
383
|
+
const handleDragOver = (e) => {
|
|
384
|
+
e.preventDefault();
|
|
385
|
+
e.stopPropagation();
|
|
386
|
+
setDragged(true);
|
|
387
|
+
};
|
|
388
|
+
const handleDrop = (e) => {
|
|
389
|
+
e.preventDefault();
|
|
390
|
+
e.stopPropagation();
|
|
391
|
+
if (e.dataTransfer) addFiles(e.dataTransfer.files);
|
|
392
|
+
setDragged(false);
|
|
393
|
+
};
|
|
394
|
+
const handleFilesChosen = (e) => {
|
|
395
|
+
const fileInput2 = e.target;
|
|
396
|
+
if (fileInput2.files) addFiles(fileInput2.files);
|
|
397
|
+
};
|
|
398
|
+
const addFiles = (newFiles) => {
|
|
399
|
+
if (enableTracking) {
|
|
400
|
+
userEvents.addFieldEvent("Interacted with form field", {
|
|
401
|
+
actionType: "change",
|
|
402
|
+
field: name || "dropzone"
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
setFiles([...newFiles, ...files]);
|
|
406
|
+
};
|
|
407
|
+
const allowedFileTypesString = allowedFileTypes.join(", ");
|
|
408
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
409
|
+
label && /* @__PURE__ */ jsx(
|
|
410
|
+
"div",
|
|
411
|
+
{
|
|
412
|
+
className: cx("adyen-kyc-label__text", {
|
|
413
|
+
"adyen-kyc-label__text--error": hasRequiredError
|
|
414
|
+
}),
|
|
415
|
+
children: label
|
|
416
|
+
}
|
|
417
|
+
),
|
|
418
|
+
files.map((file) => /* @__PURE__ */ jsx(
|
|
419
|
+
DropzoneFile,
|
|
420
|
+
{
|
|
421
|
+
file,
|
|
422
|
+
onDelete: () => handleFileDelete(file),
|
|
423
|
+
errorMessage,
|
|
424
|
+
iconPrefix
|
|
425
|
+
},
|
|
426
|
+
file
|
|
427
|
+
)),
|
|
428
|
+
showDropzone && /* @__PURE__ */ jsxs(
|
|
429
|
+
"div",
|
|
430
|
+
{
|
|
431
|
+
role: "region",
|
|
432
|
+
className: cx("adyen-kyc-dropzone", {
|
|
433
|
+
"adyen-kyc-dropzone--dragged": dragged,
|
|
434
|
+
"adyen-kyc-dropzone--error": !dragged && hasRequiredError
|
|
435
|
+
}),
|
|
436
|
+
onDrop: handleDrop,
|
|
437
|
+
onDragOver: handleDragOver,
|
|
438
|
+
onDragEnter: handleDragEnter,
|
|
439
|
+
onDragLeave: handleDragLeave,
|
|
440
|
+
children: [
|
|
441
|
+
/* @__PURE__ */ jsx("div", { className: "adyen-kyc-dropzone__icon", children: /* @__PURE__ */ jsx(Icon, { name: "upload" }) }),
|
|
442
|
+
/* @__PURE__ */ jsxs("div", { className: "adyen-kyc-dropzone__labels", children: [
|
|
443
|
+
/* @__PURE__ */ jsx(Typography, { el: "h4", variant: "body-strongest", children: t(($) => $["dropFileToUpload"]) }),
|
|
444
|
+
/* @__PURE__ */ jsx(Typography, { color: "secondary", children: t(($) => $["supportedFileTypes"], { fileTypes: allowedFileTypesString }) }),
|
|
445
|
+
/* @__PURE__ */ jsx(Typography, { color: "secondary", children: t(($) => $["maxFileSize"], { maxSize: bytesToSize(maxSize) }) }),
|
|
446
|
+
/* @__PURE__ */ jsx(Typography, { color: "secondary", children: t(($) => $["upToFiles"], { maxFiles: maxNumberOfFiles }) })
|
|
447
|
+
] }),
|
|
448
|
+
/* @__PURE__ */ jsx("div", { className: "adyen-kyc-dropzone__button", children: /* @__PURE__ */ jsx(Button, { onClick: openFilePicker, variant: "secondary", children: t(($) => $["browseFiles"]) }) }),
|
|
449
|
+
/* @__PURE__ */ jsx(
|
|
450
|
+
"input",
|
|
451
|
+
{
|
|
452
|
+
id,
|
|
453
|
+
className: "adyen-kyc-dropzone__input",
|
|
454
|
+
ref: fileInput,
|
|
455
|
+
multiple,
|
|
456
|
+
accept: allowedFileTypesString,
|
|
457
|
+
onChange: handleFilesChosen,
|
|
458
|
+
type: "file",
|
|
459
|
+
"aria-required": !isOptional,
|
|
460
|
+
"aria-describedby": ariaDescribedBy,
|
|
461
|
+
"aria-labelledby": ariaLabelledBy,
|
|
462
|
+
"data-testid": "hidden-file-input",
|
|
463
|
+
"aria-invalid": !isValid
|
|
464
|
+
}
|
|
465
|
+
)
|
|
466
|
+
]
|
|
467
|
+
}
|
|
468
|
+
),
|
|
469
|
+
hasRequiredError && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-error-text", children: t(($) => $["fieldIsRequired"]) })
|
|
470
|
+
] });
|
|
471
|
+
}
|
|
472
|
+
const bankDocument = "adyen-kyc-bank-document";
|
|
473
|
+
const styles$2 = {
|
|
474
|
+
bankDocument
|
|
475
|
+
};
|
|
476
|
+
const documentRequirements = "adyen-kyc-document-requirements";
|
|
477
|
+
const documentRequirementsSubtitle = "adyen-kyc-document-requirements-subtitle";
|
|
478
|
+
const styles$1 = {
|
|
479
|
+
documentRequirements,
|
|
480
|
+
documentRequirementsSubtitle
|
|
481
|
+
};
|
|
482
|
+
const BankDocumentTypes = {
|
|
483
|
+
BANK_STATEMENT: "bankStatement",
|
|
484
|
+
DEPOSIT_SLIP: "depositSlip",
|
|
485
|
+
SCREENSHOT_OF_BANK: "screenshotOfOnlineBankingEnviroment",
|
|
486
|
+
A_LETTER_FROM_YOUR_BANK: "aLetterFromYourBank",
|
|
487
|
+
CHECK: "check"
|
|
488
|
+
};
|
|
489
|
+
const bankDocumentOptions = [
|
|
490
|
+
{ id: BankDocumentTypes.BANK_STATEMENT, name: "bankStatementDocument" },
|
|
491
|
+
{ id: BankDocumentTypes.DEPOSIT_SLIP, name: "depositSlip" },
|
|
492
|
+
{ id: BankDocumentTypes.SCREENSHOT_OF_BANK, name: "screenshotOfOnlineBankingEnviroment" },
|
|
493
|
+
{ id: BankDocumentTypes.A_LETTER_FROM_YOUR_BANK, name: "aLetterFromYourBank" },
|
|
494
|
+
{ id: BankDocumentTypes.CHECK, name: "check" }
|
|
495
|
+
];
|
|
496
|
+
const BankDocumentRequirement = {
|
|
497
|
+
ACCOUNT_NAME_INDIVIDUAL: "bankAccountNameIndividual",
|
|
498
|
+
ACCOUNT_NAME_ORGANIZATION: "bankAccountNameOrganization",
|
|
499
|
+
ACCOUNT_NAME_WITH_SOLE_PROP: "bankAccountNameWithSoleProprietor",
|
|
500
|
+
ACCOUNT_NAME_WITH_TRUST: "bankAccountNameWithTrust",
|
|
501
|
+
ACCOUNT_NAME_WITH_UNINCORPORATED_PARTNERSHIP: "accountMustBeInTheNameOfUnincorporatedPartnership",
|
|
502
|
+
ACCOUNT_NUMBER_OR_IBAN: "accountNumberOrIbanVisible",
|
|
503
|
+
ACCOUNT_NUMBER: "accountNumberVisible",
|
|
504
|
+
ACCOUNT_NUMBER_FULL_OR_PARTIAL: "accountNumberFullOrPartialVisible",
|
|
505
|
+
DATE_ON_DOCUMENT: "datedInTheLastXMonths",
|
|
506
|
+
COUNTRY_OF_BANK: "showsCountryOfBankAccount",
|
|
507
|
+
OFFICIAL_DOCUMENT: "hasToBeOfficialDocumentFromBank",
|
|
508
|
+
STAMP_OR_SIGNATURE: "hasBankStampOrBankSignature",
|
|
509
|
+
HIGH_RESOLUTION_CHECK: "highResolutionCheck"
|
|
510
|
+
};
|
|
511
|
+
const accountNameRequirement = {
|
|
512
|
+
[LegalEntityTypes.INDIVIDUAL]: {
|
|
513
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_INDIVIDUAL
|
|
514
|
+
},
|
|
515
|
+
[LegalEntityTypes.ORGANIZATION]: {
|
|
516
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_ORGANIZATION
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
const accountNameRequirementWithLegalArrangement = {
|
|
520
|
+
[LegalEntityTypes.INDIVIDUAL]: {
|
|
521
|
+
[LegalEntityTypes.SOLE_PROPRIETORSHIP]: {
|
|
522
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_WITH_SOLE_PROP
|
|
523
|
+
},
|
|
524
|
+
[LegalEntityTypes.TRUST]: {
|
|
525
|
+
[CountryCodes.UnitedStates]: "bankAccountNameWithTrust_US",
|
|
526
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_WITH_TRUST
|
|
527
|
+
},
|
|
528
|
+
[LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]: {
|
|
529
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_WITH_UNINCORPORATED_PARTNERSHIP
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
[LegalEntityTypes.ORGANIZATION]: {
|
|
533
|
+
[LegalEntityTypes.TRUST]: {
|
|
534
|
+
[CountryCodes.UnitedStates]: "bankAccountNameWithTrust_US",
|
|
535
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_WITH_TRUST
|
|
536
|
+
},
|
|
537
|
+
[LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]: {
|
|
538
|
+
default: BankDocumentRequirement.ACCOUNT_NAME_WITH_UNINCORPORATED_PARTNERSHIP
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
const applyNamedModifiers = (country, documentModifiers) => {
|
|
543
|
+
if (!documentModifiers.associatedEntityType || !documentModifiers.associatedEntityLegalName) {
|
|
544
|
+
switch (documentModifiers.rootEntityType) {
|
|
545
|
+
case LegalEntityTypes.INDIVIDUAL:
|
|
546
|
+
return {
|
|
547
|
+
key: accountNameRequirement[LegalEntityTypes.INDIVIDUAL].default,
|
|
548
|
+
options: { values: { individualLegalName: documentModifiers.rootEntityLegalName } }
|
|
549
|
+
};
|
|
550
|
+
case LegalEntityTypes.ORGANIZATION:
|
|
551
|
+
default:
|
|
552
|
+
return {
|
|
553
|
+
key: accountNameRequirement[LegalEntityTypes.ORGANIZATION].default,
|
|
554
|
+
options: { values: { companyLegalName: documentModifiers.rootEntityLegalName } }
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
switch (documentModifiers.rootEntityType) {
|
|
559
|
+
case LegalEntityTypes.INDIVIDUAL:
|
|
560
|
+
switch (documentModifiers.associatedEntityType) {
|
|
561
|
+
case LegalEntityTypes.TRUST:
|
|
562
|
+
return {
|
|
563
|
+
key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.TRUST]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.TRUST]?.default,
|
|
564
|
+
options: {
|
|
565
|
+
values: {
|
|
566
|
+
trusteeName: documentModifiers.rootEntityLegalName,
|
|
567
|
+
trustLegalName: documentModifiers.associatedEntityLegalName,
|
|
568
|
+
trustTradingName: documentModifiers.associatedEntityTradingName ?? documentModifiers.associatedEntityLegalName
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
|
|
573
|
+
return {
|
|
574
|
+
key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.default,
|
|
575
|
+
options: {
|
|
576
|
+
values: {
|
|
577
|
+
partnerNames: documentModifiers.unincorporatedPartnershipMembers || "",
|
|
578
|
+
partnershipName: documentModifiers.associatedEntityLegalName
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
case LegalEntityTypes.SOLE_PROPRIETORSHIP:
|
|
583
|
+
default:
|
|
584
|
+
return {
|
|
585
|
+
key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.SOLE_PROPRIETORSHIP]?.default,
|
|
586
|
+
options: {
|
|
587
|
+
values: {
|
|
588
|
+
individualLegalName: documentModifiers.rootEntityLegalName,
|
|
589
|
+
soleProprietorshipName: documentModifiers.associatedEntityLegalName
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
case LegalEntityTypes.ORGANIZATION:
|
|
595
|
+
default:
|
|
596
|
+
switch (documentModifiers.associatedEntityType) {
|
|
597
|
+
case LegalEntityTypes.TRUST:
|
|
598
|
+
return {
|
|
599
|
+
key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.TRUST]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.TRUST]?.default,
|
|
600
|
+
options: {
|
|
601
|
+
values: {
|
|
602
|
+
trusteeName: documentModifiers.rootEntityLegalName,
|
|
603
|
+
trustLegalName: documentModifiers.associatedEntityLegalName,
|
|
604
|
+
trustTradingName: documentModifiers.associatedEntityTradingName ?? documentModifiers.associatedEntityLegalName
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
|
|
609
|
+
return {
|
|
610
|
+
key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.default,
|
|
611
|
+
options: {
|
|
612
|
+
values: {
|
|
613
|
+
partnerNames: documentModifiers.unincorporatedPartnershipMembers || "",
|
|
614
|
+
partnershipName: documentModifiers.associatedEntityLegalName
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
default:
|
|
619
|
+
return { key: accountNameRequirement[LegalEntityTypes.ORGANIZATION].default };
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
const getBankDocumentRequirements = (country, documentType, documentModifiers) => {
|
|
624
|
+
const isBasedInUS = country === "US";
|
|
625
|
+
const baseRequirements = isBasedInUS ? [{ key: BankDocumentRequirement.OFFICIAL_DOCUMENT }] : [
|
|
626
|
+
{ key: BankDocumentRequirement.OFFICIAL_DOCUMENT },
|
|
627
|
+
{ key: BankDocumentRequirement.COUNTRY_OF_BANK }
|
|
628
|
+
];
|
|
629
|
+
const accountNumberRequirement = isBasedInUS ? documentType === BankDocumentTypes.CHECK || documentType === BankDocumentTypes.DEPOSIT_SLIP ? [{ key: BankDocumentRequirement.ACCOUNT_NUMBER }] : [{ key: BankDocumentRequirement.ACCOUNT_NUMBER_FULL_OR_PARTIAL }] : [{ key: BankDocumentRequirement.ACCOUNT_NUMBER_OR_IBAN }];
|
|
630
|
+
const requireLast12Months = isBasedInUS ? documentType === BankDocumentTypes.A_LETTER_FROM_YOUR_BANK || documentType === BankDocumentTypes.BANK_STATEMENT : documentType !== BankDocumentTypes.SCREENSHOT_OF_BANK;
|
|
631
|
+
const requireStampOrSignature = !isBasedInUS && (documentType === BankDocumentTypes.DEPOSIT_SLIP || documentType === BankDocumentTypes.A_LETTER_FROM_YOUR_BANK);
|
|
632
|
+
const requirements = [
|
|
633
|
+
applyNamedModifiers(country, documentModifiers),
|
|
634
|
+
...accountNumberRequirement,
|
|
635
|
+
...baseRequirements
|
|
636
|
+
];
|
|
637
|
+
if (requireLast12Months) {
|
|
638
|
+
requirements.push({
|
|
639
|
+
key: BankDocumentRequirement.DATE_ON_DOCUMENT,
|
|
640
|
+
options: { values: { number: 12 } }
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
if (requireStampOrSignature) {
|
|
644
|
+
requirements.push({ key: BankDocumentRequirement.STAMP_OR_SIGNATURE });
|
|
645
|
+
}
|
|
646
|
+
if (isBasedInUS && documentType === BankDocumentTypes.CHECK) {
|
|
647
|
+
requirements.push({ key: BankDocumentRequirement.HIGH_RESOLUTION_CHECK });
|
|
648
|
+
}
|
|
649
|
+
return requirements;
|
|
650
|
+
};
|
|
651
|
+
const BankDocumentRequirements = ({
|
|
652
|
+
country,
|
|
653
|
+
documentType,
|
|
654
|
+
documentModifiers
|
|
655
|
+
}) => {
|
|
656
|
+
const { i18n } = useI18nContext();
|
|
657
|
+
const documentRequirements2 = getBankDocumentRequirements(
|
|
658
|
+
country,
|
|
659
|
+
documentType,
|
|
660
|
+
documentModifiers
|
|
661
|
+
);
|
|
662
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$1.documentRequirements, children: [
|
|
663
|
+
/* @__PURE__ */ jsx("strong", { className: styles$1.documentRequirementsSubtitle, children: i18n.get("documentRequirements") }),
|
|
664
|
+
/* @__PURE__ */ jsx("ul", { children: documentRequirements2.map(({ key, options }, i) => /* @__PURE__ */ jsx("li", { "data-testid": key, children: i18n.get(key, options) }, i)) })
|
|
665
|
+
] });
|
|
666
|
+
};
|
|
667
|
+
const bankDocumentValidationRules = {
|
|
668
|
+
description: {
|
|
669
|
+
modes: ["blur"],
|
|
670
|
+
validate: (description) => description ? bankStatementDescriptionPattern.test(description) : true,
|
|
671
|
+
errorMessage: "invalidFormatBankStatementDescription"
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
const CHARACTERS_LIMIT = 200;
|
|
675
|
+
const bankDocumentFields = [
|
|
676
|
+
"documentType",
|
|
677
|
+
"bankStatementDocument",
|
|
678
|
+
"description"
|
|
679
|
+
];
|
|
680
|
+
function BankDocument(props) {
|
|
681
|
+
const {
|
|
682
|
+
legalEntity,
|
|
683
|
+
associatedLegalArrangement,
|
|
684
|
+
country,
|
|
685
|
+
optionalFields,
|
|
686
|
+
validators,
|
|
687
|
+
data: bankData,
|
|
688
|
+
id,
|
|
689
|
+
description,
|
|
690
|
+
heading,
|
|
691
|
+
formIsActive,
|
|
692
|
+
fieldValidationErrors,
|
|
693
|
+
shouldValidate
|
|
694
|
+
} = props;
|
|
695
|
+
const { t } = useTranslation("common");
|
|
696
|
+
const stateRef = useRef({ setState: null });
|
|
697
|
+
const isBankStatementOptional = optionalFields?.includes("bankStatementDocument") ?? false;
|
|
698
|
+
const formUtils = createFormUtils(props, t);
|
|
699
|
+
const bankStatementValidationOptions = useMemo(
|
|
700
|
+
() => ({
|
|
701
|
+
...defaultFileValidationOptions,
|
|
702
|
+
isOptional: isBankStatementOptional
|
|
703
|
+
}),
|
|
704
|
+
[isBankStatementOptional]
|
|
705
|
+
);
|
|
706
|
+
const rules2 = useMemo(
|
|
707
|
+
() => ({
|
|
708
|
+
...validators || bankDocumentValidationRules,
|
|
709
|
+
bankStatementDocument: fileValidationRules(bankStatementValidationOptions)
|
|
710
|
+
}),
|
|
711
|
+
[bankStatementValidationOptions, validators]
|
|
712
|
+
);
|
|
713
|
+
const { handleChangeFor, data, setData, valid, fieldProblems, errors, triggerValidation } = useForm({
|
|
714
|
+
...props,
|
|
715
|
+
schema: bankDocumentFields,
|
|
716
|
+
defaultData: bankData,
|
|
717
|
+
rules: rules2,
|
|
718
|
+
fieldProblems: fieldValidationErrors,
|
|
719
|
+
shouldValidate
|
|
720
|
+
});
|
|
721
|
+
useEffect(() => {
|
|
722
|
+
if (formIsActive) {
|
|
723
|
+
triggerValidation();
|
|
724
|
+
}
|
|
725
|
+
}, [formIsActive, triggerValidation]);
|
|
726
|
+
const alreadyUploadedDocuments = useMemo(
|
|
727
|
+
() => bankData?.bankStatementDocument ?? [],
|
|
728
|
+
[bankData?.bankStatementDocument]
|
|
729
|
+
);
|
|
730
|
+
const hasAlreadyUploadedDocuments = alreadyUploadedDocuments.length > 0;
|
|
731
|
+
const usingExistingUploadedDocuments = data.bankStatementDocument && doArraysMatch(alreadyUploadedDocuments, data.bankStatementDocument);
|
|
732
|
+
useEffect(() => {
|
|
733
|
+
if (hasAlreadyUploadedDocuments) {
|
|
734
|
+
setData("bankStatementDocument", alreadyUploadedDocuments);
|
|
735
|
+
if (bankData?.description) setData("description", bankData.description);
|
|
736
|
+
triggerValidation();
|
|
737
|
+
}
|
|
738
|
+
}, [
|
|
739
|
+
alreadyUploadedDocuments,
|
|
740
|
+
hasAlreadyUploadedDocuments,
|
|
741
|
+
bankData?.description,
|
|
742
|
+
setData,
|
|
743
|
+
triggerValidation
|
|
744
|
+
]);
|
|
745
|
+
useEffect(() => {
|
|
746
|
+
stateRef.current?.setState?.({
|
|
747
|
+
type: "addToState",
|
|
748
|
+
value: {
|
|
749
|
+
data,
|
|
750
|
+
valid,
|
|
751
|
+
errors,
|
|
752
|
+
fieldProblems,
|
|
753
|
+
dataStoreId: id,
|
|
754
|
+
schema: bankDocumentFields
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}, [data, valid, errors, fieldProblems, id]);
|
|
758
|
+
const getBankDocumentOptions = () => bankDocumentOptions.map(({ id: id2, name }) => ({ id: id2, name: t(($) => $[name]) }));
|
|
759
|
+
const unincorporatedPartnershipMembers = useUnincorporatedPartnershipMembers();
|
|
760
|
+
const documentsModifiers = useMemo(
|
|
761
|
+
() => ({
|
|
762
|
+
rootEntityType: legalEntity.type,
|
|
763
|
+
rootEntityLegalName: getLegalEntityNameBasedOnType(legalEntity),
|
|
764
|
+
associatedEntityType: associatedLegalArrangement?.type,
|
|
765
|
+
associatedEntityLegalName: associatedLegalArrangement?.[associatedLegalArrangement?.type]?.name,
|
|
766
|
+
associatedEntityTradingName: associatedLegalArrangement?.[associatedLegalArrangement?.type]?.doingBusinessAs,
|
|
767
|
+
unincorporatedPartnershipMembers: unincorporatedPartnershipMembers?.map((member) => member?.name)?.join(", ")
|
|
768
|
+
}),
|
|
769
|
+
[legalEntity, associatedLegalArrangement, unincorporatedPartnershipMembers]
|
|
770
|
+
);
|
|
771
|
+
return /* @__PURE__ */ jsxs("form", { className: styles$2.bankDocument, children: [
|
|
772
|
+
/* @__PURE__ */ jsx(StateContextSetter, { owner: id, stateRef }),
|
|
773
|
+
/* @__PURE__ */ jsx(FormHeader, { heading, description }),
|
|
774
|
+
/* @__PURE__ */ jsx(
|
|
775
|
+
ErrorPanel,
|
|
776
|
+
{
|
|
777
|
+
verificationErrors: props?.formVerificationErrors,
|
|
778
|
+
validationErrors: props?.fieldValidationErrors,
|
|
779
|
+
formUtils,
|
|
780
|
+
id: "ariaErrorField"
|
|
781
|
+
}
|
|
782
|
+
),
|
|
783
|
+
formUtils.isVisibleField("bankStatementDocument") && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
784
|
+
!usingExistingUploadedDocuments && /* @__PURE__ */ jsx(
|
|
785
|
+
Field,
|
|
786
|
+
{
|
|
787
|
+
name: "documentType",
|
|
788
|
+
label: formUtils.getLabel("bankStatementDocument", "selectDocumentType"),
|
|
789
|
+
className: "adyen-kyc-bank-document__document-type",
|
|
790
|
+
children: (childProps) => /* @__PURE__ */ jsx(
|
|
791
|
+
Select,
|
|
792
|
+
{
|
|
793
|
+
...childProps,
|
|
794
|
+
onChange: handleChangeFor("documentType"),
|
|
795
|
+
name: "documentType",
|
|
796
|
+
placeholder: t(($) => $["selectDocument"]),
|
|
797
|
+
isInvalid: false,
|
|
798
|
+
items: getBankDocumentOptions(),
|
|
799
|
+
selected: data.documentType
|
|
800
|
+
}
|
|
801
|
+
)
|
|
802
|
+
}
|
|
803
|
+
),
|
|
804
|
+
data.documentType ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
805
|
+
country ? /* @__PURE__ */ jsx(
|
|
806
|
+
BankDocumentRequirements,
|
|
807
|
+
{
|
|
808
|
+
country,
|
|
809
|
+
documentType: data.documentType,
|
|
810
|
+
documentModifiers: documentsModifiers
|
|
811
|
+
}
|
|
812
|
+
) : void 0,
|
|
813
|
+
/* @__PURE__ */ jsx(DocumentGuidance, { type: "bankStatement", className: "adyen-kyc-u-margin-y-24" })
|
|
814
|
+
] }) : null,
|
|
815
|
+
data.documentType || usingExistingUploadedDocuments ? /* @__PURE__ */ jsx(
|
|
816
|
+
Field,
|
|
817
|
+
{
|
|
818
|
+
className: "adyen-kyc-bank-document__document-upload adyen-kyc-upload-field",
|
|
819
|
+
name: "bankStatementDocument",
|
|
820
|
+
isValid: valid.bankStatementDocument,
|
|
821
|
+
children: (childProps) => /* @__PURE__ */ jsx(
|
|
822
|
+
FilePicker,
|
|
823
|
+
{
|
|
824
|
+
...childProps,
|
|
825
|
+
name: "bankStatementDocument",
|
|
826
|
+
files: data.bankStatementDocument ?? [],
|
|
827
|
+
setFiles: handleChangeFor("bankStatementDocument"),
|
|
828
|
+
isValid: valid.bankStatementDocument ?? isBankStatementOptional,
|
|
829
|
+
errorMessage: errors.bankStatementDocument?.errorMessage,
|
|
830
|
+
...bankStatementValidationOptions
|
|
831
|
+
}
|
|
832
|
+
)
|
|
833
|
+
}
|
|
834
|
+
) : null
|
|
835
|
+
] }),
|
|
836
|
+
data.documentType || usingExistingUploadedDocuments ? /* @__PURE__ */ jsx(
|
|
837
|
+
Field,
|
|
838
|
+
{
|
|
839
|
+
className: "adyen-kyc-bank-document__document-description",
|
|
840
|
+
name: "description",
|
|
841
|
+
label: formUtils.getLabel("bankDocumentFileDescription"),
|
|
842
|
+
errorMessage: formUtils.getErrorMessage("description", errors, fieldProblems),
|
|
843
|
+
isValid: valid.description,
|
|
844
|
+
children: (childProps) => /* @__PURE__ */ jsx(
|
|
845
|
+
TextArea,
|
|
846
|
+
{
|
|
847
|
+
...childProps,
|
|
848
|
+
name: "description",
|
|
849
|
+
value: data.description,
|
|
850
|
+
maxLength: CHARACTERS_LIMIT,
|
|
851
|
+
onInput: handleChangeFor("description"),
|
|
852
|
+
"aria-invalid": !valid.description
|
|
853
|
+
}
|
|
854
|
+
)
|
|
855
|
+
}
|
|
856
|
+
) : null
|
|
857
|
+
] });
|
|
858
|
+
}
|
|
859
|
+
const MemoizedBankDocument = memo(
|
|
860
|
+
BankDocument,
|
|
861
|
+
(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 && prevProps.heading === nextProps.heading && prevProps.formIsActive === nextProps.formIsActive
|
|
862
|
+
);
|
|
863
|
+
const bankVerificationValidationRules = {
|
|
864
|
+
verifiedAccountHolder: {
|
|
865
|
+
modes: ["blur"],
|
|
866
|
+
validate: (verifiedAccountHolder) => !isEmpty(verifiedAccountHolder),
|
|
867
|
+
errorMessage: "fieldIsRequired"
|
|
868
|
+
},
|
|
869
|
+
verifiedBankCountry: {
|
|
870
|
+
modes: ["blur"],
|
|
871
|
+
validate: (verifiedBankCountry) => !isEmpty(verifiedBankCountry),
|
|
872
|
+
errorMessage: "fieldIsRequired"
|
|
873
|
+
},
|
|
874
|
+
verifiedBankName: {
|
|
875
|
+
modes: ["blur"],
|
|
876
|
+
validate: (verifiedBankName) => !isEmpty(verifiedBankName),
|
|
877
|
+
errorMessage: "fieldIsRequired"
|
|
878
|
+
},
|
|
879
|
+
verifiedCurrencyCode: {
|
|
880
|
+
modes: ["blur"],
|
|
881
|
+
validate: (verifiedCurrencyCode) => !isEmpty(verifiedCurrencyCode),
|
|
882
|
+
errorMessage: "fieldIsRequired"
|
|
883
|
+
},
|
|
884
|
+
verifiedBankAccountNumber: {
|
|
885
|
+
modes: ["blur"],
|
|
886
|
+
validate: (verifiedBankAccountNumber) => !isEmpty(verifiedBankAccountNumber),
|
|
887
|
+
errorMessage: "fieldIsRequired"
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
const handleBankVerificationError = async (legalEntityId, baseUrl, bankVerificationErrorParams) => {
|
|
891
|
+
return httpPost(
|
|
892
|
+
{
|
|
893
|
+
baseUrl,
|
|
894
|
+
path: `legalEntities/${legalEntityId}/transferInstruments/trusted/error`
|
|
895
|
+
},
|
|
896
|
+
bankVerificationErrorParams
|
|
897
|
+
);
|
|
898
|
+
};
|
|
899
|
+
const useHandleBankVerificationError = (options) => {
|
|
900
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
901
|
+
return useMutation({
|
|
902
|
+
mutationFn: (params) => handleBankVerificationError(rootLegalEntityId.value, baseUrl.value, params),
|
|
903
|
+
...options
|
|
904
|
+
});
|
|
905
|
+
};
|
|
906
|
+
const addAnimationStartListener = (element, listener) => {
|
|
907
|
+
element.addEventListener("animationstart", listener, false);
|
|
908
|
+
};
|
|
909
|
+
const removeAnimationStartListener = (element, listener) => {
|
|
910
|
+
element.removeEventListener("animationstart", listener, false);
|
|
911
|
+
};
|
|
912
|
+
const VerificationWidgetCallbackActions = {
|
|
913
|
+
HANDLE_EXCEPTION: "handle_exception",
|
|
914
|
+
VERIFICATION_SUCCESS: "verification_success",
|
|
915
|
+
RETRY_VERIFICATION: "retry_verification",
|
|
916
|
+
HANDLE_EVENT: "handle_event"
|
|
917
|
+
};
|
|
918
|
+
const WIDGET_IFRAME_CLASS = "adyen-kyc-bank-verification-widget";
|
|
919
|
+
const WIDGET_CONTAINER_CLASS = `${WIDGET_IFRAME_CLASS}-container`;
|
|
920
|
+
const EMPTY_WIDGET_CONTAINER_ANIMATION = "adyen-kyc-empty-bank-verification-widget-container";
|
|
921
|
+
function BankVerificationWidget({
|
|
922
|
+
url,
|
|
923
|
+
vendor,
|
|
924
|
+
setBankVerificationError,
|
|
925
|
+
setHideVerificationWidget,
|
|
926
|
+
onBack,
|
|
927
|
+
retrieveBankAccountInfo,
|
|
928
|
+
createTrustedTransferInstrument: createTrustedTransferInstrument2,
|
|
929
|
+
fullscreen
|
|
930
|
+
}) {
|
|
931
|
+
const { i18n } = useI18nContext();
|
|
932
|
+
const userEvents = useAnalyticsContext();
|
|
933
|
+
const widgetContainerRef = useRef(null);
|
|
934
|
+
const sdkToken = getSdkToken();
|
|
935
|
+
const { mutateAsync: handleBankVerificationError2 } = useHandleBankVerificationError();
|
|
936
|
+
const trackVerificationError = (returnValue) => {
|
|
937
|
+
userEvents.addPageEvent("Encountered error", {
|
|
938
|
+
actionType: "add",
|
|
939
|
+
returnType: "sdk error",
|
|
940
|
+
returnValue
|
|
941
|
+
});
|
|
942
|
+
};
|
|
943
|
+
const DEFAULT_ERROR = {
|
|
944
|
+
error: "UNKNOWN_ERROR",
|
|
945
|
+
message: i18n.get("weCouldntCompleteTheAccountCheck")
|
|
946
|
+
};
|
|
947
|
+
setBankVerificationError(null);
|
|
948
|
+
const widgetCallback = useCallback(
|
|
949
|
+
(payload) => {
|
|
950
|
+
const errorContent = i18n.get("tryAgainOrManualAccountDetails");
|
|
951
|
+
switch (payload.action) {
|
|
952
|
+
case VerificationWidgetCallbackActions.HANDLE_EXCEPTION: {
|
|
953
|
+
let errorTitle;
|
|
954
|
+
const { err } = payload;
|
|
955
|
+
switch (!(err instanceof Error) && err?.error) {
|
|
956
|
+
case "USER_CANCELLED":
|
|
957
|
+
errorTitle = "";
|
|
958
|
+
break;
|
|
959
|
+
case "CONNECTION_ERROR":
|
|
960
|
+
errorTitle = i18n.get("couldNotEstablishBankConnection");
|
|
961
|
+
break;
|
|
962
|
+
case "GENERIC_ERROR":
|
|
963
|
+
errorTitle = i18n.get("ranIntoTechnicalError");
|
|
964
|
+
break;
|
|
965
|
+
case "UNKNOWN_ERROR":
|
|
966
|
+
default: {
|
|
967
|
+
errorTitle = i18n.get("couldNotCompleteAccountCheck");
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (errorTitle) {
|
|
972
|
+
setBankVerificationError({ title: errorTitle, content: errorContent });
|
|
973
|
+
}
|
|
974
|
+
setHideVerificationWidget(true);
|
|
975
|
+
onBack?.();
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
case VerificationWidgetCallbackActions.RETRY_VERIFICATION:
|
|
979
|
+
setBankVerificationError({
|
|
980
|
+
title: i18n.get("failedInitializeInstantVerification"),
|
|
981
|
+
content: errorContent
|
|
982
|
+
});
|
|
983
|
+
setHideVerificationWidget(true);
|
|
984
|
+
onBack?.();
|
|
985
|
+
break;
|
|
986
|
+
case VerificationWidgetCallbackActions.HANDLE_EVENT: {
|
|
987
|
+
const { name, provider } = payload.event;
|
|
988
|
+
if (name === "institution_selected" && provider === "plaid") {
|
|
989
|
+
widgetContainerRef.current?.classList.add(`${WIDGET_CONTAINER_CLASS}--plaid-modal`);
|
|
990
|
+
}
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
case VerificationWidgetCallbackActions.VERIFICATION_SUCCESS: {
|
|
994
|
+
const { accounts } = payload.result;
|
|
995
|
+
if (accounts) retrieveBankAccountInfo(accounts[0]);
|
|
996
|
+
setHideVerificationWidget(true);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
[i18n, retrieveBankAccountInfo, onBack, setBankVerificationError, setHideVerificationWidget]
|
|
1001
|
+
);
|
|
1002
|
+
useEffect(
|
|
1003
|
+
() => {
|
|
1004
|
+
const container = widgetContainerRef.current;
|
|
1005
|
+
if (!container) {
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
let iFrame;
|
|
1009
|
+
let iFrameWidget;
|
|
1010
|
+
let openBanking;
|
|
1011
|
+
addAnimationStartListener(container, function refreshWidgetIframe(evt) {
|
|
1012
|
+
if (evt.animationName !== EMPTY_WIDGET_CONTAINER_ANIMATION) return;
|
|
1013
|
+
requestAnimationFrame(async () => {
|
|
1014
|
+
if (createTrustedTransferInstrument2) {
|
|
1015
|
+
openBanking = OpenBankingSDK.create({
|
|
1016
|
+
divElement: container,
|
|
1017
|
+
link: url,
|
|
1018
|
+
successHandler: (code, state) => {
|
|
1019
|
+
createTrustedTransferInstrument2(code, state).then((res) => {
|
|
1020
|
+
userEvents.addPageEvent("Success", { actionType: "add" });
|
|
1021
|
+
if (res) {
|
|
1022
|
+
widgetCallback({
|
|
1023
|
+
action: VerificationWidgetCallbackActions.VERIFICATION_SUCCESS,
|
|
1024
|
+
result: res
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
}).catch(() => {
|
|
1028
|
+
trackVerificationError(DEFAULT_ERROR.error);
|
|
1029
|
+
widgetCallback({
|
|
1030
|
+
action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1031
|
+
err: DEFAULT_ERROR
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
},
|
|
1035
|
+
errorHandler: (errorCode, errorMessage, state, metadata) => {
|
|
1036
|
+
trackVerificationError(errorCode);
|
|
1037
|
+
handleBankVerificationError2?.({
|
|
1038
|
+
errorCode,
|
|
1039
|
+
errorMessage,
|
|
1040
|
+
state,
|
|
1041
|
+
metadata: metadata && Object.fromEntries(metadata)
|
|
1042
|
+
}).then(
|
|
1043
|
+
(error) => widgetCallback({
|
|
1044
|
+
action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1045
|
+
err: error
|
|
1046
|
+
})
|
|
1047
|
+
).catch(
|
|
1048
|
+
() => widgetCallback({
|
|
1049
|
+
action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1050
|
+
err: DEFAULT_ERROR
|
|
1051
|
+
})
|
|
1052
|
+
);
|
|
1053
|
+
},
|
|
1054
|
+
eventHandler: (eventName, provider) => {
|
|
1055
|
+
widgetCallback({
|
|
1056
|
+
action: VerificationWidgetCallbackActions.HANDLE_EVENT,
|
|
1057
|
+
event: { name: eventName, provider }
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
openBanking.open();
|
|
1062
|
+
} else {
|
|
1063
|
+
removeAnimationStartListener(container, refreshWidgetIframe);
|
|
1064
|
+
iFrame = document.createElement("iframe");
|
|
1065
|
+
iFrame.setAttribute("allowFullscreen", "true");
|
|
1066
|
+
iFrame.classList.add(WIDGET_IFRAME_CLASS);
|
|
1067
|
+
evt.target.appendChild(iFrame);
|
|
1068
|
+
requestAnimationFrame(async () => {
|
|
1069
|
+
try {
|
|
1070
|
+
iFrameWidget = new IFrameWidget(iFrame, url, vendor, sdkToken);
|
|
1071
|
+
const result = await iFrameWidget.mountAndWaitForResponse();
|
|
1072
|
+
widgetCallback({
|
|
1073
|
+
action: VerificationWidgetCallbackActions.VERIFICATION_SUCCESS,
|
|
1074
|
+
result
|
|
1075
|
+
});
|
|
1076
|
+
userEvents.addPageEvent("Success", { actionType: "add" });
|
|
1077
|
+
} catch (err) {
|
|
1078
|
+
if (err instanceof AdyenKycSdkError) {
|
|
1079
|
+
switch (err.message) {
|
|
1080
|
+
case "WIDGET_ACCOUNT_COMMIT_FAILURE":
|
|
1081
|
+
return widgetCallback({
|
|
1082
|
+
action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1083
|
+
err: err.sourceError
|
|
1084
|
+
});
|
|
1085
|
+
case "WIDGET_LAUNCH_FAILED":
|
|
1086
|
+
case "WIDGET_URL_MALFORMED":
|
|
1087
|
+
case "WIDGET_TIMEOUT":
|
|
1088
|
+
return widgetCallback({
|
|
1089
|
+
action: VerificationWidgetCallbackActions.RETRY_VERIFICATION
|
|
1090
|
+
});
|
|
1091
|
+
default:
|
|
1092
|
+
return widgetCallback({
|
|
1093
|
+
action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1094
|
+
err: {
|
|
1095
|
+
error: err?.name ?? VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1096
|
+
message: err.sourceError?.message ?? VerificationWidgetCallbackActions.HANDLE_EXCEPTION
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
trackVerificationError(err instanceof AdyenKycSdkError ? err.message : "sdk error");
|
|
1102
|
+
return widgetCallback({
|
|
1103
|
+
action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
|
|
1104
|
+
err
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
});
|
|
1111
|
+
container.classList.add(WIDGET_CONTAINER_CLASS);
|
|
1112
|
+
if (fullscreen) {
|
|
1113
|
+
container.classList.add(`${WIDGET_CONTAINER_CLASS}--fullscreen`);
|
|
1114
|
+
}
|
|
1115
|
+
return () => {
|
|
1116
|
+
iFrameWidget?.unmount();
|
|
1117
|
+
iFrame?.remove();
|
|
1118
|
+
openBanking?.destroy();
|
|
1119
|
+
};
|
|
1120
|
+
},
|
|
1121
|
+
// Effect dependencies have been omitted here, which isn't intended. However, there seems to be
|
|
1122
|
+
// some problematic behaviour in the overall flow with the dependencies present, which requires
|
|
1123
|
+
// further debugging and tracing to resolve (totally out of the scope of this component).
|
|
1124
|
+
// [url, vendor, widgetCallback]
|
|
1125
|
+
[]
|
|
1126
|
+
);
|
|
1127
|
+
return /* @__PURE__ */ jsx("div", { ref: widgetContainerRef });
|
|
1128
|
+
}
|
|
1129
|
+
const accountVerificationFields = [
|
|
1130
|
+
"verifiedAccountHolder",
|
|
1131
|
+
"verifiedBankCountry",
|
|
1132
|
+
"verifiedBankName",
|
|
1133
|
+
"verifiedCurrencyCode",
|
|
1134
|
+
"verifiedBankAccountNumber"
|
|
1135
|
+
];
|
|
1136
|
+
const InstantVerificationErrorContext = createContext(null);
|
|
1137
|
+
const useInstantVerificationErrorNotification = (notificationVisibilityDuration) => {
|
|
1138
|
+
const [errorNotification, setErrorNotification] = useState(null);
|
|
1139
|
+
const dismissNotificationTimeoutRef = useRef();
|
|
1140
|
+
const clearNotificationTimeout = useCallback(() => {
|
|
1141
|
+
if (dismissNotificationTimeoutRef.current) {
|
|
1142
|
+
clearTimeout(dismissNotificationTimeoutRef.current);
|
|
1143
|
+
dismissNotificationTimeoutRef.current = void 0;
|
|
1144
|
+
}
|
|
1145
|
+
}, []);
|
|
1146
|
+
useEffect(() => {
|
|
1147
|
+
clearNotificationTimeout();
|
|
1148
|
+
if (errorNotification && notificationVisibilityDuration > 0) {
|
|
1149
|
+
dismissNotificationTimeoutRef.current = setTimeout(() => {
|
|
1150
|
+
setErrorNotification(null);
|
|
1151
|
+
clearNotificationTimeout();
|
|
1152
|
+
}, notificationVisibilityDuration);
|
|
1153
|
+
}
|
|
1154
|
+
return () => clearNotificationTimeout();
|
|
1155
|
+
}, [errorNotification, clearNotificationTimeout, notificationVisibilityDuration]);
|
|
1156
|
+
return [errorNotification, setErrorNotification];
|
|
1157
|
+
};
|
|
1158
|
+
function BankVerification(props) {
|
|
1159
|
+
const {
|
|
1160
|
+
heading,
|
|
1161
|
+
setBankVerificationError,
|
|
1162
|
+
onBack,
|
|
1163
|
+
hideSidebar,
|
|
1164
|
+
setBankInfoValidated,
|
|
1165
|
+
bankInfoValidated,
|
|
1166
|
+
formIsActive,
|
|
1167
|
+
createTrustedTransferInstrument: createTrustedTransferInstrument2,
|
|
1168
|
+
country,
|
|
1169
|
+
data: propData,
|
|
1170
|
+
provider,
|
|
1171
|
+
id,
|
|
1172
|
+
fieldValidationErrors
|
|
1173
|
+
} = props;
|
|
1174
|
+
const { i18n } = useI18nContext();
|
|
1175
|
+
const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
|
|
1176
|
+
const schema = accountVerificationFields;
|
|
1177
|
+
const stateRef = useRef({ setState: null });
|
|
1178
|
+
const [hideVerificationWidget, setHideVerificationWidget] = useState(false);
|
|
1179
|
+
const { handleChangeFor, data, valid, errors, isValid, triggerValidation, fieldProblems } = useForm({
|
|
1180
|
+
...props,
|
|
1181
|
+
schema,
|
|
1182
|
+
defaultData: propData,
|
|
1183
|
+
rules: bankVerificationValidationRules,
|
|
1184
|
+
fieldProblems: fieldValidationErrors
|
|
1185
|
+
});
|
|
1186
|
+
const retrieveBankAccountInfo = async ({
|
|
1187
|
+
realLastFour,
|
|
1188
|
+
number,
|
|
1189
|
+
bankName
|
|
1190
|
+
}) => {
|
|
1191
|
+
handleChangeFor("verifiedBankAccountNumber")(realLastFour ? `*******${realLastFour}` : number);
|
|
1192
|
+
handleChangeFor("verifiedBankName")(bankName);
|
|
1193
|
+
handleChangeFor("verifiedBankCountry")(country);
|
|
1194
|
+
handleChangeFor("verifiedAccountHolder")(propData?.verifiedAccountHolder);
|
|
1195
|
+
handleChangeFor("verifiedCurrencyCode")(
|
|
1196
|
+
propData?.verifiedCurrencyCode ?? currencyByCountry[country]?.[0]
|
|
1197
|
+
);
|
|
1198
|
+
setBankInfoValidated?.(true);
|
|
1199
|
+
hideSidebar?.(false);
|
|
1200
|
+
triggerValidation();
|
|
1201
|
+
await invalidateRootLegalEntity();
|
|
1202
|
+
};
|
|
1203
|
+
const handleOnBack = () => {
|
|
1204
|
+
setHideVerificationWidget(false);
|
|
1205
|
+
onBack?.();
|
|
1206
|
+
};
|
|
1207
|
+
useEffect(() => {
|
|
1208
|
+
stateRef.current.setState?.({
|
|
1209
|
+
type: "addToState",
|
|
1210
|
+
value: {
|
|
1211
|
+
data,
|
|
1212
|
+
valid,
|
|
1213
|
+
errors,
|
|
1214
|
+
fieldProblems,
|
|
1215
|
+
dataStoreId: id,
|
|
1216
|
+
schema
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
}, [data, valid, errors, isValid]);
|
|
1220
|
+
useEffect(() => {
|
|
1221
|
+
hideSidebar?.(formIsActive && !bankInfoValidated);
|
|
1222
|
+
return () => hideSidebar?.(false);
|
|
1223
|
+
}, [bankInfoValidated, formIsActive]);
|
|
1224
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1225
|
+
/* @__PURE__ */ jsx(StateContextSetter, { owner: id, stateRef }),
|
|
1226
|
+
bankInfoValidated && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1227
|
+
/* @__PURE__ */ jsx(FormHeader, { heading }),
|
|
1228
|
+
/* @__PURE__ */ jsx(Alert, { title: i18n.get("youSuccessfullyVerifiedAccount"), variant: "success" })
|
|
1229
|
+
] }),
|
|
1230
|
+
provider && formIsActive && !bankInfoValidated && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-bank-verification-container", children: /* @__PURE__ */ jsx("form", { className: "adyen-kyc-bank-verification", children: !hideVerificationWidget ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1231
|
+
/* @__PURE__ */ jsx(
|
|
1232
|
+
BankVerificationWidget,
|
|
1233
|
+
{
|
|
1234
|
+
url: provider.redirectUrl,
|
|
1235
|
+
vendor: provider.name,
|
|
1236
|
+
setBankVerificationError,
|
|
1237
|
+
setHideVerificationWidget,
|
|
1238
|
+
onBack: handleOnBack,
|
|
1239
|
+
retrieveBankAccountInfo,
|
|
1240
|
+
createTrustedTransferInstrument: createTrustedTransferInstrument2
|
|
1241
|
+
}
|
|
1242
|
+
),
|
|
1243
|
+
/* @__PURE__ */ jsx(ActionBar, { onBack: handleOnBack, backButtonLabel: i18n.get("goBack") })
|
|
1244
|
+
] }) : void 0 }) })
|
|
1245
|
+
] });
|
|
1246
|
+
}
|
|
1247
|
+
function BankAccountFormat(props) {
|
|
1248
|
+
const { i18n } = useI18nContext();
|
|
1249
|
+
const { bankAccountFormat, handleAccountFormatChange } = props;
|
|
1250
|
+
const bankFormatOptions = [
|
|
1251
|
+
{
|
|
1252
|
+
id: "iban",
|
|
1253
|
+
name: i18n.get("ibanFormat")
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
id: "local",
|
|
1257
|
+
name: i18n.get("localFormat")
|
|
1258
|
+
}
|
|
1259
|
+
];
|
|
1260
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Field, { name: "bankAccountFormat", label: i18n.get("bankAccountFormat"), children: (childProps) => /* @__PURE__ */ jsx(
|
|
1261
|
+
Select,
|
|
1262
|
+
{
|
|
1263
|
+
...childProps,
|
|
1264
|
+
onChange: (e) => handleAccountFormatChange?.(e?.target?.value),
|
|
1265
|
+
name: "bankAccountFormat",
|
|
1266
|
+
placeholder: i18n.get("localFormat"),
|
|
1267
|
+
selected: bankAccountFormat,
|
|
1268
|
+
items: bankFormatOptions
|
|
1269
|
+
}
|
|
1270
|
+
) }) });
|
|
1271
|
+
}
|
|
1272
|
+
const simpleBankAccountNumberMetadata = (example, length, maxLength) => {
|
|
1273
|
+
if (maxLength) {
|
|
1274
|
+
return {
|
|
1275
|
+
label: "bankAccountNumber",
|
|
1276
|
+
validators: validatePatternOnBlur(new RegExp(`^\\d{${length},${maxLength}}$`)),
|
|
1277
|
+
mask: {
|
|
1278
|
+
mask: makeMask(...numericInputs(length), ...numericInputs(maxLength - length, true))
|
|
1279
|
+
},
|
|
1280
|
+
guidanceText: {
|
|
1281
|
+
key: "enterAMaximumOfNDigitsForExample",
|
|
1282
|
+
values: {
|
|
1283
|
+
maxDigits: `${maxLength}`,
|
|
1284
|
+
example
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
return {
|
|
1290
|
+
label: "bankAccountNumber",
|
|
1291
|
+
validators: validatePatternOnBlur(new RegExp(`^\\d{${length}}$`)),
|
|
1292
|
+
mask: { mask: makeMask(...numericInputs(length)) },
|
|
1293
|
+
guidanceText: {
|
|
1294
|
+
key: "enterNDigitsForExample",
|
|
1295
|
+
values: {
|
|
1296
|
+
numDigits: `${length}`,
|
|
1297
|
+
example
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
};
|
|
1302
|
+
const defaultFieldMetadata$3 = {
|
|
1303
|
+
label: "bankAccountNumber",
|
|
1304
|
+
validators: isNotEmptyValidator
|
|
1305
|
+
};
|
|
1306
|
+
const defaultFieldConfig$3 = {
|
|
1307
|
+
[CountryCodes.CzechRepublic]: {
|
|
1308
|
+
// Validators & masks pulled from https://docs.adyen.com/api-explorer/legalentity/4/post/transferInstruments#request-bankAccount-accountIdentification-CZLocalAccountIdentification
|
|
1309
|
+
label: "bankAccountNumber",
|
|
1310
|
+
validators: validatePatternOnBlur(/^((\d{2}|\d{6})-)?\d*\d{2}$/),
|
|
1311
|
+
mask: {
|
|
1312
|
+
mask: makeMask(
|
|
1313
|
+
...numericInputs(2),
|
|
1314
|
+
...customInputs(1, /-|\d/),
|
|
1315
|
+
...numericInputs(3),
|
|
1316
|
+
...customInputs(1, /-|\d/),
|
|
1317
|
+
...numericInputs(10)
|
|
1318
|
+
)
|
|
1319
|
+
},
|
|
1320
|
+
guidanceText: {
|
|
1321
|
+
key: "enterXToYDigitsWithOrWithoutPrefixForExample",
|
|
1322
|
+
values: {
|
|
1323
|
+
minDigits: "2",
|
|
1324
|
+
maxDigits: "16",
|
|
1325
|
+
firstExample: "19-123457",
|
|
1326
|
+
secondExample: "123457"
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
[CountryCodes.Denmark]: simpleBankAccountNumberMetadata("2621955959", 10),
|
|
1331
|
+
[CountryCodes.Norway]: simpleBankAccountNumberMetadata("86011117947", 11),
|
|
1332
|
+
[CountryCodes.UnitedKingdom]: simpleBankAccountNumberMetadata("10000003", 8),
|
|
1333
|
+
[CountryCodes.Australia]: simpleBankAccountNumberMetadata("0001234", 5, 10),
|
|
1334
|
+
[CountryCodes.Brazil]: simpleBankAccountNumberMetadata("0009795493", 4, 12),
|
|
1335
|
+
[CountryCodes.Canada]: simpleBankAccountNumberMetadata("10220001111", 5, 12),
|
|
1336
|
+
[CountryCodes.HongKong]: {
|
|
1337
|
+
label: "bankAccountNumber",
|
|
1338
|
+
validators: validatePatternOnBlur(new RegExp(`^\\d{${6},${18}}$`)),
|
|
1339
|
+
mask: {
|
|
1340
|
+
mask: makeMask(...numericInputs(6), ...numericInputs(12, true))
|
|
1341
|
+
},
|
|
1342
|
+
guidanceText: {
|
|
1343
|
+
key: "enterAccountNumberWithBranchCodeForExample",
|
|
1344
|
+
values: {
|
|
1345
|
+
minDigits: "9",
|
|
1346
|
+
maxDigits: "15",
|
|
1347
|
+
example: "790000000"
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
[CountryCodes.Hungary]: simpleBankAccountNumberMetadata("117730161111101800000000", 24),
|
|
1352
|
+
[CountryCodes.Singapore]: simpleBankAccountNumberMetadata("0052312891876", 4, 19),
|
|
1353
|
+
[CountryCodes.Sweden]: simpleBankAccountNumberMetadata("123456789", 7, 10),
|
|
1354
|
+
[CountryCodes.UnitedStates]: simpleBankAccountNumberMetadata("10220001111", 3, 17),
|
|
1355
|
+
[CountryCodes.Poland]: {
|
|
1356
|
+
label: "bankAccountNumber",
|
|
1357
|
+
validators: validatePatternOnBlur(/^\d{26}$/),
|
|
1358
|
+
mask: {
|
|
1359
|
+
mask: makeMask(
|
|
1360
|
+
...numericInputs(2),
|
|
1361
|
+
spacer,
|
|
1362
|
+
...numericInputs(4),
|
|
1363
|
+
spacer,
|
|
1364
|
+
...numericInputs(4),
|
|
1365
|
+
spacer,
|
|
1366
|
+
...numericInputs(4),
|
|
1367
|
+
spacer,
|
|
1368
|
+
...numericInputs(4),
|
|
1369
|
+
spacer,
|
|
1370
|
+
...numericInputs(4),
|
|
1371
|
+
spacer,
|
|
1372
|
+
...numericInputs(4)
|
|
1373
|
+
)
|
|
1374
|
+
},
|
|
1375
|
+
guidanceText: {
|
|
1376
|
+
key: "enterNDigitsForExample",
|
|
1377
|
+
values: {
|
|
1378
|
+
numDigits: "26",
|
|
1379
|
+
example: "98 1090 2402 7474 4662 2173 1624"
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1383
|
+
[CountryCodes.NewZealand]: {
|
|
1384
|
+
label: "bankAccountNumber",
|
|
1385
|
+
validators: validatePatternOnBlur(/^\d{15,16}$/),
|
|
1386
|
+
mask: {
|
|
1387
|
+
mask: makeMask(
|
|
1388
|
+
...numericInputs(2),
|
|
1389
|
+
...nonInputs(" - "),
|
|
1390
|
+
...numericInputs(4),
|
|
1391
|
+
...nonInputs(" - "),
|
|
1392
|
+
...numericInputs(7),
|
|
1393
|
+
...nonInputs(" - "),
|
|
1394
|
+
...numericInputs(2),
|
|
1395
|
+
...numericInputs(1, true)
|
|
1396
|
+
)
|
|
1397
|
+
},
|
|
1398
|
+
guidanceText: {
|
|
1399
|
+
key: "enterXToYDigitsForExample",
|
|
1400
|
+
values: {
|
|
1401
|
+
minDigits: "15",
|
|
1402
|
+
maxDigits: "16",
|
|
1403
|
+
example: "12-8765-9876543-043"
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
const bankAccountNumberFields = ["bankAccountNumber"];
|
|
1409
|
+
function BankAccountNumber(props) {
|
|
1410
|
+
const { t } = useTranslation("common");
|
|
1411
|
+
const { country, fieldConfig = defaultFieldConfig$3, onFocus, onBlur } = props;
|
|
1412
|
+
const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata$3);
|
|
1413
|
+
const mergedProps = mergeFieldMetadataIntoProps("bankAccountNumber", metadata, props);
|
|
1414
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
1415
|
+
...mergedProps,
|
|
1416
|
+
schema: bankAccountNumberFields,
|
|
1417
|
+
rules: mergedProps.validators,
|
|
1418
|
+
defaultData: mergedProps.data,
|
|
1419
|
+
fieldProblems: mergedProps?.fieldValidationErrors,
|
|
1420
|
+
obscuredFields: mergedProps.obscuredFields
|
|
1421
|
+
});
|
|
1422
|
+
const handleBlur = () => {
|
|
1423
|
+
onBlur?.();
|
|
1424
|
+
handleChangeFor("bankAccountNumber", "blur");
|
|
1425
|
+
};
|
|
1426
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
1427
|
+
"payoutAccountDetails"
|
|
1428
|
+
);
|
|
1429
|
+
useEffect(() => {
|
|
1430
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
1431
|
+
}, [data, valid, errors]);
|
|
1432
|
+
const formUtils = createFormUtils(mergedProps, t);
|
|
1433
|
+
return /* @__PURE__ */ jsx(
|
|
1434
|
+
MaskedInput,
|
|
1435
|
+
{
|
|
1436
|
+
name: "bankAccountNumber",
|
|
1437
|
+
type: "text",
|
|
1438
|
+
label: formUtils.getLabel("bankAccountNumber"),
|
|
1439
|
+
formatGuidance: formUtils.getGuidanceText("bankAccountNumber"),
|
|
1440
|
+
...formUtils.getMask("bankAccountNumber"),
|
|
1441
|
+
isValid: valid.bankAccountNumber,
|
|
1442
|
+
errorMessage: formUtils.getErrorMessage("bankAccountNumber", errors, fieldProblems),
|
|
1443
|
+
"aria-required": true,
|
|
1444
|
+
"aria-invalid": !valid.bankAccountNumber,
|
|
1445
|
+
onBlur: handleBlur,
|
|
1446
|
+
onInput: handleChangeFor("bankAccountNumber", "input"),
|
|
1447
|
+
onFocus,
|
|
1448
|
+
readonly: formUtils.isReadOnly("bankAccountNumber"),
|
|
1449
|
+
value: data.bankAccountNumber ?? "",
|
|
1450
|
+
acceptObscuredValue: formUtils.isObscured("bankAccountNumber")
|
|
1451
|
+
}
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
const bankCityFields = ["bankCity"];
|
|
1455
|
+
function BankCity(props) {
|
|
1456
|
+
const { t } = useTranslation("common");
|
|
1457
|
+
const { validators, data: bankCityData, fieldValidationErrors } = props;
|
|
1458
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
1459
|
+
...props,
|
|
1460
|
+
schema: bankCityFields,
|
|
1461
|
+
rules: validators,
|
|
1462
|
+
defaultData: bankCityData,
|
|
1463
|
+
fieldProblems: fieldValidationErrors
|
|
1464
|
+
});
|
|
1465
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
1466
|
+
"payoutAccountDetails"
|
|
1467
|
+
);
|
|
1468
|
+
useEffect(() => {
|
|
1469
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
1470
|
+
}, [data, valid, errors]);
|
|
1471
|
+
const formUtils = createFormUtils(props, t);
|
|
1472
|
+
return /* @__PURE__ */ jsx(
|
|
1473
|
+
Field,
|
|
1474
|
+
{
|
|
1475
|
+
name: "bankCity",
|
|
1476
|
+
label: formUtils.getLabel("bankCity"),
|
|
1477
|
+
errorMessage: formUtils.getErrorMessage("bankCity", errors, fieldProblems),
|
|
1478
|
+
isValid: valid.bankCity,
|
|
1479
|
+
children: (childProps) => /* @__PURE__ */ jsx(
|
|
1480
|
+
InputText,
|
|
1481
|
+
{
|
|
1482
|
+
...childProps,
|
|
1483
|
+
name: "bankCity",
|
|
1484
|
+
value: data.bankCity,
|
|
1485
|
+
readonly: formUtils.isReadOnly("bankCity"),
|
|
1486
|
+
onInput: handleChangeFor("bankCity", "input"),
|
|
1487
|
+
onBlur: handleChangeFor("bankCity", "blur"),
|
|
1488
|
+
"aria-required": true,
|
|
1489
|
+
"aria-invalid": !valid.bankCity
|
|
1490
|
+
}
|
|
1491
|
+
)
|
|
1492
|
+
}
|
|
1493
|
+
);
|
|
1494
|
+
}
|
|
1495
|
+
const defaultFieldMetadata$2 = {
|
|
1496
|
+
label: "bankCode",
|
|
1497
|
+
validators: isNotEmptyValidator
|
|
1498
|
+
};
|
|
1499
|
+
const simpleBankCodeMetadata = (length, example, label) => ({
|
|
1500
|
+
label: label ?? "bankCode",
|
|
1501
|
+
validators: validatePatternOnBlur(new RegExp(`^\\d{${length}}$`)),
|
|
1502
|
+
mask: {
|
|
1503
|
+
mask: makeMask(...numericInputs(length))
|
|
1504
|
+
},
|
|
1505
|
+
guidanceText: {
|
|
1506
|
+
key: "enterNDigitsForExample",
|
|
1507
|
+
values: {
|
|
1508
|
+
numDigits: `${length}`,
|
|
1509
|
+
example
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
const defaultFieldConfig$2 = {
|
|
1514
|
+
[CountryCodes.Brazil]: simpleBankCodeMetadata(3, "123"),
|
|
1515
|
+
[CountryCodes.Canada]: simpleBankCodeMetadata(3, "100", "institutionNumber"),
|
|
1516
|
+
[CountryCodes.CzechRepublic]: simpleBankCodeMetadata(4, "0800"),
|
|
1517
|
+
[CountryCodes.Denmark]: simpleBankCodeMetadata(4, "5051"),
|
|
1518
|
+
[CountryCodes.HongKong]: simpleBankCodeMetadata(3, "250", "bankCode"),
|
|
1519
|
+
[CountryCodes.Norway]: simpleBankCodeMetadata(4, "8601"),
|
|
1520
|
+
// Not yet implemented
|
|
1521
|
+
[CountryCodes.Ecuador]: simpleBankCodeMetadata(4, "1234"),
|
|
1522
|
+
[CountryCodes.Japan]: simpleBankCodeMetadata(4, "1234"),
|
|
1523
|
+
[CountryCodes.Taiwan]: simpleBankCodeMetadata(3, "123")
|
|
1524
|
+
};
|
|
1525
|
+
const bankCodeFields = ["bankCode"];
|
|
1526
|
+
function BankCode(props) {
|
|
1527
|
+
const { t } = useTranslation("common");
|
|
1528
|
+
const { country, fieldConfig = defaultFieldConfig$2 } = props;
|
|
1529
|
+
const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata$2);
|
|
1530
|
+
const mergedProps = mergeFieldMetadataIntoProps("bankCode", metadata, props);
|
|
1531
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
1532
|
+
...mergedProps,
|
|
1533
|
+
schema: bankCodeFields,
|
|
1534
|
+
rules: mergedProps.validators,
|
|
1535
|
+
defaultData: mergedProps.data,
|
|
1536
|
+
fieldProblems: mergedProps.fieldValidationErrors
|
|
1537
|
+
});
|
|
1538
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
1539
|
+
"payoutAccountDetails"
|
|
1540
|
+
);
|
|
1541
|
+
useEffect(() => {
|
|
1542
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
1543
|
+
}, [data, valid, errors]);
|
|
1544
|
+
const formUtils = createFormUtils(mergedProps, t);
|
|
1545
|
+
return /* @__PURE__ */ jsx(
|
|
1546
|
+
MaskedInput,
|
|
1547
|
+
{
|
|
1548
|
+
name: "bankCode",
|
|
1549
|
+
type: "text",
|
|
1550
|
+
label: formUtils.getLabel("bankCode"),
|
|
1551
|
+
errorMessage: formUtils.getErrorMessage("bankCode", errors, fieldProblems),
|
|
1552
|
+
formatGuidance: formUtils.getGuidanceText("bankCode"),
|
|
1553
|
+
...formUtils.getMask("bankCode"),
|
|
1554
|
+
isValid: valid.bankCode,
|
|
1555
|
+
value: data.bankCode ?? "",
|
|
1556
|
+
readonly: formUtils.isReadOnly("bankCode"),
|
|
1557
|
+
onInput: handleChangeFor("bankCode", "input"),
|
|
1558
|
+
onBlur: handleChangeFor("bankCode", "blur"),
|
|
1559
|
+
"aria-required": true,
|
|
1560
|
+
"aria-invalid": !valid.bankCode
|
|
1561
|
+
}
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
const bankNameFields = ["bankName"];
|
|
1565
|
+
function BankName(props) {
|
|
1566
|
+
const { t } = useTranslation("common");
|
|
1567
|
+
const { validators, data: bankNameData, fieldValidationErrors } = props;
|
|
1568
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
1569
|
+
...props,
|
|
1570
|
+
schema: bankNameFields,
|
|
1571
|
+
rules: validators,
|
|
1572
|
+
defaultData: bankNameData,
|
|
1573
|
+
fieldProblems: fieldValidationErrors
|
|
1574
|
+
});
|
|
1575
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
1576
|
+
"payoutAccountDetails"
|
|
1577
|
+
);
|
|
1578
|
+
useEffect(() => {
|
|
1579
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
1580
|
+
}, [data, valid, errors]);
|
|
1581
|
+
const formUtils = createFormUtils(props, t);
|
|
1582
|
+
return /* @__PURE__ */ jsx(
|
|
1583
|
+
Field,
|
|
1584
|
+
{
|
|
1585
|
+
name: "bankName",
|
|
1586
|
+
label: formUtils.getLabel("bankName"),
|
|
1587
|
+
errorMessage: formUtils.getErrorMessage("bankName", errors, fieldProblems),
|
|
1588
|
+
isValid: valid.bankName,
|
|
1589
|
+
children: (childProps) => /* @__PURE__ */ jsx(
|
|
1590
|
+
InputText,
|
|
1591
|
+
{
|
|
1592
|
+
...childProps,
|
|
1593
|
+
name: "bankName",
|
|
1594
|
+
value: data.bankName,
|
|
1595
|
+
readonly: formUtils.isReadOnly("bankName"),
|
|
1596
|
+
onInput: handleChangeFor("bankName", "input"),
|
|
1597
|
+
onBlur: handleChangeFor("bankName", "blur"),
|
|
1598
|
+
"aria-required": true,
|
|
1599
|
+
"aria-invalid": !valid.bankName
|
|
1600
|
+
}
|
|
1601
|
+
)
|
|
1602
|
+
}
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
const defaultFieldMetadata$1 = {
|
|
1606
|
+
label: "branchCode",
|
|
1607
|
+
validators: isNotEmptyValidator
|
|
1608
|
+
};
|
|
1609
|
+
const defaultFieldConfig$1 = {
|
|
1610
|
+
[CountryCodes.UnitedKingdom]: {
|
|
1611
|
+
label: "sortCode",
|
|
1612
|
+
validators: validatePatternOnBlur(/^\d{6}$/),
|
|
1613
|
+
mask: { mask: makeMask(...numericInputs(6)) },
|
|
1614
|
+
guidanceText: {
|
|
1615
|
+
key: "enterNDigitsForExample",
|
|
1616
|
+
values: {
|
|
1617
|
+
numDigits: "6",
|
|
1618
|
+
example: "401199"
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
},
|
|
1622
|
+
[CountryCodes.Australia]: {
|
|
1623
|
+
label: "bsbNumber",
|
|
1624
|
+
validators: validatePatternOnBlur(/^\d{6}$/),
|
|
1625
|
+
mask: { mask: makeMask(...numericInputs(3), ...nonInputs(" - "), ...numericInputs(3)) },
|
|
1626
|
+
guidanceText: {
|
|
1627
|
+
key: "enterNDigitsForExample",
|
|
1628
|
+
values: {
|
|
1629
|
+
numDigits: "6",
|
|
1630
|
+
example: "033-547"
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
},
|
|
1634
|
+
[CountryCodes.Brazil]: {
|
|
1635
|
+
label: "branchCode",
|
|
1636
|
+
validators: validatePatternOnBlur(/^\d{1,5}$/),
|
|
1637
|
+
mask: { mask: makeMask(...numericInputs(1), ...numericInputs(4, true)) },
|
|
1638
|
+
guidanceText: {
|
|
1639
|
+
key: "enterAMaximumOfNDigitsForExample",
|
|
1640
|
+
values: {
|
|
1641
|
+
maxDigits: "5",
|
|
1642
|
+
example: "36257"
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1646
|
+
[CountryCodes.Canada]: {
|
|
1647
|
+
label: "transitNumber",
|
|
1648
|
+
validators: validatePatternOnBlur(/^\d{5}$/),
|
|
1649
|
+
mask: { mask: makeMask(...numericInputs(5)) },
|
|
1650
|
+
guidanceText: {
|
|
1651
|
+
key: "enterNDigitsForExample",
|
|
1652
|
+
values: {
|
|
1653
|
+
numDigits: "5",
|
|
1654
|
+
example: "27601"
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
},
|
|
1658
|
+
[CountryCodes.UnitedStates]: {
|
|
1659
|
+
label: "routingNumber",
|
|
1660
|
+
validators: validatePatternOnBlur(/^\d{9}$/),
|
|
1661
|
+
mask: { mask: makeMask(...numericInputs(9)) },
|
|
1662
|
+
guidanceText: {
|
|
1663
|
+
key: "enterNDigitsForExample",
|
|
1664
|
+
values: {
|
|
1665
|
+
numDigits: "9",
|
|
1666
|
+
example: "107005432"
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
},
|
|
1670
|
+
[CountryCodes.Sweden]: {
|
|
1671
|
+
label: "branchCode",
|
|
1672
|
+
validators: validatePatternOnBlur(/^\d{4,5}$/),
|
|
1673
|
+
mask: {
|
|
1674
|
+
mask: makeMask(
|
|
1675
|
+
...numericInputs(4),
|
|
1676
|
+
...nonInputs(" - ", { displayEagerly: false }),
|
|
1677
|
+
...numericInputs(1, true)
|
|
1678
|
+
)
|
|
1679
|
+
},
|
|
1680
|
+
guidanceText: {
|
|
1681
|
+
key: "enterXToYDigitsForExample",
|
|
1682
|
+
values: {
|
|
1683
|
+
minDigits: "4",
|
|
1684
|
+
maxDigits: "5",
|
|
1685
|
+
example: "5678 or 7635-2"
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
},
|
|
1689
|
+
// Not yet implemented
|
|
1690
|
+
[CountryCodes.Indonesia]: {
|
|
1691
|
+
label: "clearingCode",
|
|
1692
|
+
validators: isNotEmptyValidator
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
const branchCodeFields = ["branchCode"];
|
|
1696
|
+
function BranchCode(props) {
|
|
1697
|
+
const { t } = useTranslation("common");
|
|
1698
|
+
const { country, fieldConfig = defaultFieldConfig$1, onFocus, onBlur } = props;
|
|
1699
|
+
const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata$1);
|
|
1700
|
+
const mergedProps = mergeFieldMetadataIntoProps("branchCode", metadata, props);
|
|
1701
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
1702
|
+
...mergedProps,
|
|
1703
|
+
schema: branchCodeFields,
|
|
1704
|
+
rules: mergedProps.validators,
|
|
1705
|
+
defaultData: mergedProps.data,
|
|
1706
|
+
fieldProblems: mergedProps?.fieldValidationErrors
|
|
1707
|
+
});
|
|
1708
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
1709
|
+
"payoutAccountDetails"
|
|
1710
|
+
);
|
|
1711
|
+
const handleBlur = () => {
|
|
1712
|
+
onBlur?.();
|
|
1713
|
+
handleChangeFor("branchCode", "blur");
|
|
1714
|
+
};
|
|
1715
|
+
useEffect(() => {
|
|
1716
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
1717
|
+
}, [data, valid, errors]);
|
|
1718
|
+
const formUtils = createFormUtils(mergedProps, t);
|
|
1719
|
+
return /* @__PURE__ */ jsx(
|
|
1720
|
+
MaskedInput,
|
|
1721
|
+
{
|
|
1722
|
+
name: "branchCode",
|
|
1723
|
+
type: "text",
|
|
1724
|
+
label: formUtils.getLabel("branchCode"),
|
|
1725
|
+
formatGuidance: formUtils.getGuidanceText("branchCode"),
|
|
1726
|
+
...formUtils.getMask("branchCode"),
|
|
1727
|
+
errorMessage: formUtils.getErrorMessage("branchCode", errors, fieldProblems),
|
|
1728
|
+
isValid: valid.branchCode,
|
|
1729
|
+
value: data.branchCode ?? "",
|
|
1730
|
+
readonly: formUtils.isReadOnly("branchCode"),
|
|
1731
|
+
onInput: handleChangeFor("branchCode", "input"),
|
|
1732
|
+
onBlur: handleBlur,
|
|
1733
|
+
onFocus,
|
|
1734
|
+
"aria-required": true,
|
|
1735
|
+
"aria-invalid": !valid.branchCode
|
|
1736
|
+
}
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
const bbanPatternsByCountry = {
|
|
1740
|
+
[CountryCodes.Albania]: /\d{8}[\dA-Z]{16}/,
|
|
1741
|
+
[CountryCodes.Andorra]: /\d{8}[\dA-Z]{12}/,
|
|
1742
|
+
[CountryCodes.Austria]: /\d{16}/,
|
|
1743
|
+
[CountryCodes.Azerbaijan]: /[\dA-Z]{4}\d{20}/,
|
|
1744
|
+
[CountryCodes.Belgium]: /\d{12}/,
|
|
1745
|
+
[CountryCodes.Bahrain]: /[A-Z]{4}[\dA-Z]{14}/,
|
|
1746
|
+
[CountryCodes.BosniaAndHerzegovina]: /\d{16}/,
|
|
1747
|
+
[CountryCodes.Brazil]: /\d{23}[A-Z][\dA-Z]/,
|
|
1748
|
+
[CountryCodes.Bulgaria]: /[A-Z]{4}\d{6}[\dA-Z]{8}/,
|
|
1749
|
+
[CountryCodes.CostaRica]: /\d{17}/,
|
|
1750
|
+
[CountryCodes.Croatia]: /\d{17}/,
|
|
1751
|
+
[CountryCodes.Cyprus]: /\d{8}[\dA-Z]{16}/,
|
|
1752
|
+
[CountryCodes.CzechRepublic]: /\d{20}/,
|
|
1753
|
+
[CountryCodes.Denmark]: /\d{14}/,
|
|
1754
|
+
[CountryCodes.DominicanRepublic]: /[A-Z]{4}\d{20}/,
|
|
1755
|
+
[CountryCodes.Estonia]: /\d{16}/,
|
|
1756
|
+
[CountryCodes.FaroeIslands]: /\d{14}/,
|
|
1757
|
+
[CountryCodes.Finland]: /\d{14}/,
|
|
1758
|
+
[CountryCodes.France]: /\d{10}[\dA-Z]{11}\d{2}/,
|
|
1759
|
+
[CountryCodes.Georgia]: /[\dA-Z]{2}\d{16}/,
|
|
1760
|
+
[CountryCodes.Germany]: /\d{18}/,
|
|
1761
|
+
[CountryCodes.Gibraltar]: /[A-Z]{4}[\dA-Z]{15}/,
|
|
1762
|
+
[CountryCodes.Greece]: /\d{7}[\dA-Z]{16}/,
|
|
1763
|
+
[CountryCodes.Greenland]: /\d{14}/,
|
|
1764
|
+
[CountryCodes.Guatemala]: /[\dA-Z]{4}[\dA-Z]{20}/,
|
|
1765
|
+
[CountryCodes.Hungary]: /\d{24}/,
|
|
1766
|
+
[CountryCodes.Iceland]: /\d{22}/,
|
|
1767
|
+
[CountryCodes.Ireland]: /[\dA-Z]{4}\d{14}/,
|
|
1768
|
+
[CountryCodes.Israel]: /\d{19}/,
|
|
1769
|
+
[CountryCodes.Italy]: /[A-Z]\d{10}[\dA-Z]{12}/,
|
|
1770
|
+
[CountryCodes.Kazakhstan]: /\d{3}[\dA-Z]{13}/,
|
|
1771
|
+
[CountryCodes.Kuwait]: /[A-Z]{4}[\dA-Z]{22}/,
|
|
1772
|
+
[CountryCodes.Latvia]: /[A-Z]{4}[\dA-Z]{13}/,
|
|
1773
|
+
[CountryCodes.Lebanon]: /\d{4}[\dA-Z]{20}/,
|
|
1774
|
+
[CountryCodes.Liechtenstein]: /\d{5}[\dA-Z]{12}/,
|
|
1775
|
+
[CountryCodes.Lithuania]: /\d{16}/,
|
|
1776
|
+
[CountryCodes.Luxembourg]: /\d{3}[\dA-Z]{13}/,
|
|
1777
|
+
[CountryCodes.Macedonia]: /\d{3}[\dA-Z]{10}\d{2}/,
|
|
1778
|
+
[CountryCodes.Malta]: /[A-Z]{4}\d{5}[\dA-Z]{18}/,
|
|
1779
|
+
[CountryCodes.Mauritania]: /\d{23}/,
|
|
1780
|
+
[CountryCodes.Mauritius]: /[A-Z]{4}\d{19}[A-Z]{3}/,
|
|
1781
|
+
[CountryCodes.Monaco]: /\d{10}[\dA-Z]{11}\d{2}/,
|
|
1782
|
+
[CountryCodes.Moldova]: /[\dA-Z]{2}\d{18}/,
|
|
1783
|
+
[CountryCodes.Montenegro]: /\d{18}/,
|
|
1784
|
+
[CountryCodes.Netherlands]: /[A-Z]{4}\d{10}/,
|
|
1785
|
+
[CountryCodes.Norway]: /\d{11}/,
|
|
1786
|
+
[CountryCodes.Pakistan]: /[\dA-Z]{4}\d{16}/,
|
|
1787
|
+
[CountryCodes.PalestinianTerritory]: /[\dA-Z]{4}\d{21}/,
|
|
1788
|
+
[CountryCodes.Poland]: /\d{24}/,
|
|
1789
|
+
[CountryCodes.Portugal]: /\d{21}/,
|
|
1790
|
+
[CountryCodes.Romania]: /[A-Z]{4}[\dA-Z]{16}/,
|
|
1791
|
+
[CountryCodes.SanMarino]: /[A-Z]\d{10}[\dA-Z]{12}/,
|
|
1792
|
+
[CountryCodes.SaudiArabia]: /\d{2}[\dA-Z]{18}/,
|
|
1793
|
+
[CountryCodes.Serbia]: /\d{18}/,
|
|
1794
|
+
[CountryCodes.Slovakia]: /\d{20}/,
|
|
1795
|
+
[CountryCodes.Slovenia]: /\d{15}/,
|
|
1796
|
+
[CountryCodes.Spain]: /\d{20}/,
|
|
1797
|
+
[CountryCodes.Sweden]: /\d{20}/,
|
|
1798
|
+
[CountryCodes.Switzerland]: /\d{5}[\dA-Z]{12}/,
|
|
1799
|
+
[CountryCodes.Tunisia]: /\d{20}/,
|
|
1800
|
+
[CountryCodes.Turkey]: /\d{5}[\dA-Z]{17}/,
|
|
1801
|
+
[CountryCodes.UnitedArabEmirates]: /\d{3}\d{16}/,
|
|
1802
|
+
[CountryCodes.UnitedKingdom]: /[A-Z]{4}\d{14}/,
|
|
1803
|
+
[CountryCodes.VirginIslandsBritish]: /[\dA-Z]{4}\d{16}/
|
|
1804
|
+
};
|
|
1805
|
+
const customPrefixByCountry = {
|
|
1806
|
+
[CountryCodes.Guernsey]: "GB",
|
|
1807
|
+
[CountryCodes.Jersey]: "GB",
|
|
1808
|
+
[CountryCodes.IsleOfMan]: "GB"
|
|
1809
|
+
};
|
|
1810
|
+
function ibanValidator(input, bankCountry) {
|
|
1811
|
+
if (isEmpty(input)) return false;
|
|
1812
|
+
const ibanInput = input.replace(/ /g, "").toUpperCase();
|
|
1813
|
+
if (!/^([a-zA-Z0-9]{4} ){2,8}[a-zA-Z0-9]{1,4}|[a-zA-Z0-9]{12,34}$/.test(ibanInput)) {
|
|
1814
|
+
return false;
|
|
1815
|
+
}
|
|
1816
|
+
const countryCode = ibanInput.substring(0, 2);
|
|
1817
|
+
const allowedPrefix = customPrefixByCountry[bankCountry] ?? bankCountry;
|
|
1818
|
+
if (countryCode !== allowedPrefix) {
|
|
1819
|
+
return {
|
|
1820
|
+
key: "yourIbanShouldBeginWith_",
|
|
1821
|
+
values: {
|
|
1822
|
+
countryCode: allowedPrefix
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
const bbanPattern = bbanPatternsByCountry[countryCode];
|
|
1827
|
+
if (bbanPattern) {
|
|
1828
|
+
const ibanPattern = new RegExp(`^[A-Z]{2}\\d{2}${bbanPattern.source}$`, "");
|
|
1829
|
+
if (!ibanPattern.test(ibanInput)) {
|
|
1830
|
+
return false;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
const ibanCheck = ibanInput.substring(4, ibanInput.length) + ibanInput.substring(0, 4);
|
|
1834
|
+
let leadingZeroes = true;
|
|
1835
|
+
let ibanCheckDigits = "";
|
|
1836
|
+
for (let i = 0; i < ibanCheck.length; i += 1) {
|
|
1837
|
+
const charAt = ibanCheck.charAt(i);
|
|
1838
|
+
if (charAt !== "0") {
|
|
1839
|
+
leadingZeroes = false;
|
|
1840
|
+
}
|
|
1841
|
+
if (!leadingZeroes) {
|
|
1842
|
+
ibanCheckDigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(charAt);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
let cRest = 0;
|
|
1846
|
+
for (let p = 0; p < ibanCheckDigits.length; p += 1) {
|
|
1847
|
+
const cChar = ibanCheckDigits.charAt(p);
|
|
1848
|
+
const cOperator = +`${cRest}${cChar}`;
|
|
1849
|
+
cRest = cOperator % 97;
|
|
1850
|
+
}
|
|
1851
|
+
return cRest === 1;
|
|
1852
|
+
}
|
|
1853
|
+
const validateIbanOnBlurAndInput = (country) => ({
|
|
1854
|
+
modes: ["blur", "input"],
|
|
1855
|
+
validate: (iban) => ibanValidator(iban, country) === true,
|
|
1856
|
+
errorMessage: (iban) => {
|
|
1857
|
+
const result = ibanValidator(iban, country);
|
|
1858
|
+
return typeof result === "boolean" ? void 0 : result;
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
const ibanMask = (country, inputLength, allowLettersInBban) => {
|
|
1862
|
+
const tokens = [];
|
|
1863
|
+
tokens.push(...nonInputs(country, { includeInValue: true }), ...numericInputs(2));
|
|
1864
|
+
inputLength -= 2;
|
|
1865
|
+
const inputToken = allowLettersInBban ? alphanumericInputs : numericInputs;
|
|
1866
|
+
const numGroups = Math.floor(inputLength / 4);
|
|
1867
|
+
const remainder = inputLength % 4;
|
|
1868
|
+
for (let i = 0; i < numGroups; i += 1) {
|
|
1869
|
+
tokens.push(spacer, ...inputToken(4));
|
|
1870
|
+
}
|
|
1871
|
+
if (remainder > 0) {
|
|
1872
|
+
tokens.push(spacer, ...inputToken(remainder));
|
|
1873
|
+
}
|
|
1874
|
+
return {
|
|
1875
|
+
mask: makeMask(...tokens),
|
|
1876
|
+
transformOnType: allowLettersInBban ? uppercase : void 0
|
|
1877
|
+
};
|
|
1878
|
+
};
|
|
1879
|
+
const ibanGuidance = (type, numDigitsOrChars, example) => type === "digits" ? {
|
|
1880
|
+
key: "enterTheRemainingNDigitsForExample",
|
|
1881
|
+
values: {
|
|
1882
|
+
numDigits: `${numDigitsOrChars}`,
|
|
1883
|
+
example
|
|
1884
|
+
}
|
|
1885
|
+
} : {
|
|
1886
|
+
key: "enterTheRemainingNCharactersForExample",
|
|
1887
|
+
values: {
|
|
1888
|
+
numChars: `${numDigitsOrChars}`,
|
|
1889
|
+
example
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
const ibanMetadata = (country, inputLength, example, allowLettersInBban) => ({
|
|
1893
|
+
label: "iban",
|
|
1894
|
+
validators: validateIbanOnBlurAndInput(country),
|
|
1895
|
+
mask: ibanMask(country, inputLength, allowLettersInBban),
|
|
1896
|
+
guidanceText: ibanGuidance(allowLettersInBban ? "characters" : "digits", inputLength, example)
|
|
1897
|
+
});
|
|
1898
|
+
const gbIbanMetadata = ibanMetadata(
|
|
1899
|
+
CountryCodes.UnitedKingdom,
|
|
1900
|
+
20,
|
|
1901
|
+
"GB09 BARC 2003 9554 8297 59",
|
|
1902
|
+
true
|
|
1903
|
+
);
|
|
1904
|
+
const defaultFieldMetadata = {
|
|
1905
|
+
label: "iban",
|
|
1906
|
+
validators: isNotEmptyValidator
|
|
1907
|
+
};
|
|
1908
|
+
const defaultFieldConfig = {
|
|
1909
|
+
[CountryCodes.Austria]: ibanMetadata(CountryCodes.Austria, 18, "AT88 5400 0746 7265 9747"),
|
|
1910
|
+
[CountryCodes.Belgium]: ibanMetadata(CountryCodes.Belgium, 14, "BE59 9788 6743 2226"),
|
|
1911
|
+
[CountryCodes.Croatia]: ibanMetadata(CountryCodes.Croatia, 19, "HR51 2484 0083 5929 6973 8"),
|
|
1912
|
+
[CountryCodes.Cyprus]: ibanMetadata(
|
|
1913
|
+
CountryCodes.Cyprus,
|
|
1914
|
+
26,
|
|
1915
|
+
"CY16 5183 1221 8756 5858 5388 7678"
|
|
1916
|
+
),
|
|
1917
|
+
[CountryCodes.CzechRepublic]: ibanMetadata(
|
|
1918
|
+
CountryCodes.CzechRepublic,
|
|
1919
|
+
22,
|
|
1920
|
+
"CZ23 5051 3674 5924 5233 3465"
|
|
1921
|
+
),
|
|
1922
|
+
[CountryCodes.Denmark]: ibanMetadata(CountryCodes.Denmark, 16, "DK95 2000 0123 4567 89"),
|
|
1923
|
+
[CountryCodes.Estonia]: ibanMetadata(CountryCodes.Estonia, 18, "EE26 1291 5123 1542 6371"),
|
|
1924
|
+
[CountryCodes.Finland]: ibanMetadata(CountryCodes.Finland, 16, "FI03 9319 8995 3742 51"),
|
|
1925
|
+
[CountryCodes.Germany]: ibanMetadata(CountryCodes.Germany, 20, "DE91 1000 0000 0123 4567 89"),
|
|
1926
|
+
[CountryCodes.Greece]: ibanMetadata(CountryCodes.Greece, 25, "GR57 0107 7142 7681 6687 9575 217"),
|
|
1927
|
+
[CountryCodes.Hungary]: ibanMetadata(
|
|
1928
|
+
CountryCodes.Hungary,
|
|
1929
|
+
26,
|
|
1930
|
+
"HU68 1070 0024 3428 4128 3192 4812"
|
|
1931
|
+
),
|
|
1932
|
+
[CountryCodes.Lithuania]: ibanMetadata(CountryCodes.Lithuania, 18, "LT59 9244 6228 2176 2762"),
|
|
1933
|
+
[CountryCodes.Luxembourg]: ibanMetadata(CountryCodes.Luxembourg, 18, "LU71 0106 9242 5365 8562"),
|
|
1934
|
+
[CountryCodes.Norway]: ibanMetadata(CountryCodes.Norway, 13, "NO83 3000 1234 567"),
|
|
1935
|
+
[CountryCodes.Poland]: ibanMetadata(
|
|
1936
|
+
CountryCodes.Poland,
|
|
1937
|
+
26,
|
|
1938
|
+
"PL98 1090 2402 7474 4662 2173 1624"
|
|
1939
|
+
),
|
|
1940
|
+
[CountryCodes.Portugal]: ibanMetadata(
|
|
1941
|
+
CountryCodes.Portugal,
|
|
1942
|
+
23,
|
|
1943
|
+
"PT42 0035 0651 8646 9119 5263 5"
|
|
1944
|
+
),
|
|
1945
|
+
[CountryCodes.Slovakia]: ibanMetadata(CountryCodes.Slovakia, 22, "SK25 5173 1333 4916 3219 3521"),
|
|
1946
|
+
[CountryCodes.Slovenia]: ibanMetadata(CountryCodes.Slovenia, 17, "SI56 1920 0123 4567 892"),
|
|
1947
|
+
[CountryCodes.Spain]: ibanMetadata(CountryCodes.Spain, 22, "ES76 1465 5599 9226 7623 2635"),
|
|
1948
|
+
[CountryCodes.Sweden]: ibanMetadata(CountryCodes.Sweden, 22, "SE72 8000 0810 3400 0978 3242"),
|
|
1949
|
+
// These include letters in the BBAN (bank account number)
|
|
1950
|
+
[CountryCodes.Bulgaria]: ibanMetadata(
|
|
1951
|
+
CountryCodes.Bulgaria,
|
|
1952
|
+
20,
|
|
1953
|
+
"BG17 BNPA 9440 4432 7749 93",
|
|
1954
|
+
true
|
|
1955
|
+
),
|
|
1956
|
+
[CountryCodes.France]: ibanMetadata(
|
|
1957
|
+
CountryCodes.France,
|
|
1958
|
+
25,
|
|
1959
|
+
"FR64 1009 6000 4035 3425 9742 Y90",
|
|
1960
|
+
true
|
|
1961
|
+
),
|
|
1962
|
+
[CountryCodes.Gibraltar]: ibanMetadata(
|
|
1963
|
+
CountryCodes.Gibraltar,
|
|
1964
|
+
21,
|
|
1965
|
+
"GI96 JYJT 9899 9587 8655 898",
|
|
1966
|
+
true
|
|
1967
|
+
),
|
|
1968
|
+
[CountryCodes.Ireland]: ibanMetadata(
|
|
1969
|
+
CountryCodes.Ireland,
|
|
1970
|
+
20,
|
|
1971
|
+
"IE64 IRCE 9205 0112 3456 78",
|
|
1972
|
+
true
|
|
1973
|
+
),
|
|
1974
|
+
[CountryCodes.Italy]: ibanMetadata(
|
|
1975
|
+
CountryCodes.Italy,
|
|
1976
|
+
25,
|
|
1977
|
+
"IT06 L030 0203 2809 8485 8934 882",
|
|
1978
|
+
true
|
|
1979
|
+
),
|
|
1980
|
+
[CountryCodes.Latvia]: ibanMetadata(CountryCodes.Latvia, 19, "LV80 BANK 0000 4351 9500 1", true),
|
|
1981
|
+
[CountryCodes.Liechtenstein]: ibanMetadata(
|
|
1982
|
+
CountryCodes.Liechtenstein,
|
|
1983
|
+
19,
|
|
1984
|
+
"LI21 0881 0000 2324 013A A",
|
|
1985
|
+
true
|
|
1986
|
+
),
|
|
1987
|
+
[CountryCodes.Malta]: ibanMetadata(
|
|
1988
|
+
CountryCodes.Malta,
|
|
1989
|
+
29,
|
|
1990
|
+
"MT03 VIXW 2487 8926 8575 8586 8929 858",
|
|
1991
|
+
true
|
|
1992
|
+
),
|
|
1993
|
+
[CountryCodes.Monaco]: ibanMetadata(
|
|
1994
|
+
CountryCodes.Monaco,
|
|
1995
|
+
25,
|
|
1996
|
+
"MC58 1122 2000 0101 2345 6789 030",
|
|
1997
|
+
true
|
|
1998
|
+
),
|
|
1999
|
+
[CountryCodes.Netherlands]: ibanMetadata(
|
|
2000
|
+
CountryCodes.Netherlands,
|
|
2001
|
+
16,
|
|
2002
|
+
"NL50 ABNA 4452 7591 49",
|
|
2003
|
+
true
|
|
2004
|
+
),
|
|
2005
|
+
[CountryCodes.Romania]: ibanMetadata(
|
|
2006
|
+
CountryCodes.Romania,
|
|
2007
|
+
22,
|
|
2008
|
+
"RO36 PORL 9596 9966 4965 4284",
|
|
2009
|
+
true
|
|
2010
|
+
),
|
|
2011
|
+
[CountryCodes.Switzerland]: ibanMetadata(
|
|
2012
|
+
CountryCodes.Switzerland,
|
|
2013
|
+
19,
|
|
2014
|
+
"CH56 0483 5012 3456 7800 9",
|
|
2015
|
+
true
|
|
2016
|
+
),
|
|
2017
|
+
[CountryCodes.UnitedKingdom]: gbIbanMetadata,
|
|
2018
|
+
// IBANs for Guernsey, Jersey, and Isle of Man also use United Kingdom's format (starting with `GB`)
|
|
2019
|
+
[CountryCodes.Guernsey]: gbIbanMetadata,
|
|
2020
|
+
[CountryCodes.Jersey]: gbIbanMetadata,
|
|
2021
|
+
[CountryCodes.IsleOfMan]: gbIbanMetadata
|
|
2022
|
+
};
|
|
2023
|
+
const ibanFields = ["iban"];
|
|
2024
|
+
function Iban(props) {
|
|
2025
|
+
const { t } = useTranslation("common");
|
|
2026
|
+
const {
|
|
2027
|
+
country,
|
|
2028
|
+
fieldConfig = defaultFieldConfig,
|
|
2029
|
+
data: ibanData,
|
|
2030
|
+
obscuredFields,
|
|
2031
|
+
fieldValidationErrors
|
|
2032
|
+
} = props;
|
|
2033
|
+
const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata);
|
|
2034
|
+
const mergedProps = mergeFieldMetadataIntoProps("iban", metadata, props);
|
|
2035
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
2036
|
+
...mergedProps,
|
|
2037
|
+
schema: ibanFields,
|
|
2038
|
+
rules: mergedProps.validators,
|
|
2039
|
+
defaultData: ibanData,
|
|
2040
|
+
fieldProblems: fieldValidationErrors,
|
|
2041
|
+
obscuredFields
|
|
2042
|
+
});
|
|
2043
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
2044
|
+
"payoutAccountDetails"
|
|
2045
|
+
);
|
|
2046
|
+
useEffect(() => {
|
|
2047
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
2048
|
+
}, [data, errors, valid]);
|
|
2049
|
+
const formUtils = createFormUtils(mergedProps, t);
|
|
2050
|
+
return /* @__PURE__ */ jsx(
|
|
2051
|
+
MaskedInput,
|
|
2052
|
+
{
|
|
2053
|
+
name: "iban",
|
|
2054
|
+
type: "text",
|
|
2055
|
+
label: formUtils.getLabel("iban"),
|
|
2056
|
+
formatGuidance: formUtils.getGuidanceText("iban"),
|
|
2057
|
+
...formUtils.getMask("iban"),
|
|
2058
|
+
errorMessage: formUtils.getErrorMessage("iban", errors, fieldProblems),
|
|
2059
|
+
isValid: valid.iban,
|
|
2060
|
+
value: data.iban ?? "",
|
|
2061
|
+
readonly: formUtils.isReadOnly("iban"),
|
|
2062
|
+
onInput: handleChangeFor("iban", "blur"),
|
|
2063
|
+
onBlur: handleChangeFor("iban", "blur"),
|
|
2064
|
+
"aria-required": true,
|
|
2065
|
+
"aria-invalid": !valid.iban,
|
|
2066
|
+
acceptObscuredValue: formUtils.isObscured("iban")
|
|
2067
|
+
}
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
const swiftCodeFieldMetadata = {
|
|
2071
|
+
label: "bicSwift",
|
|
2072
|
+
validators: validatePatternOnBlur(/^([a-zA-Z0-9]{8}|[a-zA-Z0-9]{11})$/),
|
|
2073
|
+
mask: {
|
|
2074
|
+
mask: makeMask(...alphaInputs(6), ...alphanumericInputs(2), ...alphanumericInputs(3, true)),
|
|
2075
|
+
transformOnType: uppercase
|
|
2076
|
+
},
|
|
2077
|
+
guidanceText: {
|
|
2078
|
+
key: "enterXOrYCharactersForExample",
|
|
2079
|
+
values: {
|
|
2080
|
+
xChars: "8",
|
|
2081
|
+
yChars: "11",
|
|
2082
|
+
example: "BANKDE65287"
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
const swiftCodeFields = ["swiftCode"];
|
|
2087
|
+
function SwiftCode(props) {
|
|
2088
|
+
const { t } = useTranslation("common");
|
|
2089
|
+
const mergedProps = mergeFieldMetadataIntoProps("swiftCode", swiftCodeFieldMetadata, props);
|
|
2090
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
2091
|
+
...mergedProps,
|
|
2092
|
+
schema: swiftCodeFields,
|
|
2093
|
+
rules: mergedProps.validators,
|
|
2094
|
+
defaultData: mergedProps.data,
|
|
2095
|
+
fieldProblems: mergedProps?.fieldValidationErrors
|
|
2096
|
+
});
|
|
2097
|
+
const { updateStateSlice } = useGlobalDataSlice(
|
|
2098
|
+
"payoutAccountDetails"
|
|
2099
|
+
);
|
|
2100
|
+
useEffect(() => {
|
|
2101
|
+
updateStateSlice({ data, valid, errors, fieldProblems });
|
|
2102
|
+
}, [data, valid, errors]);
|
|
2103
|
+
const formUtils = createFormUtils(mergedProps, t);
|
|
2104
|
+
return /* @__PURE__ */ jsx(
|
|
2105
|
+
MaskedInput,
|
|
2106
|
+
{
|
|
2107
|
+
name: "swiftCode",
|
|
2108
|
+
type: "text",
|
|
2109
|
+
label: formUtils.getLabel("swiftCode"),
|
|
2110
|
+
formatGuidance: formUtils.getGuidanceText("swiftCode"),
|
|
2111
|
+
...formUtils.getMask("swiftCode"),
|
|
2112
|
+
errorMessage: formUtils.getErrorMessage("swiftCode", errors, fieldProblems),
|
|
2113
|
+
isValid: valid.swiftCode,
|
|
2114
|
+
value: data.swiftCode ?? "",
|
|
2115
|
+
readonly: formUtils.isReadOnly("swiftCode"),
|
|
2116
|
+
onInput: handleChangeFor("swiftCode", "input"),
|
|
2117
|
+
onBlur: handleChangeFor("swiftCode", "blur"),
|
|
2118
|
+
"aria-required": true,
|
|
2119
|
+
"aria-invalid": !valid.swiftCode
|
|
2120
|
+
}
|
|
2121
|
+
);
|
|
2122
|
+
}
|
|
2123
|
+
const countriesWithMultipleCurrencies = /* @__PURE__ */ new Set([
|
|
2124
|
+
CountryCodes.Bulgaria,
|
|
2125
|
+
CountryCodes.Canada,
|
|
2126
|
+
CountryCodes.Croatia,
|
|
2127
|
+
CountryCodes.CzechRepublic,
|
|
2128
|
+
CountryCodes.Hungary,
|
|
2129
|
+
CountryCodes.Romania,
|
|
2130
|
+
CountryCodes.Switzerland
|
|
2131
|
+
]);
|
|
2132
|
+
const countriesWithLocalFormat = /* @__PURE__ */ new Set([
|
|
2133
|
+
CountryCodes.CzechRepublic,
|
|
2134
|
+
CountryCodes.Denmark,
|
|
2135
|
+
CountryCodes.Hungary,
|
|
2136
|
+
CountryCodes.Norway,
|
|
2137
|
+
CountryCodes.Poland,
|
|
2138
|
+
CountryCodes.Sweden,
|
|
2139
|
+
CountryCodes.UnitedKingdom
|
|
2140
|
+
]);
|
|
2141
|
+
const payoutCurrencySupport = {
|
|
2142
|
+
[CountryCodes.Sweden]: {
|
|
2143
|
+
local: [Currencies.SEK],
|
|
2144
|
+
iban: [Currencies.EUR, Currencies.SEK]
|
|
2145
|
+
},
|
|
2146
|
+
[CountryCodes.Canada]: {
|
|
2147
|
+
local: [Currencies.CAD, Currencies.USD],
|
|
2148
|
+
iban: [Currencies.CAD, Currencies.USD]
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
const shouldShowCheckGuidance = (country) => country === "US";
|
|
2152
|
+
const shouldShowPayoutAccountFormatSelector = (country) => countriesWithLocalFormat.has(country);
|
|
2153
|
+
const shouldShowPayoutAlert = (country) => shouldShowPayoutAccountFormatSelector(country) || countriesWithMultipleCurrencies.has(country);
|
|
2154
|
+
const getSupportedCurrencyGuidance = (i18n, country, requiredFields) => {
|
|
2155
|
+
const format = requiredFields.includes("iban") ? "iban" : "local";
|
|
2156
|
+
if (!shouldShowPayoutAlert(country)) {
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
const supportedCurrencies = getSupportedCurrenciesPerFormat(country, format);
|
|
2160
|
+
if (!supportedCurrencies) {
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
return supportedCurrencies.length > 1 ? i18n.get("payoutIn_Or_", {
|
|
2164
|
+
values: { currencyOne: supportedCurrencies[0], currencyTwo: supportedCurrencies[1] }
|
|
2165
|
+
}) : i18n.get("payoutInOnly_", {
|
|
2166
|
+
values: { currency: supportedCurrencies[0] }
|
|
2167
|
+
});
|
|
2168
|
+
};
|
|
2169
|
+
const getSupportedCurrenciesPerFormat = (country, format) => {
|
|
2170
|
+
const supportedCurrencies = payoutCurrencySupport[country];
|
|
2171
|
+
if (!supportedCurrencies) {
|
|
2172
|
+
const defaultCurrency = currencyByCountry[country]?.[0];
|
|
2173
|
+
if (!defaultCurrency) {
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
return format === "iban" ? [Currencies.EUR, defaultCurrency] : [defaultCurrency];
|
|
2177
|
+
}
|
|
2178
|
+
return supportedCurrencies[format];
|
|
2179
|
+
};
|
|
2180
|
+
const AccountHolderDescriptionFragment = ({
|
|
2181
|
+
legalEntityResponse
|
|
2182
|
+
}) => {
|
|
2183
|
+
const { i18n } = useI18nContext();
|
|
2184
|
+
const hasSolePropEntityAssociations = hasOwnEntityAssociationOfType(
|
|
2185
|
+
LegalEntityTypes.SOLE_PROPRIETORSHIP,
|
|
2186
|
+
legalEntityResponse.entityAssociations,
|
|
2187
|
+
legalEntityResponse.id
|
|
2188
|
+
);
|
|
2189
|
+
const { accountHolder } = useAccountHolder();
|
|
2190
|
+
const unincorporatedPartnershipMembers = useUnincorporatedPartnershipMembers();
|
|
2191
|
+
if (accountHolder === "mySoleProprietorName" || hasSolePropEntityAssociations) {
|
|
2192
|
+
const soleProp = legalEntityResponse.entityAssociations?.find(
|
|
2193
|
+
(ea) => ea.entityType === "soleProprietorship"
|
|
2194
|
+
);
|
|
2195
|
+
const { individual: individual2 } = legalEntityResponse;
|
|
2196
|
+
return /* @__PURE__ */ jsxs(Typography, { children: [
|
|
2197
|
+
`${i18n.get("bankAccountHasToBeInYourName")} `,
|
|
2198
|
+
/* @__PURE__ */ jsx(
|
|
2199
|
+
Typography,
|
|
2200
|
+
{
|
|
2201
|
+
el: "span",
|
|
2202
|
+
variant: "body-stronger",
|
|
2203
|
+
children: `${individual2?.name.firstName} ${individual2?.name.lastName}`
|
|
2204
|
+
}
|
|
2205
|
+
),
|
|
2206
|
+
` ${i18n.get("orSoleProprietorshipName")} `,
|
|
2207
|
+
" ",
|
|
2208
|
+
/* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: `${soleProp?.name ?? ""}` })
|
|
2209
|
+
] });
|
|
2210
|
+
}
|
|
2211
|
+
const hasTrustsEntityAssociations = hasOwnEntityAssociationOfType(
|
|
2212
|
+
LegalEntityTypes.TRUST,
|
|
2213
|
+
legalEntityResponse.entityAssociations,
|
|
2214
|
+
legalEntityResponse.id
|
|
2215
|
+
);
|
|
2216
|
+
if (accountHolder === "aTrust" || hasTrustsEntityAssociations) {
|
|
2217
|
+
const trust = legalEntityResponse.entityAssociations?.find((ea) => ea.entityType === "trust");
|
|
2218
|
+
if (legalEntityResponse.type === LegalEntityTypes.INDIVIDUAL) {
|
|
2219
|
+
return /* @__PURE__ */ jsxs(Typography, { children: [
|
|
2220
|
+
`${i18n.get("bankAccountToHaveSameNameAsTrust")} `,
|
|
2221
|
+
/* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: i18n.get("trusteeAsTrusteeForTrust", {
|
|
2222
|
+
values: {
|
|
2223
|
+
trusteeName: `${legalEntityResponse?.individual?.name.firstName} ${legalEntityResponse?.individual?.name.lastName}`,
|
|
2224
|
+
trustName: trust?.name ?? ""
|
|
2225
|
+
}
|
|
2226
|
+
}) })
|
|
2227
|
+
] });
|
|
2228
|
+
}
|
|
2229
|
+
const companyTrusteeBankAccountName = legalEntityResponse?.organization?.legalName !== legalEntityResponse?.organization?.doingBusinessAs ? i18n.get("trusteeAsTrusteeForTrustDoingBusinessAs", {
|
|
2230
|
+
values: {
|
|
2231
|
+
trusteeName: legalEntityResponse?.organization?.legalName ?? "",
|
|
2232
|
+
trustName: trust?.name ?? "",
|
|
2233
|
+
tradingName: legalEntityResponse?.organization?.doingBusinessAs
|
|
2234
|
+
}
|
|
2235
|
+
}) : i18n.get("trusteeAsTrusteeForTrust", {
|
|
2236
|
+
values: {
|
|
2237
|
+
trusteeName: legalEntityResponse?.organization?.legalName ?? "",
|
|
2238
|
+
trustName: trust?.name ?? ""
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
return /* @__PURE__ */ jsxs(Typography, { children: [
|
|
2242
|
+
`${i18n.get("bankAccountToHaveSameNameAsTrust")} `,
|
|
2243
|
+
/* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: companyTrusteeBankAccountName })
|
|
2244
|
+
] });
|
|
2245
|
+
}
|
|
2246
|
+
const hasUnincorporatedPartnershipEntityAssociations = hasOwnEntityAssociationOfType(
|
|
2247
|
+
LegalEntityTypes.UNINCORPORATED_PARTNERSHIP,
|
|
2248
|
+
legalEntityResponse.entityAssociations,
|
|
2249
|
+
legalEntityResponse.id
|
|
2250
|
+
);
|
|
2251
|
+
if (accountHolder === "anUnincorporatedPartnership" || hasUnincorporatedPartnershipEntityAssociations) {
|
|
2252
|
+
const unincorporatedPartnership = legalEntityResponse?.entityAssociations?.find(
|
|
2253
|
+
(ea) => ea.entityType === "unincorporatedPartnership"
|
|
2254
|
+
);
|
|
2255
|
+
const partnerNames = unincorporatedPartnershipMembers?.map((member) => member?.name)?.sort();
|
|
2256
|
+
return /* @__PURE__ */ jsx(Typography, { children: `${i18n.get("bankAccountToHaveSameNameAsUnincorporatedPartnership", {
|
|
2257
|
+
values: {
|
|
2258
|
+
partnerNames: `${partnerNames?.join(", ")}`,
|
|
2259
|
+
partnershipName: unincorporatedPartnership?.name ?? ""
|
|
2260
|
+
}
|
|
2261
|
+
})} ` });
|
|
2262
|
+
}
|
|
2263
|
+
if (legalEntityResponse.type === LegalEntityTypes.ORGANIZATION) {
|
|
2264
|
+
return /* @__PURE__ */ jsxs(Typography, { children: [
|
|
2265
|
+
`${i18n.get("bankAccountHasToBeInYourCompanyName")} `,
|
|
2266
|
+
/* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: legalEntityResponse?.organization?.legalName })
|
|
2267
|
+
] });
|
|
2268
|
+
}
|
|
2269
|
+
const { individual } = legalEntityResponse;
|
|
2270
|
+
return /* @__PURE__ */ jsxs(Typography, { children: [
|
|
2271
|
+
`${i18n.get("bankAccountHasToBeInYourName")} `,
|
|
2272
|
+
/* @__PURE__ */ jsx(
|
|
2273
|
+
Typography,
|
|
2274
|
+
{
|
|
2275
|
+
el: "span",
|
|
2276
|
+
variant: "body-stronger",
|
|
2277
|
+
children: `${individual?.name.firstName} ${individual?.name.lastName}`
|
|
2278
|
+
}
|
|
2279
|
+
)
|
|
2280
|
+
] });
|
|
2281
|
+
};
|
|
2282
|
+
const checkGuidance = "adyen-kyc-check-guidance";
|
|
2283
|
+
const checkGuidanceImage = "adyen-kyc-check-guidance-image";
|
|
2284
|
+
const checkGuidanceAnnotated = "adyen-kyc-check-guidance-annotated";
|
|
2285
|
+
const checkGuidanceInactive = "adyen-kyc-check-guidance-inactive";
|
|
2286
|
+
const styles = {
|
|
2287
|
+
checkGuidance,
|
|
2288
|
+
checkGuidanceImage,
|
|
2289
|
+
checkGuidanceAnnotated,
|
|
2290
|
+
checkGuidanceInactive
|
|
2291
|
+
};
|
|
2292
|
+
const usCheckAccount = lazy(() => import("./us-check-account-number-C7KE5YzX.js"));
|
|
2293
|
+
const usCheckRouting = lazy(() => import("./us-check-routing-number-DUbhsYAR.js"));
|
|
2294
|
+
const usCheck = lazy(() => import("./us-check-CYY6Crhr.js"));
|
|
2295
|
+
const CheckGuidance = ({ annotated }) => {
|
|
2296
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.checkGuidance, children: [
|
|
2297
|
+
/* @__PURE__ */ jsx(
|
|
2298
|
+
Image,
|
|
2299
|
+
{
|
|
2300
|
+
lazyLoadedImage: usCheckAccount,
|
|
2301
|
+
className: cx(styles.checkGuidanceImage, styles.checkGuidanceAnnotated, {
|
|
2302
|
+
[styles.checkGuidanceInactive]: annotated !== "account"
|
|
2303
|
+
})
|
|
2304
|
+
}
|
|
2305
|
+
),
|
|
2306
|
+
/* @__PURE__ */ jsx(
|
|
2307
|
+
Image,
|
|
2308
|
+
{
|
|
2309
|
+
lazyLoadedImage: usCheckRouting,
|
|
2310
|
+
className: cx(styles.checkGuidanceImage, styles.checkGuidanceAnnotated, {
|
|
2311
|
+
[styles.checkGuidanceInactive]: annotated !== "routing"
|
|
2312
|
+
})
|
|
2313
|
+
}
|
|
2314
|
+
),
|
|
2315
|
+
/* @__PURE__ */ jsx(Image, { lazyLoadedImage: usCheck, className: styles.checkGuidanceImage })
|
|
2316
|
+
] });
|
|
2317
|
+
};
|
|
2318
|
+
const payoutAccountFields = [
|
|
2319
|
+
"accountHolder",
|
|
2320
|
+
...ibanFields,
|
|
2321
|
+
...branchCodeFields,
|
|
2322
|
+
...swiftCodeFields,
|
|
2323
|
+
...bankAccountNumberFields,
|
|
2324
|
+
...bankNameFields,
|
|
2325
|
+
...bankCodeFields
|
|
2326
|
+
];
|
|
2327
|
+
const defaultArray = [];
|
|
2328
|
+
function PayoutAccount(props) {
|
|
2329
|
+
const accountFormat = payoutAccountFormat.value;
|
|
2330
|
+
const { t } = useTranslation("banking");
|
|
2331
|
+
const { t: commonT } = useTranslation("common");
|
|
2332
|
+
const { i18n } = useI18nContext();
|
|
2333
|
+
const [checkAnnotation, setCheckAnnotation] = useState();
|
|
2334
|
+
const { isSettingEnabled } = useSettingsContext();
|
|
2335
|
+
const bankAccountFormatSelectionAllowed = isSettingEnabled(
|
|
2336
|
+
SettingNames.AllowBankAccountFormatSelection
|
|
2337
|
+
);
|
|
2338
|
+
const {
|
|
2339
|
+
heading,
|
|
2340
|
+
country,
|
|
2341
|
+
id,
|
|
2342
|
+
legalEntityResponse,
|
|
2343
|
+
requiredFields = defaultArray,
|
|
2344
|
+
arePayoutAccountDetailsInvalid,
|
|
2345
|
+
invalidFieldNames,
|
|
2346
|
+
formVerificationErrors,
|
|
2347
|
+
fieldValidationErrors
|
|
2348
|
+
} = props;
|
|
2349
|
+
const showCheckGuidance = shouldShowCheckGuidance(country);
|
|
2350
|
+
const formUtils = createFormUtils({ ...props, requiredFields }, commonT);
|
|
2351
|
+
const bankAccountNumberProps = getFieldProps(props, bankAccountNumberFields);
|
|
2352
|
+
const swiftCodeProps = getFieldProps(props, swiftCodeFields);
|
|
2353
|
+
const ibanProps = getFieldProps(
|
|
2354
|
+
props,
|
|
2355
|
+
ibanFields
|
|
2356
|
+
);
|
|
2357
|
+
const branchCodeProps = getFieldProps(props, branchCodeFields);
|
|
2358
|
+
const bankNameProps = getFieldProps(props, bankNameFields);
|
|
2359
|
+
const bankCodeProps = getFieldProps(props, bankCodeFields);
|
|
2360
|
+
const bankCityProps = getFieldProps(props, bankCityFields);
|
|
2361
|
+
const { clearStateSlice } = useGlobalDataSlice(
|
|
2362
|
+
"payoutAccountDetails"
|
|
2363
|
+
);
|
|
2364
|
+
const handleAccountFormatChange = (accountFormat2) => {
|
|
2365
|
+
clearStateSlice();
|
|
2366
|
+
payoutAccountFormat.value = accountFormat2;
|
|
2367
|
+
};
|
|
2368
|
+
return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-individual__payout-account", "aria-describedby": "ariaErrorField", children: [
|
|
2369
|
+
/* @__PURE__ */ jsx(FormHeader, { heading, children: /* @__PURE__ */ jsx(
|
|
2370
|
+
AccountHolderDescriptionFragment,
|
|
2371
|
+
{
|
|
2372
|
+
slot: "description",
|
|
2373
|
+
legalEntityResponse
|
|
2374
|
+
}
|
|
2375
|
+
) }),
|
|
2376
|
+
/* @__PURE__ */ jsx(
|
|
2377
|
+
ErrorPanel,
|
|
2378
|
+
{
|
|
2379
|
+
verificationErrors: formVerificationErrors,
|
|
2380
|
+
validationErrors: fieldValidationErrors,
|
|
2381
|
+
formUtils,
|
|
2382
|
+
id: "ariaErrorField"
|
|
2383
|
+
}
|
|
2384
|
+
),
|
|
2385
|
+
showCheckGuidance ? /* @__PURE__ */ jsx(CheckGuidance, { annotated: checkAnnotation }) : void 0,
|
|
2386
|
+
bankAccountFormatSelectionAllowed && shouldShowPayoutAccountFormatSelector(country) && accountFormat && /* @__PURE__ */ jsx(
|
|
2387
|
+
BankAccountFormat,
|
|
2388
|
+
{
|
|
2389
|
+
bankAccountFormat: accountFormat,
|
|
2390
|
+
handleAccountFormatChange
|
|
2391
|
+
}
|
|
2392
|
+
),
|
|
2393
|
+
formUtils.isRequiredField("branchCode") && /* @__PURE__ */ jsx(
|
|
2394
|
+
BranchCode,
|
|
2395
|
+
{
|
|
2396
|
+
...branchCodeProps,
|
|
2397
|
+
country,
|
|
2398
|
+
dataStoreId: id,
|
|
2399
|
+
onFocus: showCheckGuidance ? () => setCheckAnnotation("routing") : void 0,
|
|
2400
|
+
onBlur: showCheckGuidance ? () => setCheckAnnotation(void 0) : void 0
|
|
2401
|
+
}
|
|
2402
|
+
),
|
|
2403
|
+
formUtils.isRequiredField("bankAccountNumber") && /* @__PURE__ */ jsx(
|
|
2404
|
+
BankAccountNumber,
|
|
2405
|
+
{
|
|
2406
|
+
...bankAccountNumberProps,
|
|
2407
|
+
country,
|
|
2408
|
+
dataStoreId: id,
|
|
2409
|
+
onFocus: showCheckGuidance ? () => setCheckAnnotation("account") : void 0,
|
|
2410
|
+
onBlur: showCheckGuidance ? () => setCheckAnnotation(void 0) : void 0
|
|
2411
|
+
}
|
|
2412
|
+
),
|
|
2413
|
+
formUtils.isRequiredField("iban") && /* @__PURE__ */ jsx(Iban, { ...ibanProps, dataStoreId: id, country }),
|
|
2414
|
+
formUtils.isRequiredField("swiftCode") && /* @__PURE__ */ jsx(SwiftCode, { ...swiftCodeProps, dataStoreId: id }),
|
|
2415
|
+
formUtils.isRequiredField("bankName") && /* @__PURE__ */ jsx(BankName, { ...bankNameProps, dataStoreId: id }),
|
|
2416
|
+
formUtils.isRequiredField("bankCode") && /* @__PURE__ */ jsx(BankCode, { ...bankCodeProps, country, dataStoreId: id }),
|
|
2417
|
+
formUtils.isRequiredField("bankCity") && /* @__PURE__ */ jsx(BankCity, { ...bankCityProps, dataStoreId: id }),
|
|
2418
|
+
shouldShowPayoutAlert(country) && /* @__PURE__ */ jsx(
|
|
2419
|
+
Alert,
|
|
2420
|
+
{
|
|
2421
|
+
title: getSupportedCurrencyGuidance(i18n, country, requiredFields),
|
|
2422
|
+
className: "adyen-kyc-u-margin-bottom-8"
|
|
2423
|
+
}
|
|
2424
|
+
),
|
|
2425
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "tertiary", children: t(($) => $["thisAccountWillBeVerifiedToPrevent"]) }),
|
|
2426
|
+
arePayoutAccountDetailsInvalid && /* @__PURE__ */ jsx(
|
|
2427
|
+
Alert,
|
|
2428
|
+
{
|
|
2429
|
+
className: "adyen-kyc-u-margin-top-16",
|
|
2430
|
+
variant: "error",
|
|
2431
|
+
title: invalidFieldNames ? t(($) => $["pleaseEnterValidField"], {
|
|
2432
|
+
fieldNames: invalidFieldNames
|
|
2433
|
+
}) : t(($) => $["pleaseEnterValidAccountDetails"])
|
|
2434
|
+
}
|
|
2435
|
+
)
|
|
2436
|
+
] });
|
|
2437
|
+
}
|
|
2438
|
+
const regions = {
|
|
2439
|
+
europe: [
|
|
2440
|
+
...EEA_Countries,
|
|
2441
|
+
CountryCodes.Switzerland,
|
|
2442
|
+
CountryCodes.UnitedKingdom,
|
|
2443
|
+
CountryCodes.Gibraltar
|
|
2444
|
+
],
|
|
2445
|
+
apac: [CountryCodes.NewZealand, CountryCodes.Australia]
|
|
2446
|
+
};
|
|
2447
|
+
const getAllowedBankCountries = (country) => Object.values(regions).find((countriesInARegion) => countriesInARegion.includes(country)) ?? [
|
|
2448
|
+
country
|
|
2449
|
+
];
|
|
2450
|
+
const tinkLogo = lazy(() => import("./tink-logo-BcIv93ND.js"));
|
|
2451
|
+
const plaidLogo = lazy(() => import("./plaid-logo-CtActXTN.js"));
|
|
2452
|
+
const yapilyLogo = lazy(() => import("./yapily-logo-CZ4ywjwA.js"));
|
|
2453
|
+
const instantVerificationImage = lazy(
|
|
2454
|
+
() => import("./instant-verification-Dvvkyfmp.js")
|
|
2455
|
+
);
|
|
2456
|
+
const manualVerificationImage = lazy(
|
|
2457
|
+
() => import("./manual-verification-BvZWqA00.js")
|
|
2458
|
+
);
|
|
2459
|
+
const getProviderIconName = (providerName) => {
|
|
2460
|
+
switch (providerName?.toLowerCase()) {
|
|
2461
|
+
case "tink":
|
|
2462
|
+
return tinkLogo;
|
|
2463
|
+
case "plaid":
|
|
2464
|
+
return plaidLogo;
|
|
2465
|
+
case "yapily":
|
|
2466
|
+
return yapilyLogo;
|
|
2467
|
+
default:
|
|
2468
|
+
return void 0;
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
const makePayoutVerificationMethodsMetadata = (instantVerificationProviderName) => ({
|
|
2472
|
+
instantVerification: {
|
|
2473
|
+
name: "verifyViaMobileBankingAppOrWebsite",
|
|
2474
|
+
subtitle: "instant",
|
|
2475
|
+
description: "instantVerificationDescription",
|
|
2476
|
+
svgImport: instantVerificationImage,
|
|
2477
|
+
provider: instantVerificationProviderName ? {
|
|
2478
|
+
name: instantVerificationProviderName,
|
|
2479
|
+
svgImport: getProviderIconName(instantVerificationProviderName)
|
|
2480
|
+
} : void 0
|
|
2481
|
+
},
|
|
2482
|
+
manualVerification: {
|
|
2483
|
+
name: "uploadABankStatement",
|
|
2484
|
+
subtitle: "mayTakeAFewDays",
|
|
2485
|
+
description: "manualVerificationDescription",
|
|
2486
|
+
svgImport: manualVerificationImage
|
|
2487
|
+
}
|
|
2488
|
+
});
|
|
2489
|
+
const payoutVerificationMethods = ["instantVerification", "manualVerification"];
|
|
2490
|
+
const PayoutVerificationMethodOptionFooter = ({
|
|
2491
|
+
method,
|
|
2492
|
+
methodsMetadata
|
|
2493
|
+
}) => {
|
|
2494
|
+
const { i18n } = useI18nContext();
|
|
2495
|
+
const { provider } = methodsMetadata[method];
|
|
2496
|
+
return provider ? /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "adyen-kyc-field-verification-methods__footer", children: [
|
|
2497
|
+
i18n.get("poweredBy"),
|
|
2498
|
+
provider.svgImport ? /* @__PURE__ */ jsx(
|
|
2499
|
+
Image,
|
|
2500
|
+
{
|
|
2501
|
+
className: "adyen-kyc-field-verification-methods__logo",
|
|
2502
|
+
lazyLoadedImage: provider.svgImport
|
|
2503
|
+
}
|
|
2504
|
+
) : ` ${provider.name}`
|
|
2505
|
+
] }) : null;
|
|
2506
|
+
};
|
|
2507
|
+
const payoutVerificationMethodFields = ["payoutVerificationMethod", "bankCountry", ...accountVerificationFields];
|
|
2508
|
+
const getMustHaveSameAccountHolderNameTransKey = (legalEntityType) => {
|
|
2509
|
+
switch (legalEntityType) {
|
|
2510
|
+
case LegalEntityTypes.INDIVIDUAL:
|
|
2511
|
+
case LegalEntityTypes.SOLE_PROPRIETORSHIP:
|
|
2512
|
+
return "theBankAccountHolderMustBeInYourName";
|
|
2513
|
+
case LegalEntityTypes.ORGANIZATION:
|
|
2514
|
+
case LegalEntityTypes.TRUST:
|
|
2515
|
+
case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
|
|
2516
|
+
return "theBankAccountHolderMustHaveTheSameNameAsYourCompany";
|
|
2517
|
+
}
|
|
2518
|
+
};
|
|
2519
|
+
function PayoutVerificationMethod(props) {
|
|
2520
|
+
const {
|
|
2521
|
+
heading,
|
|
2522
|
+
country,
|
|
2523
|
+
accountHolder,
|
|
2524
|
+
provider,
|
|
2525
|
+
bankVendorsLoadingStatus,
|
|
2526
|
+
instantVerificationAvailable,
|
|
2527
|
+
legalEntityResponse,
|
|
2528
|
+
validators,
|
|
2529
|
+
bankInfoValidated,
|
|
2530
|
+
data: payoutVerificationMethodData,
|
|
2531
|
+
fieldValidationErrors,
|
|
2532
|
+
formVerificationErrors
|
|
2533
|
+
} = props;
|
|
2534
|
+
const { type: legalEntityType } = legalEntityResponse;
|
|
2535
|
+
const { t } = useTranslation("banking");
|
|
2536
|
+
const { t: commonT } = useTranslation("common");
|
|
2537
|
+
const instantVerificationError = useContext(InstantVerificationErrorContext);
|
|
2538
|
+
const { isSettingEnabled } = useSettingsContext();
|
|
2539
|
+
const { isExperimentEnabled } = useExperimentsContext();
|
|
2540
|
+
const canChangeEntityType = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange);
|
|
2541
|
+
const intraRegionCrossBorderPayoutsAllowed = isSettingEnabled(
|
|
2542
|
+
SettingNames.AllowIntraRegionCrossBorderPayout
|
|
2543
|
+
);
|
|
2544
|
+
const enabledUnbiasedVerificationMethod = isExperimentEnabled(
|
|
2545
|
+
"BankVerificationMethodAutonomy_UnbiasedSelection"
|
|
2546
|
+
);
|
|
2547
|
+
const [hasSelectedMethod, setHasSelectedMethod] = useState(false);
|
|
2548
|
+
const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
|
|
2549
|
+
...props,
|
|
2550
|
+
schema: payoutVerificationMethodFields,
|
|
2551
|
+
defaultData: {
|
|
2552
|
+
verifiedAccountHolder: accountHolder,
|
|
2553
|
+
verifiedCurrencyCode: currencyByCountry[country]?.[0],
|
|
2554
|
+
bankCountry: country,
|
|
2555
|
+
...payoutVerificationMethodData
|
|
2556
|
+
},
|
|
2557
|
+
rules: validators || {
|
|
2558
|
+
payoutVerificationMethod: {
|
|
2559
|
+
modes: ["blur"],
|
|
2560
|
+
validate: (payoutVerificationMethod) => !enabledUnbiasedVerificationMethod || !!payoutVerificationMethod
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
fieldProblems: fieldValidationErrors
|
|
2564
|
+
});
|
|
2565
|
+
const formUtils = createFormUtils(props, commonT);
|
|
2566
|
+
const { sliceData, updateStateSlice } = useGlobalDataSlice("payoutVerificationMethod");
|
|
2567
|
+
const { clearStateSlice: clearPayoutAccountDetails } = useGlobalDataSlice("payoutAccountDetails");
|
|
2568
|
+
useEffect(
|
|
2569
|
+
() => updateStateSlice({ data: { ...sliceData, ...data }, errors, valid, fieldProblems }),
|
|
2570
|
+
[data, errors, fieldProblems, valid]
|
|
2571
|
+
);
|
|
2572
|
+
const methodsMetadata = makePayoutVerificationMethodsMetadata(provider?.name);
|
|
2573
|
+
const selectVerificationMethod = (method) => {
|
|
2574
|
+
setHasSelectedMethod(true);
|
|
2575
|
+
handleChangeFor("payoutVerificationMethod")(method);
|
|
2576
|
+
};
|
|
2577
|
+
useEffect(() => {
|
|
2578
|
+
if (bankInfoValidated || enabledUnbiasedVerificationMethod) return;
|
|
2579
|
+
if (!hasSelectedMethod && instantVerificationAvailable && data.payoutVerificationMethod !== "instantVerification") {
|
|
2580
|
+
handleChangeFor("payoutVerificationMethod")("instantVerification");
|
|
2581
|
+
}
|
|
2582
|
+
if (!instantVerificationAvailable && data.payoutVerificationMethod !== "manualVerification") {
|
|
2583
|
+
handleChangeFor("payoutVerificationMethod")("manualVerification");
|
|
2584
|
+
}
|
|
2585
|
+
}, [
|
|
2586
|
+
data.payoutVerificationMethod,
|
|
2587
|
+
handleChangeFor,
|
|
2588
|
+
instantVerificationAvailable,
|
|
2589
|
+
hasSelectedMethod,
|
|
2590
|
+
bankInfoValidated
|
|
2591
|
+
]);
|
|
2592
|
+
const { dataset: countries } = useDataset(datasetIdentifier.country);
|
|
2593
|
+
const bankCountryName = countries.find((country2) => country2.id === data.bankCountry)?.name ?? data.bankCountry;
|
|
2594
|
+
const allowedBankCountries = getAllowedBankCountries(country);
|
|
2595
|
+
const countryField = /* @__PURE__ */ jsx(
|
|
2596
|
+
CountryField,
|
|
2597
|
+
{
|
|
2598
|
+
data: { country: data.bankCountry },
|
|
2599
|
+
valid: { country: valid?.bankCountry },
|
|
2600
|
+
errors: { country: formUtils.getErrorMessage("bankCountry", errors, fieldProblems) },
|
|
2601
|
+
labels: { country: formUtils.getLabel("bankCountry", "bankAccountCountryRegion") },
|
|
2602
|
+
readonly: !intraRegionCrossBorderPayoutsAllowed || allowedBankCountries.length === 1 || bankInfoValidated,
|
|
2603
|
+
allowedCountries: allowedBankCountries,
|
|
2604
|
+
handleChangeFor: () => (e) => {
|
|
2605
|
+
clearPayoutAccountDetails();
|
|
2606
|
+
return handleChangeFor("bankCountry", "input")(e);
|
|
2607
|
+
},
|
|
2608
|
+
helperText: {
|
|
2609
|
+
country: intraRegionCrossBorderPayoutsAllowed ? void 0 : t(
|
|
2610
|
+
($) => $[legalEntityType === LegalEntityTypes.INDIVIDUAL ? "youCanOnlyUseABankAccountInTheCountryRegionWhereYouLive" : "youCanOnlyUseABankAccountInTheCountryRegionWhereYourCompanyIsRegistered"]
|
|
2611
|
+
)
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
);
|
|
2615
|
+
const description = canChangeEntityType ? /* @__PURE__ */ jsx(AccountHolderDescriptionFragment, { legalEntityResponse }) : /* @__PURE__ */ jsxs(Typography, { children: [
|
|
2616
|
+
t(($) => $["forYouToReceiveYourPayouts"]),
|
|
2617
|
+
" ",
|
|
2618
|
+
/* @__PURE__ */ jsx(
|
|
2619
|
+
Trans,
|
|
2620
|
+
{
|
|
2621
|
+
t,
|
|
2622
|
+
ns: "banking",
|
|
2623
|
+
i18nKey: ($) => $[getMustHaveSameAccountHolderNameTransKey(legalEntityType)],
|
|
2624
|
+
values: { name: accountHolder, companyName: accountHolder }
|
|
2625
|
+
}
|
|
2626
|
+
)
|
|
2627
|
+
] });
|
|
2628
|
+
return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-payout-verification-method", children: [
|
|
2629
|
+
/* @__PURE__ */ jsx(FormHeader, { heading, children: /* @__PURE__ */ jsx("div", { slot: "description", className: "adyen-kyc-u-margin-bottom-12", children: description }) }),
|
|
2630
|
+
instantVerificationError && /* @__PURE__ */ jsx(
|
|
2631
|
+
Alert,
|
|
2632
|
+
{
|
|
2633
|
+
variant: "error",
|
|
2634
|
+
className: "adyen-kyc-instant-verification-error",
|
|
2635
|
+
title: instantVerificationError.title,
|
|
2636
|
+
children: instantVerificationError.content && /* @__PURE__ */ jsx("p", { className: "adyen-kyc-u-margin-0", children: instantVerificationError.content })
|
|
2637
|
+
}
|
|
2638
|
+
),
|
|
2639
|
+
countryField,
|
|
2640
|
+
/* @__PURE__ */ jsx(
|
|
2641
|
+
Field,
|
|
2642
|
+
{
|
|
2643
|
+
el: "fieldset",
|
|
2644
|
+
name: "verificationMethods",
|
|
2645
|
+
label: formUtils.getLabel("payoutVerificationMethod", "verificationMethod"),
|
|
2646
|
+
errorMessage: formUtils.getErrorMessage("payoutVerificationMethod", errors, fieldProblems),
|
|
2647
|
+
helper: instantVerificationAvailable ? void 0 : t(($) => $["weDoNotYetSupportInstantVerificationForBankAccountsIn"], {
|
|
2648
|
+
countryName: bankCountryName
|
|
2649
|
+
}),
|
|
2650
|
+
children: (childProps) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
2651
|
+
RadioGroupCard,
|
|
2652
|
+
{
|
|
2653
|
+
...childProps,
|
|
2654
|
+
name: "verificationMethod",
|
|
2655
|
+
options: payoutVerificationMethods,
|
|
2656
|
+
onSelect: selectVerificationMethod,
|
|
2657
|
+
selected: data.payoutVerificationMethod,
|
|
2658
|
+
optionId: (method) => method,
|
|
2659
|
+
optionName: (method) => methodsMetadata[method].name,
|
|
2660
|
+
optionDescription: (method) => methodsMetadata[method].description,
|
|
2661
|
+
optionSubtitle: (method) => methodsMetadata[method].subtitle,
|
|
2662
|
+
className: "adyen-kyc-field-verification-methods",
|
|
2663
|
+
optionClassNames: () => ({
|
|
2664
|
+
label: "adyen-kyc-field-verification-methods__card"
|
|
2665
|
+
}),
|
|
2666
|
+
isOptionDisabled: (option) => bankInfoValidated || option === "instantVerification" && !instantVerificationAvailable,
|
|
2667
|
+
renderOptionIcon: (method) => /* @__PURE__ */ jsx("div", { className: "adyen-kyc-radio-group-card__illustration", children: methodsMetadata[method]?.svgImport && /* @__PURE__ */ jsx(Image, { lazyLoadedImage: methodsMetadata[method].svgImport }) }),
|
|
2668
|
+
renderOptionFooter: (method) => /* @__PURE__ */ jsx(
|
|
2669
|
+
PayoutVerificationMethodOptionFooter,
|
|
2670
|
+
{
|
|
2671
|
+
method,
|
|
2672
|
+
methodsMetadata
|
|
2673
|
+
}
|
|
2674
|
+
),
|
|
2675
|
+
floatingRadio: true
|
|
2676
|
+
}
|
|
2677
|
+
) })
|
|
2678
|
+
}
|
|
2679
|
+
),
|
|
2680
|
+
/* @__PURE__ */ jsx(
|
|
2681
|
+
ErrorPanel,
|
|
2682
|
+
{
|
|
2683
|
+
verificationErrors: formVerificationErrors,
|
|
2684
|
+
validationErrors: fieldValidationErrors,
|
|
2685
|
+
formUtils,
|
|
2686
|
+
id: "ariaErrorField"
|
|
2687
|
+
}
|
|
2688
|
+
),
|
|
2689
|
+
provider && bankVendorsLoadingStatus === "success" ? /* @__PURE__ */ jsx(
|
|
2690
|
+
ContextGuidance,
|
|
2691
|
+
{
|
|
2692
|
+
titleId: "howDoesVerificationWithOurPartnerWorks",
|
|
2693
|
+
contentId: "bankVerificationWithPartnerSteps",
|
|
2694
|
+
title: t(($) => $["howDoesVerificationWithOurPartnerWork"], {
|
|
2695
|
+
provider: provider.name
|
|
2696
|
+
}),
|
|
2697
|
+
content: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2698
|
+
/* @__PURE__ */ jsx(Typography, { children: t(($) => $["isOurTrustedPartnerHelpingSpeedUpSetup"], {
|
|
2699
|
+
provider: provider.name
|
|
2700
|
+
}) }),
|
|
2701
|
+
/* @__PURE__ */ jsxs("ul", { children: [
|
|
2702
|
+
/* @__PURE__ */ jsx("li", { children: t(($) => $["selectTheBankToReceivePayouts"]) }),
|
|
2703
|
+
/* @__PURE__ */ jsx("li", { children: t(($) => $["loginIntoYourBankingEnvironment"]) }),
|
|
2704
|
+
/* @__PURE__ */ jsx("li", { children: t(($) => $["yourBankWillConfirmYourAccountDetails"]) })
|
|
2705
|
+
] }),
|
|
2706
|
+
/* @__PURE__ */ jsx(Typography, { children: t(($) => $["adyenWillOnlyGetTemporaryAccess"]) }),
|
|
2707
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: /* @__PURE__ */ jsx(Link, { href: "https://www.adyen.com/policies-and-disclaimer/privacy-policy", external: true, children: commonT(($) => $["adyenPrivacyPolicy"]) }) })
|
|
2708
|
+
] })
|
|
2709
|
+
}
|
|
2710
|
+
) : void 0
|
|
2711
|
+
] });
|
|
2712
|
+
}
|
|
2713
|
+
const payoutSteps = {
|
|
2714
|
+
payoutVerificationMethod: {
|
|
2715
|
+
formId: "payoutVerificationMethod",
|
|
2716
|
+
formName: "verificationMethod",
|
|
2717
|
+
fields: payoutVerificationMethodFields
|
|
2718
|
+
},
|
|
2719
|
+
payoutAccountDetails: {
|
|
2720
|
+
formId: "payoutAccountDetails",
|
|
2721
|
+
formName: "bankAccount",
|
|
2722
|
+
fields: payoutAccountFields
|
|
2723
|
+
},
|
|
2724
|
+
payoutAccountDocuments: {
|
|
2725
|
+
formId: "payoutAccountDocuments",
|
|
2726
|
+
formName: "bankDocument",
|
|
2727
|
+
formHeader: "bankDocumentHeader",
|
|
2728
|
+
formDescription: "bankDocumentDescription",
|
|
2729
|
+
fields: bankDocumentFields
|
|
2730
|
+
},
|
|
2731
|
+
payoutAccountVerification: {
|
|
2732
|
+
formId: "payoutAccountVerification",
|
|
2733
|
+
formName: "instantVerification",
|
|
2734
|
+
fields: accountVerificationFields
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
const PayoutVerificationMethodFormID = payoutSteps.payoutVerificationMethod.formId;
|
|
2738
|
+
const PayoutAccountDocumentsFormID = payoutSteps.payoutAccountDocuments.formId;
|
|
2739
|
+
const PayoutAccountVerificationFormID = payoutSteps.payoutAccountVerification.formId;
|
|
2740
|
+
function PayoutDetails(props) {
|
|
2741
|
+
const { t } = useTranslation("banking");
|
|
2742
|
+
const { t: commonT } = useTranslation("common");
|
|
2743
|
+
const {
|
|
2744
|
+
activeForm,
|
|
2745
|
+
legalEntityResponse,
|
|
2746
|
+
associatedLegalArrangement,
|
|
2747
|
+
provider,
|
|
2748
|
+
bankVendorsLoadingStatus,
|
|
2749
|
+
instantVerificationAvailable,
|
|
2750
|
+
setHideSidebar,
|
|
2751
|
+
setSkipSubmit,
|
|
2752
|
+
createTrustedTransferInstrument: createTrustedTransferInstrument2,
|
|
2753
|
+
accountDetailsFromInput,
|
|
2754
|
+
country,
|
|
2755
|
+
accountHolder,
|
|
2756
|
+
data: propData,
|
|
2757
|
+
onBack,
|
|
2758
|
+
trustedTransferInstrumentId
|
|
2759
|
+
} = props;
|
|
2760
|
+
const [instantVerificationError, setInstantVerificationError] = useInstantVerificationErrorNotification(1e4);
|
|
2761
|
+
const verificationMethodFormProps = getFormProps(props, PayoutVerificationMethodFormID);
|
|
2762
|
+
const accountVerificationFormProps = getFormProps(props, PayoutAccountVerificationFormID);
|
|
2763
|
+
const payoutAccountFormProps = getFormProps(props, payoutSteps.payoutAccountDetails.formId);
|
|
2764
|
+
const bankDocumentFormProps = getFormProps(props, PayoutAccountDocumentsFormID);
|
|
2765
|
+
const taskHeading = t(($) => $["addABankAccountForPayouts"]);
|
|
2766
|
+
const isBankStatementDocumentOptional = createFormUtils(
|
|
2767
|
+
bankDocumentFormProps ?? {},
|
|
2768
|
+
commonT
|
|
2769
|
+
).isOptionalField("bankStatementDocument");
|
|
2770
|
+
const globalData = useGlobalData();
|
|
2771
|
+
const data = isEmpty(globalData) || propData?.payoutAccountDetails?.transferInstrumentId ? propData : globalData;
|
|
2772
|
+
const resetData = useResetGlobalData();
|
|
2773
|
+
const verifyInstantly = data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification";
|
|
2774
|
+
const bankCountry = data?.payoutVerificationMethod?.bankCountry ?? country;
|
|
2775
|
+
const bankDocumentDescription = t(
|
|
2776
|
+
($) => $[legalEntityResponse.type === "individual" ? "toHelpVerifyYourBankDetailsIndividual" : "toHelpVerifyYourBankDetailsBusiness"]
|
|
2777
|
+
);
|
|
2778
|
+
useEffect(() => resetData(), [resetData]);
|
|
2779
|
+
useEffect(() => {
|
|
2780
|
+
if (activeForm?.formId === summaryStep.formId && verifyInstantly && trustedTransferInstrumentId) {
|
|
2781
|
+
setSkipSubmit?.(true);
|
|
2782
|
+
}
|
|
2783
|
+
}, [activeForm, trustedTransferInstrumentId]);
|
|
2784
|
+
const [bankInfoValidated, setBankInfoValidated] = useState(false);
|
|
2785
|
+
const [arePayoutAccountDetailsInvalid, setArePayoutAccountDetailsInvalid] = useState(false);
|
|
2786
|
+
const [invalidFieldNames, setInvalidFieldNames] = useState("");
|
|
2787
|
+
const payload = useMemo(
|
|
2788
|
+
() => bankCountry && accountDetailsFromInput ? getAccountIdentificationFromPayoutAccountSchema(accountDetailsFromInput, bankCountry) : {},
|
|
2789
|
+
[accountDetailsFromInput, bankCountry]
|
|
2790
|
+
);
|
|
2791
|
+
const validateAccountDetails = useAsyncAccountDetailsValidationRules(
|
|
2792
|
+
payload,
|
|
2793
|
+
hasEmptyFields(payload),
|
|
2794
|
+
isAccountIdentifierObscured(payload)
|
|
2795
|
+
);
|
|
2796
|
+
const resetInvalidFieldState = () => {
|
|
2797
|
+
setInvalidFieldNames("");
|
|
2798
|
+
setArePayoutAccountDetailsInvalid(false);
|
|
2799
|
+
};
|
|
2800
|
+
useEffect(() => {
|
|
2801
|
+
if (validateAccountDetails?.invalidFields && validateAccountDetails.invalidFields.length > 0) {
|
|
2802
|
+
const fieldNames = validateAccountDetails.invalidFields.map((field) => extractFieldName(field.name)).map((key) => commonT(($) => $[key]));
|
|
2803
|
+
const invalidFieldsString = concatenateFieldNames(fieldNames);
|
|
2804
|
+
setInvalidFieldNames(invalidFieldsString);
|
|
2805
|
+
setArePayoutAccountDetailsInvalid(true);
|
|
2806
|
+
} else {
|
|
2807
|
+
resetInvalidFieldState();
|
|
2808
|
+
}
|
|
2809
|
+
}, [t, validateAccountDetails]);
|
|
2810
|
+
return /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-payout", children: [
|
|
2811
|
+
/* @__PURE__ */ jsx(
|
|
2812
|
+
"div",
|
|
2813
|
+
{
|
|
2814
|
+
className: activeForm?.formId !== PayoutVerificationMethodFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
2815
|
+
children: /* @__PURE__ */ jsx(InstantVerificationErrorContext.Provider, { value: instantVerificationError, children: /* @__PURE__ */ jsx(
|
|
2816
|
+
PayoutVerificationMethod,
|
|
2817
|
+
{
|
|
2818
|
+
...verificationMethodFormProps,
|
|
2819
|
+
id: PayoutVerificationMethodFormID,
|
|
2820
|
+
heading: taskHeading,
|
|
2821
|
+
country,
|
|
2822
|
+
accountHolder,
|
|
2823
|
+
legalEntityResponse,
|
|
2824
|
+
provider,
|
|
2825
|
+
bankVendorsLoadingStatus,
|
|
2826
|
+
bankInfoValidated,
|
|
2827
|
+
instantVerificationAvailable
|
|
2828
|
+
}
|
|
2829
|
+
) })
|
|
2830
|
+
}
|
|
2831
|
+
),
|
|
2832
|
+
verifyInstantly ? /* @__PURE__ */ jsx(
|
|
2833
|
+
"div",
|
|
2834
|
+
{
|
|
2835
|
+
className: activeForm?.formId !== PayoutAccountVerificationFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
2836
|
+
children: /* @__PURE__ */ jsx(
|
|
2837
|
+
BankVerification,
|
|
2838
|
+
{
|
|
2839
|
+
...accountVerificationFormProps,
|
|
2840
|
+
heading: t(($) => $["bankAccountVerification"]),
|
|
2841
|
+
id: PayoutAccountVerificationFormID,
|
|
2842
|
+
provider,
|
|
2843
|
+
country: bankCountry,
|
|
2844
|
+
onBack,
|
|
2845
|
+
hideSidebar: setHideSidebar,
|
|
2846
|
+
setBankVerificationError: setInstantVerificationError,
|
|
2847
|
+
bankInfoValidated,
|
|
2848
|
+
setBankInfoValidated,
|
|
2849
|
+
formIsActive: activeForm?.formId === PayoutAccountVerificationFormID,
|
|
2850
|
+
createTrustedTransferInstrument: createTrustedTransferInstrument2
|
|
2851
|
+
}
|
|
2852
|
+
)
|
|
2853
|
+
}
|
|
2854
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2855
|
+
/* @__PURE__ */ jsx(
|
|
2856
|
+
"div",
|
|
2857
|
+
{
|
|
2858
|
+
className: activeForm?.formId !== payoutSteps.payoutAccountDetails.formId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
2859
|
+
children: /* @__PURE__ */ jsx(
|
|
2860
|
+
PayoutAccount,
|
|
2861
|
+
{
|
|
2862
|
+
...payoutAccountFormProps,
|
|
2863
|
+
heading: taskHeading,
|
|
2864
|
+
id: payoutSteps.payoutAccountDetails.formId,
|
|
2865
|
+
country: bankCountry,
|
|
2866
|
+
legalEntityResponse,
|
|
2867
|
+
arePayoutAccountDetailsInvalid,
|
|
2868
|
+
invalidFieldNames
|
|
2869
|
+
}
|
|
2870
|
+
)
|
|
2871
|
+
}
|
|
2872
|
+
),
|
|
2873
|
+
/* @__PURE__ */ jsx(
|
|
2874
|
+
"div",
|
|
2875
|
+
{
|
|
2876
|
+
className: activeForm?.formId !== PayoutAccountDocumentsFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
2877
|
+
children: /* @__PURE__ */ jsx(
|
|
2878
|
+
MemoizedBankDocument,
|
|
2879
|
+
{
|
|
2880
|
+
...bankDocumentFormProps,
|
|
2881
|
+
heading: t(
|
|
2882
|
+
($) => $[isBankStatementDocumentOptional ? "uploadABankDocumentOptional" : "uploadABankDocument"]
|
|
2883
|
+
),
|
|
2884
|
+
description: bankDocumentDescription,
|
|
2885
|
+
id: PayoutAccountDocumentsFormID,
|
|
2886
|
+
legalEntity: legalEntityResponse,
|
|
2887
|
+
associatedLegalArrangement,
|
|
2888
|
+
country: bankCountry,
|
|
2889
|
+
formIsActive: activeForm?.formId === PayoutAccountDocumentsFormID
|
|
2890
|
+
}
|
|
2891
|
+
)
|
|
2892
|
+
}
|
|
2893
|
+
)
|
|
2894
|
+
] }),
|
|
2895
|
+
/* @__PURE__ */ jsx(Show, { when: showPayoutVerificationMethodError, children: /* @__PURE__ */ jsx(
|
|
2896
|
+
Confirm,
|
|
2897
|
+
{
|
|
2898
|
+
analyticsEventLabel: "payoutVerificationMethodError",
|
|
2899
|
+
title: t(($) => $["toContinuePleaseChooseAVerificationMethod"]),
|
|
2900
|
+
confirmText: commonT(($) => $["ok"]),
|
|
2901
|
+
onConfirm: () => {
|
|
2902
|
+
showPayoutVerificationMethodError.value = false;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
) })
|
|
2906
|
+
] });
|
|
2907
|
+
}
|
|
2908
|
+
const rules = ({
|
|
2909
|
+
data,
|
|
2910
|
+
requiredFields,
|
|
2911
|
+
isExperimentEnabled
|
|
2912
|
+
}) => createFormRules({
|
|
2913
|
+
whenUsingManualVerification: () => {
|
|
2914
|
+
if (!data.payoutVerificationMethod) return;
|
|
2915
|
+
if (data?.payoutVerificationMethod?.payoutVerificationMethod === "manualVerification") {
|
|
2916
|
+
return "REQUIRED";
|
|
2917
|
+
}
|
|
2918
|
+
},
|
|
2919
|
+
whenUsingInstantVerification: () => {
|
|
2920
|
+
if (!data.payoutVerificationMethod) {
|
|
2921
|
+
return "REQUIRED";
|
|
2922
|
+
}
|
|
2923
|
+
if (data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification") {
|
|
2924
|
+
return "REQUIRED";
|
|
2925
|
+
}
|
|
2926
|
+
},
|
|
2927
|
+
verifiedBankAccountNumber: () => {
|
|
2928
|
+
if (data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification") {
|
|
2929
|
+
return "REQUIRED";
|
|
2930
|
+
}
|
|
2931
|
+
},
|
|
2932
|
+
bankStatementRequirement: () => {
|
|
2933
|
+
if (data?.payoutVerificationMethod?.payoutVerificationMethod !== "instantVerification" && (isExperimentEnabled?.("EnableCheckOnCreateBankAccount") || isExperimentEnabled?.("BankVerificationFlowOptimization_CAASIntegration"))) {
|
|
2934
|
+
return "REQUIRED";
|
|
2935
|
+
}
|
|
2936
|
+
if (data?.payoutVerificationMethod?.payoutVerificationMethod === "manualVerification") {
|
|
2937
|
+
return requiredFields?.bankStatementRequirement;
|
|
2938
|
+
}
|
|
2939
|
+
},
|
|
2940
|
+
// "bankStatement description" field is always "optional" and it's coupled with bank statement document.
|
|
2941
|
+
bankStatementDescription: () => {
|
|
2942
|
+
if (data?.payoutVerificationMethod?.payoutVerificationMethod === "manualVerification" && !!requiredFields?.bankStatementRequirement) {
|
|
2943
|
+
return "OPTIONAL";
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
});
|
|
2947
|
+
const mapApiDocumentToPayoutDocuments = (entityId) => {
|
|
2948
|
+
const bankStatement = getDocument(entityId, "bankStatement");
|
|
2949
|
+
if (!bankStatement) throw new Error(`bankStatement with id ${entityId} not found`);
|
|
2950
|
+
return {
|
|
2951
|
+
bankStatementDocument: [mapExistingFile(getPageName(bankStatement))],
|
|
2952
|
+
description: bankStatement.description
|
|
2953
|
+
};
|
|
2954
|
+
};
|
|
2955
|
+
const mapPayoutDetailsToTransferInstrument = ({
|
|
2956
|
+
data,
|
|
2957
|
+
legalEntity
|
|
2958
|
+
}) => {
|
|
2959
|
+
if (!data.payoutAccountDetails || !data.payoutVerificationMethod) {
|
|
2960
|
+
throw new Error("Missing payout details data");
|
|
2961
|
+
}
|
|
2962
|
+
return {
|
|
2963
|
+
bankAccount: mapPayoutAccountSchemaToApiBankAccount(
|
|
2964
|
+
data.payoutAccountDetails,
|
|
2965
|
+
data.payoutVerificationMethod.bankCountry
|
|
2966
|
+
),
|
|
2967
|
+
legalEntityId: legalEntity.id,
|
|
2968
|
+
type: "bankAccount"
|
|
2969
|
+
};
|
|
2970
|
+
};
|
|
2971
|
+
const mapPayoutDocumentsToApiDocuments = async (data, entityId) => {
|
|
2972
|
+
const { bankStatementDocument, description } = data.payoutAccountDocuments ?? {};
|
|
2973
|
+
if (!bankStatementDocument) {
|
|
2974
|
+
throw new Error("Bank statement document missing");
|
|
2975
|
+
}
|
|
2976
|
+
const page1 = bankStatementDocument[0];
|
|
2977
|
+
if (!page1) {
|
|
2978
|
+
throw new Error("Document needs at least one page");
|
|
2979
|
+
}
|
|
2980
|
+
const existingDocument = getDocument(entityId, "bankStatement");
|
|
2981
|
+
return await createDocumentRequest({
|
|
2982
|
+
entityId,
|
|
2983
|
+
entityType: "bankAccount",
|
|
2984
|
+
documentType: "bankStatement",
|
|
2985
|
+
page1,
|
|
2986
|
+
description,
|
|
2987
|
+
existingDocument
|
|
2988
|
+
});
|
|
2989
|
+
};
|
|
2990
|
+
const CUSTOM_LABELS = {
|
|
2991
|
+
verifiedAccountHolder: "accountHolder",
|
|
2992
|
+
verifiedBankCountry: "bankCountry",
|
|
2993
|
+
verifiedBankName: "bankName",
|
|
2994
|
+
verifiedCurrencyCode: "currencyCode",
|
|
2995
|
+
verifiedBankAccountNumber: "bankAccountNumber"
|
|
2996
|
+
};
|
|
2997
|
+
const formatAccountVerificationSummary = (data) => {
|
|
2998
|
+
if (!data) return {};
|
|
2999
|
+
const summary = {};
|
|
3000
|
+
keysOf(CUSTOM_LABELS).forEach((key) => {
|
|
3001
|
+
if (!data[key]) return;
|
|
3002
|
+
summary[key] = summaryItem(CUSTOM_LABELS[key], data[key]);
|
|
3003
|
+
});
|
|
3004
|
+
return summary;
|
|
3005
|
+
};
|
|
3006
|
+
const obscuredPayoutFields = ["bankAccountNumber", "iban"];
|
|
3007
|
+
const payoutDetailsCountryConfig = {
|
|
3008
|
+
[CountryCodes.Canada]: {
|
|
3009
|
+
bankStatementDocument: {
|
|
3010
|
+
label: "listitemVoidedChequeBankLetterBankStatementOnline"
|
|
3011
|
+
}
|
|
3012
|
+
},
|
|
3013
|
+
[CountryCodes.UnitedKingdom]: {
|
|
3014
|
+
bankCity: {
|
|
3015
|
+
label: "bankCityTown"
|
|
3016
|
+
},
|
|
3017
|
+
bankStatementDocument: {
|
|
3018
|
+
label: "listitemVoidedChequeBankLetterBankStatementOnline"
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
};
|
|
3022
|
+
const parseConfiguration = ({
|
|
3023
|
+
requiredFields,
|
|
3024
|
+
country,
|
|
3025
|
+
bankVerificationAvailable
|
|
3026
|
+
}) => parsePayoutScenarios({
|
|
3027
|
+
requiredFields: requiredFields?.fields,
|
|
3028
|
+
country,
|
|
3029
|
+
bankVerificationAvailable
|
|
3030
|
+
});
|
|
3031
|
+
function parsePayoutScenarios({
|
|
3032
|
+
requiredFields,
|
|
3033
|
+
country,
|
|
3034
|
+
bankVerificationAvailable
|
|
3035
|
+
}) {
|
|
3036
|
+
if (!requiredFields) return {};
|
|
3037
|
+
let formConfig = {
|
|
3038
|
+
payoutVerificationMethod: {
|
|
3039
|
+
rule: "REQUIRED"
|
|
3040
|
+
},
|
|
3041
|
+
bankCountry: {
|
|
3042
|
+
rule: "REQUIRED"
|
|
3043
|
+
},
|
|
3044
|
+
bankStatementDocument: {
|
|
3045
|
+
rule: "bankStatementRequirement"
|
|
3046
|
+
},
|
|
3047
|
+
description: {
|
|
3048
|
+
rule: "bankStatementDescription"
|
|
3049
|
+
}
|
|
3050
|
+
};
|
|
3051
|
+
requiredFields.forEach((fieldName) => {
|
|
3052
|
+
formConfig[fieldName] = {
|
|
3053
|
+
rule: bankVerificationAvailable ? "whenUsingManualVerification" : "REQUIRED",
|
|
3054
|
+
obscured: obscuredPayoutFields.includes(fieldName)
|
|
3055
|
+
};
|
|
3056
|
+
});
|
|
3057
|
+
if (bankVerificationAvailable) {
|
|
3058
|
+
formConfig = {
|
|
3059
|
+
...formConfig,
|
|
3060
|
+
verifiedAccountHolder: {
|
|
3061
|
+
rule: "whenUsingInstantVerification"
|
|
3062
|
+
},
|
|
3063
|
+
verifiedBankCountry: {
|
|
3064
|
+
rule: "whenUsingInstantVerification"
|
|
3065
|
+
},
|
|
3066
|
+
verifiedBankName: {
|
|
3067
|
+
rule: "whenUsingInstantVerification"
|
|
3068
|
+
},
|
|
3069
|
+
verifiedCurrencyCode: {
|
|
3070
|
+
rule: "whenUsingInstantVerification"
|
|
3071
|
+
},
|
|
3072
|
+
verifiedBankAccountNumber: {
|
|
3073
|
+
rule: "whenUsingInstantVerification"
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
return augmentWithCountryConfigs(payoutDetailsCountryConfig[country], formConfig);
|
|
3078
|
+
}
|
|
3079
|
+
const getAppropriatePayoutDetailsSteps = (isEditing, instantVerificationAvailable, canChangeCountry) => {
|
|
3080
|
+
const dependentSteps = {
|
|
3081
|
+
payoutAccountDetails: payoutSteps.payoutAccountDetails,
|
|
3082
|
+
payoutAccountDocuments: payoutSteps.payoutAccountDocuments,
|
|
3083
|
+
payoutAccountVerification: payoutSteps.payoutAccountVerification
|
|
3084
|
+
};
|
|
3085
|
+
if (!isEditing && (instantVerificationAvailable || canChangeCountry)) {
|
|
3086
|
+
return {
|
|
3087
|
+
payoutVerificationMethod: payoutSteps.payoutVerificationMethod,
|
|
3088
|
+
...dependentSteps
|
|
3089
|
+
};
|
|
3090
|
+
}
|
|
3091
|
+
return dependentSteps;
|
|
3092
|
+
};
|
|
3093
|
+
const getInvalidFieldsErrorHeader = (invalidField) => {
|
|
3094
|
+
switch (invalidField) {
|
|
3095
|
+
case "LEGAL_BUSINESS_NAME":
|
|
3096
|
+
case "FIRST_NAME":
|
|
3097
|
+
case "LAST_NAME":
|
|
3098
|
+
return "caasBankAccountHolderDoesNotMatch";
|
|
3099
|
+
default:
|
|
3100
|
+
return "weCouldntCompleteTheAccountCheck";
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
const getInvalidFieldsErrorContent = (invalidField) => {
|
|
3104
|
+
switch (invalidField) {
|
|
3105
|
+
case "LEGAL_BUSINESS_NAME":
|
|
3106
|
+
return "caasBankAccountMustBeInYourNameYourBusinessLegalNameOrDoingBusinessAs";
|
|
3107
|
+
case "FIRST_NAME":
|
|
3108
|
+
case "LAST_NAME":
|
|
3109
|
+
return "caasBankAccountMustBeInYourName";
|
|
3110
|
+
default:
|
|
3111
|
+
return "weCouldntCompleteTheAccountCheck";
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
const defaultInvalidErrorMessage = {
|
|
3115
|
+
header: "weCouldntCompleteTheAccountCheck",
|
|
3116
|
+
content: "weCouldntCompleteTheAccountCheck"
|
|
3117
|
+
};
|
|
3118
|
+
const getInvalidFieldsErrorMessage = (errors) => {
|
|
3119
|
+
if (!errors || errors.length === 0) {
|
|
3120
|
+
return defaultInvalidErrorMessage;
|
|
3121
|
+
}
|
|
3122
|
+
const [firstError] = errors;
|
|
3123
|
+
const { invalidFields } = firstError;
|
|
3124
|
+
if (!invalidFields || invalidFields.length === 0) {
|
|
3125
|
+
return defaultInvalidErrorMessage;
|
|
3126
|
+
}
|
|
3127
|
+
const [firstInvalidField] = invalidFields;
|
|
3128
|
+
return {
|
|
3129
|
+
header: getInvalidFieldsErrorHeader(firstInvalidField),
|
|
3130
|
+
content: getInvalidFieldsErrorContent(firstInvalidField)
|
|
3131
|
+
};
|
|
3132
|
+
};
|
|
3133
|
+
const getPayoutVerificationMethod = (transferInstrument, instantVerificationEnabled, enabledUnbiasedVerificationMethod) => {
|
|
3134
|
+
if (transferInstrument) {
|
|
3135
|
+
return "manualVerification";
|
|
3136
|
+
} else {
|
|
3137
|
+
return enabledUnbiasedVerificationMethod || !instantVerificationEnabled ? void 0 : "instantVerification";
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3140
|
+
function PayoutDetailsDropin({
|
|
3141
|
+
legalEntityResponse,
|
|
3142
|
+
associatedLegalArrangement,
|
|
3143
|
+
problems: propProblems,
|
|
3144
|
+
onSubmit: externalOnSubmit,
|
|
3145
|
+
onChange,
|
|
3146
|
+
asModal = false,
|
|
3147
|
+
handleCloseClick,
|
|
3148
|
+
taskType: propTaskType,
|
|
3149
|
+
handleHomeClick,
|
|
3150
|
+
currentTransferInstrumentId,
|
|
3151
|
+
setCurrentTransferInstrumentId,
|
|
3152
|
+
navigateBackToTaskList,
|
|
3153
|
+
handleBackClick: externalBackClick,
|
|
3154
|
+
hideSidebar,
|
|
3155
|
+
openBankingPartnerConfigId
|
|
3156
|
+
}) {
|
|
3157
|
+
const { baseUrl, rootLegalEntityId } = useApiContext();
|
|
3158
|
+
const {
|
|
3159
|
+
data: transferInstrument,
|
|
3160
|
+
refetch: refetchTransferInstrument,
|
|
3161
|
+
isLoading: isTransferInstrumentLoading
|
|
3162
|
+
} = useTransferInstrument(currentTransferInstrumentId ?? skipToken);
|
|
3163
|
+
const { mutateAsync: handleUpdateTransferInstrument } = useUpdateTransferInstrument();
|
|
3164
|
+
const {
|
|
3165
|
+
mutateAsync: handleCreateTrustedTransferInstrument,
|
|
3166
|
+
status: createTrustedTransferInstrumentStatus
|
|
3167
|
+
} = useCreateTrustedTransferInstrument();
|
|
3168
|
+
const [previousTrustedInstrumentStatus, setPreviousTrustedInstrumentStatus] = useState(
|
|
3169
|
+
createTrustedTransferInstrumentStatus
|
|
3170
|
+
);
|
|
3171
|
+
const { t, i18n: i18next } = useTranslation("common");
|
|
3172
|
+
const { i18n } = useI18nContext();
|
|
3173
|
+
const userEvents = useAnalyticsContext();
|
|
3174
|
+
const { showToast, clearToasts } = useToastContext();
|
|
3175
|
+
const { isExperimentEnabled } = useExperimentsContext();
|
|
3176
|
+
const { isSettingEnabled } = useSettingsContext();
|
|
3177
|
+
const defaultPayoutCountry = getLegalEntityCountry(legalEntityResponse);
|
|
3178
|
+
const existingPayoutDetails = useMemo(
|
|
3179
|
+
() => transferInstrument ? mapTransferInstrumentToPayoutAccount(transferInstrument) : void 0,
|
|
3180
|
+
[transferInstrument]
|
|
3181
|
+
);
|
|
3182
|
+
const [documents, setDocuments] = useState();
|
|
3183
|
+
const [isCaasCalled, setIsCaasCalled] = useState(false);
|
|
3184
|
+
const enableCheckOnCreateBankAccount = isExperimentEnabled("EnableCheckOnCreateBankAccount") || isExperimentEnabled("BankVerificationFlowOptimization_CAASIntegration");
|
|
3185
|
+
const enabledUnbiasedVerificationMethod = isExperimentEnabled(
|
|
3186
|
+
"BankVerificationMethodAutonomy_UnbiasedSelection"
|
|
3187
|
+
);
|
|
3188
|
+
const accountHolder = getPayoutAccountHolderName(legalEntityResponse, t);
|
|
3189
|
+
const fallbackCurrency = currencyByCountry[defaultPayoutCountry]?.[0];
|
|
3190
|
+
const accountHolderName = accountHolder || getLegalEntityNameBasedOnType(legalEntityResponse);
|
|
3191
|
+
const instantVerificationEnabled = Boolean(
|
|
3192
|
+
!isTransferInstrumentLoading && !transferInstrument && isSettingEnabled("instantBankVerification")
|
|
3193
|
+
);
|
|
3194
|
+
const taskType = propTaskType ?? TaskTypes.PAYOUT;
|
|
3195
|
+
const [trustedTransferInstrumentId, setTrustedTransferInstrumentId] = useState();
|
|
3196
|
+
const prefilledData = {
|
|
3197
|
+
payoutAccountDetails: {
|
|
3198
|
+
accountHolder: accountHolderName,
|
|
3199
|
+
currency: fallbackCurrency,
|
|
3200
|
+
...existingPayoutDetails?.payoutAccountDetails
|
|
3201
|
+
},
|
|
3202
|
+
payoutVerificationMethod: {
|
|
3203
|
+
payoutVerificationMethod: getPayoutVerificationMethod(
|
|
3204
|
+
transferInstrument,
|
|
3205
|
+
instantVerificationEnabled,
|
|
3206
|
+
enabledUnbiasedVerificationMethod
|
|
3207
|
+
),
|
|
3208
|
+
bankCountry: defaultPayoutCountry,
|
|
3209
|
+
...existingPayoutDetails?.payoutVerificationMethod
|
|
3210
|
+
},
|
|
3211
|
+
payoutAccountVerification: {
|
|
3212
|
+
verifiedAccountHolder: accountHolderName,
|
|
3213
|
+
verifiedBankCountry: defaultPayoutCountry,
|
|
3214
|
+
...existingPayoutDetails?.payoutAccountVerification
|
|
3215
|
+
}
|
|
3216
|
+
};
|
|
3217
|
+
const documentUtils = documentApiUtils({
|
|
3218
|
+
baseUrl: baseUrl.value,
|
|
3219
|
+
rootLegalEntityId: rootLegalEntityId.value
|
|
3220
|
+
});
|
|
3221
|
+
const {
|
|
3222
|
+
state: { currentState }
|
|
3223
|
+
} = useStateContext();
|
|
3224
|
+
const formValidity = currentState.validityByForm;
|
|
3225
|
+
const bankAccountCountry = currentState?.data?.payoutVerificationMethod?.bankCountry ?? defaultPayoutCountry;
|
|
3226
|
+
const [hideFooterAndSidebar, setHideFooterAndSidebar] = useState(false);
|
|
3227
|
+
const [skipSubmit, setSkipSubmit] = useState(false);
|
|
3228
|
+
const [loadingStatus, setLoadingStatus] = useState("loading");
|
|
3229
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
3230
|
+
const [configurationLoadingStatus, setConfigurationLoadingStatus] = useState("loading");
|
|
3231
|
+
const [data, setData] = useState(prefilledData);
|
|
3232
|
+
const [problems, setProblems] = useState(
|
|
3233
|
+
propProblems || (transferInstrument?.id ? getCapabilityProblems(legalEntityResponse, bankAccountCountry)?.BankAccount?.[transferInstrument.id] : void 0)
|
|
3234
|
+
);
|
|
3235
|
+
const [accountDetailsFromInput, setAccountDetailsFromInput] = useState(
|
|
3236
|
+
prefilledData.payoutAccountDetails
|
|
3237
|
+
);
|
|
3238
|
+
const isMaskedBankAccountNumber = data.payoutAccountDetails?.bankAccountNumber?.includes("*") || data.payoutAccountDetails?.iban?.includes("*");
|
|
3239
|
+
const existingBankAccountFormat = transferInstrument ? existingPayoutDetails?.payoutAccountDetails?.iban ? "iban" : "local" : void 0;
|
|
3240
|
+
const checkAsAServiceAnalyticsProps = {
|
|
3241
|
+
"Experiment name": ExperimentNames.BankVerificationFlowOptimization_CAASIntegration,
|
|
3242
|
+
"Experiment value": enableCheckOnCreateBankAccount ? "TREATMENT" : "CONTROL"
|
|
3243
|
+
};
|
|
3244
|
+
useEffect(() => {
|
|
3245
|
+
userEvents.updateBaseTrackingPayload({ task: taskType });
|
|
3246
|
+
userEvents.addTaskEvent("Landed on page", {
|
|
3247
|
+
actionType: "start",
|
|
3248
|
+
...checkAsAServiceAnalyticsProps
|
|
3249
|
+
});
|
|
3250
|
+
}, []);
|
|
3251
|
+
useEffect(() => {
|
|
3252
|
+
setData({
|
|
3253
|
+
...currentState.data,
|
|
3254
|
+
payoutAccountDetails: {
|
|
3255
|
+
...currentState.data?.payoutAccountDetails,
|
|
3256
|
+
currency: currencyByCountry[bankAccountCountry]?.[0]
|
|
3257
|
+
}
|
|
3258
|
+
});
|
|
3259
|
+
onChange?.(currentState);
|
|
3260
|
+
}, [bankAccountCountry, currentState, onChange]);
|
|
3261
|
+
const {
|
|
3262
|
+
data: providers,
|
|
3263
|
+
refetch: refetchBankVerificationProviders,
|
|
3264
|
+
status: bankVendorsLoadingStatus
|
|
3265
|
+
} = useBankVerificationProviders(
|
|
3266
|
+
{
|
|
3267
|
+
country: bankAccountCountry,
|
|
3268
|
+
configId: openBankingPartnerConfigId,
|
|
3269
|
+
locale: i18next.language
|
|
3270
|
+
},
|
|
3271
|
+
{
|
|
3272
|
+
enabled: instantVerificationEnabled
|
|
3273
|
+
}
|
|
3274
|
+
);
|
|
3275
|
+
const instantVerificationAvailable = useMemo(
|
|
3276
|
+
() => Boolean(instantVerificationEnabled && providers?.[0]?.redirectUrl),
|
|
3277
|
+
[instantVerificationEnabled, providers]
|
|
3278
|
+
);
|
|
3279
|
+
const getPayoutAccountFormatData = useCallback(
|
|
3280
|
+
async () => getAccountFormatsForCountry(bankAccountCountry),
|
|
3281
|
+
[bankAccountCountry]
|
|
3282
|
+
);
|
|
3283
|
+
const { fieldConfigurations, requiredFields } = useScenarioConfiguration({
|
|
3284
|
+
parseConfiguration,
|
|
3285
|
+
legalEntityType: legalEntityResponse.type,
|
|
3286
|
+
getPayoutAccountFormatData,
|
|
3287
|
+
instantVerificationAvailable,
|
|
3288
|
+
setLoadingStatus: setConfigurationLoadingStatus,
|
|
3289
|
+
country: bankAccountCountry,
|
|
3290
|
+
existingBankAccountFormat
|
|
3291
|
+
});
|
|
3292
|
+
const fieldsFromCustomRules = useMemo(
|
|
3293
|
+
() => rules({
|
|
3294
|
+
data,
|
|
3295
|
+
requiredFields,
|
|
3296
|
+
isExperimentEnabled
|
|
3297
|
+
}),
|
|
3298
|
+
[bankAccountCountry, data, taskType, isExperimentEnabled]
|
|
3299
|
+
);
|
|
3300
|
+
const apiBankAccount = useMemo(() => {
|
|
3301
|
+
const payoutAccountDetails = data.payoutAccountDetails ?? { bankAccountNumber: "" };
|
|
3302
|
+
return mapPayoutAccountSchemaToApiBankAccount(payoutAccountDetails, bankAccountCountry);
|
|
3303
|
+
}, [data, bankAccountCountry]);
|
|
3304
|
+
const {
|
|
3305
|
+
data: checkAsAServiceData,
|
|
3306
|
+
refetch: refetchCheckAsAService,
|
|
3307
|
+
isLoading: isCheckAsAServiceLoading,
|
|
3308
|
+
isError: isCheckAsAServiceError
|
|
3309
|
+
} = useCheck(apiBankAccount.accountIdentification, {
|
|
3310
|
+
enabled: false
|
|
3311
|
+
});
|
|
3312
|
+
const checkAsAServiceResultStatus = checkAsAServiceData?.status;
|
|
3313
|
+
const checkAsAServiceResultErrors = checkAsAServiceData?.errors;
|
|
3314
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
3315
|
+
const payoutDetailsSteps = useMemo(() => {
|
|
3316
|
+
const appropriatePayoutDetailsSteps = getAppropriatePayoutDetailsSteps(
|
|
3317
|
+
Boolean(prefilledData?.payoutAccountDetails?.transferInstrumentId),
|
|
3318
|
+
instantVerificationAvailable,
|
|
3319
|
+
isSettingEnabled(SettingNames.AllowIntraRegionCrossBorderPayout)
|
|
3320
|
+
);
|
|
3321
|
+
const { payoutAccountDocuments: _, ...restOfAppropriatePayoutDetailsSteps } = appropriatePayoutDetailsSteps;
|
|
3322
|
+
if (enableCheckOnCreateBankAccount && !isCheckAsAServiceError && (checkAsAServiceResultStatus === "VALID" || checkAsAServiceResultStatus === void 0) && !isMaskedBankAccountNumber) {
|
|
3323
|
+
return restOfAppropriatePayoutDetailsSteps;
|
|
3324
|
+
}
|
|
3325
|
+
return appropriatePayoutDetailsSteps;
|
|
3326
|
+
}, [
|
|
3327
|
+
providers,
|
|
3328
|
+
enableCheckOnCreateBankAccount,
|
|
3329
|
+
checkAsAServiceResultStatus,
|
|
3330
|
+
isCheckAsAServiceError,
|
|
3331
|
+
isMaskedBankAccountNumber
|
|
3332
|
+
]);
|
|
3333
|
+
const derivedProps = useMemo(() => {
|
|
3334
|
+
return getPropsFromConfigurations({
|
|
3335
|
+
scenarioConfiguration: fieldConfigurations,
|
|
3336
|
+
forms: payoutDetailsSteps,
|
|
3337
|
+
remediationActions: problems?.remediationActions ? Object.values(problems?.remediationActions) : [],
|
|
3338
|
+
dataMissingErrors: problems?.missingData ?? [],
|
|
3339
|
+
fieldsWithExistingData: [],
|
|
3340
|
+
customRules: fieldsFromCustomRules,
|
|
3341
|
+
legalEntityType: legalEntityResponse.type
|
|
3342
|
+
});
|
|
3343
|
+
}, [
|
|
3344
|
+
fieldConfigurations,
|
|
3345
|
+
payoutDetailsSteps,
|
|
3346
|
+
problems?.remediationActions,
|
|
3347
|
+
problems?.missingData,
|
|
3348
|
+
fieldsFromCustomRules,
|
|
3349
|
+
legalEntityResponse.type
|
|
3350
|
+
]);
|
|
3351
|
+
useUnifyLoadingStatus(
|
|
3352
|
+
setLoadingStatus,
|
|
3353
|
+
configurationLoadingStatus,
|
|
3354
|
+
// bank vendor loading status only matters when we fetch bank vendors
|
|
3355
|
+
instantVerificationEnabled ? bankVendorsLoadingStatus : "success",
|
|
3356
|
+
isSubmitting ? "loading" : "success"
|
|
3357
|
+
);
|
|
3358
|
+
const forms = useMemo(() => {
|
|
3359
|
+
const requiredForms = getRequiredForms(
|
|
3360
|
+
payoutDetailsSteps,
|
|
3361
|
+
derivedProps?.requiredFields,
|
|
3362
|
+
derivedProps?.optionalFields
|
|
3363
|
+
);
|
|
3364
|
+
return addValidityToForms(requiredForms, formValidity, problems);
|
|
3365
|
+
}, [derivedProps, formValidity, problems, payoutDetailsSteps]);
|
|
3366
|
+
useEffect(() => {
|
|
3367
|
+
if (!transferInstrument?.documentDetails?.length) return;
|
|
3368
|
+
if (transferInstrument.id) {
|
|
3369
|
+
documentUtils.fetchDocuments(transferInstrument.documentDetails, transferInstrument.id).then(() => {
|
|
3370
|
+
setDocuments(mapApiDocumentToPayoutDocuments(transferInstrument.id));
|
|
3371
|
+
}).catch(() => {
|
|
3372
|
+
showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" });
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3375
|
+
}, [transferInstrument?.documentDetails]);
|
|
3376
|
+
const submitDocuments = async ({
|
|
3377
|
+
forms: forms2,
|
|
3378
|
+
transferInstrument: transferInstrument2,
|
|
3379
|
+
dataSubmitted
|
|
3380
|
+
}) => {
|
|
3381
|
+
const isRequiredDocuments = isDocumentsRequired(forms2);
|
|
3382
|
+
if (isRequiredDocuments) {
|
|
3383
|
+
const documentToUpload = await mapPayoutDocumentsToApiDocuments(
|
|
3384
|
+
dataSubmitted,
|
|
3385
|
+
transferInstrument2.id
|
|
3386
|
+
);
|
|
3387
|
+
if (documentToUpload) {
|
|
3388
|
+
try {
|
|
3389
|
+
const documents2 = await documentUtils.uploadDocuments(
|
|
3390
|
+
[documentToUpload],
|
|
3391
|
+
transferInstrument2.id
|
|
3392
|
+
);
|
|
3393
|
+
documents2.forEach((document2) => {
|
|
3394
|
+
userEvents.addTaskEvent("Success", {
|
|
3395
|
+
actionType: "upload",
|
|
3396
|
+
documentType: dataSubmitted.payoutAccountDocuments?.documentType ?? document2.type,
|
|
3397
|
+
// tracks BankDocumentTypes
|
|
3398
|
+
fileExtention: document2.attachments?.map((item) => getFileExtention(item.pageName ?? "")).filter((item) => item !== void 0) ?? null
|
|
3399
|
+
});
|
|
3400
|
+
});
|
|
3401
|
+
} catch {
|
|
3402
|
+
setProblems({
|
|
3403
|
+
...problems,
|
|
3404
|
+
validationErrors: {
|
|
3405
|
+
payoutAccountDocuments: { bankStatementDocument: true }
|
|
3406
|
+
}
|
|
3407
|
+
});
|
|
3408
|
+
throw new Error(i18n.get("remediationMessage_1_704"));
|
|
3409
|
+
} finally {
|
|
3410
|
+
await refetchTransferInstrument?.();
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
};
|
|
3415
|
+
useEffect(() => {
|
|
3416
|
+
const payoutAccountData = cloneObject(data)?.payoutAccountDetails;
|
|
3417
|
+
if (payoutAccountData) setAccountDetailsFromInput(payoutAccountData);
|
|
3418
|
+
}, [data]);
|
|
3419
|
+
const onSubmit = async () => {
|
|
3420
|
+
setIsSubmitting(true);
|
|
3421
|
+
const dataSubmitted = cloneObject(data);
|
|
3422
|
+
const { payoutAccountDetails, payoutVerificationMethod } = dataSubmitted;
|
|
3423
|
+
const baseTracking = {
|
|
3424
|
+
actionType: "submit",
|
|
3425
|
+
documentType: "bankStatement",
|
|
3426
|
+
bankCountry: payoutVerificationMethod?.bankCountry ?? defaultPayoutCountry,
|
|
3427
|
+
bankCurrency: payoutAccountDetails?.currency ?? null
|
|
3428
|
+
};
|
|
3429
|
+
let transferInstrumentFromInput = mapPayoutDetailsToTransferInstrument({
|
|
3430
|
+
data: dataSubmitted,
|
|
3431
|
+
legalEntity: legalEntityResponse
|
|
3432
|
+
});
|
|
3433
|
+
transferInstrumentFromInput = omitObscuredFieldsIfUnchanged(
|
|
3434
|
+
["bankAccount.accountIdentification.accountNumber", "bankAccount.accountIdentification.iban"],
|
|
3435
|
+
transferInstrumentFromInput,
|
|
3436
|
+
transferInstrument
|
|
3437
|
+
);
|
|
3438
|
+
try {
|
|
3439
|
+
if (!transferInstrumentFromInput) return;
|
|
3440
|
+
const response = await (transferInstrument ? handleUpdateTransferInstrument({
|
|
3441
|
+
transferInstrument: transferInstrumentFromInput,
|
|
3442
|
+
transferInstrumentId: transferInstrument.id
|
|
3443
|
+
}) : createTransferInstrument(
|
|
3444
|
+
rootLegalEntityId.value,
|
|
3445
|
+
baseUrl.value,
|
|
3446
|
+
transferInstrumentFromInput
|
|
3447
|
+
));
|
|
3448
|
+
setCurrentTransferInstrumentId?.(response?.id);
|
|
3449
|
+
userEvents.addTaskEvent("Success", {
|
|
3450
|
+
...baseTracking,
|
|
3451
|
+
...checkAsAServiceAnalyticsProps
|
|
3452
|
+
});
|
|
3453
|
+
try {
|
|
3454
|
+
await submitDocuments({ forms, transferInstrument: response, dataSubmitted });
|
|
3455
|
+
clearToasts();
|
|
3456
|
+
externalOnSubmit?.({ ...dataSubmitted, id: response?.id });
|
|
3457
|
+
} catch (e) {
|
|
3458
|
+
showToast({ label: e.message, variant: "error" });
|
|
3459
|
+
} finally {
|
|
3460
|
+
setIsSubmitting(false);
|
|
3461
|
+
}
|
|
3462
|
+
} catch (e) {
|
|
3463
|
+
if (isValidationError(e)) {
|
|
3464
|
+
const validationErrors = processValidationErrors(e, taskType);
|
|
3465
|
+
setProblems({ ...problems, validationErrors });
|
|
3466
|
+
} else if (isIdDocumentUploadError(e)) {
|
|
3467
|
+
showToast({ label: i18n.get("idDocumentAlreadyUploaded"), variant: "error" });
|
|
3468
|
+
} else if (isBankStatementUploadError(e)) {
|
|
3469
|
+
showToast({ label: i18n.get("bankStatementAlreadyUploaded"), variant: "error" });
|
|
3470
|
+
} else if (isMaintenanceModeError(e)) {
|
|
3471
|
+
showToast({
|
|
3472
|
+
label: i18n.get("maintenanceModeMessage"),
|
|
3473
|
+
variant: "error",
|
|
3474
|
+
duration: "indefinite"
|
|
3475
|
+
});
|
|
3476
|
+
} else {
|
|
3477
|
+
const errorTranslatable = mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable(e);
|
|
3478
|
+
showToast({ label: i18n.get(errorTranslatable), variant: "error" });
|
|
3479
|
+
}
|
|
3480
|
+
setIsSubmitting(false);
|
|
3481
|
+
userEvents.addTaskEvent("Encountered error", {
|
|
3482
|
+
...baseTracking,
|
|
3483
|
+
returnType: e?.errorCode || "backend",
|
|
3484
|
+
returnValue: e?.title || e?.message,
|
|
3485
|
+
...checkAsAServiceAnalyticsProps
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
};
|
|
3489
|
+
const isDocumentsRequired = (forms2) => forms2.some((form) => form.formId === payoutSteps.payoutAccountDocuments.formId);
|
|
3490
|
+
const formatFileSummaryData = (bankDocuments) => {
|
|
3491
|
+
const bankStatementDocument = bankDocuments?.bankStatementDocument?.[0];
|
|
3492
|
+
return {
|
|
3493
|
+
...bankStatementDocument && {
|
|
3494
|
+
fileName: bankStatementDocument.name
|
|
3495
|
+
}
|
|
3496
|
+
};
|
|
3497
|
+
};
|
|
3498
|
+
const canSubmit = () => {
|
|
3499
|
+
if (data.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification") {
|
|
3500
|
+
return false;
|
|
3501
|
+
}
|
|
3502
|
+
const bankDetails = data.payoutAccountDetails;
|
|
3503
|
+
return !isEmpty(bankDetails) && Object.values(bankDetails).every(Boolean);
|
|
3504
|
+
};
|
|
3505
|
+
const datasetUtils = datasetUtilities(i18next.language);
|
|
3506
|
+
const formatDataForSummary = () => {
|
|
3507
|
+
const summaryData = cloneObject(data);
|
|
3508
|
+
summaryData.payoutAccountDetails.accountHolder = accountHolderName;
|
|
3509
|
+
if (summaryData.payoutVerificationMethod?.bankCountry && summaryData.payoutAccountDetails) {
|
|
3510
|
+
summaryData.payoutAccountDetails.bankCountry = datasetUtils.getCountryName(
|
|
3511
|
+
summaryData.payoutVerificationMethod.bankCountry
|
|
3512
|
+
);
|
|
3513
|
+
}
|
|
3514
|
+
if (summaryData.payoutAccountDocuments) {
|
|
3515
|
+
summaryData.payoutAccountDocuments.bankStatementDocument = formatFileSummaryData(
|
|
3516
|
+
data?.payoutAccountDocuments
|
|
3517
|
+
);
|
|
3518
|
+
}
|
|
3519
|
+
summaryData.payoutAccountVerification = formatAccountVerificationSummary(
|
|
3520
|
+
data.payoutAccountVerification
|
|
3521
|
+
);
|
|
3522
|
+
return summaryData;
|
|
3523
|
+
};
|
|
3524
|
+
const createTrustedTransferInstrumentHandler = async (code, state) => {
|
|
3525
|
+
try {
|
|
3526
|
+
const trustedTransferInstrument = await handleCreateTrustedTransferInstrument({
|
|
3527
|
+
code,
|
|
3528
|
+
state
|
|
3529
|
+
});
|
|
3530
|
+
if (trustedTransferInstrument) {
|
|
3531
|
+
setTrustedTransferInstrumentId(trustedTransferInstrument.verificationReference);
|
|
3532
|
+
return trustedTransferInstrument;
|
|
3533
|
+
}
|
|
3534
|
+
} catch (e) {
|
|
3535
|
+
refetchBankVerificationProviders();
|
|
3536
|
+
const errorTranslatable = mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable(e);
|
|
3537
|
+
if (errorTranslatable === "transferInstrumentLimitHasAlreadyBeenMet") {
|
|
3538
|
+
showToast({ label: i18n.get(errorTranslatable), variant: "error" });
|
|
3539
|
+
}
|
|
3540
|
+
throw e;
|
|
3541
|
+
}
|
|
3542
|
+
};
|
|
3543
|
+
const {
|
|
3544
|
+
handleNextClick,
|
|
3545
|
+
handleBackClick,
|
|
3546
|
+
activeForm,
|
|
3547
|
+
setShouldValidate,
|
|
3548
|
+
gotoFormByFormIndex,
|
|
3549
|
+
steps
|
|
3550
|
+
} = useFormComposer({
|
|
3551
|
+
problems,
|
|
3552
|
+
forms,
|
|
3553
|
+
externalBackClick,
|
|
3554
|
+
navigationTrackingParams: {
|
|
3555
|
+
...checkAsAServiceAnalyticsProps
|
|
3556
|
+
},
|
|
3557
|
+
onSubmit: skipSubmit ? () => {
|
|
3558
|
+
if (trustedTransferInstrumentId) {
|
|
3559
|
+
externalOnSubmit?.({ ...data, id: trustedTransferInstrumentId });
|
|
3560
|
+
}
|
|
3561
|
+
userEvents.addTaskEvent("Success", {
|
|
3562
|
+
actionType: "submit"
|
|
3563
|
+
});
|
|
3564
|
+
navigateBackToTaskList?.();
|
|
3565
|
+
} : onSubmit
|
|
3566
|
+
});
|
|
3567
|
+
useEffect(() => {
|
|
3568
|
+
if (isCaasCalled && forms) {
|
|
3569
|
+
if (checkAsAServiceResultStatus !== "VALID") {
|
|
3570
|
+
const formIndex = forms.findIndex((f) => f.formId === "payoutAccountDocuments");
|
|
3571
|
+
if (formIndex > -1) {
|
|
3572
|
+
gotoFormByFormIndex(formIndex);
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
if (checkAsAServiceResultStatus === "VALID") {
|
|
3576
|
+
handleNextClick();
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
setIsCaasCalled(false);
|
|
3580
|
+
}, [forms, checkAsAServiceResultStatus, isCaasCalled]);
|
|
3581
|
+
const handleFormNextClick = async () => {
|
|
3582
|
+
if (!data?.payoutVerificationMethod?.payoutVerificationMethod) {
|
|
3583
|
+
showPayoutVerificationMethodError.value = true;
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
if (enableCheckOnCreateBankAccount && activeForm.formId === "payoutAccountDetails" && activeForm.isValid && data.payoutAccountDetails && !isMaskedBankAccountNumber) {
|
|
3587
|
+
try {
|
|
3588
|
+
const { data: response } = await refetchCheckAsAService();
|
|
3589
|
+
setIsCaasCalled(true);
|
|
3590
|
+
if (response?.status === "INCOMPLETE_INPUT") {
|
|
3591
|
+
setIsModalOpen(true);
|
|
3592
|
+
} else {
|
|
3593
|
+
handleNextClick();
|
|
3594
|
+
}
|
|
3595
|
+
} catch {
|
|
3596
|
+
handleNextClick();
|
|
3597
|
+
}
|
|
3598
|
+
} else {
|
|
3599
|
+
handleNextClick();
|
|
3600
|
+
}
|
|
3601
|
+
};
|
|
3602
|
+
if (previousTrustedInstrumentStatus !== createTrustedTransferInstrumentStatus) {
|
|
3603
|
+
if (activeForm.formId === "payoutAccountVerification" && activeForm.isValid && createTrustedTransferInstrumentStatus === "success" && data.payoutAccountVerification?.verifiedBankAccountNumber) {
|
|
3604
|
+
handleNextClick();
|
|
3605
|
+
setPreviousTrustedInstrumentStatus(createTrustedTransferInstrumentStatus);
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
const omittedForms = data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification" ? [] : [payoutSteps.payoutVerificationMethod.formId];
|
|
3609
|
+
const { header: invalidFieldHeader, content: invalidFieldContent } = getInvalidFieldsErrorMessage(
|
|
3610
|
+
checkAsAServiceResultErrors ?? []
|
|
3611
|
+
);
|
|
3612
|
+
return /* @__PURE__ */ jsxs(
|
|
3613
|
+
LoaderWrapper,
|
|
3614
|
+
{
|
|
3615
|
+
showSpinner: true,
|
|
3616
|
+
status: isCheckAsAServiceLoading || isModalOpen ? "loading" : "success",
|
|
3617
|
+
formOpacityWhenLoading: 0.3,
|
|
3618
|
+
children: [
|
|
3619
|
+
isModalOpen && /* @__PURE__ */ jsx(
|
|
3620
|
+
Confirm,
|
|
3621
|
+
{
|
|
3622
|
+
title: i18n.get(invalidFieldHeader),
|
|
3623
|
+
description: i18n.get(invalidFieldContent),
|
|
3624
|
+
cancelText: i18n.get("editDetails"),
|
|
3625
|
+
confirmText: i18n.get("continueAnyway"),
|
|
3626
|
+
onConfirm: () => {
|
|
3627
|
+
handleNextClick();
|
|
3628
|
+
setIsModalOpen(false);
|
|
3629
|
+
},
|
|
3630
|
+
onCancel: () => {
|
|
3631
|
+
gotoFormByFormIndex(0);
|
|
3632
|
+
setIsModalOpen(false);
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
),
|
|
3636
|
+
/* @__PURE__ */ jsx(
|
|
3637
|
+
FormWrapper,
|
|
3638
|
+
{
|
|
3639
|
+
taskName: taskType === TaskTypes.PAYIN ? "payinDetails" : "payoutDetails",
|
|
3640
|
+
activeForm,
|
|
3641
|
+
summary: {
|
|
3642
|
+
data: formatDataForSummary(),
|
|
3643
|
+
omitted: {
|
|
3644
|
+
keys: ["transferInstrumentId", "payoutVerificationMethod"],
|
|
3645
|
+
forms: omittedForms,
|
|
3646
|
+
summaryEditButton: ["payoutVerificationMethod"]
|
|
3647
|
+
}
|
|
3648
|
+
},
|
|
3649
|
+
handleBackClick,
|
|
3650
|
+
handleNextClick: handleFormNextClick,
|
|
3651
|
+
handleHomeClick,
|
|
3652
|
+
handleCloseClick,
|
|
3653
|
+
hideSidebar: hideSidebar || hideFooterAndSidebar,
|
|
3654
|
+
hideFooter: hideFooterAndSidebar,
|
|
3655
|
+
loadingStatus: isTransferInstrumentLoading ? "loading" : loadingStatus,
|
|
3656
|
+
asModal,
|
|
3657
|
+
forms,
|
|
3658
|
+
onSubmit,
|
|
3659
|
+
gotoFormByFormIndex,
|
|
3660
|
+
validateForm: () => setShouldValidate(true),
|
|
3661
|
+
canSubmit: canSubmit(),
|
|
3662
|
+
problems,
|
|
3663
|
+
steps,
|
|
3664
|
+
children: (!isTransferInstrumentLoading || isSubmitting) && /* @__PURE__ */ jsx(
|
|
3665
|
+
PayoutDetails,
|
|
3666
|
+
{
|
|
3667
|
+
...derivedProps,
|
|
3668
|
+
data: { ...prefilledData, payoutAccountDocuments: documents },
|
|
3669
|
+
country: defaultPayoutCountry,
|
|
3670
|
+
activeForm,
|
|
3671
|
+
onBack: handleBackClick,
|
|
3672
|
+
accountHolder: accountHolder ?? getLegalEntityNameBasedOnType(legalEntityResponse),
|
|
3673
|
+
setHideSidebar: setHideFooterAndSidebar,
|
|
3674
|
+
setSkipSubmit,
|
|
3675
|
+
legalEntityResponse,
|
|
3676
|
+
associatedLegalArrangement,
|
|
3677
|
+
provider: providers?.[0],
|
|
3678
|
+
bankVendorsLoadingStatus,
|
|
3679
|
+
instantVerificationAvailable,
|
|
3680
|
+
createTrustedTransferInstrument: createTrustedTransferInstrumentHandler,
|
|
3681
|
+
accountDetailsFromInput,
|
|
3682
|
+
trustedTransferInstrumentId
|
|
3683
|
+
}
|
|
3684
|
+
)
|
|
3685
|
+
}
|
|
3686
|
+
)
|
|
3687
|
+
]
|
|
3688
|
+
}
|
|
3689
|
+
);
|
|
3690
|
+
}
|
|
3691
|
+
export {
|
|
3692
|
+
PayoutDetailsDropin as P,
|
|
3693
|
+
PayoutDetailsPage$1 as a
|
|
3694
|
+
};
|