UNPKG

@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.

48 lines (47 loc) 2.35 kB
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] = "10ff0354-839c-4c38-9568-550beb4f0a0a", e._sentryDebugIdIdentifier = "sentry-dbid-10ff0354-839c-4c38-9568-550beb4f0a0a"); } catch (e) {} import { r as httpPost, s as useApiContext } from "./http-D1NDkBxF.js"; import { t as useSettingsContext } from "./useSettingsContext-DzwVt0W0.js"; import { t as useBusinessLines } from "./useBusinessLines-CgnQUuie.js"; import { t as SettingNames } from "./types-CNZsK2dZ.js"; import { useMemo } from "preact/hooks"; import { useQuery } from "@tanstack/preact-query"; //#region src/api/pci/usePciStatus.ts var getPciStatus = async (legalEntityId, baseUrl, data) => { const filteredData = { ...data, additionalSalesChannels: data.additionalSalesChannels?.filter((channel) => channel !== "payByLink") }; return httpPost({ baseUrl, path: `legalEntities/${legalEntityId}/pci/signingRequired` }, filteredData); }; var usePciStatus = (data, options) => { const { rootLegalEntityId, baseUrl } = useApiContext(); return useQuery({ queryKey: ["pciStatus", data], queryFn: () => getPciStatus(rootLegalEntityId.value, baseUrl.value, data), staleTime: 0, ...options }); }; //#endregion //#region src/components/Contract/hooks/useSalesChannels.ts function useSalesChannels() { const { isSettingEnabled } = useSettingsContext(); const { data: existingBusinessLines } = useBusinessLines(["paymentProcessing"]); return useMemo(() => { const settings = []; const businessLinesSalesChannels = [...new Set(existingBusinessLines?.flatMap((item) => item.salesChannels ?? []))]; if (isSettingEnabled(SettingNames.RequirePciSignEcommerce)) settings.push("eCommerce"); if (isSettingEnabled(SettingNames.RequirePciSignPos)) settings.push("pos"); if (isSettingEnabled(SettingNames.RequirePciSignEcomMoto)) settings.push("ecomMoto"); if (isSettingEnabled(SettingNames.RequirePciSignPosMoto)) settings.push("posMoto"); return isSettingEnabled("allowBusinessLines") ? businessLinesSalesChannels : settings; }, [existingBusinessLines, isSettingEnabled]); } //#endregion export { usePciStatus as n, useSalesChannels as t };