@adyen/kyc-components
Version:
This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.
98 lines (97 loc) • 7.09 kB
JavaScript
try {
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "6c8be08a-68d9-452b-b1f5-7326e84f29f8", e._sentryDebugIdIdentifier = "sentry-dbid-6c8be08a-68d9-452b-b1f5-7326e84f29f8");
} catch (e) {}
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as CountryCodes } from "./country-code-CX5KqMBr.js";
//#region src/stores/globalStore/taskTypes.ts
var TaskTypes = {
BUSINESS_TYPE_SELECTION: "BUSINESS_TYPE_SELECTION",
ACQUIRING_BUSINESS_LINE: "ACQUIRING_BUSINESS_LINE",
INTRODUCTION: "INTRODUCTION",
TASKS_OVERVIEW: "TASKS_OVERVIEW",
REVIEW: "REVIEW",
INDIVIDUAL: "INDIVIDUAL",
BUSINESS_DETAILS: "BUSINESS_DETAILS",
CUSTOMER_SUPPORT: "CUSTOMER_SUPPORT",
PAYOUT: "PAYOUT",
PAYIN: "PAYIN",
SERVICE_AGREEMENT: "SERVICE_AGREEMENT",
PCI_DSS: "PCI_DSS",
DECISION_MAKER: "DECISION_MAKER",
DECISION_MAKER_OVERVIEW: "DECISION_MAKER_OVERVIEW",
TRUST: "TRUST",
TRUST_MEMBER: "TRUST_MEMBER",
TRUST_MEMBER_OVERVIEW: "TRUST_MEMBER_OVERVIEW",
TRUST_MEMBER_INDIVIDUAL: "TRUST_MEMBER_INDIVIDUAL",
TRUST_MEMBER_COMPANY: "TRUST_MEMBER_COMPANY",
TRUST_MEMBER_ROLE_AND_TYPE: "TRUST_MEMBER_ROLE_AND_TYPE",
TRUST_MEMBER_COMPANY_OWNER: "TRUST_MEMBER_COMPANY_OWNER",
UNINCORPORATED_PARTNERSHIP: "UNINCORPORATED_PARTNERSHIP",
UNINCORPORATED_PARTNERSHIP_MEMBER_OVERVIEW: "UNINCORPORATED_PARTNERSHIP_MEMBER_OVERVIEW",
UNINCORPORATED_PARTNERSHIP_MEMBER_INDIVIDUAL: "UNINCORPORATED_PARTNERSHIP_MEMBER_INDIVIDUAL",
UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY: "UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY",
UNINCORPORATED_PARTNERSHIP_MEMBER_ROLE_AND_TYPE: "UNINCORPORATED_PARTNERSHIP_MEMBER_ROLE_AND_TYPE",
UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER: "UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER",
SOLE_PROPRIETOR_COMPANY: "SOLE_PROPRIETOR_COMPANY",
CAPABILITY_REJECTED: "CAPABILITY_REJECTED",
SINGPASS_SELECTION: "SINGPASS_SELECTION",
LEGAL_REPRESENTATIVE_DETAILS: "LEGAL_REPRESENTATIVE_DETAILS",
SOURCE_OF_FUNDS: "SOURCE_OF_FUNDS",
BUSINESS_FINANCING: "BUSINESS_FINANCING",
TAX_REPORTING: "TAX_REPORTING",
INVITED_INDIVIDUAL: "INVITED_INDIVIDUAL"
};
//#endregion
//#region src/utils/entityAssociationUtil.ts
/**
* Returns the entity associations from the root LE which have a {@link LegalEntityAssociation.associatorId} matching the given `legalEntityId`.
* Can be used to find members of a trust, or decision makers of a trustee company.
*
* @param rootLE the root legal entity which holds all the entity associations
* @param legalEntityId the ID of the legal entity whose associations we wish to find
*/
var getDirectEntityAssociations = (rootLE, legalEntityId) => rootLE?.entityAssociations?.filter((association) => association.associatorId === legalEntityId) ?? [];
var getOwnEntityAssociations = (legalEntity) => getDirectEntityAssociations(legalEntity, legalEntity.id);
var getOwnSoleProprietorshipIdArray = (legalEntity) => {
return getOwnEntityAssociations(legalEntity).filter((ea) => ea.entityType === LegalEntityTypes.SOLE_PROPRIETORSHIP).map((ea) => ea.legalEntityId).filter((id) => id !== void 0);
};
var hasSolePropInLegalEntity = (rootLegalEntity) => rootLegalEntity.entityAssociations?.some((ea) => ea.entityType === LegalEntityTypes.SOLE_PROPRIETORSHIP && ea.associatorId === rootLegalEntity.id) ?? false;
var getOwnSolePropProblems = (rootLegalEntity, capabilityProblems) => {
const solePropLegalEntityId = getOwnSoleProprietorshipIdArray(rootLegalEntity)[0];
return capabilityProblems?.LegalEntity?.[solePropLegalEntityId];
};
var hasOwnEntityAssociationOfType = (type, entityAssociations, legalEntityId) => entityAssociations?.some((ea) => ea.type === type && ea.associatorId === legalEntityId) ?? false;
var removeEntityAssociationByType = (type, entityAssociations, legalEntityId) => entityAssociations.filter((ea) => ea.type !== type || ea.associatorId !== legalEntityId);
var isRootLegalEntity = (legalEntity, taskType) => legalEntity.type === LegalEntityTypes.INDIVIDUAL && taskType === TaskTypes.INDIVIDUAL || legalEntity.type === LegalEntityTypes.ORGANIZATION && taskType === TaskTypes.BUSINESS_DETAILS;
var filterOutUnwantedAssociationsIfRootLE = (taskType, legalEntity, accountHolder) => {
if (!legalEntity?.entityAssociations) return;
let entityAssociations = getOwnEntityAssociations(legalEntity);
if (!isRootLegalEntity(legalEntity, taskType)) return entityAssociations;
if (accountHolder !== "mySoleProprietorName" && hasOwnEntityAssociationOfType(LegalEntityTypes.SOLE_PROPRIETORSHIP, entityAssociations, legalEntity.id)) entityAssociations = removeEntityAssociationByType(LegalEntityTypes.SOLE_PROPRIETORSHIP, entityAssociations, legalEntity.id);
if (accountHolder !== "aTrust" && hasOwnEntityAssociationOfType(LegalEntityTypes.TRUST, entityAssociations, legalEntity.id)) entityAssociations = removeEntityAssociationByType(LegalEntityTypes.TRUST, entityAssociations, legalEntity.id);
return entityAssociations;
};
var getLegalRepresentative = (legalEntityResponse) => getDirectEntityAssociations(legalEntityResponse, legalEntityResponse.id).find((la) => la.type === "legalRepresentative");
var allowedCountriesForNominee = [CountryCodes.NewZealand];
var attachNomineeToRole = (existingEntityAssociation, country, nominee) => {
const clonedEntity = { ...existingEntityAssociation };
if (!allowedCountriesForNominee.includes(country) || !nominee) return existingEntityAssociation;
if (clonedEntity.type === "uboThroughOwnership") clonedEntity.nominee = nominee?.isNomineeShareholder === "Yes" || nominee?.nomineeShareholder === "Yes";
if (clonedEntity.type === "director") clonedEntity.nominee = nominee?.isNomineeDirector === "Yes" || nominee?.nomineeDirector === "Yes";
return clonedEntity;
};
var getNomineeFromAssociation = (entityAssociations, basicDetails) => {
if (!entityAssociations?.length) return basicDetails;
const clonedBasicDetails = { ...basicDetails };
entityAssociations.forEach((entityAssociation) => {
if (entityAssociation.type === "uboThroughOwnership") clonedBasicDetails.nomineeShareholder = entityAssociation.nominee ? "Yes" : "No";
if (entityAssociation.type === "director") clonedBasicDetails.nomineeDirector = entityAssociation.nominee ? "Yes" : "No";
});
return clonedBasicDetails;
};
var hasNomineesChanged = (basicDetails, nomineesSubmitted) => {
return !(basicDetails?.nomineeShareholder === nomineesSubmitted?.nomineeShareholder && basicDetails?.nomineeDirector === nomineesSubmitted?.nomineeDirector);
};
//#endregion
export { getLegalRepresentative as a, getOwnSolePropProblems as c, hasOwnEntityAssociationOfType as d, hasSolePropInLegalEntity as f, getDirectEntityAssociations as i, getOwnSoleProprietorshipIdArray as l, attachNomineeToRole as n, getNomineeFromAssociation as o, TaskTypes as p, filterOutUnwantedAssociationsIfRootLE as r, getOwnEntityAssociations as s, allowedCountriesForNominee as t, hasNomineesChanged as u };