@adyen/adyen-web 6.2.0 → 6.3.0
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/cjs/adyen.css +1 -0
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +38 -3
- package/dist/es/adyen.css +1 -0
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/ClickToPayHolder.js +1 -1
- package/dist/es/components/Card/components/ClickToPayHolder.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js +2 -0
- package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -0
- package/dist/es/components/components-name-map.js +1 -1
- package/dist/es/components/components-name-map.js.map +1 -1
- package/dist/es/components/index.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js +1 -1
- package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js +1 -1
- package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
- package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/execute-with-timeout.js +2 -0
- package/dist/es/components/internal/ClickToPay/services/execute-with-timeout.js.map +1 -0
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/tx-variants.js +1 -1
- package/dist/es/components/tx-variants.js.map +1 -1
- package/dist/es/core/Context/CoreProvider.js +1 -1
- package/dist/es/core/Context/CoreProvider.js.map +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/filters.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/filters.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/index.d.ts +38 -3
- package/dist/es/index.js +1 -1
- package/dist/es/utils/listenerUtils.js +1 -1
- package/dist/es/utils/listenerUtils.js.map +1 -1
- package/dist/es-legacy/adyen.css +1 -0
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/ClickToPayHolder.js +1 -1
- package/dist/es-legacy/components/Card/components/ClickToPayHolder.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +2 -0
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -0
- package/dist/es-legacy/components/components-name-map.js +1 -1
- package/dist/es-legacy/components/components-name-map.js.map +1 -1
- package/dist/es-legacy/components/index.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/errors/TimeoutError.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/execute-with-timeout.js +2 -0
- package/dist/es-legacy/components/internal/ClickToPay/services/execute-with-timeout.js.map +1 -0
- package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es-legacy/components/tx-variants.js +1 -1
- package/dist/es-legacy/components/tx-variants.js.map +1 -1
- package/dist/es-legacy/core/Context/CoreProvider.js +1 -1
- package/dist/es-legacy/core/Context/CoreProvider.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/filters.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/filters.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/index.js +1 -1
- package/dist/es-legacy/utils/listenerUtils.js +1 -1
- package/dist/es-legacy/utils/listenerUtils.js.map +1 -1
- package/package.json +3 -3
- package/styles/adyen.css +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayComponent.js","sources":["../../../../../src/components/internal/ClickToPay/ClickToPayComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { CtpState } from './services/ClickToPayService';\nimport useClickToPayContext from './context/useClickToPayContext';\nimport CtPOneTimePassword from './components/CtPOneTimePassword';\nimport CtPCards from './components/CtPCards';\nimport CtPSection from './components/CtPSection';\nimport CtPLoader from './components/CtPLoader';\nimport CtPLogin from './components/CtPLogin';\nimport SrciError from './services/sdks/SrciError';\n\ntype ClickToPayComponentProps = {\n onDisplayCardComponent?(): void;\n};\n\nconst ClickToPayComponent = ({ onDisplayCardComponent }: ClickToPayComponentProps): h.JSX.Element => {\n const { ctpState, onReady, startIdentityValidation, logoutShopper } = useClickToPayContext();\n\n useEffect(() => {\n if ([CtpState.OneTimePassword, CtpState.Login, CtpState.Ready].includes(ctpState)) {\n onReady();\n }\n }, [ctpState, onReady]);\n\n useEffect(() => {\n async function sendOneTimePassword() {\n try {\n await startIdentityValidation();\n } catch (error) {\n if (error instanceof SrciError) console.warn(`CtP - Identity Validation error: ${error.toString()}`);\n await logoutShopper();\n }\n }\n if (ctpState === CtpState.ShopperIdentified) {\n void sendOneTimePassword();\n }\n }, [ctpState]);\n\n if (ctpState === CtpState.NotAvailable) {\n return null;\n }\n\n return (\n <CtPSection>\n {[CtpState.Loading, CtpState.ShopperIdentified].includes(ctpState) && <CtPLoader />}\n {ctpState === CtpState.OneTimePassword && <CtPOneTimePassword onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Ready && <CtPCards onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Login && <CtPLogin />}\n </CtPSection>\n );\n};\n\nexport default ClickToPayComponent;\n"],"names":["ClickToPayComponent","onDisplayCardComponent","ctpState","onReady","startIdentityValidation","logoutShopper","useClickToPayContext","useEffect","CtpState","OneTimePassword","Login","Ready","includes","ShopperIdentified","async","error","SrciError","console","warn","toString","sendOneTimePassword","NotAvailable","h","CtPSection","Loading","CtPLoader","CtPOneTimePassword","CtPCards","CtPLogin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClickToPayComponent.js","sources":["../../../../../src/components/internal/ClickToPay/ClickToPayComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect } from 'preact/hooks';\nimport { CtpState } from './services/ClickToPayService';\nimport useClickToPayContext from './context/useClickToPayContext';\nimport CtPOneTimePassword from './components/CtPOneTimePassword';\nimport CtPCards from './components/CtPCards';\nimport CtPSection from './components/CtPSection';\nimport CtPLoader from './components/CtPLoader';\nimport CtPLogin from './components/CtPLogin';\nimport SrciError from './services/sdks/SrciError';\n\ntype ClickToPayComponentProps = {\n onDisplayCardComponent?(): void;\n};\n\nconst ClickToPayComponent = ({ onDisplayCardComponent }: ClickToPayComponentProps): h.JSX.Element => {\n const { ctpState, onReady, startIdentityValidation, logoutShopper } = useClickToPayContext();\n\n useEffect(() => {\n if ([CtpState.OneTimePassword, CtpState.Login, CtpState.Ready].includes(ctpState)) {\n onReady();\n }\n }, [ctpState, onReady]);\n\n useEffect(() => {\n async function sendOneTimePassword() {\n try {\n await startIdentityValidation();\n } catch (error) {\n if (error instanceof SrciError) console.warn(`CtP - Identity Validation error: ${error.toString()}`);\n await logoutShopper();\n }\n }\n if (ctpState === CtpState.ShopperIdentified) {\n void sendOneTimePassword();\n }\n }, [ctpState]);\n\n /**\n * We capture the ENTER keypress within the ClickToPay component because we do not want to propagate the event up to the UIElement\n * UIElement would perform the payment flow (by calling .submit), which is not relevant/supported by Click to Pay\n */\n const handleEnterKeyPress = useCallback((event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n event.stopPropagation(); // Prevent global BaseElement keypress event to be triggered\n }\n }, []);\n\n if (ctpState === CtpState.NotAvailable) {\n return null;\n }\n\n return (\n <CtPSection onEnterKeyPress={handleEnterKeyPress}>\n {[CtpState.Loading, CtpState.ShopperIdentified].includes(ctpState) && <CtPLoader />}\n {ctpState === CtpState.OneTimePassword && <CtPOneTimePassword onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Ready && <CtPCards onDisplayCardComponent={onDisplayCardComponent} />}\n {ctpState === CtpState.Login && <CtPLogin />}\n </CtPSection>\n );\n};\n\nexport default ClickToPayComponent;\n"],"names":["ClickToPayComponent","onDisplayCardComponent","ctpState","onReady","startIdentityValidation","logoutShopper","useClickToPayContext","useEffect","CtpState","OneTimePassword","Login","Ready","includes","ShopperIdentified","async","error","SrciError","console","warn","toString","sendOneTimePassword","handleEnterKeyPress","useCallback","event","key","preventDefault","stopPropagation","NotAvailable","h","CtPSection","onEnterKeyPress","Loading","CtPLoader","CtPOneTimePassword","CtPCards","CtPLogin"],"mappings":"ykBAeA,MAAMA,EAAsB,EAAGC,6BAC3B,MAAMC,SAAEA,EAAQC,QAAEA,EAAOC,wBAAEA,EAAuBC,cAAEA,GAAkBC,IAEtEC,GAAU,KACF,CAACC,EAASC,gBAAiBD,EAASE,MAAOF,EAASG,OAAOC,SAASV,IACpEC,GACJ,GACD,CAACD,EAAUC,IAEdI,GAAU,KASFL,IAAaM,EAASK,mBAR1BC,iBACI,UACUV,GACV,CAAE,MAAOW,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,oCAAoCH,EAAMI,oBACjFd,GACV,CACJ,CAESe,EACT,GACD,CAAClB,IAMJ,MAAMmB,EAAsBC,GAAaC,IACnB,UAAdA,EAAMC,MACND,EAAME,iBACNF,EAAMG,kBACV,GACD,IAEH,OAAIxB,IAAaM,EAASmB,aACf,KAIPC,EAACC,EAAAA,CAAWC,gBAAiBT,GACxB,CAACb,EAASuB,QAASvB,EAASK,mBAAmBD,SAASV,IAAa0B,EAACI,QACtE9B,IAAaM,EAASC,iBAAmBmB,EAACK,EAAAA,CAAmBhC,uBAAwBA,IACrFC,IAAaM,EAASG,OAASiB,EAACM,EAAAA,CAASjC,uBAAwBA,IACjEC,IAAaM,EAASE,OAASkB,EAACO,EAAAA,MAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as r,useEffect as o,useCallback as s}from"../../../../../external/preact/hooks/dist/hooks.js";import
|
|
1
|
+
import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as r,useEffect as o,useCallback as s}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../context/useClickToPayContext.js";import a from"./CtPSingleCard/CtPSingleCard.js";import i from"../../../PayButton/PayButton.js";import{amountLabel as c}from"../../../PayButton/utils.js";import l from"./CtPCardsList/CtPCardsList.js";import m from"../../services/sdks/SrciError.js";import u from"../CtPSection/CtPSection.js";import{CTP_IFRAME_NAME as d}from"../../services/utils.js";import p from"../../../IFrame/Iframe.js";import f from"../../../../../core/Context/useImage.js";import{useCoreContext as g}from"../../../../../core/Context/CoreProvider.js";import C from"../../../../../utils/isMobile.js";import h from"../../../../../core/Errors/AdyenCheckoutError.js";import{PREFIX as y}from"../../../Icon/constants.js";function k(t,e){if(!t)return null;const r=e.get(`ctp.errors.${t}`);return r.includes("ctp.errors")?e.get("ctp.errors.UNKNOWN_ERROR"):r}function P(t,e,r){return r?C()?null:t.get("payButton.with",{values:{value:c(t,e),maskedData:`•••• ${r?.panLastFour}`}}):t.get("payButton")}const j=({onDisplayCardComponent:c})=>{const{i18n:C}=g(),j=f(),{amount:E,cards:S,checkout:x,isCtpPrimaryPaymentMethod:b,status:v,onSubmit:R,onSetStatus:$,onError:w}=n(),[B,M]=r(S.find((t=>!t.isExpired))||S[0]),[N,D]=r(null),F=S.every((t=>t.isExpired)),[I,T]=r(!1);o((()=>{(0===S.length||F)&&c?.()}),[c,F,S]);const _=s((async()=>{if(B)try{T(!0),D(null),$("loading");const t=await x(B);R(t)}catch(t){t instanceof m&&(D(t?.reason),console.warn(`CtP - Checkout: Reason: ${t?.reason} / Source: ${t?.source} / Scheme: ${t?.scheme}`)),T(!1),w(t instanceof h?t:new h("ERROR","Error during ClickToPay checkout",{cause:t}))}}),[x,B]),L=s((t=>{M(t)}),[]),O=I&&"loading"===v&&B?.isDcfPopupEmbedded,K="loading"!==v||!O,A=s((t=>{"Enter"===t.key&&_()}),[_]);return t(e,null,t(p,{name:d,height:"380",width:"100%",classNameModifiers:[O?"":"hidden"]}),K&&t(e,null,t(u.Title,null,C.get("ctp.cards.title")),t(u.Text,null,C.get("ctp.cards.subtitle")),0===S.length&&t("div",{className:"adyen-checkout-ctp__empty-cards"},C.get("ctp.emptyProfile.message")),1===S.length&&t(a,{card:S[0],errorMessage:k(N,C)}),S.length>1&&t(l,{cardSelected:B,cards:S,onChangeCard:L,errorMessage:k(N,C)}),t(i,{disabled:F,amount:E,label:P(C,E,B),status:v,variant:b?"primary":"secondary",icon:0!==S.length&&j({imageFolder:"components/"})(b?`${y}lock`:`${y}lock_black`),onClick:_,onKeyDown:A})))};export{j as default};
|
|
2
2
|
//# sourceMappingURL=CtPCards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPCards.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCards.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPSingleCard from './CtPSingleCard/CtPSingleCard';\nimport PayButton from '../../../PayButton';\nimport { amountLabel } from '../../../PayButton/utils';\nimport CtPCardsList from './CtPCardsList';\nimport ShopperCard from '../../models/ShopperCard';\nimport SrciError from '../../services/sdks/SrciError';\nimport CtPSection from '../CtPSection';\nimport { CTP_IFRAME_NAME } from '../../services/utils';\nimport Iframe from '../../../../internal/IFrame';\nimport useImage from '../../../../../core/Context/useImage';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport isMobile from '../../../../../utils/isMobile';\nimport Language from '../../../../../language';\nimport { PaymentAmount } from '../../../../../types/global-types';\nimport './CtPCards.scss';\nimport AdyenCheckoutError from '../../../../../core/Errors/AdyenCheckoutError';\nimport { PREFIX } from '../../../Icon/constants';\n\ntype CtPCardsProps = {\n onDisplayCardComponent?(): void;\n};\n\nfunction getErrorLabel(errorCode: string, i18n: Language): string {\n if (!errorCode) return null;\n\n const errorLabel = i18n.get(`ctp.errors.${errorCode}`);\n if (errorLabel.includes('ctp.errors')) return i18n.get(`ctp.errors.UNKNOWN_ERROR`);\n return errorLabel;\n}\n\nfunction getPayButtonLabel(i18n: Language, amount: PaymentAmount, checkoutCard?: ShopperCard): string | null {\n if (!checkoutCard) return i18n.get('payButton');\n if (!isMobile())\n return i18n.get('payButton.with', {\n values: { value: amountLabel(i18n, amount), maskedData: `•••• ${checkoutCard?.panLastFour}` }\n });\n return null;\n}\n\nconst CtPCards = ({ onDisplayCardComponent }: CtPCardsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { amount, cards, checkout, isCtpPrimaryPaymentMethod, status, onSubmit, onSetStatus, onError } = useClickToPayContext();\n const [checkoutCard, setCheckoutCard] = useState<ShopperCard | undefined>(cards.find(card => !card.isExpired) || cards[0]);\n const [errorCode, setErrorCode] = useState<string>(null);\n const isEveryCardExpired = cards.every(card => card.isExpired);\n const [isShopperCheckingOutWithCtp, setIsShopperCheckingOutWithCtp] = useState<boolean>(false);\n\n useEffect(() => {\n if (cards.length === 0 || isEveryCardExpired) {\n onDisplayCardComponent?.();\n }\n }, [onDisplayCardComponent, isEveryCardExpired, cards]);\n\n const doCheckout = useCallback(async () => {\n if (!checkoutCard) return;\n\n try {\n setIsShopperCheckingOutWithCtp(true);\n setErrorCode(null);\n onSetStatus('loading');\n const payload = await checkout(checkoutCard);\n onSubmit(payload);\n } catch (error: unknown) {\n if (error instanceof SrciError) {\n setErrorCode(error?.reason);\n console.warn(`CtP - Checkout: Reason: ${error?.reason} / Source: ${error?.source} / Scheme: ${error?.scheme}`);\n }\n setIsShopperCheckingOutWithCtp(false);\n\n if (error instanceof AdyenCheckoutError) onError(error);\n else onError(new AdyenCheckoutError('ERROR', 'Error during ClickToPay checkout', { cause: error }));\n }\n }, [checkout, checkoutCard]);\n\n const handleOnChangeCard = useCallback((card: ShopperCard) => {\n setCheckoutCard(card);\n }, []);\n\n /**\n * If shopper submits the payment using the default Card component while CtP is rendered, the status here will be updated\n * and that can potentially display an iframe.\n *\n * Therefore, we use the flag 'isShopperCheckingOutWithCtp' to flag that the iframe should be displayed only in case the\n * Shopper is checking out with Click to Pay.\n */\n const displayNetworkDcf = isShopperCheckingOutWithCtp && status === 'loading' && checkoutCard?.isDcfPopupEmbedded;\n const displayCardCheckoutView = status !== 'loading' || !displayNetworkDcf;\n\n return (\n <Fragment>\n <Iframe name={CTP_IFRAME_NAME} height=\"380\" width=\"100%\" classNameModifiers={[displayNetworkDcf ? '' : 'hidden']} />\n\n {displayCardCheckoutView && (\n <Fragment>\n <CtPSection.Title>{i18n.get('ctp.cards.title')}</CtPSection.Title>\n <CtPSection.Text>{i18n.get('ctp.cards.subtitle')}</CtPSection.Text>\n
|
|
1
|
+
{"version":3,"file":"CtPCards.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCards.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPSingleCard from './CtPSingleCard/CtPSingleCard';\nimport PayButton from '../../../PayButton';\nimport { amountLabel } from '../../../PayButton/utils';\nimport CtPCardsList from './CtPCardsList';\nimport ShopperCard from '../../models/ShopperCard';\nimport SrciError from '../../services/sdks/SrciError';\nimport CtPSection from '../CtPSection';\nimport { CTP_IFRAME_NAME } from '../../services/utils';\nimport Iframe from '../../../../internal/IFrame';\nimport useImage from '../../../../../core/Context/useImage';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport isMobile from '../../../../../utils/isMobile';\nimport Language from '../../../../../language';\nimport { PaymentAmount } from '../../../../../types/global-types';\nimport './CtPCards.scss';\nimport AdyenCheckoutError from '../../../../../core/Errors/AdyenCheckoutError';\nimport { PREFIX } from '../../../Icon/constants';\n\ntype CtPCardsProps = {\n onDisplayCardComponent?(): void;\n};\n\nfunction getErrorLabel(errorCode: string, i18n: Language): string {\n if (!errorCode) return null;\n\n const errorLabel = i18n.get(`ctp.errors.${errorCode}`);\n if (errorLabel.includes('ctp.errors')) return i18n.get(`ctp.errors.UNKNOWN_ERROR`);\n return errorLabel;\n}\n\nfunction getPayButtonLabel(i18n: Language, amount: PaymentAmount, checkoutCard?: ShopperCard): string | null {\n if (!checkoutCard) return i18n.get('payButton');\n if (!isMobile())\n return i18n.get('payButton.with', {\n values: { value: amountLabel(i18n, amount), maskedData: `•••• ${checkoutCard?.panLastFour}` }\n });\n return null;\n}\n\nconst CtPCards = ({ onDisplayCardComponent }: CtPCardsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { amount, cards, checkout, isCtpPrimaryPaymentMethod, status, onSubmit, onSetStatus, onError } = useClickToPayContext();\n const [checkoutCard, setCheckoutCard] = useState<ShopperCard | undefined>(cards.find(card => !card.isExpired) || cards[0]);\n const [errorCode, setErrorCode] = useState<string>(null);\n const isEveryCardExpired = cards.every(card => card.isExpired);\n const [isShopperCheckingOutWithCtp, setIsShopperCheckingOutWithCtp] = useState<boolean>(false);\n\n useEffect(() => {\n if (cards.length === 0 || isEveryCardExpired) {\n onDisplayCardComponent?.();\n }\n }, [onDisplayCardComponent, isEveryCardExpired, cards]);\n\n const doCheckout = useCallback(async () => {\n if (!checkoutCard) return;\n\n try {\n setIsShopperCheckingOutWithCtp(true);\n setErrorCode(null);\n onSetStatus('loading');\n const payload = await checkout(checkoutCard);\n onSubmit(payload);\n } catch (error: unknown) {\n if (error instanceof SrciError) {\n setErrorCode(error?.reason);\n console.warn(`CtP - Checkout: Reason: ${error?.reason} / Source: ${error?.source} / Scheme: ${error?.scheme}`);\n }\n setIsShopperCheckingOutWithCtp(false);\n\n if (error instanceof AdyenCheckoutError) onError(error);\n else onError(new AdyenCheckoutError('ERROR', 'Error during ClickToPay checkout', { cause: error }));\n }\n }, [checkout, checkoutCard]);\n\n const handleOnChangeCard = useCallback((card: ShopperCard) => {\n setCheckoutCard(card);\n }, []);\n\n /**\n * If shopper submits the payment using the default Card component while CtP is rendered, the status here will be updated\n * and that can potentially display an iframe.\n *\n * Therefore, we use the flag 'isShopperCheckingOutWithCtp' to flag that the iframe should be displayed only in case the\n * Shopper is checking out with Click to Pay.\n */\n const displayNetworkDcf = isShopperCheckingOutWithCtp && status === 'loading' && checkoutCard?.isDcfPopupEmbedded;\n const displayCardCheckoutView = status !== 'loading' || !displayNetworkDcf;\n\n const handlePayButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void doCheckout();\n }\n },\n [doCheckout]\n );\n\n return (\n <Fragment>\n <Iframe name={CTP_IFRAME_NAME} height=\"380\" width=\"100%\" classNameModifiers={[displayNetworkDcf ? '' : 'hidden']} />\n\n {displayCardCheckoutView && (\n <Fragment>\n <CtPSection.Title>{i18n.get('ctp.cards.title')}</CtPSection.Title>\n <CtPSection.Text>{i18n.get('ctp.cards.subtitle')}</CtPSection.Text>\n {cards.length === 0 && <div className=\"adyen-checkout-ctp__empty-cards\">{i18n.get('ctp.emptyProfile.message')}</div>}\n {cards.length === 1 && <CtPSingleCard card={cards[0]} errorMessage={getErrorLabel(errorCode, i18n)} />}\n {cards.length > 1 && (\n <CtPCardsList\n cardSelected={checkoutCard}\n cards={cards}\n onChangeCard={handleOnChangeCard}\n errorMessage={getErrorLabel(errorCode, i18n)}\n />\n )}\n\n <PayButton\n disabled={isEveryCardExpired}\n amount={amount}\n label={getPayButtonLabel(i18n, amount, checkoutCard)}\n status={status}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n icon={\n cards.length !== 0 &&\n getImage({ imageFolder: 'components/' })(isCtpPrimaryPaymentMethod ? `${PREFIX}lock` : `${PREFIX}lock_black`)\n }\n onClick={doCheckout}\n onKeyDown={handlePayButtonKeyDown}\n />\n </Fragment>\n )}\n </Fragment>\n );\n};\n\nexport default CtPCards;\n"],"names":["getErrorLabel","errorCode","i18n","errorLabel","get","includes","getPayButtonLabel","amount","checkoutCard","isMobile","values","value","amountLabel","maskedData","panLastFour","CtPCards","onDisplayCardComponent","useCoreContext","getImage","useImage","cards","checkout","isCtpPrimaryPaymentMethod","status","onSubmit","onSetStatus","onError","useClickToPayContext","setCheckoutCard","useState","find","card","isExpired","setErrorCode","isEveryCardExpired","every","isShopperCheckingOutWithCtp","setIsShopperCheckingOutWithCtp","useEffect","length","doCheckout","useCallback","async","payload","error","SrciError","reason","console","warn","source","scheme","AdyenCheckoutError","cause","handleOnChangeCard","displayNetworkDcf","isDcfPopupEmbedded","displayCardCheckoutView","handlePayButtonKeyDown","event","key","h","Fragment","Iframe","name","CTP_IFRAME_NAME","height","width","classNameModifiers","CtPSection","Title","Text","div","className","CtPSingleCard","errorMessage","CtPCardsList","cardSelected","onChangeCard","PayButton","disabled","label","variant","icon","imageFolder","PREFIX","onClick","onKeyDown"],"mappings":"46BAyBA,SAASA,EAAcC,EAAmBC,GACtC,IAAKD,EAAW,OAAO,KAEvB,MAAME,EAAaD,EAAKE,IAAI,cAAcH,KAC1C,OAAIE,EAAWE,SAAS,cAAsBH,EAAKE,IAAI,4BAChDD,CACX,CAEA,SAASG,EAAkBJ,EAAgBK,EAAuBC,GAC9D,OAAKA,EACAC,IAIE,KAHIP,EAAKE,IAAI,iBAAkB,CAC9BM,OAAQ,CAAEC,MAAOC,EAAYV,EAAMK,GAASM,WAAY,QAAQL,GAAcM,iBAH5DZ,EAAKE,IAAI,YAMvC,CAEA,MAAMW,EAAW,EAAGC,6BAChB,MAAMd,KAAEA,GAASe,IACXC,EAAWC,KACXZ,OAAEA,EAAMa,MAAEA,EAAKC,SAAEA,EAAQC,0BAAEA,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IC,UAAU,mCAAmCtE,EAAKE,IAAI,6BAChE,IAAjBgB,EAAMmB,QAAgBqB,EAACa,EAAAA,CAAc1C,KAAMX,EAAM,GAAIsD,aAAc1E,EAAcC,EAAWC,KAC5FkB,EAAMmB,OAAS,GACZqB,EAACe,EAAAA,CACGC,aAAcpE,EACdY,MAAOA,EACPyD,aAAcxB,EACdqB,aAAc1E,EAAcC,EAAWC,KAI/C0D,EAACkB,EAAAA,CACGC,SAAU7C,EACV3B,OAAQA,EACRyE,MAAO1E,EAAkBJ,EAAMK,EAAQC,GACvCe,OAAQA,EACR0D,QAAS3D,EAA4B,UAAY,YACjD4D,KACqB,IAAjB9D,EAAMmB,QACNrB,EAAS,CAAEiE,YAAa,eAAxBjE,CAAyCI,EAA4B,GAAG8D,QAAe,GAAGA,eAE9FC,QAAS7C,EACT8C,UAAW7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t,Fragment as
|
|
1
|
+
import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import m from"../../services/sdks/SrciError.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";import{isSrciError as u}from"../../services/utils.js";const d=()=>{const{i18n:d}=p(),{isCtpPrimaryPaymentMethod:f,setIsCtpPrimaryPaymentMethod:g,verifyIfShopperIsEnrolled:C,startIdentityValidation:y}=s(),[P,h]=r(null),[j,I]=r(!1),[E,S]=r(null),[k,x]=r(!1),[v,w]=r(null),T=e((t=>{w(t)}),[]),b=e((({data:t,isValid:o})=>{h(t.shopperLogin),I(o),t?.shopperLogin?.length>0&&g(!0)}),[]),L=e((async()=>{if(S(null),j){x(!0);try{const{isEnrolled:t}=await C({shopperEmail:P});t?await y():(S("NOT_FOUND"),x(!1))}catch(t){t instanceof m&&console.warn(`CtP - Login error: ${t.toString()}`),t instanceof c&&console.warn(t.toString()),u(t)?S(t?.reason):console.error(t),x(!1)}}else v.validateInput()}),[C,y,P,j,v]),M=e((t=>{"Enter"===t.key&&L()}),[L]);return t(o,null,t(l.Title,{endAdornment:t(a,null)},d.get("ctp.login.title")),t(l.Text,null,d.get("ctp.login.subtitle")),t(i,{onChange:b,onSetInputHandlers:T,disabled:k,errorMessage:E&&d.get(`ctp.errors.${E}`),onPressEnter:L}),t(n,{label:d.get("continue"),variant:f?"primary":"secondary",status:k&&"loading",onClick:()=>{L()},onKeyDown:M}))};export{d as default};
|
|
2
2
|
//# sourceMappingURL=CtPLogin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) setErrorCode(error?.reason);\n else console.error(error);\n\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","isSrciError","reason","validateInput","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick"],"mappings":"qnBAaA,MAAMA,EAAW,KACb,MAAMC,KAAEA,GAASC,KACXC,0BAAEA,EAAyBC,6BAAEA,EAA4BC,0BAAEA,EAAyBC,wBAAEA,GAA4BC,KACjHC,EAAcC,GAAmBC,EAAiB,OAClDC,EAASC,GAAcF,GAAkB,IACzCG,EAAWC,GAAgBJ,EAAiB,OAC5CK,EAAaC,GAAkBN,GAAkB,IACjDO,EAAoBC,GAAyBR,EAAgC,MAE9ES,EAA0BC,GAAaC,IACzCH,EAAsBG,EAAAA,GACvB,IAEGC,EAAsBF,GAAY,EAAGG,OAAMZ,cAC7CF,EAAgBc,EAAKf,cACrBI,EAAWD,GAGPY,GAAMf,cAAcgB,OAAS,GAC7BpB,GAA6B,EACjC,GACD,IAEGqB,EAA2BL,GAAYM,UAGzC,GAFAZ,EAAa,MAERH,EAAL,CAKAK,GAAe,GAEf,IACI,MAAMW,WAAEA,SAAqBtB,EAA0B,CAAEuB,aAAcpB,IACnEmB,QACMrB,KAENQ,EAAa,aACbE,GAAe,GAEvB,CAAE,MAAOa,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,sBAAsBH,EAAMI,cACrEJ,aAAiBK,GAAcH,QAAQC,KAAKH,EAAMI,YAClDE,EAAYN,GAAQf,EAAae,GAAOO,QACvCL,QAAQF,MAAMA,GAEnBb,GAAe,EACnB,CAnBA,MAFIC,EAAmBoB,eAqBvB,GACD,CAAChC,EAA2BC,EAAyBE,EAAcG,EAASM,
|
|
1
|
+
{"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) setErrorCode(error?.reason);\n else console.error(error);\n\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n const handleButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void handleOnLoginButtonClick();\n }\n },\n [handleOnLoginButtonClick]\n );\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n onKeyDown={handleButtonKeyDown}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","isSrciError","reason","validateInput","handleButtonKeyDown","event","key","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick","onKeyDown"],"mappings":"qnBAaA,MAAMA,EAAW,KACb,MAAMC,KAAEA,GAASC,KACXC,0BAAEA,EAAyBC,6BAAEA,EAA4BC,0BAAEA,EAAyBC,wBAAEA,GAA4BC,KACjHC,EAAcC,GAAmBC,EAAiB,OAClDC,EAASC,GAAcF,GAAkB,IACzCG,EAAWC,GAAgBJ,EAAiB,OAC5CK,EAAaC,GAAkBN,GAAkB,IACjDO,EAAoBC,GAAyBR,EAAgC,MAE9ES,EAA0BC,GAAaC,IACzCH,EAAsBG,EAAAA,GACvB,IAEGC,EAAsBF,GAAY,EAAGG,OAAMZ,cAC7CF,EAAgBc,EAAKf,cACrBI,EAAWD,GAGPY,GAAMf,cAAcgB,OAAS,GAC7BpB,GAA6B,EACjC,GACD,IAEGqB,EAA2BL,GAAYM,UAGzC,GAFAZ,EAAa,MAERH,EAAL,CAKAK,GAAe,GAEf,IACI,MAAMW,WAAEA,SAAqBtB,EAA0B,CAAEuB,aAAcpB,IACnEmB,QACMrB,KAENQ,EAAa,aACbE,GAAe,GAEvB,CAAE,MAAOa,GACDA,aAAiBC,GAAWC,QAAQC,KAAK,sBAAsBH,EAAMI,cACrEJ,aAAiBK,GAAcH,QAAQC,KAAKH,EAAMI,YAClDE,EAAYN,GAAQf,EAAae,GAAOO,QACvCL,QAAQF,MAAMA,GAEnBb,GAAe,EACnB,CAnBA,MAFIC,EAAmBoB,eAqBvB,GACD,CAAChC,EAA2BC,EAAyBE,EAAcG,EAASM,IAEzEqB,EAAsBlB,GACvBmB,IACqB,UAAdA,EAAMC,KACDf,GACT,GAEJ,CAACA,IAGL,OACIgB,EAACC,EAAAA,KACGD,EAACE,EAAWC,MAAK,CAACC,aAAcJ,EAACK,EAAAA,OAAa7C,EAAK8C,IAAI,oBAEvDN,EAACE,EAAWK,KAAI,KAAE/C,EAAK8C,IAAI,uBAE3BN,EAACQ,EAAAA,CACGC,SAAU5B,EACV6B,mBAAoBhC,EACpBiC,SAAUrC,EACVsC,aAAcxC,GAAaZ,EAAK8C,IAAI,cAAclC,KAClDyC,aAAc7B,IAGlBgB,EAACc,EAAAA,CACGC,MAAOvD,EAAK8C,IAAI,YAChBU,QAAStD,EAA4B,UAAY,YACjDuD,OAAQ3C,GAAe,UACvB4C,QAAS,KACAlC,GAAAA,EAETmC,UAAWtB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as a}from"./validate.js";import{useCoreContext as n}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useForm.js";import p from"../../../FormFields/Field/Field.js";import l from"../../../FormFields/InputEmail.js";const d=d=>{const{i18n:u}=n(),{handleChangeFor:m,data:c,triggerValidation:g,valid:h,errors:f,isValid:L}=i({schema:["shopperLogin"],rules:a}),F=r({validateInput:null}),[j,v]=o(!1),b=s((()=>{v(!0),g()}),[g]);t((()=>{c.shopperLogin&&v(!0)}),[c.shopperLogin]),t((()=>{F.current.validateInput=b,d.onSetInputHandlers(F.current)}),[b,d.onSetInputHandlers]);const E=s((e=>{"Enter"===e.key&&d.onPressEnter()}),[d.onPressEnter]);return t((()=>{d.onChange({data:c,valid:h,errors:f,isValid:L})}),[c,h,f]),e(p,{name:"shopperLogin",label:u.get("ctp.login.inputLabel"),errorMessage:j?d.errorMessage||!!f.shopperLogin:null,classNameModifiers:["shopperLogin"]},e(l,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:c.shopperLogin,disabled:d.disabled,onInput:m("shopperLogin","input"),onBlur:m("shopperLogin","blur"),onKeyPress:E}))};export{d as default};
|
|
2
2
|
//# sourceMappingURL=CtPLoginInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPLoginInput = (props: CtPLoginInputProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useForm<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const
|
|
1
|
+
{"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPLoginInput = (props: CtPLoginInputProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useForm<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || !!errors.shopperLogin : null}\n classNameModifiers={['shopperLogin']}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","handleChangeFor","data","triggerValidation","valid","errors","isValid","useForm","schema","rules","loginValidationRules","loginInputHandlersRef","useRef","validateInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","shopperLogin","current","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","Field","name","label","get","errorMessage","classNameModifiers","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress"],"mappings":"oeA0BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,KAEXC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAgC,CACzGC,OAFe,CAAC,gBAGhBC,MAAOC,IAELC,EAAwBC,EAA8B,CAAEC,cAAe,QACtEC,EAAmBC,GAAwBC,GAAkB,GAE9DH,EAAgBI,GAAY,KAC9BF,GAAqB,GACrBZ,GAAAA,GACD,CAACA,IAEJe,GAAU,KACFhB,EAAKiB,cAAcJ,GAAqB,EAAA,GAC7C,CAACb,EAAKiB,eAETD,GAAU,KACNP,EAAsBS,QAAQP,cAAgBA,EAC9Cf,EAAMuB,mBAAmBV,EAAsBS,QAAO,GACvD,CAACP,EAAef,EAAMuB,qBAEzB,MAAMC,EAAmBL,GACpBM,IACqB,UAAdA,EAAMC,KACD1B,EAAM2B,cACf,GAEJ,CAAC3B,EAAM2B,eAOX,OAJAP,GAAU,KACNpB,EAAM4B,SAAS,CAAExB,OAAME,QAAOC,SAAQC,WAAQ,GAC/C,CAACJ,EAAME,EAAOC,IAGbsB,EAACC,EAAAA,CACGC,KAAK,eACLC,MAAO/B,EAAKgC,IAAI,wBAChBC,aAAclB,EAAoBhB,EAAMkC,gBAAkB3B,EAAOc,aAAe,KAChFc,mBAAoB,CAAC,iBAErBN,EAACO,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOnC,EAAKiB,aACZmB,SAAUxC,EAAMwC,SAChBC,QAAStC,EAAgB,eAAgB,SACzCuC,OAAQvC,EAAgB,eAAgB,QACxCwC,WAAYnB"}
|
package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as o,useCallback as n}from"../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../Button/Button.js";import r from"../../context/useClickToPayContext.js";import a from"./CtPOneTimePasswordInput/CtPOneTimePasswordInput.js";import{CtPInfo as i}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import d from"./CtPSaveCookiesCheckbox/CtPSaveCookiesCheckbox.js";import{isSrciError as m}from"../../services/utils.js";const c=({onDisplayCardComponent:c})=>{const{i18n:u}=p(),{finishIdentityValidation:C,otpMaskedContact:f,otpNetwork:P,isCtpPrimaryPaymentMethod:h}=r(),[k,
|
|
1
|
+
import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as o,useCallback as n}from"../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../Button/Button.js";import r from"../../context/useClickToPayContext.js";import a from"./CtPOneTimePasswordInput/CtPOneTimePasswordInput.js";import{CtPInfo as i}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import d from"./CtPSaveCookiesCheckbox/CtPSaveCookiesCheckbox.js";import{isSrciError as m}from"../../services/utils.js";const c=({onDisplayCardComponent:c})=>{const{i18n:u}=p(),{finishIdentityValidation:C,otpMaskedContact:f,otpNetwork:P,isCtpPrimaryPaymentMethod:h}=r(),[k,y]=o(null),[g,j]=o(!1),[x,I]=o(!1),[b,S]=o(null),[v,T]=o(null),[w,E]=o(!1),B=n((t=>{T(t)}),[]),O=n((({data:t,isValid:e})=>{y(t.otp),j(e)}),[]),A=n((()=>{S(null)}),[]),M=n((async()=>{if(S(null),g){I(!0);try{await C(k)}catch(t){if(!m(t))return void I(!1);S(t?.reason),I(!1),"ACCT_INACCESSIBLE"===t?.reason&&(E(!0),c?.())}}else v.validateInput()}),[k,g,v,c]),N=n((t=>{"Enter"===t.key&&M()}),[M]),V=u.get("ctp.otp.subtitle").split("%@");return t(e,null,t(l.Title,{endAdornment:t(i,null)},u.get("ctp.otp.title")),t(l.Text,null,V[0]," ",P," ",V[1],t("span",{className:"adyen-checkout-ctp__otp-subtitle--highlighted"},f),V[2]),t(a,{hideResendOtpButton:w,onChange:O,onSetInputHandlers:B,disabled:x,errorMessage:b&&u.get(`ctp.errors.${b}`),onPressEnter:M,onResendCode:A,isValidatingOtp:x}),t(d,null),t(s,{disabled:w,label:u.get("continue"),variant:h?"primary":"secondary",onClick:M,status:x&&"loading",onKeyDown:N}))};export{c as default};
|
|
2
2
|
//# sourceMappingURL=CtPOneTimePassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPOneTimePassword.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPOneTimePasswordInput from './CtPOneTimePasswordInput';\nimport { CtPOneTimePasswordInputHandlers } from './CtPOneTimePasswordInput/CtPOneTimePasswordInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPOneTimePassword.scss';\nimport CtPSaveCookiesCheckbox from './CtPSaveCookiesCheckbox';\nimport { isSrciError } from '../../services/utils';\n\ntype CtPOneTimePasswordProps = {\n onDisplayCardComponent?(): void;\n};\nconst CtPOneTimePassword = ({ onDisplayCardComponent }: CtPOneTimePasswordProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { finishIdentityValidation, otpMaskedContact, otpNetwork, isCtpPrimaryPaymentMethod } = useClickToPayContext();\n const [otp, setOtp] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [isValidatingOtp, setIsValidatingOtp] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [otpInputHandlers, setOtpInputHandlers] = useState<CtPOneTimePasswordInputHandlers>(null);\n const [isAccountLocked, setIsAccountLocked] = useState<boolean>(false);\n\n const onSetOtpInputHandlers = useCallback((handlers: CtPOneTimePasswordInputHandlers) => {\n setOtpInputHandlers(handlers);\n }, []);\n\n const onChangeOtpInput = useCallback(({ data, isValid }) => {\n setOtp(data.otp);\n setIsValid(isValid);\n }, []);\n\n const onResendCode = useCallback(() => {\n setErrorCode(null);\n }, []);\n\n const onSubmitPassword = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n otpInputHandlers.validateInput();\n return;\n }\n\n setIsValidatingOtp(true);\n\n try {\n await finishIdentityValidation(otp);\n } catch (error: unknown) {\n if (!isSrciError(error)) {\n setIsValidatingOtp(false);\n return;\n }\n\n setErrorCode(error?.reason);\n setIsValidatingOtp(false);\n\n if (error?.reason === 'ACCT_INACCESSIBLE') {\n setIsAccountLocked(true);\n onDisplayCardComponent?.();\n }\n }\n }, [otp, isValid, otpInputHandlers, onDisplayCardComponent]);\n\n const subtitleParts = i18n.get('ctp.otp.subtitle').split('%@');\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.otp.title')}</CtPSection.Title>\n\n <CtPSection.Text>\n {subtitleParts[0]} {otpNetwork} {subtitleParts[1]}\n <span className=\"adyen-checkout-ctp__otp-subtitle--highlighted\">{otpMaskedContact}</span>\n {subtitleParts[2]}\n </CtPSection.Text>\n\n <CtPOneTimePasswordInput\n hideResendOtpButton={isAccountLocked}\n onChange={onChangeOtpInput}\n onSetInputHandlers={onSetOtpInputHandlers}\n disabled={isValidatingOtp}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={onSubmitPassword}\n onResendCode={onResendCode}\n isValidatingOtp={isValidatingOtp}\n />\n\n <CtPSaveCookiesCheckbox />\n\n <Button\n disabled={isAccountLocked}\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n onClick={onSubmitPassword}\n status={isValidatingOtp && 'loading'}\n />\n </Fragment>\n );\n};\n\nexport default CtPOneTimePassword;\n"],"names":["CtPOneTimePassword","onDisplayCardComponent","i18n","useCoreContext","finishIdentityValidation","otpMaskedContact","otpNetwork","isCtpPrimaryPaymentMethod","useClickToPayContext","otp","setOtp","useState","isValid","setIsValid","isValidatingOtp","setIsValidatingOtp","errorCode","setErrorCode","otpInputHandlers","setOtpInputHandlers","isAccountLocked","setIsAccountLocked","onSetOtpInputHandlers","useCallback","handlers","onChangeOtpInput","data","onResendCode","onSubmitPassword","async","error","isSrciError","reason","validateInput","subtitleParts","get","split","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","Text","span","className","CtPOneTimePasswordInput","hideResendOtpButton","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","CtPSaveCookiesCheckbox","Button","label","variant","onClick","status"],"mappings":"6nBAgBA,MAAMA,EAAqB,EAAGC,6BAC1B,MAAMC,KAAEA,GAASC,KACXC,yBAAEA,EAAwBC,iBAAEA,EAAgBC,WAAEA,EAAUC,0BAAEA,GAA8BC,KACvFC,EAAKC,GAAUC,EAAiB,OAChCC,EAASC,GAAcF,GAAkB,IACzCG,EAAiBC,GAAsBJ,GAAkB,IACzDK,EAAWC,GAAgBN,EAAiB,OAC5CO,EAAkBC,GAAuBR,EAA0C,OACnFS,EAAiBC,GAAsBV,GAAkB,GAE1DW,EAAwBC,GAAaC,IACvCL,EAAoBK,EAAAA,GACrB,IAEGC,EAAmBF,GAAY,EAAGG,OAAMd,cAC1CF,EAAOgB,EAAKjB,KACZI,EAAWD,EAAAA,GACZ,IAEGe,EAAeJ,GAAY,KAC7BN,EAAa,KAAA,GACd,IAEGW,EAAmBL,GAAYM,UAGjC,GAFAZ,EAAa,MAERL,EAAL,CAKAG,GAAmB,GAEnB,UACUX,EAAyBK,EACnC,CAAE,MAAOqB,GACL,IAAKC,EAAYD,GAEb,YADAf,GAAmB,GAIvBE,EAAaa,GAAOE,QACpBjB,GAAmB,GAEG,sBAAlBe,GAAOE,SACPX,GAAmB,GACnBpB,MAER,CAnBA,MAFIiB,EAAiBe,eAqBrB,GACD,CAACxB,EAAKG,EAASM,EAAkBjB,IAE9BiC,
|
|
1
|
+
{"version":3,"file":"CtPOneTimePassword.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPOneTimePasswordInput from './CtPOneTimePasswordInput';\nimport { CtPOneTimePasswordInputHandlers } from './CtPOneTimePasswordInput/CtPOneTimePasswordInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPOneTimePassword.scss';\nimport CtPSaveCookiesCheckbox from './CtPSaveCookiesCheckbox';\nimport { isSrciError } from '../../services/utils';\n\ntype CtPOneTimePasswordProps = {\n onDisplayCardComponent?(): void;\n};\nconst CtPOneTimePassword = ({ onDisplayCardComponent }: CtPOneTimePasswordProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { finishIdentityValidation, otpMaskedContact, otpNetwork, isCtpPrimaryPaymentMethod } = useClickToPayContext();\n const [otp, setOtp] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [isValidatingOtp, setIsValidatingOtp] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [otpInputHandlers, setOtpInputHandlers] = useState<CtPOneTimePasswordInputHandlers>(null);\n const [isAccountLocked, setIsAccountLocked] = useState<boolean>(false);\n\n const onSetOtpInputHandlers = useCallback((handlers: CtPOneTimePasswordInputHandlers) => {\n setOtpInputHandlers(handlers);\n }, []);\n\n const onChangeOtpInput = useCallback(({ data, isValid }) => {\n setOtp(data.otp);\n setIsValid(isValid);\n }, []);\n\n const onResendCode = useCallback(() => {\n setErrorCode(null);\n }, []);\n\n const onSubmitPassword = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n otpInputHandlers.validateInput();\n return;\n }\n\n setIsValidatingOtp(true);\n\n try {\n await finishIdentityValidation(otp);\n } catch (error: unknown) {\n if (!isSrciError(error)) {\n setIsValidatingOtp(false);\n return;\n }\n\n setErrorCode(error?.reason);\n setIsValidatingOtp(false);\n\n if (error?.reason === 'ACCT_INACCESSIBLE') {\n setIsAccountLocked(true);\n onDisplayCardComponent?.();\n }\n }\n }, [otp, isValid, otpInputHandlers, onDisplayCardComponent]);\n\n const handleButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void onSubmitPassword();\n }\n },\n [onSubmitPassword]\n );\n\n const subtitleParts = i18n.get('ctp.otp.subtitle').split('%@');\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.otp.title')}</CtPSection.Title>\n\n <CtPSection.Text>\n {subtitleParts[0]} {otpNetwork} {subtitleParts[1]}\n <span className=\"adyen-checkout-ctp__otp-subtitle--highlighted\">{otpMaskedContact}</span>\n {subtitleParts[2]}\n </CtPSection.Text>\n\n <CtPOneTimePasswordInput\n hideResendOtpButton={isAccountLocked}\n onChange={onChangeOtpInput}\n onSetInputHandlers={onSetOtpInputHandlers}\n disabled={isValidatingOtp}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={onSubmitPassword}\n onResendCode={onResendCode}\n isValidatingOtp={isValidatingOtp}\n />\n\n <CtPSaveCookiesCheckbox />\n\n <Button\n disabled={isAccountLocked}\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n onClick={onSubmitPassword}\n status={isValidatingOtp && 'loading'}\n onKeyDown={handleButtonKeyDown}\n />\n </Fragment>\n );\n};\n\nexport default CtPOneTimePassword;\n"],"names":["CtPOneTimePassword","onDisplayCardComponent","i18n","useCoreContext","finishIdentityValidation","otpMaskedContact","otpNetwork","isCtpPrimaryPaymentMethod","useClickToPayContext","otp","setOtp","useState","isValid","setIsValid","isValidatingOtp","setIsValidatingOtp","errorCode","setErrorCode","otpInputHandlers","setOtpInputHandlers","isAccountLocked","setIsAccountLocked","onSetOtpInputHandlers","useCallback","handlers","onChangeOtpInput","data","onResendCode","onSubmitPassword","async","error","isSrciError","reason","validateInput","handleButtonKeyDown","event","key","subtitleParts","get","split","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","Text","span","className","CtPOneTimePasswordInput","hideResendOtpButton","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","CtPSaveCookiesCheckbox","Button","label","variant","onClick","status","onKeyDown"],"mappings":"6nBAgBA,MAAMA,EAAqB,EAAGC,6BAC1B,MAAMC,KAAEA,GAASC,KACXC,yBAAEA,EAAwBC,iBAAEA,EAAgBC,WAAEA,EAAUC,0BAAEA,GAA8BC,KACvFC,EAAKC,GAAUC,EAAiB,OAChCC,EAASC,GAAcF,GAAkB,IACzCG,EAAiBC,GAAsBJ,GAAkB,IACzDK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AShC,EACTiC,OAAQ/C,GAAmB,UAC3BgD,UAAW5B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useRef as r,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as n}from"./validate.js";import a from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import d from"../../../../../../utils/useForm/useForm.js";import u from"../../../../FormFields/Field/Field.js";import p from"../../../../FormFields/InputText.js";const c=c=>{const{i18n:m}=i(),{configuration:{disableOtpAutoFocus:f}}=l(),[C,g]=t(null),{handleChangeFor:F,data:b,triggerValidation:j,valid:h,errors:k,isValid:v,setData:
|
|
1
|
+
import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useRef as r,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as n}from"./validate.js";import a from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import d from"../../../../../../utils/useForm/useForm.js";import u from"../../../../FormFields/Field/Field.js";import p from"../../../../FormFields/InputText.js";const c=c=>{const{i18n:m}=i(),{configuration:{disableOtpAutoFocus:f}}=l(),[C,g]=t(null),{handleChangeFor:F,data:b,triggerValidation:j,valid:h,errors:k,isValid:v,setData:x}=d({schema:["otp"],rules:n}),E=r({validateInput:null}),P=r(null),[R,I]=t(!1),O=o((()=>{I(!0),j()}),[j]);s((()=>{b.otp&&I(!0)}),[b.otp]),s((()=>{!f&&P.current&&P.current.focus()}),[P.current,f]),s((()=>{E.current.validateInput=O,c.onSetInputHandlers(E.current)}),[O,c.onSetInputHandlers]);const V=o((()=>{x("otp",""),g(null),f||P.current.focus(),c.onResendCode()}),[c.onResendCode,P.current,f]),y=o((e=>{const t=m.get(`ctp.errors.${e}`);t&&g(t)}),[m]),M=o((e=>{"Enter"===e.key&&c.onPressEnter()}),[c.onPressEnter]);return s((()=>{c.onChange({data:b,valid:h,errors:k,isValid:v})}),[b,h,k]),e(u,{name:"oneTimePassword",label:m.get("ctp.otp.fieldLabel"),labelEndAdornment:!c.hideResendOtpButton&&e(a,{disabled:c.isValidatingOtp,onError:y,onResendCode:V}),errorMessage:R?C||c.errorMessage||!!k.otp:null,classNameModifiers:["otp"]},e(p,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:c.disabled,onInput:F("otp","input"),onBlur:F("otp","blur"),onKeyPress:M,setRef:e=>{P.current=e}}))};export{c as default};
|
|
2
2
|
//# sourceMappingURL=CtPOneTimePasswordInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../../utils/useForm';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: CtPOneTimePasswordInputProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useForm<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const
|
|
1
|
+
{"version":3,"file":"CtPOneTimePasswordInput.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { otpValidationRules } from './validate';\nimport CtPResendOtpLink from './CtPResendOtpLink';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../../utils/useForm';\nimport Field from '../../../../FormFields/Field';\nimport './CtPOneTimePasswordInput.scss';\nimport InputText from '../../../../FormFields/InputText';\n\ntype OnChangeProps = { data: CtPOneTimePasswordInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPOneTimePasswordInputProps {\n hideResendOtpButton: boolean;\n disabled: boolean;\n isValidatingOtp: boolean;\n errorMessage?: string;\n onSetInputHandlers(handlers: CtPOneTimePasswordInputHandlers): void;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onResendCode(): void;\n}\n\ninterface CtPOneTimePasswordInputDataState {\n otp?: string;\n}\n\nexport type CtPOneTimePasswordInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPOneTimePasswordInput = (props: CtPOneTimePasswordInputProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const {\n configuration: { disableOtpAutoFocus }\n } = useClickToPayContext();\n\n const formSchema = ['otp'];\n const [resendOtpError, setResendOtpError] = useState<string>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid, setData } = useForm<CtPOneTimePasswordInputDataState>({\n schema: formSchema,\n rules: otpValidationRules\n });\n const otpInputHandlersRef = useRef<CtPOneTimePasswordInputHandlers>({ validateInput: null });\n const inputRef = useRef<HTMLInputElement>(null);\n const [isOtpFielDirty, setIsOtpFieldDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsOtpFieldDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n /**\n * If shopper changes the value of the OTP fields, input becomes dirty\n */\n useEffect(() => {\n if (data.otp) setIsOtpFieldDirty(true);\n }, [data.otp]);\n\n useEffect(() => {\n if (!disableOtpAutoFocus && inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef.current, disableOtpAutoFocus]);\n\n useEffect(() => {\n otpInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(otpInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnResendOtp = useCallback(() => {\n setData('otp', '');\n setResendOtpError(null);\n if (!disableOtpAutoFocus) {\n inputRef.current.focus();\n }\n props.onResendCode();\n }, [props.onResendCode, inputRef.current, disableOtpAutoFocus]);\n\n const handleOnResendOtpError = useCallback(\n (errorCode: string) => {\n const message = i18n.get(`ctp.errors.${errorCode}`);\n if (message) setResendOtpError(message);\n },\n [i18n]\n );\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <Field\n name=\"oneTimePassword\"\n label={i18n.get('ctp.otp.fieldLabel')}\n labelEndAdornment={\n !props.hideResendOtpButton && (\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n )\n }\n errorMessage={isOtpFielDirty ? resendOtpError || props.errorMessage || !!errors.otp : null}\n classNameModifiers={['otp']}\n >\n <InputText\n name={'otp'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.otp}\n disabled={props.disabled}\n onInput={handleChangeFor('otp', 'input')}\n onBlur={handleChangeFor('otp', 'blur')}\n onKeyPress={handleOnKeyPress}\n setRef={(ref: HTMLInputElement) => {\n inputRef.current = ref;\n }}\n />\n </Field>\n );\n};\n\nexport default CtPOneTimePasswordInput;\n"],"names":["CtPOneTimePasswordInput","props","i18n","useCoreContext","configuration","disableOtpAutoFocus","useClickToPayContext","resendOtpError","setResendOtpError","useState","handleChangeFor","data","triggerValidation","valid","errors","isValid","setData","useForm","schema","rules","otpValidationRules","otpInputHandlersRef","useRef","validateInput","inputRef","isOtpFielDirty","setIsOtpFieldDirty","useCallback","useEffect","otp","current","focus","onSetInputHandlers","handleOnResendOtp","onResendCode","handleOnResendOtpError","errorCode","message","get","handleOnKeyPress","event","key","onPressEnter","onChange","h","Field","name","label","labelEndAdornment","hideResendOtpButton","CtPResendOtpLink","disabled","isValidatingOtp","onError","errorMessage","classNameModifiers","InputText","autocorrect","spellcheck","value","onInput","onBlur","onKeyPress","setRef","ref"],"mappings":"glBAgCA,MAAMA,EAA2BC,IAC7B,MAAMC,KAAEA,GAASC,KAEbC,eAAeC,oBAAEA,IACjBC,KAGGC,EAAgBC,GAAqBC,EAAiB,OACvDC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,QAAEA,GAAYC,EAA0C,CAC5HC,OAHe,CAAC,OAIhBC,MAAOC,IAELC,EAAsBC,EAAwC,CAAEC,cAAe,OAC/EC,EAAWF,EAAyB,OACnCG,EAAgBC,GAAsBjB,GAAkB,GAEzDc,EAAgBI,GAAY,KAC9BD,GAAmB,GACnBd,GAAAA,GACD,CAACA,IAKJgB,GAAU,KACFjB,EAAKkB,KAAKH,GAAmB,EAAA,GAClC,CAACf,EAAKkB,MAETD,GAAU,MACDvB,GAAuBmB,EAASM,SACjCN,EAASM,QAAQC,OACrB,GACD,CAACP,EAASM,QAASzB,IAEtBuB,GAAU,KACNP,EAAoBS,QAAQP,cAAgBA,EAC5CtB,EAAM+B,mBAAmBX,EAAoBS,QAAO,GACrD,CAACP,EAAetB,EAAM+B,qBAEzB,MAAMC,EAAoBN,GAAY,KAClCX,EAAQ,MAAO,IACfR,EAAkB,MACbH,GACDmB,EAASM,QAAQC,QAErB9B,EAAMiC,cAAY,GACnB,CAACjC,EAAMiC,aAAcV,EAASM,QAASzB,IAEpC8B,EAAyBR,GAC1BS,IACG,MAAMC,EAAUnC,EAAKoC,IAAI,cAAcF,KACnCC,GAAS7B,EAAkB6B,EAAAA,GAEnC,CAACnC,IAGCqC,EAAmBZ,GACpBa,IACqB,UAAdA,EAAMC,KACDxC,EAAMyC,cACf,GAEJ,CAACzC,EAAMyC,eAOX,OAJAd,GAAU,KACN3B,EAAM0C,SAAS,CAAEhC,OAAME,QAAOC,SAAQC,WAAQ,GAC/C,CAACJ,EAAME,EAAOC,IAGb8B,EAACC,EAAAA,CACGC,KAAK,kBACLC,MAAO7C,EAAKoC,IAAI,sBAChBU,mBACK/C,EAAMgD,qBACHL,EAACM,EAAAA,CAAiBC,SAAUlD,EAAMmD,gBAAiBC,QAASlB,EAAwBD,aAAcD,IAG1GqB,aAAc7B,EAAiBlB,GAAkBN,EAAMqD,gBAAkBxC,EAAOe,IAAM,KACtF0B,mBAAoB,CAAC,QAErBX,EAACY,EAAAA,CACGV,KAAM,MACNW,YAAa,MACbC,YAAY,EACZC,MAAOhD,EAAKkB,IACZsB,SAAUlD,EAAMkD,SAChBS,QAASlD,EAAgB,MAAO,SAChCmD,OAAQnD,EAAgB,MAAO,QAC/BoD,WAAYvB,EACZwB,OAASC,IACLxC,EAASM,QAAUkC,CAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../external/classnames/index.js";import
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../external/classnames/index.js";import n from"./CtPLogoutLink.js";import{CtPBrand as c}from"../CtPBrand/CtPBrand.js";import a from"../../context/useClickToPayContext.js";const o=({children:o,onEnterKeyPress:s})=>{const{isStandaloneComponent:r}=a();return e("div",{className:t("adyen-checkout-ctp__section",{"adyen-checkout-ctp__section--standalone":r}),onKeyPress:s},e("div",{className:"adyen-checkout-ctp__section-brand"},e(c,null),e(n,null)),o)};o.Title=({endAdornment:t,children:n})=>e("div",{className:"adyen-checkout-ctp__section-header"},e("h1",{className:"adyen-checkout-ctp__section-header-title"},n),t&&e("span",{className:"adyen-checkout-ctp__section-header-adornment"},t)),o.Text=({children:t})=>e("p",{className:"adyen-checkout-ctp__section-text"},t);export{o as default};
|
|
2
2
|
//# sourceMappingURL=CtPSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPSection.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPSection/CtPSection.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classnames from 'classnames';\nimport CtPLogoutLink from './CtPLogoutLink';\nimport { CtPBrand } from '../CtPBrand';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport './CtPSection.scss';\n\ninterface CtPSectionProps {\n children?: h.JSX.Element[];\n}\n\nconst CtPSection = ({ children }: CtPSectionProps): h.JSX.Element => {\n const { isStandaloneComponent } = useClickToPayContext();\n\n return (\n <div
|
|
1
|
+
{"version":3,"file":"CtPSection.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPSection/CtPSection.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classnames from 'classnames';\nimport CtPLogoutLink from './CtPLogoutLink';\nimport { CtPBrand } from '../CtPBrand';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport './CtPSection.scss';\n\ninterface CtPSectionProps {\n onEnterKeyPress: (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => void;\n children?: h.JSX.Element[];\n}\n\nconst CtPSection = ({ children, onEnterKeyPress }: CtPSectionProps): h.JSX.Element => {\n const { isStandaloneComponent } = useClickToPayContext();\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n className={classnames('adyen-checkout-ctp__section', { 'adyen-checkout-ctp__section--standalone': isStandaloneComponent })}\n onKeyPress={onEnterKeyPress}\n >\n <div className=\"adyen-checkout-ctp__section-brand\">\n <CtPBrand />\n <CtPLogoutLink />\n </div>\n\n {children}\n </div>\n );\n};\n\nconst Title = ({ endAdornment, children }: { endAdornment?; children }) => (\n <div className=\"adyen-checkout-ctp__section-header\">\n <h1 className=\"adyen-checkout-ctp__section-header-title\">{children}</h1>\n {endAdornment && <span className=\"adyen-checkout-ctp__section-header-adornment\">{endAdornment}</span>}\n </div>\n);\nconst Text = ({ children }: { children }) => <p className=\"adyen-checkout-ctp__section-text\">{children}</p>;\n\nCtPSection.Title = Title;\nCtPSection.Text = Text;\n\nexport default CtPSection;\n"],"names":["CtPSection","children","onEnterKeyPress","isStandaloneComponent","useClickToPayContext","h","div","className","classnames","onKeyPress","CtPBrand","CtPLogoutLink","Title","endAdornment","h1","span","Text","p"],"mappings":"mRAYA,MAAMA,EAAa,EAAGC,WAAUC,sBAC5B,MAAMC,sBAAEA,GAA0BC,IAElC,OAEIC,EAACC,MAAAA,CACGC,UAAWC,EAAW,8BAA+B,CAAE,0CAA2CL,IAClGM,WAAYP,GAEZG,EAACC,MAAAA,CAAIC,UAAU,qCACXF,EAACK,EAAAA,MACDL,EAACM,EAGJV,OAAAA,EAAAA,EAabD,EAAWY,MARG,EAAGC,eAAcZ,cAC3BI,EAACC,MAAAA,CAAIC,UAAU,sCACXF,EAACS,KAAAA,CAAGP,UAAU,4CAA4CN,GACzDY,GAAgBR,EAACU,OAAAA,CAAKR,UAAU,gDAAgDM,IAMzFb,EAAWgB,KAHE,EAAGf,cAA6BI,EAACY,IAAAA,CAAEV,UAAU,oCAAoCN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class
|
|
1
|
+
class e extends Error{scheme;source;isTimeoutTriggeredBySchemeSdk;correlationId;constructor(e){super(`ClickToPayService - Timeout during ${e.source}() of the scheme '${e.scheme}'`),this.name="TimeoutError",this.source=e.source,this.scheme=e.scheme,this.isTimeoutTriggeredBySchemeSdk=e.isTimeoutTriggeredBySchemeSdk}setCorrelationId(e){this.correlationId=e}toString(){return this.message}}export{e as default};
|
|
2
2
|
//# sourceMappingURL=TimeoutError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeoutError.js","sources":["../../../../../../src/components/internal/ClickToPay/errors/TimeoutError.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"TimeoutError.js","sources":["../../../../../../src/components/internal/ClickToPay/errors/TimeoutError.ts"],"sourcesContent":["interface TimeoutErrorProps {\n source: string;\n scheme: string;\n isTimeoutTriggeredBySchemeSdk: boolean;\n}\n\nclass TimeoutError extends Error {\n public scheme: string;\n public source: string;\n public isTimeoutTriggeredBySchemeSdk: boolean;\n\n /** Currently populated only by Visa SDK if available */\n public correlationId?: string;\n\n constructor(options: TimeoutErrorProps) {\n super(`ClickToPayService - Timeout during ${options.source}() of the scheme '${options.scheme}'`);\n\n this.name = 'TimeoutError';\n this.source = options.source;\n this.scheme = options.scheme;\n this.isTimeoutTriggeredBySchemeSdk = options.isTimeoutTriggeredBySchemeSdk;\n }\n\n public setCorrelationId(correlationId: string): void {\n this.correlationId = correlationId;\n }\n\n public toString() {\n return this.message;\n }\n}\n\nexport default TimeoutError;\n"],"names":["TimeoutError","Error","scheme","source","isTimeoutTriggeredBySchemeSdk","correlationId","constructor","options","super","this","name","setCorrelationId","toString","message"],"mappings":"AAMA,MAAMA,UAAqBC,MAChBC,OACAC,OACAC,8BAGPC,cAEAC,WAAAA,CAAYC,GACRC,MAAM,sCAAsCD,EAAQJ,2BAA2BI,EAAQL,WAEvFO,KAAKC,KAAO,eACZD,KAAKN,OAASI,EAAQJ,OACtBM,KAAKP,OAASK,EAAQL,OACtBO,KAAKL,8BAAgCG,EAAQH,6BACjD,CAEOO,gBAAAA,CAAiBN,GACpBI,KAAKJ,cAAgBA,CACzB,CAEOO,QAAAA,GACH,OAAOH,KAAKI,OAChB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CTP_IFRAME_NAME as e,createCheckoutPayloadBasedOnScheme as t,createShopperCardsList as i}from"./utils.js";import s from"./sdks/SrciError.js";import{SchemeNames as o}from"./sdks/utils.js";import n from"../../../../utils/uuid.js";import r from"../../../../core/Errors/AdyenCheckoutError.js";import{isRejected as a,isFulfilled as d}from"../../../../utils/promise-util.js";import c from"../errors/TimeoutError.js";
|
|
1
|
+
import{CTP_IFRAME_NAME as e,createCheckoutPayloadBasedOnScheme as t,createShopperCardsList as i}from"./utils.js";import s from"./sdks/SrciError.js";import{SchemeNames as o}from"./sdks/utils.js";import n from"../../../../utils/uuid.js";import r from"../../../../core/Errors/AdyenCheckoutError.js";import{isRejected as a,isFulfilled as d}from"../../../../utils/promise-util.js";import c from"../errors/TimeoutError.js";import{executeWithTimeout as h}from"./execute-with-timeout.js";var l;!function(e){e.Idle="Idle",e.Loading="Loading",e.ShopperIdentified="ShopperIdentified",e.OneTimePassword="OneTimePassword",e.Ready="Ready",e.Login="Login",e.NotAvailable="NotAvailable"}(l||(l={}));class m{sdkLoader;schemesConfig;shopperIdentity;environment;onTimeout;srciTransactionId=n();sdks;validationSchemeSdk=null;stateSubscriber;state="Idle";shopperCards=null;identityValidationData=null;storeCookies=!1;constructor(e,t,i,s,o){this.sdkLoader=t,this.schemesConfig=e,this.shopperIdentity=s,this.environment=i,this.onTimeout=o}get shopperAccountFound(){return["Ready","ShopperIdentified"].includes(this.state)}get schemes(){return this.sdkLoader.schemes}updateStoreCookiesConsent(e){this.storeCookies=e}async initialize(){this.setState("Loading");try{this.sdks=await this.sdkLoader.load(this.environment),await this.initiateSdks();const{recognized:e=!1,idTokens:t=null}=await this.verifyIfShopperIsRecognized();if(e)return await this.getShopperProfile(t),void this.setState("Ready");if(!this.shopperIdentity)return void this.setState("NotAvailable");const{isEnrolled:i}=await this.verifyIfShopperIsEnrolled(this.shopperIdentity);if(i)return void this.setState("ShopperIdentified");this.setState("NotAvailable")}catch(e){e instanceof s&&"REQUEST_TIMEOUT"===e?.reason||e instanceof c?this.handleTimeout(e):e instanceof s?console.warn(`Error at ClickToPayService # init: ${e.toString()}`):console.warn(e),this.setState("NotAvailable")}}subscribeOnStateChange(e){this.stateSubscriber=e}async startIdentityValidation(){if(!this.validationSchemeSdk)throw Error("startIdentityValidation: No ValidationSDK set for the validation process");try{const{maskedValidationChannel:e}=await this.validationSchemeSdk.initiateIdentityValidation();this.identityValidationData={maskedShopperContact:e.replace(/\*/g,"•"),selectedNetwork:o[this.validationSchemeSdk.schemeName]},this.setState("OneTimePassword")}catch(e){throw this.validationSchemeSdk=null,e}}async finishIdentityValidation(e){if(!this.validationSchemeSdk)throw Error("finishIdentityValidation: No ValidationSDK set for the validation process");const t=await this.validationSchemeSdk.completeIdentityValidation(e);await this.getShopperProfile([t.idToken]),this.setState("Ready"),this.validationSchemeSdk=null}async checkout(i){if(!i)throw Error("ClickToPayService # checkout: Missing card data");const s=this.sdks.find((e=>e.schemeName===i.scheme)),o=await s.checkout({srcDigitalCardId:i.srcDigitalCardId,srcCorrelationId:i.srcCorrelationId,...i.isDcfPopupEmbedded&&{windowRef:window.frames[e]},...this.storeCookies&&{complianceSettings:{complianceResources:[{complianceType:"REMEMBER_ME",uri:""}]}}});if("COMPLETE"!==o.dcfActionCode)throw new r("ERROR",`Checkout through Scheme DCF did not complete. DCF Action code received: ${o.dcfActionCode}`);return t(i,o,this.environment)}async logout(){if(!this.sdks)throw new r("ERROR","ClickToPayService is not initialized");try{const e=this.sdks.map((e=>e.unbindAppInstance()));await Promise.all(e)}catch(e){e instanceof s?console.warn(`Error at ClickToPayService # logout: ${e.toString()}`):console.warn(e)}this.shopperCards=null,this.identityValidationData=null,this.validationSchemeSdk=null,this.setState("Login")}verifyIfShopperIsEnrolled(e){const{shopperEmail:t}=e;return new Promise(((e,i)=>{const s=this.sdks.map((s=>h((()=>s.identityLookup({identityValue:t,type:"email"})),5e3,new c({source:"identityLookup",scheme:s.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((t=>{t.consumerPresent&&!this.validationSchemeSdk&&(this.setSdkForPerformingShopperIdentityValidation(s),e({isEnrolled:!0}))})).catch((e=>{i(e)}))));Promise.allSettled(s).then((()=>{e({isEnrolled:!1})}))}))}setState(e){this.state=e,this.stateSubscriber?.(this.state)}setSdkForPerformingShopperIdentityValidation(e){this.validationSchemeSdk=e}handleTimeout(e){const t=e instanceof s?new c({source:e.source,scheme:e.scheme,isTimeoutTriggeredBySchemeSdk:!0}):e;"visa"===t.scheme&&(t.setCorrelationId(window.VISA_SDK?.correlationId),window.VISA_SDK?.correlationId?window.VISA_SDK?.buildClientProfile?.():window.VISA_SDK?.buildClientProfile?.(this.schemesConfig.visa.srciDpaId)),this.onTimeout?.(t)}async getShopperProfile(e){return new Promise(((t,s)=>{const o=this.sdks.map((t=>t.getSrcProfile(e)));Promise.allSettled(o).then((e=>{e.every(a)&&s(e[0].reason);const o=e.map(((e,t)=>d(e)&&{...e.value,scheme:this.sdks[t].schemeName})).filter((e=>!!e));this.shopperCards=i(o),t()}))}))}verifyIfShopperIsRecognized(){return new Promise(((e,t)=>{const i=this.sdks.map((i=>h((()=>i.isRecognized()),5e3,new c({source:"isRecognized",scheme:i.schemeName,isTimeoutTriggeredBySchemeSdk:!1})).then((t=>{t.recognized&&e(t)})).catch((e=>{t(e)}))));Promise.allSettled(i).then((()=>{e({recognized:!1})}))}))}initiateSdks(){const e=this.sdks.map((e=>{const t=this.schemesConfig[e.schemeName];return h((()=>e.init(t,this.srciTransactionId)),5e3,new c({source:"init",scheme:e.schemeName,isTimeoutTriggeredBySchemeSdk:!1}))}));return Promise.all(e)}}export{l as CtpState,m as default};
|
|
2
2
|
//# sourceMappingURL=ClickToPayService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayService.js","sources":["../../../../../../src/components/internal/ClickToPay/services/ClickToPayService.ts"],"sourcesContent":["import { ISrcInitiator } from './sdks/AbstractSrcInitiator';\nimport {\n CallbackStateSubscriber,\n IClickToPayService,\n IdentityLookupParams,\n ClickToPayCheckoutPayload,\n SrcProfileWithScheme,\n SchemesConfiguration,\n IdentityValidationData\n} from './types';\nimport { ISrcSdkLoader } from './sdks/SrcSdkLoader';\nimport { createCheckoutPayloadBasedOnScheme, createShopperCardsList, CTP_IFRAME_NAME } from './utils';\nimport { SrciIdentityLookupResponse, SrciIsRecognizedResponse, SrcProfile } from './sdks/types';\nimport SrciError from './sdks/SrciError';\nimport { SchemeNames } from './sdks/utils';\nimport ShopperCard from '../models/ShopperCard';\nimport uuidv4 from '../../../../utils/uuid';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { isFulfilled, isRejected } from '../../../../utils/promise-util';\nimport TimeoutError from '../errors/TimeoutError';\n\nexport enum CtpState {\n Idle = 'Idle',\n Loading = 'Loading',\n ShopperIdentified = 'ShopperIdentified',\n OneTimePassword = 'OneTimePassword',\n Ready = 'Ready',\n Login = 'Login',\n NotAvailable = 'NotAvailable'\n}\n\nfunction executeWithTimeout<T>(fn: () => Promise<T>, timer: number, error: Error): Promise<T> {\n const timeout = new Promise<T>((resolve, reject) => setTimeout(() => reject(error), timer));\n return Promise.race<T>([fn(), timeout]);\n}\n\nclass ClickToPayService implements IClickToPayService {\n private readonly sdkLoader: ISrcSdkLoader;\n private readonly schemesConfig: SchemesConfiguration;\n private readonly shopperIdentity?: IdentityLookupParams;\n private readonly environment: string;\n\n private readonly onTimeout?: (error: TimeoutError) => void;\n\n /**\n * Mandatory unique ID passed to all the networks (Click to Pay systems), used to track user journey\n */\n private readonly srciTransactionId: string = uuidv4();\n\n private sdks: ISrcInitiator[];\n private validationSchemeSdk: ISrcInitiator = null;\n private stateSubscriber: CallbackStateSubscriber;\n\n public state: CtpState = CtpState.Idle;\n public shopperCards: ShopperCard[] = null;\n public identityValidationData: IdentityValidationData = null;\n\n /**\n * Indicates if the shopper opted for saving cookies during the transaction\n */\n public storeCookies = false;\n\n constructor(\n schemesConfig: SchemesConfiguration,\n sdkLoader: ISrcSdkLoader,\n environment: string,\n shopperIdentity?: IdentityLookupParams,\n onTimeout?: (error: TimeoutError) => void\n ) {\n this.sdkLoader = sdkLoader;\n this.schemesConfig = schemesConfig;\n this.shopperIdentity = shopperIdentity;\n this.environment = environment;\n this.onTimeout = onTimeout;\n }\n\n public get shopperAccountFound(): boolean {\n return [CtpState.Ready, CtpState.ShopperIdentified].includes(this.state);\n }\n\n public get schemes(): string[] {\n return this.sdkLoader.schemes;\n }\n\n public updateStoreCookiesConsent(shouldStore: boolean) {\n this.storeCookies = shouldStore;\n }\n\n public async initialize(): Promise<void> {\n this.setState(CtpState.Loading);\n\n try {\n this.sdks = await this.sdkLoader.load(this.environment);\n await this.initiateSdks();\n\n const { recognized = false, idTokens = null } = await this.verifyIfShopperIsRecognized();\n\n if (recognized) {\n await this.getShopperProfile(idTokens);\n this.setState(CtpState.Ready);\n return;\n }\n\n if (!this.shopperIdentity) {\n this.setState(CtpState.NotAvailable);\n return;\n }\n\n const { isEnrolled } = await this.verifyIfShopperIsEnrolled(this.shopperIdentity);\n if (isEnrolled) {\n this.setState(CtpState.ShopperIdentified);\n return;\n }\n\n this.setState(CtpState.NotAvailable);\n } catch (error) {\n if (error instanceof SrciError && error?.reason === 'REQUEST_TIMEOUT') {\n const timeoutError = new TimeoutError(`ClickToPayService - Timeout during ${error.source}() of the scheme '${error.scheme}'`);\n this.onTimeout?.(timeoutError);\n } else if (error instanceof TimeoutError) {\n console.warn(error.toString());\n this.onTimeout?.(error);\n } else if (error instanceof SrciError) {\n console.warn(`Error at ClickToPayService # init: ${error.toString()}`);\n } else {\n console.warn(error);\n }\n\n this.setState(CtpState.NotAvailable);\n }\n }\n\n /**\n * Set the callback for notifying when the CtPState changes\n */\n public subscribeOnStateChange(callback: CallbackStateSubscriber): void {\n this.stateSubscriber = callback;\n }\n\n /**\n * Initiates Consumer Identity validation with one Click to Pay System.\n * The Click to Pay System sends a one-time-password (OTP) to the registered email address or mobile number.\n **/\n public async startIdentityValidation(): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('startIdentityValidation: No ValidationSDK set for the validation process');\n }\n const { maskedValidationChannel } = await this.validationSchemeSdk.initiateIdentityValidation();\n\n this.identityValidationData = {\n maskedShopperContact: maskedValidationChannel.replace(/\\*/g, '•'),\n selectedNetwork: SchemeNames[this.validationSchemeSdk.schemeName]\n };\n\n this.setState(CtpState.OneTimePassword);\n }\n\n /**\n * Completes the validation of the Shopper by evaluating the supplied OTP.\n */\n public async finishIdentityValidation(otpCode: string): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('finishIdentityValidation: No ValidationSDK set for the validation process');\n }\n const validationToken = await this.validationSchemeSdk.completeIdentityValidation(otpCode);\n await this.getShopperProfile([validationToken.idToken]);\n this.setState(CtpState.Ready);\n\n this.validationSchemeSdk = null;\n }\n\n /**\n * This method performs checkout using the selected card\n */\n public async checkout(card: ShopperCard): Promise<ClickToPayCheckoutPayload> {\n if (!card) {\n throw Error('ClickToPayService # checkout: Missing card data');\n }\n\n const checkoutSdk = this.sdks.find(sdk => sdk.schemeName === card.scheme);\n\n const checkoutResponse = await checkoutSdk.checkout({\n srcDigitalCardId: card.srcDigitalCardId,\n srcCorrelationId: card.srcCorrelationId,\n ...(card.isDcfPopupEmbedded && { windowRef: window.frames[CTP_IFRAME_NAME] }),\n ...(this.storeCookies && { complianceSettings: { complianceResources: [{ complianceType: 'REMEMBER_ME', uri: '' }] } })\n });\n\n if (checkoutResponse.dcfActionCode !== 'COMPLETE') {\n throw new AdyenCheckoutError(\n 'ERROR',\n `Checkout through Scheme DCF did not complete. DCF Action code received: ${checkoutResponse.dcfActionCode}`\n );\n }\n\n return createCheckoutPayloadBasedOnScheme(card, checkoutResponse, this.environment);\n }\n\n /**\n * Call the 'unbindAppInstance()' method of each SRC SDK in order to remove the shopper cookies.\n * Besides, it deletes all information stored about the shopper.\n */\n public async logout(): Promise<void> {\n if (!this.sdks) {\n throw new AdyenCheckoutError('ERROR', 'ClickToPayService is not initialized');\n }\n\n try {\n const logoutPromises = this.sdks.map(sdk => sdk.unbindAppInstance());\n await Promise.all(logoutPromises);\n } catch (error) {\n if (error instanceof SrciError) console.warn(`Error at ClickToPayService # logout: ${error.toString()}`);\n else console.warn(error);\n }\n\n this.shopperCards = null;\n this.identityValidationData = null;\n this.validationSchemeSdk = null;\n\n this.setState(CtpState.Login);\n }\n\n /**\n * Call the 'identityLookup()' method of each SRC SDK in order to verify if the shopper has an account.\n *\n * Based on the responses from the Click to Pay Systems, we should do the validation process using the SDK that\n * that responds faster with 'consumerPresent=true'\n */\n public async verifyIfShopperIsEnrolled(shopperIdentity: IdentityLookupParams): Promise<{ isEnrolled: boolean }> {\n const { shopperEmail } = shopperIdentity;\n\n return new Promise((resolve, reject) => {\n const lookupPromises = this.sdks.map(sdk => {\n const identityLookupPromise = executeWithTimeout<SrciIdentityLookupResponse>(\n () => sdk.identityLookup({ identityValue: shopperEmail, type: 'email' }),\n 5000,\n new TimeoutError(`ClickToPayService - Timeout during identityLookup() of the scheme '${sdk.schemeName}'`)\n );\n\n identityLookupPromise\n .then(response => {\n if (response.consumerPresent && !this.validationSchemeSdk) {\n this.setSdkForPerformingShopperIdentityValidation(sdk);\n resolve({ isEnrolled: true });\n }\n })\n .catch(error => {\n reject(error);\n });\n\n return identityLookupPromise;\n });\n\n void Promise.allSettled(lookupPromises).then(() => {\n resolve({ isEnrolled: false });\n });\n });\n }\n\n private setState(state: CtpState): void {\n this.state = state;\n this.stateSubscriber?.(this.state);\n }\n\n private setSdkForPerformingShopperIdentityValidation(sdk: ISrcInitiator) {\n this.validationSchemeSdk = sdk;\n }\n\n /**\n * Based on the given 'idToken', this method goes through each SRCi SDK and fetches the shopper\n * profile with his cards.\n */\n private async getShopperProfile(idTokens: string[]): Promise<void> {\n return new Promise((resolve, reject) => {\n const srcProfilesPromises = this.sdks.map(sdk => sdk.getSrcProfile(idTokens));\n\n void Promise.allSettled(srcProfilesPromises).then(srcProfilesResponses => {\n if (srcProfilesResponses.every(isRejected)) {\n reject(srcProfilesResponses[0].reason);\n }\n\n const createProfileWithScheme = (promiseResult: PromiseSettledResult<SrcProfile>, index) =>\n isFulfilled(promiseResult) && { ...promiseResult.value, scheme: this.sdks[index].schemeName };\n\n const profilesWithScheme: SrcProfileWithScheme[] = srcProfilesResponses.map(createProfileWithScheme).filter(profile => !!profile);\n\n this.shopperCards = createShopperCardsList(profilesWithScheme);\n resolve();\n });\n });\n }\n\n /**\n * Calls the 'isRecognized()' method of each SRC SDK in order to verify if the shopper is\n * recognized on the device. The shopper is recognized if he/she has the Cookies stored\n * on their browser\n */\n private async verifyIfShopperIsRecognized(): Promise<SrciIsRecognizedResponse> {\n return new Promise((resolve, reject) => {\n const promises = this.sdks.map(sdk => {\n const isRecognizedPromise = executeWithTimeout<SrciIsRecognizedResponse>(\n () => sdk.isRecognized(),\n 5000,\n new TimeoutError(`ClickToPayService - Timeout during isRecognized() of the scheme '${sdk.schemeName}'`)\n );\n isRecognizedPromise.then(response => response.recognized && resolve(response)).catch(error => reject(error));\n return isRecognizedPromise;\n });\n\n // If the 'resolve' didn't happen until this point, then shopper is not recognized\n void Promise.allSettled(promises).then(() => resolve({ recognized: false }));\n });\n }\n\n private async initiateSdks(): Promise<void> {\n const initPromises = this.sdks.map(sdk => {\n const cfg = this.schemesConfig[sdk.schemeName];\n\n return executeWithTimeout<void>(\n () => sdk.init(cfg, this.srciTransactionId),\n 5000,\n new TimeoutError(`ClickToPayService - Timeout during init() of the scheme '${sdk.schemeName}'`)\n );\n });\n\n await Promise.all(initPromises);\n }\n}\n\nexport default ClickToPayService;\n"],"names":["executeWithTimeout","fn","timer","error","timeout","Promise","resolve","reject","setTimeout","race","CtpState","ClickToPayService","sdkLoader","schemesConfig","shopperIdentity","environment","onTimeout","srciTransactionId","uuidv4","sdks","validationSchemeSdk","stateSubscriber","state","shopperCards","identityValidationData","storeCookies","constructor","this","shopperAccountFound","includes","schemes","updateStoreCookiesConsent","shouldStore","initialize","setState","load","initiateSdks","recognized","idTokens","verifyIfShopperIsRecognized","getShopperProfile","isEnrolled","verifyIfShopperIsEnrolled","SrciError","reason","timeoutError","TimeoutError","source","scheme","console","warn","toString","subscribeOnStateChange","callback","startIdentityValidation","Error","maskedValidationChannel","initiateIdentityValidation","maskedShopperContact","replace","selectedNetwork","SchemeNames","schemeName","finishIdentityValidation","otpCode","validationToken","completeIdentityValidation","idToken","checkout","card","checkoutSdk","find","sdk","checkoutResponse","srcDigitalCardId","srcCorrelationId","isDcfPopupEmbedded","windowRef","window","frames","CTP_IFRAME_NAME","complianceSettings","complianceResources","complianceType","uri","dcfActionCode","AdyenCheckoutError","createCheckoutPayloadBasedOnScheme","logout","logoutPromises","map","unbindAppInstance","all","shopperEmail","lookupPromises","identityLookupPromise","identityLookup","identityValue","type","then","response","consumerPresent","setSdkForPerformingShopperIdentityValidation","catch","allSettled","srcProfilesPromises","getSrcProfile","srcProfilesResponses","every","isRejected","profilesWithScheme","promiseResult","index","isFulfilled","value","filter","profile","createShopperCardsList","promises","isRecognizedPromise","isRecognized","initPromises","cfg","init"],"mappings":"uaA+BA,SAASA,EAAsBC,EAAsBC,EAAeC,GAChE,MAAMC,EAAU,IAAIC,SAAW,CAACC,EAASC,IAAWC,YAAW,IAAMD,EAAOJ,IAAQD,KACpF,OAAOG,QAAQI,KAAQ,CAACR,IAAMG,GAClC,EAbYM,SAAAA,+KAAAA,CAAAA,IAAAA,EAAAA,CAAAA,IAeZ,MAAMC,EACeC,UACAC,cACAC,gBACAC,YAEAC,UAKAC,kBAA4BC,IAErCC,KACAC,oBAAqC,KACrCC,gBAEDC,MAAgC,OAChCC,aAA8B,KAC9BC,uBAAiD,KAKjDC,cAAe,EAEtBC,WAAAA,CACIb,EACAD,EACAG,EACAD,EACAE,GAEAW,KAAKf,UAAYA,EACjBe,KAAKd,cAAgBA,EACrBc,KAAKb,gBAAkBA,EACvBa,KAAKZ,YAAcA,EACnBY,KAAKX,UAAYA,CACrB,CAEA,uBAAWY,GACP,MAAO,8BAA6CC,SAASF,KAAKL,MACtE,CAEA,WAAWQ,GACP,OAAOH,KAAKf,UAAUkB,OAC1B,CAEOC,yBAAAA,CAA0BC,GAC7BL,KAAKF,aAAeO,CACxB,CAEA,gBAAaC,GACTN,KAAKO,SAAQ,WAEb,IACIP,KAAKR,WAAaQ,KAAKf,UAAUuB,KAAKR,KAAKZ,mBACrCY,KAAKS,eAEX,MAAMC,WAAEA,GAAa,EAAKC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IAAI6B,EAAa,4DAA4D0B,EAAIV,eAAa,UAIhGzD,QAAQuF,IAAI6B,EACtB"}
|
|
1
|
+
{"version":3,"file":"ClickToPayService.js","sources":["../../../../../../src/components/internal/ClickToPay/services/ClickToPayService.ts"],"sourcesContent":["import { ISrcInitiator } from './sdks/AbstractSrcInitiator';\nimport {\n CallbackStateSubscriber,\n IClickToPayService,\n IdentityLookupParams,\n ClickToPayCheckoutPayload,\n SrcProfileWithScheme,\n SchemesConfiguration,\n IdentityValidationData\n} from './types';\nimport { ISrcSdkLoader } from './sdks/SrcSdkLoader';\nimport { createCheckoutPayloadBasedOnScheme, createShopperCardsList, CTP_IFRAME_NAME } from './utils';\nimport { SrciIdentityLookupResponse, SrciIsRecognizedResponse, SrcProfile } from './sdks/types';\nimport SrciError from './sdks/SrciError';\nimport { SchemeNames } from './sdks/utils';\nimport ShopperCard from '../models/ShopperCard';\nimport uuidv4 from '../../../../utils/uuid';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { isFulfilled, isRejected } from '../../../../utils/promise-util';\nimport TimeoutError from '../errors/TimeoutError';\nimport { executeWithTimeout } from './execute-with-timeout';\n\nexport enum CtpState {\n Idle = 'Idle',\n Loading = 'Loading',\n ShopperIdentified = 'ShopperIdentified',\n OneTimePassword = 'OneTimePassword',\n Ready = 'Ready',\n Login = 'Login',\n NotAvailable = 'NotAvailable'\n}\n\nclass ClickToPayService implements IClickToPayService {\n private readonly sdkLoader: ISrcSdkLoader;\n private readonly schemesConfig: SchemesConfiguration;\n private readonly shopperIdentity?: IdentityLookupParams;\n private readonly environment: string;\n\n private readonly onTimeout?: (error: TimeoutError) => void;\n\n /**\n * Mandatory unique ID passed to all the networks (Click to Pay systems), used to track user journey\n */\n private readonly srciTransactionId: string = uuidv4();\n\n private sdks: ISrcInitiator[];\n private validationSchemeSdk: ISrcInitiator = null;\n private stateSubscriber: CallbackStateSubscriber;\n\n public state: CtpState = CtpState.Idle;\n public shopperCards: ShopperCard[] = null;\n public identityValidationData: IdentityValidationData = null;\n\n /**\n * Indicates if the shopper opted for saving cookies during the transaction\n */\n public storeCookies = false;\n\n constructor(\n schemesConfig: SchemesConfiguration,\n sdkLoader: ISrcSdkLoader,\n environment: string,\n shopperIdentity?: IdentityLookupParams,\n onTimeout?: (error: TimeoutError) => void\n ) {\n this.sdkLoader = sdkLoader;\n this.schemesConfig = schemesConfig;\n this.shopperIdentity = shopperIdentity;\n this.environment = environment;\n this.onTimeout = onTimeout;\n }\n\n public get shopperAccountFound(): boolean {\n return [CtpState.Ready, CtpState.ShopperIdentified].includes(this.state);\n }\n\n public get schemes(): string[] {\n return this.sdkLoader.schemes;\n }\n\n public updateStoreCookiesConsent(shouldStore: boolean) {\n this.storeCookies = shouldStore;\n }\n\n public async initialize(): Promise<void> {\n this.setState(CtpState.Loading);\n\n try {\n this.sdks = await this.sdkLoader.load(this.environment);\n await this.initiateSdks();\n\n const { recognized = false, idTokens = null } = await this.verifyIfShopperIsRecognized();\n\n if (recognized) {\n await this.getShopperProfile(idTokens);\n this.setState(CtpState.Ready);\n return;\n }\n\n if (!this.shopperIdentity) {\n this.setState(CtpState.NotAvailable);\n return;\n }\n\n const { isEnrolled } = await this.verifyIfShopperIsEnrolled(this.shopperIdentity);\n if (isEnrolled) {\n this.setState(CtpState.ShopperIdentified);\n return;\n }\n\n this.setState(CtpState.NotAvailable);\n } catch (error) {\n if ((error instanceof SrciError && error?.reason === 'REQUEST_TIMEOUT') || error instanceof TimeoutError) {\n this.handleTimeout(error);\n } else if (error instanceof SrciError) {\n console.warn(`Error at ClickToPayService # init: ${error.toString()}`);\n } else {\n console.warn(error);\n }\n\n this.setState(CtpState.NotAvailable);\n }\n }\n\n /**\n * Set the callback for notifying when the CtPState changes\n */\n public subscribeOnStateChange(callback: CallbackStateSubscriber): void {\n this.stateSubscriber = callback;\n }\n\n /**\n * Initiates Consumer Identity validation with one Click to Pay System.\n * The Click to Pay System sends a one-time-password (OTP) to the registered email address or mobile number.\n **/\n public async startIdentityValidation(): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('startIdentityValidation: No ValidationSDK set for the validation process');\n }\n try {\n const { maskedValidationChannel } = await this.validationSchemeSdk.initiateIdentityValidation();\n\n this.identityValidationData = {\n maskedShopperContact: maskedValidationChannel.replace(/\\*/g, '•'),\n selectedNetwork: SchemeNames[this.validationSchemeSdk.schemeName]\n };\n\n this.setState(CtpState.OneTimePassword);\n } catch (error: unknown) {\n // If there is an error when 'startIdentityValidation' (Ex: account is blocked), we reset the scheme chosen to perform this step\n this.validationSchemeSdk = null;\n throw error;\n }\n }\n\n /**\n * Completes the validation of the Shopper by evaluating the supplied OTP.\n */\n public async finishIdentityValidation(otpCode: string): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('finishIdentityValidation: No ValidationSDK set for the validation process');\n }\n\n const validationToken = await this.validationSchemeSdk.completeIdentityValidation(otpCode);\n await this.getShopperProfile([validationToken.idToken]);\n this.setState(CtpState.Ready);\n this.validationSchemeSdk = null;\n }\n\n /**\n * This method performs checkout using the selected card\n */\n public async checkout(card: ShopperCard): Promise<ClickToPayCheckoutPayload> {\n if (!card) {\n throw Error('ClickToPayService # checkout: Missing card data');\n }\n\n const checkoutSdk = this.sdks.find(sdk => sdk.schemeName === card.scheme);\n\n const checkoutResponse = await checkoutSdk.checkout({\n srcDigitalCardId: card.srcDigitalCardId,\n srcCorrelationId: card.srcCorrelationId,\n ...(card.isDcfPopupEmbedded && { windowRef: window.frames[CTP_IFRAME_NAME] }),\n ...(this.storeCookies && { complianceSettings: { complianceResources: [{ complianceType: 'REMEMBER_ME', uri: '' }] } })\n });\n\n if (checkoutResponse.dcfActionCode !== 'COMPLETE') {\n throw new AdyenCheckoutError(\n 'ERROR',\n `Checkout through Scheme DCF did not complete. DCF Action code received: ${checkoutResponse.dcfActionCode}`\n );\n }\n\n return createCheckoutPayloadBasedOnScheme(card, checkoutResponse, this.environment);\n }\n\n /**\n * Call the 'unbindAppInstance()' method of each SRC SDK in order to remove the shopper cookies.\n * Besides, it deletes all information stored about the shopper.\n */\n public async logout(): Promise<void> {\n if (!this.sdks) {\n throw new AdyenCheckoutError('ERROR', 'ClickToPayService is not initialized');\n }\n\n try {\n const logoutPromises = this.sdks.map(sdk => sdk.unbindAppInstance());\n await Promise.all(logoutPromises);\n } catch (error) {\n if (error instanceof SrciError) console.warn(`Error at ClickToPayService # logout: ${error.toString()}`);\n else console.warn(error);\n }\n\n this.shopperCards = null;\n this.identityValidationData = null;\n this.validationSchemeSdk = null;\n\n this.setState(CtpState.Login);\n }\n\n /**\n * Call the 'identityLookup()' method of each SRC SDK in order to verify if the shopper has an account.\n *\n * Based on the responses from the Click to Pay Systems, we should do the validation process using the SDK that\n * that responds faster with 'consumerPresent=true'\n */\n public verifyIfShopperIsEnrolled(shopperIdentity: IdentityLookupParams): Promise<{ isEnrolled: boolean }> {\n const { shopperEmail } = shopperIdentity;\n\n return new Promise((resolve, reject) => {\n const lookupPromises = this.sdks.map(sdk => {\n const identityLookupPromise = executeWithTimeout<SrciIdentityLookupResponse>(\n () => sdk.identityLookup({ identityValue: shopperEmail, type: 'email' }),\n 5000,\n new TimeoutError({\n source: 'identityLookup',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n\n return identityLookupPromise\n .then(response => {\n if (response.consumerPresent && !this.validationSchemeSdk) {\n this.setSdkForPerformingShopperIdentityValidation(sdk);\n resolve({ isEnrolled: true });\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n\n void Promise.allSettled(lookupPromises).then(() => {\n resolve({ isEnrolled: false });\n });\n });\n }\n\n private setState(state: CtpState): void {\n this.state = state;\n this.stateSubscriber?.(this.state);\n }\n\n private setSdkForPerformingShopperIdentityValidation(sdk: ISrcInitiator) {\n this.validationSchemeSdk = sdk;\n }\n\n private handleTimeout(error: SrciError | TimeoutError) {\n // If the timeout error was thrown directly by the scheme SDK, we convert it to TimeoutError\n // If the timeout error was thrown by our internal timeout mechanism, we don't do anything\n const timeoutError =\n error instanceof SrciError\n ? new TimeoutError({ source: error.source, scheme: error.scheme, isTimeoutTriggeredBySchemeSdk: true })\n : error;\n\n if (timeoutError.scheme === 'visa') {\n timeoutError.setCorrelationId(window.VISA_SDK?.correlationId);\n\n // Visa srciDpaId must be passed when there is no correlation ID available\n if (window.VISA_SDK?.correlationId) window.VISA_SDK?.buildClientProfile?.();\n else window.VISA_SDK?.buildClientProfile?.(this.schemesConfig.visa.srciDpaId);\n }\n this.onTimeout?.(timeoutError);\n }\n\n /**\n * Based on the given 'idToken', this method goes through each SRCi SDK and fetches the shopper\n * profile with his cards.\n */\n private async getShopperProfile(idTokens: string[]): Promise<void> {\n return new Promise((resolve, reject) => {\n const srcProfilesPromises = this.sdks.map(sdk => sdk.getSrcProfile(idTokens));\n\n void Promise.allSettled(srcProfilesPromises).then(srcProfilesResponses => {\n if (srcProfilesResponses.every(isRejected)) {\n reject(srcProfilesResponses[0].reason);\n }\n\n const createProfileWithScheme = (promiseResult: PromiseSettledResult<SrcProfile>, index) =>\n isFulfilled(promiseResult) && { ...promiseResult.value, scheme: this.sdks[index].schemeName };\n\n const profilesWithScheme: SrcProfileWithScheme[] = srcProfilesResponses.map(createProfileWithScheme).filter(profile => !!profile);\n\n this.shopperCards = createShopperCardsList(profilesWithScheme);\n resolve();\n });\n });\n }\n\n /**\n * Calls the 'isRecognized()' method of each SRC SDK in order to verify if the shopper is\n * recognized on the device. The shopper is recognized if he/she has the Cookies stored\n * on their browser\n */\n private verifyIfShopperIsRecognized(): Promise<SrciIsRecognizedResponse> {\n return new Promise((resolve, reject) => {\n const promises = this.sdks.map(sdk => {\n const isRecognizedPromise = executeWithTimeout<SrciIsRecognizedResponse>(\n () => sdk.isRecognized(),\n 5000,\n new TimeoutError({\n source: 'isRecognized',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n\n return isRecognizedPromise\n .then(response => {\n if (response.recognized) resolve(response);\n })\n .catch(error => {\n reject(error);\n });\n });\n\n // If the 'resolve' didn't happen until this point, then shopper is not recognized\n void Promise.allSettled(promises).then(() => {\n resolve({ recognized: false });\n });\n });\n }\n\n private initiateSdks(): Promise<void[]> {\n const initPromises = this.sdks.map(sdk => {\n const cfg = this.schemesConfig[sdk.schemeName];\n\n return executeWithTimeout<void>(\n () => sdk.init(cfg, this.srciTransactionId),\n 5000,\n new TimeoutError({\n source: 'init',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n });\n\n return Promise.all(initPromises);\n }\n}\n\nexport default ClickToPayService;\n"],"names":["CtpState","ClickToPayService","sdkLoader","schemesConfig","shopperIdentity","environment","onTimeout","srciTransactionId","uuidv4","sdks","validationSchemeSdk","stateSubscriber","state","shopperCards","identityValidationData","storeCookies","constructor","this","shopperAccountFound","includes","schemes","updateStoreCookiesConsent","shouldStore","initialize","setState","load","initiateSdks","recognized","idTokens","verifyIfShopperIsRecognized","getShopperProfile","isEnrolled","verifyIfShopperIsEnrolled","error","SrciError","reason","TimeoutError","handleTimeout","console","warn","toString","subscribeOnStateChange","callback","startIdentityValidation","Error","maskedValidationChannel","initiateIdentityValidation","maskedShopperContact","replace","selectedNetwork","SchemeNames","schemeName","finishIdentityValidation","otpCode","validationToken","completeIdentityValidation","idToken","checkout","card","checkoutSdk","find","sdk","scheme","checkoutResponse","srcDigitalCardId","srcCorrelationId","isDcfPopupEmbedded","windowRef","window","frames","CTP_IFRAME_NAME","complianceSettings","complianceResources","complianceType","uri","dcfActionCode","AdyenCheckoutError","createCheckoutPayloadBasedOnScheme","logout","logoutPromises","map","unbindAppInstance","Promise","all","shopperEmail","resolve","reject","lookupPromises","executeWithTimeout","identityLookup","identityValue","type","source","isTimeoutTriggeredBySchemeSdk","then","response","consumerPresent","setSdkForPerformingShopperIdentityValidation","catch","allSettled","timeoutError","setCorrelationId","VISA_SDK","correlationId","buildClientProfile","visa","srciDpaId","srcProfilesPromises","getSrcProfile","srcProfilesResponses","every","isRejected","profilesWithScheme","promiseResult","index","isFulfilled","value","filter","profile","createShopperCardsList","promises","isRecognized","initPromises","cfg","init"],"mappings":"ueAsBYA,SAAAA,+KAAAA,CAAAA,IAAAA,EAAAA,CAAAA,IAUZ,MAAMC,EACeC,UACAC,cACAC,gBACAC,YAEAC,UAKAC,kBAA4BC,IAErCC,KACAC,oBAAqC,KACrCC,gBAEDC,MAAgC,OAChCC,aAA8B,KAC9BC,uBAAiD,KAKjDC,cAAe,EAEtBC,WAAAA,CACIb,EACAD,EACAG,EACAD,EACAE,GAEAW,KAAKf,UAAYA,EACjBe,KAAKd,cAAgBA,EACrBc,KAAKb,gBAAkBA,EACvBa,KAAKZ,YAAcA,EACnBY,KAAKX,UAAYA,CACrB,CAEA,uBAAWY,GACP,MAAO,8BAA6CC,SAASF,KAAKL,MACtE,CAEA,WAAWQ,GACP,OAAOH,KAAKf,UAAUkB,OAC1B,CAEOC,yBAAAA,CAA0BC,GAC7BL,KAAKF,aAAeO,CACxB,CAEA,gBAAaC,GACTN,KAAKO,SAAQ,WAEb,IACIP,KAAKR,WAAaQ,KAAKf,UAAUuB,KAAKR,KAAKZ,mBACrCY,KAAKS,eAEX,MAAMC,WAAEA,GAAa,EAAKC,SAAEA,EAAW,YAAeX,KAAKY,8BAE3D,GAAIF,EAGA,aAFMV,KAAKa,kBAAkBF,QAC7BX,KAAKO,SAAQ,SAIjB,IAAKP,KAAKb,gBAEN,YADAa,KAAKO,SAAQ,gBAIjB,MAAMO,WAAEA,SAAqBd,KAAKe,0BAA0Bf,KAAKb,iBACjE,GAAI2B,EAEA,YADAd,KAAKO,SAAQ,qBAIjBP,KAAKO,SAAQ,eACjB,CAAE,MAAOS,GACDA,aAAkBC,GAA+B,oBAAlBD,GAAOE,QAAiCF,aAAiBG,EACxFnB,KAAKoB,cAAcJ,GACZA,aAAiBC,EACxBI,QAAQC,KAAK,sCAAsCN,EAAMO,cAEzDF,QAAQC,KAAKN,GAGjBhB,KAAKO,SAAQ,eACjB,CACJ,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BAActE,CAAkBF,GAC5B,OAAO,IAAIsD,SAAQ,CAACG,EAASC,KACzB,MAAMqB,EAAsB1F,KAAKR,KAAKuE,KAAInB,GAAOA,EAAI+C,cAAchF,KAE9DsD,QAAQiB,WAAWQ,GAAqBb,MAAKe,IAC1CA,EAAqBC,MAAMC,IAC3BzB,EAAOuB,EAAqB,GAAG1E,QAGnC,MAGM6E,EAA6CH,EAAqB7B,KAHxC,CAACiC,EAAiDC,IAC9EC,EAAYF,IAAkB,IAAKA,EAAcG,MAAOtD,OAAQ7C,KAAKR,KAAKyG,GAAO/D,cAEgBkE,QAAOC,KAAaA,IAEzHrG,KAAKJ,aAAe0G,EAAuBP,GAC3C3B,GAAAA,GACJ,GAER,CAOA,2BAAAxD,GACI,OAAO,IAAIqD,SAAQ,CAACG,EAASC,KACzB,MAAMkC,EAAWvG,KAAKR,KAAKuE,KAAInB,GACC2B,GACxB,IAAM3B,EAAI4D,gBACV,IACA,IAAIrF,EAAa,CACbwD,OAAQ,eACR9B,OAAQD,EAAIV,WACZ0C,+BAA+B,KAKlCC,MAAKC,IACEA,EAASpE,YAAY0D,EAAQU,EAAAA,IAEpCG,OAAMjE,IACHqD,EAAOrD,EAAAA,MAKdiD,QAAQiB,WAAWqB,GAAU1B,MAAK,KACnCT,EAAQ,CAAE1D,YAAY,GAAM,GAChC,GAER,CAEQD,YAAAA,GACJ,MAAMgG,EAAezG,KAAKR,KAAKuE,KAAInB,IAC/B,MAAM8D,EAAM1G,KAAKd,cAAc0D,EAAIV,YAEnC,OAAOqC,GACH,IAAM3B,EAAI+D,KAAKD,EAAK1G,KAAKV,oBACzB,IACA,IAAI6B,EAAa,CACbwD,OAAQ,OACR9B,OAAQD,EAAIV,WACZ0C,+BAA+B,IACnC,IAIR,OAAOX,QAAQC,IAAIuC,EACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-with-timeout.js","sources":["../../../../../../src/components/internal/ClickToPay/services/execute-with-timeout.ts"],"sourcesContent":["import TimeoutError from '../errors/TimeoutError';\n\nfunction executeWithTimeout<T>(asyncFn: () => Promise<T>, timer: number, error: TimeoutError): Promise<T> {\n let timeout = null;\n const wait = (seconds: number) =>\n new Promise<T>((_, reject) => {\n timeout = setTimeout(() => reject(error), seconds);\n });\n return Promise.race<T>([asyncFn(), wait(timer)])\n .then(value => {\n clearTimeout(timeout);\n return value;\n })\n .catch(error => {\n clearTimeout(timeout);\n throw error;\n });\n}\nexport { executeWithTimeout };\n"],"names":["executeWithTimeout","asyncFn","timer","error","timeout","Promise","race","seconds","_","reject","setTimeout","then","value","clearTimeout","catch"],"mappings":"AAEA,SAASA,EAAsBC,EAA2BC,EAAeC,GACrE,IAAIC,EAAU,KAKd,OAAOC,QAAQC,KAAQ,CAACL,KAJVM,EAI0BL,EAHpC,IAAIG,SAAW,CAACG,EAAGC,KACfL,EAAUM,YAAW,IAAMD,EAAON,IAAQI,EAAAA,OAG7CI,MAAKC,IACFC,aAAaT,GACNQ,KAEVE,OAAMX,IAEH,MADAU,aAAaT,GACPD,CAAAA,IAXD,IAACI,CAalB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import { h, RefCallback } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends h.JSX.HTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n}\n\nexport default function InputBase({ setRef, ...props }: InputBaseProps) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: h.JSX.TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n const handleKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n const handleKeyUp = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: h.JSX.TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...newProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...newProps}\n aria-required={newProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n spellCheck={spellCheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellCheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","newProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"uSA8Be,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,GACfC,IACGnB,EAAMoB,QAAQD,EAAAA,GAElB,CAACnB,EAAMoB,
|
|
1
|
+
{"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import { h, RefCallback } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends h.JSX.HTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n}\n\nexport default function InputBase({ setRef, ...props }: InputBaseProps) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: h.JSX.TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: h.JSX.TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...newProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...newProps}\n aria-required={newProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n spellCheck={spellCheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellCheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","newProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"uSA8Be,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,GACfC,IACGnB,EAAMoB,QAAQD,EAAAA,GAElB,CAACnB,EAAMoB,UAULC,EAAiBH,GAClBC,IACOnB,GAAOsB,YAAYtB,EAAMsB,WAAWH,EAAAA,GAE5C,CAACnB,GAAOsB,aASNC,EAAcL,GACfC,IACOnB,GAAOwB,SAASxB,EAAMwB,QAAQL,EAAAA,GAEtC,CAACnB,GAAOwB,UAGNC,EAAaP,GACdC,IACGnB,GAAO0B,gBAAgBP,GAEnBnB,EAAM2B,aACLR,EAAMS,OAA4BC,MAAQV,EAAOS,OAA4BC,MAAMC,QAGxF9B,GAAO+B,SAASZ,EAAAA,GAEpB,CAACnB,EAAM+B,OAAQ/B,EAAM0B,gBAGnBM,EAAcd,GACfC,IACGnB,GAAOiC,iBAAiBd,KAE5B,CAACnB,EAAMiC,iBAGLC,EAAkBC,EAC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