@adyen/adyen-web 6.26.0 → 6.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adyen.css +1 -1
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +15 -15
- package/dist/es/adyen.css +1 -1
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ANCV/ANCV.js +1 -1
- package/dist/es/components/ANCV/ANCV.js.map +1 -1
- package/dist/es/components/Ach/Ach.js +1 -1
- package/dist/es/components/Ach/Ach.js.map +1 -1
- package/dist/es/components/Blik/Blik.js +1 -1
- package/dist/es/components/Blik/Blik.js.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
- package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es/components/Klarna/constants.js +1 -1
- package/dist/es/components/Klarna/constants.js.map +1 -1
- package/dist/es/components/MBWay/MBWay.js +1 -1
- package/dist/es/components/MBWay/MBWay.js.map +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es/components/PayTo/PayTo.js +1 -1
- package/dist/es/components/PayTo/PayTo.js.map +1 -1
- package/dist/es/components/Pix/Pix.js +1 -1
- package/dist/es/components/Pix/Pix.js.map +1 -1
- package/dist/es/components/UPI/UPI.js +1 -1
- package/dist/es/components/UPI/UPI.js.map +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
- package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
- package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
- package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
- package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/core/Errors/SRPanel.js +1 -1
- package/dist/es/core/Errors/SRPanel.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/index.d.ts +15 -15
- package/dist/es/utils/Script.js +1 -1
- package/dist/es/utils/Script.js.map +1 -1
- package/dist/es-legacy/adyen.css +1 -1
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
- package/dist/es-legacy/components/Ach/Ach.js +1 -1
- package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
- package/dist/es-legacy/components/Blik/Blik.js +1 -1
- package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es-legacy/components/Klarna/constants.js +1 -1
- package/dist/es-legacy/components/Klarna/constants.js.map +1 -1
- package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
- package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
- package/dist/es-legacy/components/Pix/Pix.js +1 -1
- package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
- package/dist/es-legacy/components/UPI/UPI.js +1 -1
- package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
- package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
- package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
- package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/utils/Script.js +1 -1
- package/dist/es-legacy/utils/Script.js.map +1 -1
- package/package.json +1 -1
- package/styles/adyen.css +1 -1
|
@@ -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';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\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
|
|
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';\nimport { getErrorMessage } from '../../../../../../utils/getErrorMessage';\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 const getOtpErrorMessage = useCallback(() => {\n if (!isOtpFielDirty) return null;\n\n return resendOtpError || props.errorMessage || getErrorMessage(i18n, errors.otp, i18n.get('ctp.otp.fieldLabel'));\n }, [isOtpFielDirty, resendOtpError, props.errorMessage, errors.otp, i18n]);\n\n return (\n <div className={'adyen-checkout-ctp__otp-field-wrapper'}>\n <Field name=\"oneTimePassword\" label={i18n.get('ctp.otp.fieldLabel')} errorMessage={getOtpErrorMessage()} classNameModifiers={['otp']}>\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 <div className={'adyen-checkout-ctp__otp-resend-code-wrapper'}>\n <CtPResendOtpLink disabled={props.isValidatingOtp} onError={handleOnResendOtpError} onResendCode={handleOnResendOtp} />\n </div>\n </div>\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","getOtpErrorMessage","errorMessage","getErrorMessage","h","div","className","Field","name","label","classNameModifiers","InputText","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress","setRef","ref","CtPResendOtpLink","isValidatingOtp","onError"],"mappings":"6pBAiCA,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,EAAY,KAC9BD,GAAmB,GACnBd,KACD,CAACA,IAKJgB,EAAU,KACFjB,EAAKkB,KAAKH,GAAmB,IAClC,CAACf,EAAKkB,MAETD,EAAU,MACDvB,GAAuBmB,EAASM,SACjCN,EAASM,QAAQC,SAEtB,CAACP,EAASM,QAASzB,IAEtBuB,EAAU,KACNP,EAAoBS,QAAQP,cAAgBA,EAC5CtB,EAAM+B,mBAAmBX,EAAoBS,UAC9C,CAACP,EAAetB,EAAM+B,qBAEzB,MAAMC,EAAoBN,EAAY,KAClCX,EAAQ,MAAO,IACfR,EAAkB,MACbH,GACDmB,EAASM,QAAQC,QAErB9B,EAAMiC,gBACP,CAACjC,EAAMiC,aAAcV,EAASM,QAASzB,IAEpC8B,EAAyBR,EAC1BS,IACG,MAAMC,EAAUnC,EAAKoC,IAAI,cAAcF,KACnCC,GAAS7B,EAAkB6B,IAEnC,CAACnC,IAGCqC,EAAmBZ,EACpBa,IACqB,UAAdA,EAAMC,KACDxC,EAAMyC,gBAGnB,CAACzC,EAAMyC,eAGXd,EAAU,KACN3B,EAAM0C,SAAS,CAAEhC,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAEjB,MAAM8B,EAAqBjB,EAAY,IAC9BF,EAEElB,GAAkBN,EAAM4C,cAAgBC,EAAgB5C,EAAMY,EAAOe,IAAK3B,EAAKoC,IAAI,uBAF9D,KAG7B,CAACb,EAAgBlB,EAAgBN,EAAM4C,aAAc/B,EAAOe,IAAK3B,IAEpE,OACI6C,EAACC,MAAAA,CAAIC,UAAW,yCACZF,EAACG,EAAAA,CAAMC,KAAK,kBAAkBC,MAAOlD,EAAKoC,IAAI,sBAAuBO,aAAcD,IAAsBS,mBAAoB,CAAC,QAC1HN,EAACO,EAAAA,CACGH,KAAM,MACNI,YAAa,MACbC,YAAY,EACZC,MAAO9C,EAAKkB,IACZ6B,SAAUzD,EAAMyD,SAChBC,QAASjD,EAAgB,MAAO,SAChCkD,OAAQlD,EAAgB,MAAO,QAC/BmD,WAAYtB,EACZuB,OAASC,IACLvC,EAASM,QAAUiC,MAI/BhB,EAACC,MAAAA,CAAIC,UAAW,+CACZF,EAACiB,EAAAA,CAAiBN,SAAUzD,EAAMgE,gBAAiBC,QAAS/B,EAAwBD,aAAcD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";function
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{stopPropagationForActionKeys as o}from"../Button/stopPropagationForActionKeys.js";function n({classNameModifiers:n=[],selectedValue:a,disabled:s=!1,options:r,onChange:l}){return r&&0!==r.length?e("div",{className:t("adyen-checkout__segmented-control",{"adyen-checkout__segmented-control--disabled":s},...n.map(e=>`adyen-checkout__segmented-control--${e}`)),role:"group"},r.map(({label:n,value:r,controls:c,htmlProps:d})=>e("button",{disabled:s,key:r,onClick:e=>l(r,e),onKeyPress:o,onKeyDown:o,className:t("adyen-checkout__segmented-control-segment",{"adyen-checkout__segmented-control-segment--selected":a===r}),"aria-controls":c,"aria-expanded":a===r,type:"button",...d},n))):null}export{n as default};
|
|
2
2
|
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport './SegmentedControl.scss';\n\nexport interface SegmentedControlOption<T> {\n label: string;\n value: T;\n id: string;\n controls: string;\n htmlProps?: {};\n}\n\nexport type SegmentedControlOptions<T> = Array<SegmentedControlOption<T>>;\n\nexport interface SegmentedControlProps<T> {\n classNameModifiers?: string[];\n selectedValue: T;\n disabled?: boolean;\n options: SegmentedControlOptions<T>;\n onChange(value: T, event: MouseEvent): void;\n}\n\n/**\n *\n * example:\n * <SegmentedControl\n * onChange={(value) = setMode(value)}\n * selectedValue={mode}\n * disabled={status === 'loading'}\n * classNameModifiers={['css-class']}\n * options={segmentedControlOptions}\n * />\n *\n * @param classNameModifiers\n * @param selectedValue\n * @param disabled\n * @param options\n * @param onChange\n * @constructor\n */\nfunction SegmentedControl<T>({ classNameModifiers = [], selectedValue, disabled = false, options, onChange }: SegmentedControlProps<T>) {\n if (!options || options.length === 0) {\n return null;\n }\n\n return (\n <div\n className={cx(\n 'adyen-checkout__segmented-control',\n { 'adyen-checkout__segmented-control--disabled': disabled },\n ...classNameModifiers.map(modifier => `adyen-checkout__segmented-control--${modifier}`)\n )}\n role=\"group\"\n >\n {options.map(({ label, value, controls, htmlProps }: SegmentedControlOption<T>) => (\n <button\n disabled={disabled}\n key={value}\n onClick={(event: MouseEvent) => onChange(value, event)}\n className={cx('adyen-checkout__segmented-control-segment', {\n 'adyen-checkout__segmented-control-segment--selected': selectedValue === value\n })}\n aria-controls={controls}\n aria-expanded={selectedValue === value}\n type=\"button\"\n {...htmlProps}\n >\n {label}\n </button>\n ))}\n </div>\n );\n}\n\nexport default SegmentedControl;\n"],"names":["SegmentedControl","classNameModifiers","selectedValue","disabled","options","onChange","length","h","div","className","cx","map","modifier","role","label","value","controls","htmlProps","button","key","onClick","event","aria-controls","aria-expanded","type"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport './SegmentedControl.scss';\nimport { stopPropagationForActionKeys } from '../Button/stopPropagationForActionKeys';\n\nexport interface SegmentedControlOption<T> {\n label: string;\n value: T;\n id: string;\n controls: string;\n htmlProps?: {};\n}\n\nexport type SegmentedControlOptions<T> = Array<SegmentedControlOption<T>>;\n\nexport interface SegmentedControlProps<T> {\n classNameModifiers?: string[];\n selectedValue: T;\n disabled?: boolean;\n options: SegmentedControlOptions<T>;\n onChange(value: T, event: MouseEvent): void;\n}\n\n/**\n *\n * example:\n * <SegmentedControl\n * onChange={(value) = setMode(value)}\n * selectedValue={mode}\n * disabled={status === 'loading'}\n * classNameModifiers={['css-class']}\n * options={segmentedControlOptions}\n * />\n *\n * @param classNameModifiers\n * @param selectedValue\n * @param disabled\n * @param options\n * @param onChange\n * @constructor\n */\nfunction SegmentedControl<T>({ classNameModifiers = [], selectedValue, disabled = false, options, onChange }: SegmentedControlProps<T>) {\n if (!options || options.length === 0) {\n return null;\n }\n\n return (\n <div\n className={cx(\n 'adyen-checkout__segmented-control',\n { 'adyen-checkout__segmented-control--disabled': disabled },\n ...classNameModifiers.map(modifier => `adyen-checkout__segmented-control--${modifier}`)\n )}\n role=\"group\"\n >\n {options.map(({ label, value, controls, htmlProps }: SegmentedControlOption<T>) => (\n <button\n disabled={disabled}\n key={value}\n onClick={(event: MouseEvent) => onChange(value, event)}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n className={cx('adyen-checkout__segmented-control-segment', {\n 'adyen-checkout__segmented-control-segment--selected': selectedValue === value\n })}\n aria-controls={controls}\n aria-expanded={selectedValue === value}\n type=\"button\"\n {...htmlProps}\n >\n {label}\n </button>\n ))}\n </div>\n );\n}\n\nexport default SegmentedControl;\n"],"names":["SegmentedControl","classNameModifiers","selectedValue","disabled","options","onChange","length","h","div","className","cx","map","modifier","role","label","value","controls","htmlProps","button","key","onClick","event","onKeyPress","stopPropagationForActionKeys","onKeyDown","aria-controls","aria-expanded","type"],"mappings":"2MAyCA,SAASA,GAAoBC,mBAAEA,EAAqB,GAAEC,cAAEA,EAAaC,SAAEA,GAAW,EAAKC,QAAEA,EAAOC,SAAEA,IAC9F,OAAKD,GAA8B,IAAnBA,EAAQE,OAKpBC,EAACC,MAAAA,CACGC,UAAWC,EACP,oCACA,CAAE,8CAA+CP,MAC9CF,EAAmBU,IAAIC,GAAY,sCAAsCA,MAEhFC,KAAK,SAEJT,EAAQO,IAAI,EAAGG,QAAOC,QAAOC,WAAUC,eACpCV,EAACW,SAAAA,CACGf,SAAUA,EACVgB,IAAKJ,EACLK,QAAUC,GAAsBhB,EAASU,EAAOM,GAEhDC,WAAYC,EACZC,UAAWD,EACXd,UAAWC,EAAG,4CAA6C,CACvD,sDAAuDR,IAAkBa,IAE7EU,gBAAeT,EACfU,gBAAexB,IAAkBa,EACjCY,KAAK,YACDV,GAEHH,KA5BN,IAiCf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import t,{NETWORK_ERROR as s}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as i}from"../../../utils/hasOwnProperty.js";import n from"../BaseElement/BaseElement.js";import o from"../PayButton/PayButton.js";import{assertIsDropin as r,getRegulatoryDefaults as a,sanitizeResponse as h,verifyPaymentDidNotFail as l,cleanupFinalResult as d}from"./utils.js";import{AnalyticsErrorEvent as m,ErrorEventType as p}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as c,InfoEventType as u}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as y,LogEventType as f}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import R from"../../../core/Errors/CancelError.js";import{CoreProvider as b}from"../../../core/Context/CoreProvider.js";function A(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import t,{NETWORK_ERROR as s}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as i}from"../../../utils/hasOwnProperty.js";import n from"../BaseElement/BaseElement.js";import o from"../PayButton/PayButton.js";import{assertIsDropin as r,getRegulatoryDefaults as a,sanitizeResponse as h,verifyPaymentDidNotFail as l,cleanupFinalResult as d}from"./utils.js";import{AnalyticsErrorEvent as m,ErrorEventType as p}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as c,InfoEventType as u}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as y,LogEventType as f}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import R from"../../../core/Errors/CancelError.js";import{CoreProvider as b}from"../../../core/Context/CoreProvider.js";import P from"../../../core/Errors/SRPanelProvider.js";function A(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class E extends n{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(e?.originalAction)return;const t=new c({type:u.rendered,component:this.type,configData:{...e,showPayButton:this.props.showPayButton},...e?.oneClick&&{isStoredPaymentMethod:!0}});this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return e?.storedPaymentMethodId?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(e?.type,e?.paymentMethodId)}buildElementProps(e){const t={showPayButton:!0,...this.core.getCorePropsForComponent(),...this.getPaymentMethodConfigFromResponse(e),...e},s=r(this);this.props=this.formatProps({...this.constructor.defaultProps,...a(this.core.options.countryCode,s),...t})}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){return t?this.core.paymentMethodsResponse.findById(t):this.core.paymentMethodsResponse?.find(e||this.constructor.type)}storeElementRefOnCore(e){e?.isDropin||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state={...this.state,...e},this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(e,t){return this.elementRef?.setStatus(e,t),this}setStatus(e,t){return this.componentRef?.setStatus&&this.componentRef.setStatus(e,t),this}onChange(){this.props.onChange?.({data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(h).then(l).then(this.handleResponse).catch(e=>{e instanceof R?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new R("beforeSubmitRejected"))})):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new t("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new y({component:this.type,type:f.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const s=new y({component:this.type,type:f.submit,message:"Shopper clicked pay"});this.submitAnalytics(s);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof t?this.handleError(e):this.handleError(new t("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(h).then(l).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new t("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof t?this.handleError(e):this.handleError(new t("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(i(e,"action")&&i(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,{...this.elementRef.props,...t});return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){this.props?.onActionHandled?.({originalAction:this.props.originalAction,...e})}handleResponse(e){e.action?this.elementRef.handleAction(e.action):e.order?.remainingAmount?.value>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyPress(e){"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(document?.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){const e=this.props.paymentMethodType||this.type;return this.props.icon??this.resources.getImage()(e)}get displayName(){const e=this.core.paymentMethodsResponse?.paymentMethods?.find(e=>e.type===this.type);return this.props.name||e?.name||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,s){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest({...e&&{order:{orderData:e.orderData,pspReference:e.pspReference}},locale:this.core.options.locale},{resolve:t,reject:s})}).catch(e=>{this.handleError(new t("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(t=>this.core.update({...t&&{paymentMethodsResponse:t},order:e,amount:e?e.remainingAmount:s}))}render(){return e(b,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(P,{srPanel:this.srPanel},this.componentToRender()))}constructor(t,i){super(t,i),A(this,"componentRef",void 0),A(this,"resources",void 0),A(this,"elementRef",void 0),A(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===s&&e.options.code){const t=new m({component:this.type,errorType:p.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),A(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{this.props.onOrderUpdated?.({order:t})})}),A(this,"handleFailedResult",e=>{r(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),d(e),this.props.onPaymentFailed?.(e,this.elementRef)}),A(this,"handleSuccessResult",e=>{r(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),d(e),this.props.onPaymentCompleted?.(e,this.elementRef)}),A(this,"setComponentRef",e=>{this.componentRef=e}),A(this,"payButton",t=>e(o,{...t,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,onClick:this.submit})),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.elementRef=i&&i.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(i),this.reportIntegrationFlavor()}}A(E,"type",void 0),A(E,"txVariants",[]);export{E as UIElement,E as default};
|
|
2
2
|
//# sourceMappingURL=UIElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { Resources } from '../../../core/Context/Resources';\nimport AdyenCheckoutError, { NETWORK_ERROR } from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\n\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventType } from '../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AnalyticsLogEvent, LogEventType } from '../../../core/Analytics/events/AnalyticsLogEvent';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\nimport type { AdditionalDetailsData, CoreConfiguration, ICore } from '../../../core/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentMethod\n} from '../../../types/global-types';\nimport type { IDropin } from '../../Dropin/types';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementProps, UIElementStatus } from './types';\nimport type { IAnalytics } from '../../../core/Analytics/Analytics';\n\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport { SRPanel } from '../../../core/Errors/SRPanel';\nimport './UIElement.scss';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n protected componentRef: any;\n\n protected resources: Resources;\n\n public elementRef: UIElement;\n\n public static type = undefined;\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n\n this.onEnterKeyPressed = this.onEnterKeyPressed.bind(this);\n this.onActionHandled = this.onActionHandled.bind(this);\n\n this.createBeforeRenderHook(props);\n this.reportIntegrationFlavor();\n }\n\n /**\n * Creates a hook tied to render() method. This hook is called every time render() is invoked.\n * Currently useful for Analytics\n *\n * @param configSetByMerchant\n * @private\n */\n private createBeforeRenderHook(configSetByMerchant: P): void {\n const originalRender = this.render;\n\n this.render = (...args: any[]) => {\n this.beforeRender(configSetByMerchant);\n return originalRender.apply(this, args);\n };\n }\n\n protected beforeRender(configSetByMerchant?: P): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && { isStoredPaymentMethod: true })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n protected reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('components');\n }\n\n get analytics(): IAnalytics {\n return this.core.modules.analytics;\n }\n\n get srPanel(): SRPanel {\n return this.core.modules.srPanel;\n }\n\n private getPaymentMethodConfigFromResponse(componentProps: P) {\n if (componentProps?.storedPaymentMethodId) return this.getStoredPaymentMethodDetails(componentProps.storedPaymentMethodId);\n return this.getPaymentMethodFromPaymentMethodsResponse(componentProps?.type, componentProps?.paymentMethodId);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n\n const paymentMethodFromResponse = this.getPaymentMethodConfigFromResponse(componentProps);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodFromResponse,\n ...componentProps\n };\n\n const isDropinInstance = assertIsDropin(this as unknown as IDropin);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropinInstance), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected getStoredPaymentMethodDetails(storedPaymentMethodId: string) {\n return this.core.paymentMethodsResponse.findStoredPaymentMethod(storedPaymentMethodId);\n }\n\n /**\n * Get the payment method from the paymentMethodsResponse\n *\n * @param type - The type of the payment method to get. (This prop is passed by Drop-in OR Standalone components containing the property 'type' as part of their configuration)\n * @param paymentMethodId - Unique internal payment method ID\n */\n protected getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n return this.core.paymentMethodsResponse?.find(type || this.constructor['type']);\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n /**\n * elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx\n */\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n /**\n * componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx\n */\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n protected override submitAnalytics(event: AbstractAnalyticsEvent) {\n this.analytics.sendAnalytics(event);\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n });\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) =>\n this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject: () => reject(new CancelError('beforeSubmitRejected'))\n })\n )\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n }\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIO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uvSknPKBID8sdOXUStA0crmO322FYjDqh1n6FG+D7+OJSayNsXIz6Zoy0eFn4HbT8nt8L2X2tdzkMayCYHXRwKh13Xyleqxt4WoEZmhwTmB3p9d1F0SylWnjcC6o/DnshJ9mMW/8D3oWS30Z7BwRODqKGVahRD0YGRzwMbVnEe5JFRfNvJZdLGl35L9632DVmuFQ0lr/8WNL/NrAJNtI6PXrZMNiza0/omPwPfe5ZYuD1Jgq59TX4h9d+3fdkArcJYL7AdoMZON1YEiWY5EzazQwtHd9yzdty9ZHPxAfuOfCh4OhbhFNp+v5YQ+PzKZ+UpM1VxV863+9XgWEURPNvX7qq1cpUSRzrSGq01QBBM3MKzRh5mAgqIdXgtl7L0EXAep0MECc7QY0/o3tW3VR8eEJGsSzrNxpFItqj0SEaIWo25dRfkl5zuw47GQrN9Qzxl2WV3A38MQPUqFtIr/71Rjkphgg49ZGWEYCwgFmm8jJc2/5qTabSGk4bzwiETCTzeydq30bUGqCwglj8CrFViAuQeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n this.handleAdditionalDetails(state);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (error.name === NETWORK_ERROR && error.options.code) {\n const event = new AnalyticsErrorEvent({\n component: this.type,\n errorType: ErrorEventType.apiError,\n code: error.options.code\n });\n\n this.submitAnalytics(event);\n }\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected onActionHandled(actionHandledObj: ActionHandledReturnObject) {\n this.props?.onActionHandled?.({ originalAction: this.props.originalAction, ...actionHandledObj });\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session ? this.core.update({ order }) : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n void updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * Expected to be called after sanitizeResponse has been run on the raw payment response\n *\n * @param response -\n */\n protected handleResponse(response: PaymentResponseData): void {\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n e.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n\n this.onEnterKeyPressed(document?.activeElement, this);\n }\n }\n\n /**\n * Handle Enter key pressed from a UIElement (called via handleKeyPress)\n * @param obj\n */\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n if (this.props.onEnterKeyPressed) {\n this.props.onEnterKeyPressed(activeElement, component);\n } else {\n (activeElement as HTMLElement).blur();\n this.submit();\n }\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protected _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonFunctionProps) => {\n return <PayButton {...props} amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<void | PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return resolve();\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n\n protected abstract componentToRender(): h.JSX.Element;\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources} analytics={this.analytics}>\n {this.componentToRender()}\n </CoreProvider>\n );\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","createBeforeRenderHook","configSetByMerchant","originalRender","this","render","args","beforeRender","apply","originalAction","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","configData","showPayButton","props","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","reportIntegrationFlavor","sendFlavor","core","modules","srPanel","getPaymentMethodConfigFromResponse","componentProps","storedPaymentMethodId","getStoredPaymentMethodDetails","getPaymentMethodFromPaymentMethodsResponse","paymentMethodId","buildElementProps","finalProps","getCorePropsForComponent","isDropinInstance","assertIsDropin","formatProps","constructor","getRegulatoryDefaults","options","countryCode","paymentMethodsResponse","findStoredPaymentMethod","findById","find","storeElementRefOnCore","isDropin","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","setElementStatus","status","elementRef","setStatus","data","isValid","errors","valid","submitAnalytics","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","session","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","AnalyticsLogEvent","LogEventType","message","submitPayment","error","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","unmount","mount","_node","onActionHandled","actionHandledObj","response","order","remainingAmount","value","handleOrder","handleSuccessResult","handleKeyPress","key","code","preventDefault","onEnterKeyPressed","document","activeElement","blur","updateParent","update","icon","paymentMethodType","resources","getImage","displayName","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","amount","onPaymentMethodsRequest","orderData","pspReference","locale","h","CoreProvider","i18n","loadingContext","componentToRender","checkout","super","_define_property","NETWORK_ERROR","AnalyticsErrorEvent","errorType","ErrorEventType","apiError","onError","onOrderUpdated","result","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","onPaymentCompleted","setComponentRef","ref","payButton","PayButton","secondaryAmount","onClick","register","bind","undefined","txVariants"],"mappings":"u/BAmCO,MAAeA,UAA6DC,EAmDvEC,sBAAAA,CAAuBC,GAC3B,MAAMC,EAAiBC,KAAKC,OAE5BD,KAAKC,OAAS,IAAIC,KACdF,KAAKG,aAAaL,GACXC,EAAeK,MAAMJ,KAAME,GAE1C,CAEUC,YAAAA,CAAaL,GAEnB,GAAIA,GAAqBO,eACrB,OAGJ,MAAMC,EAAQ,IAAIC,EAAmB,CACjCC,KAAMC,EAAcC,SACpBC,UAAWX,KAAKQ,KAChBI,WAAY,IAAKd,EAAqBe,cAAeb,KAAKc,MAAMD,kBAC5Df,GAAqBiB,UAAY,CAAEC,uBAAuB,KAGlEhB,KAAKiB,UAAUC,cAAcZ,EACjC,CAEUa,uBAAAA,GACDnB,KAAKiB,UAAUG,WAAW,aACnC,CAEA,aAAIH,GACA,OAAOjB,KAAKqB,KAAKC,QAAQL,SAC7B,CAEA,WAAIM,GACA,OAAOvB,KAAKqB,KAAKC,QAAQC,OAC7B,CAEQC,kCAAAA,CAAmCC,GACvC,OAAIA,GAAgBC,sBAA8B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MACnDA,KAAK2F,0BAA4B3F,KAAK2F,0BAA0B2E,KAAKtK,MACrEA,KAAKgF,wBAA0BhF,KAAKgF,wBAAwBsF,KAAKtK,MAEjEA,KAAK0D,WAAc5C,GAASA,EAAM4C,YAAe1D,KACjDA,KAAK4H,UAAY5H,KAAKc,MAAMQ,QAAUtB,KAAKc,MAAMQ,QAAQsG,eAAY2C,EAErEvK,KAAK4C,sBAAsB5C,KAAKc,OAEhCd,KAAKoH,kBAAoBpH,KAAKoH,kBAAkBkD,KAAKtK,MACrDA,KAAKwG,gBAAkBxG,KAAKwG,gBAAgB8D,KAAKtK,MAEjDA,KAAKH,uBAAuBiB,GAC5Bd,KAAKmB,yBACT,EAnCA+H,EAPkBvJ,EAOJa,YAAO+J,GAKrBrB,EAZkBvJ,EAYJ6K,aAAuB"}
|
|
1
|
+
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { Resources } from '../../../core/Context/Resources';\nimport AdyenCheckoutError, { NETWORK_ERROR } from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\n\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventType } from '../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AnalyticsInfoEvent, InfoEventType } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { AnalyticsLogEvent, LogEventType } from '../../../core/Analytics/events/AnalyticsLogEvent';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\nimport type { AdditionalDetailsData, CoreConfiguration, ICore } from '../../../core/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentMethod\n} from '../../../types/global-types';\nimport type { IDropin } from '../../Dropin/types';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementProps, UIElementStatus } from './types';\nimport type { IAnalytics } from '../../../core/Analytics/Analytics';\n\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport { SRPanel } from '../../../core/Errors/SRPanel';\nimport './UIElement.scss';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\n\nexport abstract class UIElement<P extends UIElementProps = UIElementProps> extends BaseElement<P> {\n protected componentRef: any;\n\n protected resources: Resources;\n\n public elementRef: UIElement;\n\n public static type = undefined;\n\n /**\n * Defines all txVariants that the Component supports (in case it support multiple ones besides the 'type' one)\n */\n public static txVariants: string[] = [];\n\n constructor(checkout: ICore, props?: P) {\n super(checkout, props);\n\n this.core.register(this.constructor as NewableComponent);\n\n this.submit = this.submit.bind(this);\n this.setState = this.setState.bind(this);\n this.onComplete = this.onComplete.bind(this);\n this.handleAction = this.handleAction.bind(this);\n this.handleOrder = this.handleOrder.bind(this);\n this.handleAdditionalDetails = this.handleAdditionalDetails.bind(this);\n this.handleResponse = this.handleResponse.bind(this);\n this.setElementStatus = this.setElementStatus.bind(this);\n this.submitAnalytics = this.submitAnalytics.bind(this);\n this.makePaymentsCall = this.makePaymentsCall.bind(this);\n this.makeAdditionalDetailsCall = this.makeAdditionalDetailsCall.bind(this);\n this.submitUsingSessionsFlow = this.submitUsingSessionsFlow.bind(this);\n\n this.elementRef = (props && props.elementRef) || this;\n this.resources = this.props.modules ? this.props.modules.resources : undefined;\n\n this.storeElementRefOnCore(this.props);\n\n this.onEnterKeyPressed = this.onEnterKeyPressed.bind(this);\n this.onActionHandled = this.onActionHandled.bind(this);\n\n this.createBeforeRenderHook(props);\n this.reportIntegrationFlavor();\n }\n\n /**\n * Creates a hook tied to render() method. This hook is called every time render() is invoked.\n * Currently useful for Analytics\n *\n * @param configSetByMerchant\n * @private\n */\n private createBeforeRenderHook(configSetByMerchant: P): void {\n const originalRender = this.render;\n\n this.render = (...args: any[]) => {\n this.beforeRender(configSetByMerchant);\n return originalRender.apply(this, args);\n };\n }\n\n protected beforeRender(configSetByMerchant?: P): void {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.oneClick && { isStoredPaymentMethod: true })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n protected reportIntegrationFlavor(): void {\n void this.analytics.sendFlavor('components');\n }\n\n get analytics(): IAnalytics {\n return this.core.modules.analytics;\n }\n\n get srPanel(): SRPanel {\n return this.core.modules.srPanel;\n }\n\n private getPaymentMethodConfigFromResponse(componentProps: P) {\n if (componentProps?.storedPaymentMethodId) return this.getStoredPaymentMethodDetails(componentProps.storedPaymentMethodId);\n return this.getPaymentMethodFromPaymentMethodsResponse(componentProps?.type, componentProps?.paymentMethodId);\n }\n\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n\n const paymentMethodFromResponse = this.getPaymentMethodConfigFromResponse(componentProps);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodFromResponse,\n ...componentProps\n };\n\n const isDropinInstance = assertIsDropin(this as unknown as IDropin);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropinInstance), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\n }\n\n protected getStoredPaymentMethodDetails(storedPaymentMethodId: string) {\n return this.core.paymentMethodsResponse.findStoredPaymentMethod(storedPaymentMethodId);\n }\n\n /**\n * Get the payment method from the paymentMethodsResponse\n *\n * @param type - The type of the payment method to get. (This prop is passed by Drop-in OR Standalone components containing the property 'type' as part of their configuration)\n * @param paymentMethodId - Unique internal payment method ID\n */\n protected getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n return this.core.paymentMethodsResponse?.find(type || this.constructor['type']);\n }\n\n protected storeElementRefOnCore(props?: P) {\n if (!props?.isDropin) {\n this.core.storeElementReference(this);\n }\n }\n\n public isAvailable(): Promise<void> {\n return Promise.resolve();\n }\n\n public setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n this.onChange();\n }\n\n public showValidation(): this {\n if (this.componentRef && this.componentRef.showValidation) this.componentRef.showValidation();\n return this;\n }\n\n /**\n * elementRef is a ref to the subclass that extends UIElement e.g. Card.tsx\n */\n public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\n\n /**\n * componentRef is a ref to the primary component inside that subclass e.g. CardInput.tsx\n */\n public setStatus(status: UIElementStatus, props?): this {\n if (this.componentRef?.setStatus) {\n this.componentRef.setStatus(status, props);\n }\n return this;\n }\n\n protected onChange(): void {\n this.props.onChange?.(\n {\n data: this.data,\n isValid: this.isValid,\n errors: this.state.errors,\n valid: this.state.valid\n },\n this.elementRef\n );\n }\n\n protected override submitAnalytics(event: AbstractAnalyticsEvent) {\n this.analytics.sendAnalytics(event);\n }\n\n public submit(): void {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n this.makePaymentsCall()\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch((e: PaymentResponseData | Error) => {\n if (e instanceof CancelError) {\n this.setElementStatus('ready');\n return;\n }\n this.handleFailedResult(e as PaymentResponseData);\n });\n }\n\n protected makePaymentsCall(): Promise<CheckoutAdvancedFlowResponse | CheckoutSessionPaymentResponse> {\n this.setElementStatus('loading');\n\n if (this.props.onSubmit) {\n return this.submitUsingAdvancedFlow();\n }\n\n if (this.core.session) {\n const beforeSubmitEvent: Promise<PaymentData> = this.props.beforeSubmit\n ? new Promise((resolve, reject) =>\n this.props.beforeSubmit(this.data, this.elementRef, {\n resolve,\n reject: () => reject(new CancelError('beforeSubmitRejected'))\n })\n )\n : Promise.resolve(this.data);\n\n return beforeSubmitEvent.then(this.submitUsingSessionsFlow);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments call. Callback \"onSubmit\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitUsingAdvancedFlow(): Promise<CheckoutAdvancedFlowResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onSubmit(\n {\n data: this.data,\n isValid: this.isValid\n },\n this.elementRef,\n { resolve, reject }\n );\n });\n }\n\n private async submitUsingSessionsFlow(data: PaymentData): Promise<CheckoutSessionPaymentResponse> {\n const event = new AnalyticsLogEvent({\n component: this.type,\n type: LogEventType.submit,\n message: 'Shopper clicked pay'\n });\n this.submitAnalytics(event);\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\n }\n\n return Promise.reject(error);\n }\n\n // // Uncomment to simulate failed\n // return {\n // resultCode: 'Refused',\n // sessionData:\n // 'Ab02b4c0!BQABAgBKGgqfEz8uQlU4yCIOWjA8bkEwmbJ7Qt4r+x5IPXREu1rMjwNk5MDoHFNlv+MWvinS6nXIDniXgRzXCdSC4ksw9CNDBAjOa+B88wRoj/rLTieuWh/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvL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RzwMbVnEe5JFRfNvJZdLGl35L9632DVmuFQ0lr/8WNL/NrAJNtI6PXrZMNiza0/omPwPfe5ZYuD1Jgq59TX4h9d+3fdkArcJYL7AdoMZON1YEiWY5EzazQwtHd9yzdty9ZHPxAfuOfCh4OhbhFNp+v5YQ+PzKZ+UpM1VxV863+9XgWEURPNvX7qq1cpUSRzrSGq01QBBM3MKzRh5mAgqIdXgtl7L0EXAep0MECc7QY0/o3tW3VR8eEJGsSzrNxpFItqj0SEaIWo25dRfkl5zuw47GQrN9Qzxl2WV3A38MQPUqFtIr/71Rjkphgg49ZGWEYCwgFmm8jJc2/5qTabSGk4bzwiETCTzeydq30bUGqCwglj8CrFViAuQeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n this.handleAdditionalDetails(state);\n }\n\n protected handleError = (error: AdyenCheckoutError): void => {\n /**\n * Set status using elementRef, which:\n * - If Drop-in, will set status for Dropin component, and then it will propagate the new status for the active payment method component\n * - If Component, it will set its own status\n */\n this.setElementStatus('ready');\n\n if (error.name === NETWORK_ERROR && error.options.code) {\n const event = new AnalyticsErrorEvent({\n component: this.type,\n errorType: ErrorEventType.apiError,\n code: error.options.code\n });\n\n this.submitAnalytics(event);\n }\n\n if (this.props.onError) {\n this.props.onError(error, this.elementRef);\n }\n };\n\n protected handleAdditionalDetails(state: AdditionalDetailsData): void {\n this.makeAdditionalDetailsCall(state)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then(this.handleResponse)\n .catch(this.handleFailedResult);\n }\n\n private makeAdditionalDetailsCall(state: AdditionalDetailsData): Promise<CheckoutSessionDetailsResponse | CheckoutAdvancedFlowResponse> {\n if (this.props.onAdditionalDetails) {\n return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n this.props.onAdditionalDetails(state, this.elementRef, { resolve, reject });\n });\n }\n\n if (this.core.session) {\n return this.submitAdditionalDetailsUsingSessionsFlow(state.data);\n }\n\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'It can not perform /payments/details call. Callback \"onAdditionalDetails\" is missing or Checkout session is not available'\n )\n );\n }\n\n private async submitAdditionalDetailsUsingSessionsFlow(data: any): Promise<CheckoutSessionDetailsResponse> {\n try {\n return await this.core.session.submitDetails(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /details call', { cause: error }));\n\n return Promise.reject(error);\n }\n }\n\n public handleAction(action: PaymentAction, props = {}): UIElement | null {\n if (!action || !action.type) {\n if (hasOwnProperty(action, 'action') && hasOwnProperty(action, 'resultCode')) {\n throw new Error(\n 'handleAction::Invalid Action - the passed action object itself has an \"action\" property and ' +\n 'a \"resultCode\": have you passed in the whole response object by mistake?'\n );\n }\n throw new Error('handleAction::Invalid Action - the passed action object does not have a \"type\" property');\n }\n\n const paymentAction = this.core.createFromAction(action, {\n ...this.elementRef.props,\n ...props\n });\n\n if (paymentAction) {\n this.unmount();\n return paymentAction.mount(this._node);\n }\n\n return null;\n }\n\n protected onActionHandled(actionHandledObj: ActionHandledReturnObject) {\n this.props?.onActionHandled?.({ originalAction: this.props.originalAction, ...actionHandledObj });\n }\n\n protected handleOrder = (response: PaymentResponseData): void => {\n const { order } = response;\n\n const updateCorePromise = this.core.session ? this.core.update({ order }) : this.handleAdvanceFlowPaymentMethodsUpdate(order);\n\n void updateCorePromise.then(() => {\n this.props.onOrderUpdated?.({ order });\n });\n };\n\n /**\n * Handles when the payment fails. The payment fails when:\n * - adv flow: the merchant rejects the payment due to a critical error\n * - adv flow: the merchant resolves the payment with a failed resultCode\n * - sessions: a network error occurs when making the payment\n * - sessions: the payment fails with a failed resultCode\n *\n * @param result\n */\n protected handleFailedResult = (result?: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('error');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentFailed?.(result, this.elementRef);\n };\n\n protected handleSuccessResult = (result: PaymentResponseData): void => {\n if (assertIsDropin(this.elementRef)) {\n this.elementRef.displayFinalAnimation('success');\n }\n\n cleanupFinalResult(result);\n this.props.onPaymentCompleted?.(result, this.elementRef);\n };\n\n /**\n * Handles a /payments or /payments/details response.\n * The component will handle automatically actions, orders, and final results.\n *\n * Expected to be called after sanitizeResponse has been run on the raw payment response\n *\n * @param response -\n */\n protected handleResponse(response: PaymentResponseData): void {\n if (response.action) {\n this.elementRef.handleAction(response.action);\n return;\n }\n\n if (response.order?.remainingAmount?.value > 0) {\n // we don't want to call elementRef here, use the component handler\n // we do this way so the logic on handlingOrder is associated with payment method\n this.handleOrder(response);\n return;\n }\n\n this.handleSuccessResult(response);\n }\n\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement> | KeyboardEvent) {\n if (e.key === 'Enter' || e.code === 'Enter') {\n e.preventDefault(); // Prevent <form> submission if Component is placed inside a form\n\n this.onEnterKeyPressed(document?.activeElement, this);\n }\n }\n\n /**\n * Handle Enter key pressed from a UIElement (called via handleKeyPress)\n * @param obj\n */\n protected onEnterKeyPressed(activeElement: Element, component: UIElement) {\n if (this.props.onEnterKeyPressed) {\n this.props.onEnterKeyPressed(activeElement, component);\n } else {\n (activeElement as HTMLElement).blur();\n this.submit();\n }\n }\n\n /**\n * Call update on parent instance\n * This function exist to make safe access to the protected _parentInstance\n * @param options - CoreOptions\n */\n public updateParent(options: CoreConfiguration = {}): Promise<ICore> {\n return this.elementRef.core.update(options);\n }\n\n public setComponentRef = (ref: ComponentMethodsRef) => {\n this.componentRef = ref;\n };\n\n /**\n * Get the current validation status of the element\n */\n public get isValid(): boolean {\n return false;\n }\n\n /**\n * Get the element icon URL for the current environment\n */\n public get icon(): string {\n const type = this.props.paymentMethodType || this.type;\n return this.props.icon ?? this.resources.getImage()(type);\n }\n\n /**\n * Get the element's displayable name\n */\n public get displayName(): string {\n const paymentMethodFromResponse = this.core.paymentMethodsResponse?.paymentMethods?.find(pm => pm.type === this.type);\n return this.props.name || paymentMethodFromResponse?.name || this.type;\n }\n\n /**\n * Get the element accessible name, used in the aria-label of the button that controls selected payment method\n */\n public get accessibleName(): string {\n return this.displayName;\n }\n\n /**\n * Used to display the second line of a payment method item\n */\n get additionalInfo(): string {\n return null;\n }\n\n /**\n * Return the type of an element\n */\n public get type(): string {\n return this.props.type || this.constructor['type'];\n }\n\n /**\n * Get the payButton component for the current element\n */\n protected payButton = (props: PayButtonFunctionProps) => {\n return <PayButton {...props} amount={this.props.amount} secondaryAmount={this.props.secondaryAmount} onClick={this.submit} />;\n };\n\n /**\n * Used in the Partial Orders flow.\n * When the Order is updated, the merchant can request new payment methods based on the new remaining amount\n *\n * @private\n */\n protected async handleAdvanceFlowPaymentMethodsUpdate(order: Order | null, amount?: PaymentAmount) {\n return new Promise<void | PaymentMethodsResponse>((resolve, reject) => {\n if (!this.props.onPaymentMethodsRequest) {\n return resolve();\n }\n\n this.props.onPaymentMethodsRequest(\n {\n ...(order && {\n order: {\n orderData: order.orderData,\n pspReference: order.pspReference\n }\n }),\n locale: this.core.options.locale\n },\n { resolve, reject }\n );\n })\n .catch(error => {\n this.handleError(\n new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'Something failed during payment methods update or onPaymentMethodsRequest was not implemented',\n {\n cause: error\n }\n )\n );\n })\n .then(paymentMethodsResponse => {\n // in the case of the session flow we get order, amount, countryCode and shopperLocale from initialize()\n // apply the same logic here for order and amount\n // in the future it might be worth moving this logic to be performed by the core on update()\n // it would make this more consistent\n return this.core.update({\n ...(paymentMethodsResponse && { paymentMethodsResponse }),\n order,\n amount: order ? order.remainingAmount : amount\n });\n });\n }\n\n protected abstract componentToRender(): h.JSX.Element;\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources} analytics={this.analytics}>\n <SRPanelProvider srPanel={this.srPanel}>{this.componentToRender()}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UIElement;\n"],"names":["UIElement","BaseElement","createBeforeRenderHook","configSetByMerchant","originalRender","this","render","args","beforeRender","apply","originalAction","event","AnalyticsInfoEvent","type","InfoEventType","rendered","component","configData","showPayButton","props","oneClick","isStoredPaymentMethod","analytics","sendAnalytics","reportIntegrationFlavor","sendFlavor","core","modules","srPanel","getPaymentMethodConfigFromResponse","componentProps","storedPaymentMethodId","getStoredPaymentMethodDetails","getPaymentMethodFromPaymentMethodsResponse","paymentMethodId","buildElementProps","finalProps","getCorePropsForComponent","isDropinInstance","assertIsDropin","formatProps","constructor","getRegulatoryDefaults","options","countryCode","paymentMethodsResponse","findStoredPaymentMethod","findById","find","storeElementRefOnCore","isDropin","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","setElementStatus","status","elementRef","setStatus","data","isValid","errors","valid","submitAnalytics","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","session","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","AnalyticsLogEvent","LogEventType","message","submitPayment","error","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","unmount","mount","_node","onActionHandled","actionHandledObj","response","order","remainingAmount","value","handleOrder","handleSuccessResult","handleKeyPress","key","code","preventDefault","onEnterKeyPressed","document","activeElement","blur","updateParent","update","icon","paymentMethodType","resources","getImage","displayName","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","amount","onPaymentMethodsRequest","orderData","pspReference","locale","h","CoreProvider","i18n","loadingContext","SRPanelProvider","componentToRender","checkout","super","_define_property","NETWORK_ERROR","AnalyticsErrorEvent","errorType","ErrorEventType","apiError","onError","onOrderUpdated","result","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","onPaymentCompleted","setComponentRef","ref","payButton","PayButton","secondaryAmount","onClick","register","bind","undefined","txVariants"],"mappings":"8iCAoCO,MAAeA,UAA6DC,EAmDvEC,sBAAAA,CAAuBC,GAC3B,MAAMC,EAAiBC,KAAKC,OAE5BD,KAAKC,OAAS,IAAIC,KACdF,KAAKG,aAAaL,GACXC,EAAeK,MAAMJ,KAAME,GAE1C,CAEUC,YAAAA,CAAaL,GAEnB,GAAIA,GAAqBO,eACrB,OAGJ,MAAMC,EAAQ,IAAIC,EAAmB,CACjCC,KAAMC,EAAcC,SACpBC,UAAWX,KAAKQ,KAChBI,WAAY,IAAKd,EAAqBe,cAAeb,KAAKc,MAAMD,kBAC5Df,GAAqBiB,UAAY,CAAEC,uBAAuB,KAGlEhB,KAAKiB,UAAUC,cAAcZ,EACjC,CAEUa,uBAAAA,GACDnB,KAAKiB,UAAUG,WAAW,aACnC,CAEA,aAAIH,GACA,OAAOjB,KAAKqB,KAAKC,QAAQL,SAC7B,CAEA,WAAIM,GACA,OAAOvB,KAAKqB,KAAKC,QAAQC,OAC7B,CAEQC,kCAAAA,CAAmCC,GACvC,OAAIA,GAAgBC,sBAA8B1B,KAAK2B,8BAA8BF,EAAeC,uBAC7F1B,KAAK4B,2CAA2CH,GAAgBjB,KAAMiB,GAAgBI,gBACjG,CAEmBC,iBAAAA,CAAkBL,GACjC,MAIMM,E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KAAKgF,wBAAwBuF,KAAKvK,MAEjEA,KAAK0D,WAAc5C,GAASA,EAAM4C,YAAe1D,KACjDA,KAAK4H,UAAY5H,KAAKc,MAAMQ,QAAUtB,KAAKc,MAAMQ,QAAQsG,eAAY4C,EAErExK,KAAK4C,sBAAsB5C,KAAKc,OAEhCd,KAAKoH,kBAAoBpH,KAAKoH,kBAAkBmD,KAAKvK,MACrDA,KAAKwG,gBAAkBxG,KAAKwG,gBAAgB+D,KAAKvK,MAEjDA,KAAKH,uBAAuBiB,GAC5Bd,KAAKmB,yBACT,EAnCAgI,EAPkBxJ,EAOJa,YAAOgK,GAKrBrB,EAZkBxJ,EAYJ8K,aAAuB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../external/preact/dist/preact.js";import t from"../../components/internal/BaseElement/BaseElement.js";import{SRMessages as s}from"./SRMessages.js";function n(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class o extends t{get enabled(){return this._enabled}get moveFocus(){return this._moveFocus}setAriaProps(e){const t=document.querySelector('[class^="adyen-checkout-sr-panel"]');for(const[s,n]of Object.entries(e))t.setAttribute(s,n);this.props={...this.props,ariaAttributes:{...this.props.ariaAttributes,...e}}}render(){return this.props.enabled?e("div",{className:this.showPanel?"adyen-checkout-sr-panel":"adyen-checkout-sr-panel--sr-only",role:"log",...this.props.ariaAttributes},e(s,{setComponentRef:this.setComponentRef})):null}constructor(e,t){if(super(e,t),n(this,"srPanelContainer",null),n(this,"id",void 0),n(this,"showPanel",void 0),n(this,"_enabled",void 0),n(this,"_moveFocus",void 0),n(this,"componentRef",void 0),n(this,"setComponentRef",e=>{this.componentRef=e}),n(this,"setMessages",e=>{if(!this.props.enabled)return;let t=null;e&&(t=Array.isArray(e)?e:[e]),this.componentRef.setMessages(t)}),this.id=this.props.id,this.showPanel=!1,this._enabled=!1,this._moveFocus=this.props.moveFocus??!0,this.props.enabled){this._enabled=!0;const e=document.querySelector(this.props.node);if(!e)throw new Error("Component could not mount. Root node was not found.");{const t=document.getElementById(this.id);t&&e.removeChild(t),this.srPanelContainer=document.createElement("div"),this.srPanelContainer.className="sr-panel-holder",this.srPanelContainer.id=this.id,e.appendChild(this.srPanelContainer),this.mount(this.srPanelContainer)}}}}n(o,"type","srPanel"),n(o,"defaultProps",{enabled:!0,node:"body",showPanel:!1,id:"ariaLiveSRPanel",ariaAttributes:{"aria-relevant":"all","aria-live":"polite","aria-atomic":"true"}});export{o as SRPanel};
|
|
1
|
+
import{createElement as e}from"../../external/preact/dist/preact.js";import t from"../../components/internal/BaseElement/BaseElement.js";import{SRMessages as s}from"./SRMessages.js";function n(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class o extends t{get enabled(){return this._enabled}get moveFocus(){return this._moveFocus}setAriaProps(e){if(!this.props.enabled)return;const t=document.querySelector('[class^="adyen-checkout-sr-panel"]');if(t){for(const[s,n]of Object.entries(e))t.setAttribute(s,n);this.props={...this.props,ariaAttributes:{...this.props.ariaAttributes,...e}}}else console.error("SRPanel: Failed to set aria props because no panel was found")}render(){return this.props.enabled?e("div",{className:this.showPanel?"adyen-checkout-sr-panel":"adyen-checkout-sr-panel--sr-only",role:"log",...this.props.ariaAttributes},e(s,{setComponentRef:this.setComponentRef})):null}constructor(e,t){if(super(e,t),n(this,"srPanelContainer",null),n(this,"id",void 0),n(this,"showPanel",void 0),n(this,"_enabled",void 0),n(this,"_moveFocus",void 0),n(this,"componentRef",void 0),n(this,"setComponentRef",e=>{this.componentRef=e}),n(this,"setMessages",e=>{if(!this.props.enabled)return;let t=null;e&&(t=Array.isArray(e)?e:[e]),this.componentRef.setMessages(t)}),this.id=this.props.id,this.showPanel=!1,this._enabled=!1,this._moveFocus=this.props.moveFocus??!0,this.props.enabled){this._enabled=!0;const e=document.querySelector(this.props.node);if(!e)throw new Error("Component could not mount. Root node was not found.");{const t=document.getElementById(this.id);t&&e.removeChild(t),this.srPanelContainer=document.createElement("div"),this.srPanelContainer.className="sr-panel-holder",this.srPanelContainer.id=this.id,e.appendChild(this.srPanelContainer),this.mount(this.srPanelContainer)}}}}n(o,"type","srPanel"),n(o,"defaultProps",{enabled:!0,node:"body",showPanel:!1,id:"ariaLiveSRPanel",ariaAttributes:{"aria-relevant":"all","aria-live":"polite","aria-atomic":"true"}});export{o as SRPanel};
|
|
2
2
|
//# sourceMappingURL=SRPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SRPanel.js","sources":["../../../../src/core/Errors/SRPanel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport
|
|
1
|
+
{"version":3,"file":"SRPanel.js","sources":["../../../../src/core/Errors/SRPanel.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { AriaAttributes, SRPanelProps } from './types';\nimport BaseElement from '../../components/internal/BaseElement/BaseElement';\nimport { SRMessages, SRMessagesRef } from './SRMessages';\nimport type { ICore } from '../types';\nimport './SRPanel.scss';\n\n/**\n * A panel meant to hold messages that will be read out by ScreenReaders on an aria-live=\"polite\" basis\n * Expects a string or string array of message to add to the panel to be read out\n * For testing purposes can be made visible\n */\nexport class SRPanel extends BaseElement<SRPanelProps> {\n public static type = 'srPanel';\n\n public static defaultProps: Partial<SRPanelProps> = {\n enabled: true,\n node: 'body',\n showPanel: false,\n id: 'ariaLiveSRPanel',\n ariaAttributes: {\n 'aria-relevant': 'all',\n 'aria-live': 'polite',\n 'aria-atomic': 'true'\n }\n };\n\n private readonly srPanelContainer = null;\n\n private readonly id;\n private readonly showPanel;\n private readonly _enabled: boolean;\n private readonly _moveFocus: boolean;\n\n private componentRef: SRMessagesRef;\n\n constructor(checkout: ICore, props?: SRPanelProps) {\n super(checkout, props);\n\n this.id = this.props.id;\n this.showPanel = process.env.NODE_ENV !== 'production' ? this.props.showPanel : false;\n this._enabled = false;\n this._moveFocus = this.props.moveFocus ?? true;\n\n if (this.props.enabled) {\n this._enabled = true;\n\n const panelParent = document.querySelector(this.props.node);\n\n if (panelParent) {\n const preExistingSRPanel = document.getElementById(this.id);\n if (preExistingSRPanel) {\n panelParent.removeChild(preExistingSRPanel);\n }\n\n this.srPanelContainer = document.createElement('div');\n this.srPanelContainer.className = 'sr-panel-holder';\n this.srPanelContainer.id = this.id;\n\n panelParent.appendChild(this.srPanelContainer);\n\n this.mount(this.srPanelContainer);\n } else {\n throw new Error('Component could not mount. Root node was not found.');\n }\n }\n }\n\n public setComponentRef = ref => {\n this.componentRef = ref;\n };\n\n public get enabled() {\n return this._enabled;\n }\n\n public get moveFocus() {\n return this._moveFocus;\n }\n\n public setAriaProps(ariaAttributes: AriaAttributes): void {\n if (!this.props.enabled) return;\n\n const firstPanel = document.querySelector('[class^=\"adyen-checkout-sr-panel\"]');\n\n if (!firstPanel) {\n console.error('SRPanel: Failed to set aria props because no panel was found');\n return;\n }\n\n for (const [key, value] of Object.entries(ariaAttributes)) {\n firstPanel.setAttribute(key, value);\n }\n this.props = { ...this.props, ariaAttributes: { ...this.props.ariaAttributes, ...ariaAttributes } };\n }\n\n // A method we can expose to allow comps to set messages in this panel\n public setMessages = (messages: string[] | string): void => {\n if (!this.props.enabled) return;\n\n let panelMessages = null;\n if (messages) {\n // Ensure panelMessages is an array\n panelMessages = Array.isArray(messages) ? messages : [messages];\n }\n\n this.componentRef.setMessages(panelMessages);\n };\n\n render() {\n if (!this.props.enabled) return null;\n return (\n <div\n className={this.showPanel ? 'adyen-checkout-sr-panel' : 'adyen-checkout-sr-panel--sr-only'}\n role={'log'}\n {...this.props.ariaAttributes}\n {...(process.env.NODE_ENV !== 'production' && { 'data-testid': this.id })}\n >\n <SRMessages setComponentRef={this.setComponentRef} />\n </div>\n );\n }\n}\n"],"names":["SRPanel","BaseElement","enabled","this","_enabled","moveFocus","_moveFocus","setAriaProps","ariaAttributes","props","firstPanel","document","querySelector","key","value","Object","entries","setAttribute","console","error","render","h","div","className","showPanel","role","SRMessages","setComponentRef","constructor","checkout","super","_define_property","srPanelContainer","id","componentRef","ref","setMessages","messages","panelMessages","Array","isArray","panelParent","node","Error","preExistingSRPanel","getElementById","removeChild","createElement","appendChild","mount","type","defaultProps"],"mappings":"8SAYO,MAAMA,UAAgBC,EA4DzB,WAAWC,GACP,OAAOC,KAAKC,QAChB,CAEA,aAAWC,GACP,OAAOF,KAAKG,UAChB,CAEOC,YAAAA,CAAaC,GAChB,IAAKL,KAAKM,MAAMP,QAAS,OAEzB,MAAMQ,EAAaC,SAASC,cAAc,sCAE1C,GAAKF,EAAL,CAKA,IAAK,MAAOG,EAAKC,KAAUC,OAAOC,QAAQR,GACtCE,EAAWO,aAAaJ,EAAKC,GAEjCX,KAAKM,MAAQ,IAAKN,KAAKM,MAAOD,eAAgB,IAAKL,KAAKM,MAAMD,kBAAmBA,GALjF,MAFIU,QAAQC,MAAM,+DAQtB,CAeAC,MAAAA,GACI,OAAKjB,KAAKM,MAAMP,QAEZmB,EAACC,MAAAA,CACGC,UAAWpB,KAAKqB,UAAY,0BAA4B,mCACxDC,KAAM,SACFtB,KAAKM,MAAMD,gBAGfa,EAACK,EAAAA,CAAWC,gBAAiBxB,KAAKwB,mBARV,IAWpC,CArFA,WAAAC,CAAYC,EAAiBpB,GAQzB,GAPAqB,MAAMD,EAAUpB,GAVpBsB,EAAA5B,KAAiB6B,mBAAmB,MAEpCD,EAAA5B,KAAiB8B,UAAjB,GACAF,EAAA5B,KAAiBqB,iBAAjB,GACAO,EAAA5B,KAAiBC,gBAAjB,GACA2B,EAAA5B,KAAiBG,kBAAjB,GAEAyB,EAAA5B,KAAQ+B,oBAAR,GAkCAH,EAAA5B,KAAOwB,kBAAkBQ,IACrBhC,KAAK+B,aAAeC,IA4BxBJ,EAAA5B,KAAOiC,cAAeC,IAClB,IAAKlC,KAAKM,MAAMP,QAAS,OAEzB,IAAIoC,EAAgB,KAChBD,IAEAC,EAAgBC,MAAMC,QAAQH,GAAYA,EAAW,CAACA,IAG1DlC,KAAK+B,aAAaE,YAAYE,KAnE9BnC,KAAK8B,GAAK9B,KAAKM,MAAMwB,GACrB9B,KAAKqB,WAA2E,EAChFrB,KAAKC,UAAW,EAChBD,KAAKG,WAAaH,KAAKM,MAAMJ,YAAa,EAEtCF,KAAKM,MAAMP,QAAS,CACpBC,KAAKC,UAAW,EAEhB,MAAMqC,EAAc9B,SAASC,cAAcT,KAAKM,MAAMiC,MAEtD,IAAID,EAcA,MAAM,IAAIE,MAAM,uDAdH,CACb,MAAMC,EAAqBjC,SAASkC,eAAe1C,KAAK8B,IACpDW,GACAH,EAAYK,YAAYF,GAG5BzC,KAAK6B,iBAAmBrB,SAASoC,cAAc,OAC/C5C,KAAK6B,iBAAiBT,UAAY,kBAClCpB,KAAK6B,iBAAiBC,GAAK9B,KAAK8B,GAEhCQ,EAAYO,YAAY7C,KAAK6B,kBAE7B7B,KAAK8C,MAAM9C,KAAK6B,iBACpB,CAGJ,CACJ,EArDAD,EADS/B,EACKkD,OAAO,WAErBnB,EAHS/B,EAGKmD,eAAsC,CAChDjD,SAAS,EACTwC,KAAM,OACNlB,WAAW,EACXS,GAAI,kBACJzB,eAAgB,CACZ,gBAAiB,MACjB,YAAa,SACb,cAAe"}
|
package/dist/es/core/config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="https://checkoutshopper-live.adyen.com/checkoutshopper/",n="6.
|
|
1
|
+
const e="https://checkoutshopper-live.adyen.com/checkoutshopper/",n="6.27.1",o="esm",t=["amount","secondaryAmount","countryCode","environment","_environmentUrls","loadingContext","i18n","modules","order","session","clientKey","showPayButton","redirectFromTopWhenInIframe","onPaymentCompleted","onPaymentFailed","beforeRedirect","beforeSubmit","onSubmit","onActionHandled","onAdditionalDetails","onChange","onEnterKeyPressed","onError","onBalanceCheck","onOrderCancel","onOrderRequest","onOrderUpdated","onPaymentMethodsRequest"],r=6e4;export{r as DEFAULT_HTTP_TIMEOUT,e as FALLBACK_CONTEXT,t as GENERIC_OPTIONS,o as LIBRARY_BUNDLE_TYPE,n as LIBRARY_VERSION};
|
|
2
2
|
//# sourceMappingURL=config.js.map
|
package/dist/es/index.d.ts
CHANGED
|
@@ -2816,6 +2816,7 @@ interface KlarnaAdditionalDetailsData extends AdditionalDetailsData {
|
|
|
2816
2816
|
paymentData: string;
|
|
2817
2817
|
details: {
|
|
2818
2818
|
authorization_token?: string;
|
|
2819
|
+
resultCode?: ResultCode;
|
|
2819
2820
|
};
|
|
2820
2821
|
};
|
|
2821
2822
|
}
|
|
@@ -2912,11 +2913,11 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
2912
2913
|
*/
|
|
2913
2914
|
configuration?: {
|
|
2914
2915
|
/**
|
|
2915
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
2916
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#merchant-id}
|
|
2916
2917
|
*/
|
|
2917
2918
|
merchantId: string;
|
|
2918
2919
|
/**
|
|
2919
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
2920
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#intent}
|
|
2920
2921
|
*/
|
|
2921
2922
|
intent?: Intent;
|
|
2922
2923
|
};
|
|
@@ -2966,7 +2967,7 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
2966
2967
|
}) => void;
|
|
2967
2968
|
/**
|
|
2968
2969
|
* While the buyer is on the PayPal site, you can update their shopping cart to reflect the shipping address they chose on PayPal
|
|
2969
|
-
* @see {@link https://developer.paypal.com/sdk/js/reference/#
|
|
2970
|
+
* @see {@link https://developer.paypal.com/sdk/js/reference/#on-shipping-address-change}
|
|
2970
2971
|
*
|
|
2971
2972
|
* @param data - PayPal data object
|
|
2972
2973
|
* @param actions - Used to reject the address change in case the address is invalid
|
|
@@ -2977,7 +2978,7 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
2977
2978
|
}, component: PaypalElement) => Promise<void>;
|
|
2978
2979
|
/**
|
|
2979
2980
|
* This callback is triggered any time the user selects a new shipping option.
|
|
2980
|
-
* @see {@link https://developer.paypal.com/sdk/js/reference/#
|
|
2981
|
+
* @see {@link https://developer.paypal.com/sdk/js/reference/#on-shipping-options-change}
|
|
2981
2982
|
*
|
|
2982
2983
|
* @param data - An PayPal object containing the payer’s selected shipping option
|
|
2983
2984
|
* @param actions - Used to indicates to PayPal that you will not support the shipping method selected by the buyer
|
|
@@ -2994,7 +2995,7 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
2994
2995
|
/**
|
|
2995
2996
|
* Customize your buttons using the style option.
|
|
2996
2997
|
*
|
|
2997
|
-
* @see {@link https://developer.paypal.com/sdk/js/reference/#
|
|
2998
|
+
* @see {@link https://developer.paypal.com/sdk/js/reference/#style}
|
|
2998
2999
|
* @default style.height 48px
|
|
2999
3000
|
*/
|
|
3000
3001
|
style?: {
|
|
@@ -3008,31 +3009,31 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
3008
3009
|
};
|
|
3009
3010
|
/**
|
|
3010
3011
|
* Called when the button first renders. You can use it for validations on your page if you are unable to do so prior to rendering.
|
|
3011
|
-
* @see {@link https://developer.paypal.com/sdk/js/reference/#
|
|
3012
|
+
* @see {@link https://developer.paypal.com/sdk/js/reference/#oninitonclick}
|
|
3012
3013
|
*/
|
|
3013
3014
|
onInit?: (data?: any, actions?: any) => void;
|
|
3014
3015
|
/**
|
|
3015
|
-
* @see {@link https://developer.paypal.com/sdk/js/reference/#
|
|
3016
|
+
* @see {@link https://developer.paypal.com/sdk/js/reference/#oninitonclick}
|
|
3016
3017
|
*/
|
|
3017
3018
|
onClick?: () => void;
|
|
3018
3019
|
/**
|
|
3019
3020
|
* The commit status of the transaction. Determines whether to show a Pay Now or Continue button in the Checkout flow.
|
|
3020
3021
|
*
|
|
3021
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3022
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#commit}
|
|
3022
3023
|
* @default true
|
|
3023
3024
|
*/
|
|
3024
3025
|
commit?: boolean;
|
|
3025
3026
|
/**
|
|
3026
3027
|
* Whether the payment information in the transaction will be saved. Save your customers' payment information for billing agreements, subscriptions, or recurring payments.
|
|
3027
3028
|
*
|
|
3028
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3029
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#vault}
|
|
3029
3030
|
* @default false
|
|
3030
3031
|
*/
|
|
3031
3032
|
vault?: boolean;
|
|
3032
3033
|
/**
|
|
3033
3034
|
* The locale renders components. By default PayPal detects the correct locale for the buyer based on their geolocation and browser preferences.
|
|
3034
3035
|
*
|
|
3035
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3036
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#locale}
|
|
3036
3037
|
* @default undefined
|
|
3037
3038
|
*/
|
|
3038
3039
|
locale?: string;
|
|
@@ -3040,21 +3041,21 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
3040
3041
|
* Determines whether the funds are captured immediately on checkout or if the buyer authorizes the funds to be captured later.
|
|
3041
3042
|
* If set, it will override the intent passed inside the 'configuration' object
|
|
3042
3043
|
*
|
|
3043
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3044
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#intent}
|
|
3044
3045
|
* @default undefined
|
|
3045
3046
|
*/
|
|
3046
3047
|
intent?: Intent;
|
|
3047
3048
|
/**
|
|
3048
3049
|
* Pass a Content Security Policy single-use token if you use them on your site
|
|
3049
3050
|
*
|
|
3050
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3051
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#data-csp-nonce}
|
|
3051
3052
|
* @default undefined
|
|
3052
3053
|
*/
|
|
3053
3054
|
cspNonce?: string;
|
|
3054
3055
|
enableMessages?: boolean;
|
|
3055
3056
|
/**
|
|
3056
3057
|
* Set to true to enable debug mode. Defaults to false.
|
|
3057
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3058
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#debug}
|
|
3058
3059
|
* @default undefined
|
|
3059
3060
|
*/
|
|
3060
3061
|
debug?: boolean;
|
|
@@ -3062,7 +3063,7 @@ interface PayPalConfiguration extends UIElementProps {
|
|
|
3062
3063
|
* A two-letter ISO 3166 country code which will be passed to the PayPal SDK as the buyer-country.
|
|
3063
3064
|
* Note: The buyer country is only used in the sandbox. Don't pass this query parameter in production.
|
|
3064
3065
|
*
|
|
3065
|
-
* @see {@link https://developer.paypal.com/sdk/js/configuration/#
|
|
3066
|
+
* @see {@link https://developer.paypal.com/sdk/js/configuration/#buyer-country}
|
|
3066
3067
|
* @default undefined
|
|
3067
3068
|
*/
|
|
3068
3069
|
countryCode?: string;
|
|
@@ -4919,7 +4920,6 @@ declare class UPI extends UIElement<UPIConfiguration> {
|
|
|
4919
4920
|
formatData(): UpiPaymentData;
|
|
4920
4921
|
get paymentType(): UpiType;
|
|
4921
4922
|
private onUpdateMode;
|
|
4922
|
-
private renderContent;
|
|
4923
4923
|
protected componentToRender(): h.JSX.Element;
|
|
4924
4924
|
}
|
|
4925
4925
|
|
package/dist/es/utils/Script.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../core/Errors/AdyenCheckoutError.js";import{AnalyticsInfoEvent as s,InfoEventType as
|
|
1
|
+
import t from"../core/Errors/AdyenCheckoutError.js";import{AnalyticsInfoEvent as s,InfoEventType as e}from"../core/Analytics/events/AnalyticsInfoEvent.js";function i(t,s,e){return s in t?Object.defineProperty(t,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[s]=e,t}class r{removeScript(){this.cleanupListeners(),this.script?.parentNode?.removeChild(this.script),this.script=null}cleanupListeners(){this.script&&(this.script.removeEventListener("load",this.handleOnLoad),this.script.removeEventListener("error",this.handleOnError))}attachListeners(){this.script&&(this.cleanupListeners(),this.script.addEventListener("load",this.handleOnLoad),this.script.addEventListener("error",this.handleOnError))}loadScript(){return new Promise((s,e)=>{const i=document.querySelector(this.node);i?(this.resolveLoadScript=s,this.rejectLoadScript=e,this.script=i.querySelector(`script[src="${this.src}"]`),this.script?.getAttribute("data-script-loaded")?this.resolveLoadScript():this.script?this.attachListeners():(this.script=document.createElement("script"),Object.assign(this.script,this.attributes),Object.assign(this.script.dataset,this.dataAttributes),this.script.src=this.src,this.script.async=!0,this.attachListeners(),i.appendChild(this.script))):e(new t("SCRIPT_ERROR",`Unable to find script container node: ${this.node}`))})}trackEvent(t){const e=new s({type:t,component:this.component,cdnUrl:this.baseUrl});this.analytics?.sendAnalytics(e)}constructor({src:s,component:o,node:n="body",attributes:a,dataAttributes:c,analytics:h}){i(this,"src",void 0),i(this,"component",void 0),i(this,"node",void 0),i(this,"attributes",void 0),i(this,"dataAttributes",void 0),i(this,"analytics",void 0),i(this,"baseUrl",void 0),i(this,"script",void 0),i(this,"loadPromise",null),i(this,"rejectLoadPromise",null),i(this,"resolveLoadScript",null),i(this,"rejectLoadScript",null),i(this,"handleOnLoad",()=>{this.script?.setAttribute("data-script-loaded","true"),this.cleanupListeners(),this.resolveLoadScript?.()}),i(this,"handleOnError",s=>{this.cleanupListeners();const e=new t("SCRIPT_ERROR",`Unable to load script ${this.src}.${s?.message&&`Message: ${s.message}`}`,{cause:s?.error||s});this.rejectLoadScript?.(e)}),i(this,"load",()=>(null!==this.loadPromise||(this.loadPromise=new Promise((t,s)=>{this.rejectLoadPromise=s;let i=0;this.trackEvent(e.sdkDownloadInitiated);const o=async()=>{try{i++,await this.loadScript(),this.trackEvent(e.sdkDownloadCompleted),t()}catch(t){if(null===this.loadPromise)return;this.trackEvent(e.sdkDownloadFailed),this.removeScript(),i<r.MAX_NUMBER_OF_RETRIES?setTimeout(()=>{o()},r.RETRY_DELAY):(this.trackEvent(e.sdkDownloadAborted),this.loadPromise=null,this.rejectLoadPromise=null,s(t))}};o()})),this.loadPromise)),i(this,"remove",()=>{this.rejectLoadPromise?.(new t("CANCEL","Script loading cancelled.")),this.removeScript(),this.loadPromise=null}),this.src=s,this.component=o,this.node=n,this.attributes=a,this.dataAttributes=c,this.analytics=h,this.baseUrl=function(t){const s=new URL(t);return s.origin+s.pathname}(this.src)}}i(r,"RETRY_DELAY",1e3),i(r,"MAX_NUMBER_OF_RETRIES",3);export{r as default};
|
|
2
2
|
//# sourceMappingURL=Script.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Script.js","sources":["../../../src/utils/Script.ts"],"sourcesContent":["import AdyenCheckoutError from '../core/Errors/AdyenCheckoutError';\nimport { AnalyticsInfoEvent, InfoEventType } from '../core/Analytics/events/AnalyticsInfoEvent';\nimport type { IAnalytics } from '../core/Analytics/Analytics';\n\ninterface IScript {\n load(): Promise<void>;\n remove(): void;\n}\n\ninterface IScriptProps {\n src: string;\n component: string;\n analytics: IAnalytics;\n node?: string;\n attributes?: Partial<HTMLScriptElement>;\n dataAttributes?: Record<string, string | undefined>;\n}\n\n// Returns Base URL of the resource without any query parameters (e.g. merchant ID, token, etc). Used for Analytics\nfunction getBaseURL(src: string): string {\n const url = new URL(src);\n return url.origin + url.pathname;\n}\n\nclass Script implements IScript {\n private readonly src: string;\n private readonly component: string;\n private readonly node: string;\n private readonly attributes: Partial<HTMLScriptElement>;\n private readonly dataAttributes: Record<string, string | undefined>;\n private readonly analytics: IAnalytics;\n private readonly baseUrl: string;\n\n private script: HTMLScriptElement;\n private loadPromise: Promise<void> | null = null;\n private rejectLoadPromise: (reason?: any) => void | null = null;\n\n public static readonly RETRY_DELAY = 1000;\n public static readonly MAX_NUMBER_OF_RETRIES = 3;\n\n constructor({ src, component, node = 'body', attributes, dataAttributes, analytics }: IScriptProps) {\n this.src = src;\n this.component = component;\n this.node = node;\n this.attributes = attributes;\n this.dataAttributes = dataAttributes;\n this.analytics = analytics;\n this.baseUrl = getBaseURL(this.src);\n }\n\n public load = (): Promise<void> => {\n if (this.loadPromise !== null) {\n if (process.env.NODE_ENV === 'development') console.warn(`[Warning] script.load called more than once for ${this.src}`);\n return this.loadPromise;\n }\n\n this.loadPromise = new Promise((resolve, reject) => {\n this.rejectLoadPromise = reject;\n let attempts = 0;\n\n this.trackEvent(InfoEventType.sdkDownloadInitiated);\n\n const loadScriptWithRetry = async (): Promise<void> => {\n try {\n attempts++;\n await this.loadScript();\n this.trackEvent(InfoEventType.sdkDownloadCompleted);\n resolve();\n } catch (error: unknown) {\n if (this.loadPromise === null) {\n return;\n }\n\n this.trackEvent(InfoEventType.sdkDownloadFailed);\n\n this.removeScript();\n\n if (attempts < Script.MAX_NUMBER_OF_RETRIES) {\n setTimeout(() => void loadScriptWithRetry(), Script.RETRY_DELAY);\n } else {\n this.trackEvent(InfoEventType.sdkDownloadAborted);\n this.loadPromise = null;\n this.rejectLoadPromise = null;\n reject(error);\n }\n }\n };\n\n void loadScriptWithRetry();\n });\n\n return this.loadPromise;\n };\n\n public remove = () => {\n this.rejectLoadPromise?.(new AdyenCheckoutError('CANCEL', 'Script loading cancelled.'));\n this.removeScript();\n this.loadPromise = null;\n };\n\n private removeScript() {\n this.script?.parentNode?.removeChild(this.script);\n this.script = null;\n }\n\n private loadScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n const scriptContainer = document.querySelector(this.node);\n\n if (!scriptContainer) {\n reject(new AdyenCheckoutError('SCRIPT_ERROR', `Unable to find script container node: ${this.node}`));\n return;\n }\n\n const cleanupListeners = () => {\n if (!this.script) return;\n this.script.removeEventListener('load', handleOnLoad);\n this.script.removeEventListener('error', handleOnError);\n };\n\n const handleOnLoad = () => {\n this.script.setAttribute('data-script-loaded', 'true');\n cleanupListeners();\n resolve();\n };\n\n const handleOnError = (errorEvent: ErrorEvent) => {\n cleanupListeners();\n reject(\n new AdyenCheckoutError(\n 'SCRIPT_ERROR',\n `Unable to load script ${this.src}.${errorEvent?.message && `Message: ${errorEvent.message}`}`,\n {\n cause: errorEvent?.error || errorEvent\n }\n )\n );\n };\n\n this.script = scriptContainer.querySelector(`script[src=\"${this.src}\"]`);\n\n // Script element exists in the browser and is already loaded\n if (this.script?.getAttribute('data-script-loaded')) {\n resolve();\n return;\n }\n\n // Script element exists in the browser, but it is not loaded yet\n // Use-case: Multiple PayPal standalone components being loaded in different parts of the screen.\n if (this.script) {\n this.script.addEventListener('load', handleOnLoad);\n this.script.addEventListener('error', handleOnError);\n return;\n }\n\n // Script element doesn't exist in the browser, so we create it and append to the DOM tree\n this.script = document.createElement('script');\n\n Object.assign(this.script, this.attributes);\n Object.assign(this.script.dataset, this.dataAttributes);\n\n this.script.src = this.src;\n this.script.async = true;\n\n this.script.addEventListener('load', handleOnLoad);\n this.script.addEventListener('error', handleOnError);\n\n scriptContainer.appendChild(this.script);\n });\n }\n\n private trackEvent(eventType: InfoEventType) {\n const event = new AnalyticsInfoEvent({\n type: eventType,\n component: this.component,\n cdnUrl: this.baseUrl\n });\n this.analytics?.sendAnalytics(event);\n }\n}\n\nexport default Script;\n"],"names":["Script","removeScript","this","script","parentNode","removeChild","loadScript","Promise","resolve","reject","scriptContainer","document","querySelector","node","AdyenCheckoutError","cleanupListeners","removeEventListener","handleOnLoad","handleOnError","setAttribute","errorEvent","src","message","cause","error","getAttribute","addEventListener","createElement","Object","assign","attributes","dataset","dataAttributes","async","appendChild","trackEvent","eventType","event","AnalyticsInfoEvent","type","component","cdnUrl","baseUrl","analytics","sendAnalytics","constructor","_define_property","loadPromise","rejectLoadPromise","load","attempts","InfoEventType","sdkDownloadInitiated","loadScriptWithRetry","sdkDownloadCompleted","sdkDownloadFailed","MAX_NUMBER_OF_RETRIES","setTimeout","RETRY_DELAY","sdkDownloadAborted","remove","url","URL","origin","pathname","getBaseURL"],"mappings":"mRAwBA,MAAMA,EA4EMC,YAAAA,GACJC,KAAKC,QAAQC,YAAYC,YAAYH,KAAKC,QAC1CD,KAAKC,OAAS,IAClB,CAEQG,UAAAA,GACJ,OAAO,IAAIC,QAAQ,CAACC,EAASC,KACzB,MAAMC,EAA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C,GACpB,OAAOwC,EAAIE,OAASF,EAAIG,QAC5B,CAyBuBC,CAAW/D,KAAKmB,IACnC,EAXAyB,EAbE9C,EAaqB0D,cAAc,KACrCZ,EAdE9C,EAcqBwD,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"Script.js","sources":["../../../src/utils/Script.ts"],"sourcesContent":["import AdyenCheckoutError from '../core/Errors/AdyenCheckoutError';\nimport { AnalyticsInfoEvent, InfoEventType } from '../core/Analytics/events/AnalyticsInfoEvent';\nimport type { IAnalytics } from '../core/Analytics/Analytics';\n\ninterface IScript {\n load(): Promise<void>;\n remove(): void;\n}\n\ninterface IScriptProps {\n src: string;\n component: string;\n analytics: IAnalytics;\n node?: string;\n attributes?: Partial<HTMLScriptElement>;\n dataAttributes?: Record<string, string | undefined>;\n}\n\n// Returns Base URL of the resource without any query parameters (e.g. merchant ID, token, etc). Used for Analytics\nfunction getBaseURL(src: string): string {\n const url = new URL(src);\n return url.origin + url.pathname;\n}\n\nclass Script implements IScript {\n private readonly src: string;\n private readonly component: string;\n private readonly node: string;\n private readonly attributes: Partial<HTMLScriptElement>;\n private readonly dataAttributes: Record<string, string | undefined>;\n private readonly analytics: IAnalytics;\n private readonly baseUrl: string;\n\n private script: HTMLScriptElement;\n private loadPromise: Promise<void> | null = null;\n private rejectLoadPromise: (reason?: any) => void | null = null;\n private resolveLoadScript: (() => void) | null = null;\n private rejectLoadScript: ((reason?: any) => void) | null = null;\n\n private readonly handleOnLoad = () => {\n this.script?.setAttribute('data-script-loaded', 'true');\n this.cleanupListeners();\n this.resolveLoadScript?.();\n };\n\n private readonly handleOnError = (errorEvent: ErrorEvent) => {\n this.cleanupListeners();\n const error = new AdyenCheckoutError(\n 'SCRIPT_ERROR',\n `Unable to load script ${this.src}.${errorEvent?.message && `Message: ${errorEvent.message}`}`,\n {\n cause: errorEvent?.error || errorEvent\n }\n );\n this.rejectLoadScript?.(error);\n };\n\n public static readonly RETRY_DELAY = 1000;\n public static readonly MAX_NUMBER_OF_RETRIES = 3;\n\n constructor({ src, component, node = 'body', attributes, dataAttributes, analytics }: IScriptProps) {\n this.src = src;\n this.component = component;\n this.node = node;\n this.attributes = attributes;\n this.dataAttributes = dataAttributes;\n this.analytics = analytics;\n this.baseUrl = getBaseURL(this.src);\n }\n\n public load = (): Promise<void> => {\n if (this.loadPromise !== null) {\n if (process.env.NODE_ENV === 'development') console.warn(`[Warning] script.load called more than once for ${this.src}`);\n return this.loadPromise;\n }\n\n this.loadPromise = new Promise((resolve, reject) => {\n this.rejectLoadPromise = reject;\n let attempts = 0;\n\n this.trackEvent(InfoEventType.sdkDownloadInitiated);\n\n const loadScriptWithRetry = async (): Promise<void> => {\n try {\n attempts++;\n await this.loadScript();\n this.trackEvent(InfoEventType.sdkDownloadCompleted);\n resolve();\n } catch (error: unknown) {\n if (this.loadPromise === null) {\n return;\n }\n\n this.trackEvent(InfoEventType.sdkDownloadFailed);\n\n this.removeScript();\n\n if (attempts < Script.MAX_NUMBER_OF_RETRIES) {\n setTimeout(() => void loadScriptWithRetry(), Script.RETRY_DELAY);\n } else {\n this.trackEvent(InfoEventType.sdkDownloadAborted);\n this.loadPromise = null;\n this.rejectLoadPromise = null;\n reject(error);\n }\n }\n };\n\n void loadScriptWithRetry();\n });\n\n return this.loadPromise;\n };\n\n public remove = () => {\n this.rejectLoadPromise?.(new AdyenCheckoutError('CANCEL', 'Script loading cancelled.'));\n this.removeScript();\n this.loadPromise = null;\n };\n\n private removeScript() {\n this.cleanupListeners();\n this.script?.parentNode?.removeChild(this.script);\n this.script = null;\n }\n\n private cleanupListeners() {\n if (!this.script) return;\n this.script.removeEventListener('load', this.handleOnLoad);\n this.script.removeEventListener('error', this.handleOnError);\n }\n\n private attachListeners() {\n if (!this.script) return;\n this.cleanupListeners();\n this.script.addEventListener('load', this.handleOnLoad);\n this.script.addEventListener('error', this.handleOnError);\n }\n\n private loadScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n const scriptContainer = document.querySelector(this.node);\n\n if (!scriptContainer) {\n reject(new AdyenCheckoutError('SCRIPT_ERROR', `Unable to find script container node: ${this.node}`));\n return;\n }\n\n this.resolveLoadScript = resolve;\n this.rejectLoadScript = reject;\n\n this.script = scriptContainer.querySelector(`script[src=\"${this.src}\"]`);\n\n // Script element exists in the browser and is already loaded\n if (this.script?.getAttribute('data-script-loaded')) {\n this.resolveLoadScript();\n return;\n }\n\n // Script element exists in the browser, but it is not loaded yet\n // Use-case: Multiple PayPal standalone components being loaded in different parts of the screen.\n if (this.script) {\n this.attachListeners();\n return;\n }\n\n // Script element doesn't exist in the browser, so we create it and append to the DOM tree\n this.script = document.createElement('script');\n\n Object.assign(this.script, this.attributes);\n Object.assign(this.script.dataset, this.dataAttributes);\n\n this.script.src = this.src;\n this.script.async = true;\n\n this.attachListeners();\n\n scriptContainer.appendChild(this.script);\n });\n }\n\n private trackEvent(eventType: InfoEventType) {\n const event = new AnalyticsInfoEvent({\n type: eventType,\n component: this.component,\n cdnUrl: this.baseUrl\n });\n this.analytics?.sendAnalytics(event);\n }\n}\n\nexport default Script;\n"],"names":["Script","removeScript","this","cleanupListeners","script","parentNode","removeChild","removeEventListener","handleOnLoad","handleOnError","attachListeners","addEventListener","loadScript","Promise","resolve","reject","scriptContainer","document","querySelector","node","resolveLoadScript","rejectLoadScript","src","getAttribute","createElement","Object","assign","attributes","dataset","dataAttributes","async","appendChild","AdyenCheckoutError","trackEvent","eventType","event","AnalyticsInfoEvent","type","component","cdnUrl","baseUrl","analytics","sendAnalytics","constructor","_define_property","loadPromise","rejectLoadPromise","setAttribute","errorEvent","error","message","cause","load","attempts","InfoEventType","sdkDownloadInitiated","loadScriptWithRetry","sdkDownloadCompleted","sdkDownloadFailed","MAX_NUMBER_OF_RETRIES","setTimeout","RETRY_DELAY","sdkDownloadAborted","remove","url","URL","origin","pathname","getBaseURL"],"mappings":"mRAwBA,MAAMA,EAgGMC,YAAAA,GACJC,KAAKC,mBACLD,KAAKE,QAAQC,YAAYC,YAAYJ,KAAKE,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