@adyen/adyen-web 6.5.1 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adyen.css +2 -2
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +68 -30
- package/dist/es/adyen.css +2 -2
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ANCV/ANCV.js.map +1 -1
- package/dist/es/components/Ach/components/AchInput/defaultProps.js +1 -1
- package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +1 -1
- package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es/components/Boleto/Boleto.js.map +1 -1
- package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
- package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
- package/dist/es/components/CashAppPay/services/types.js +1 -1
- package/dist/es/components/CashAppPay/services/types.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/Donation/components/CampaignContent.js +1 -1
- package/dist/es/components/Donation/components/CampaignContent.js.map +1 -1
- package/dist/es/components/Donation/components/CampaignInfo.js +2 -0
- package/dist/es/components/Donation/components/CampaignInfo.js.map +1 -0
- package/dist/es/components/Donation/components/DonationComponent.js +1 -1
- package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
- package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.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/Multibanco/Multibanco.js.map +1 -1
- package/dist/es/components/OnlineBankingCZ/index.js +1 -1
- package/dist/es/components/OnlineBankingCZ/index.js.map +1 -1
- package/dist/es/components/OnlineBankingSK/index.js +1 -1
- package/dist/es/components/OnlineBankingSK/index.js.map +1 -1
- package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
- package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
- package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
- package/dist/es/components/PayPal/Paypal.js.map +1 -1
- package/dist/es/components/Redirect/Redirect.js +1 -1
- package/dist/es/components/Redirect/Redirect.js.map +1 -1
- package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
- package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
- package/dist/es/components/Twint/Twint.js.map +1 -1
- package/dist/es/components/UPI/UPI.js.map +1 -1
- package/dist/es/components/internal/Address/components/CountryField.js +1 -1
- package/dist/es/components/internal/Address/components/CountryField.js.map +1 -1
- package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
- package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
- package/dist/es/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
- package/dist/es/components/internal/Address/components/StateField.js +1 -1
- package/dist/es/components/internal/Address/components/StateField.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
- package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.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/components/tx-variants.js +1 -1
- package/dist/es/components/tx-variants.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
- package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
- package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
- package/dist/es/core/Analytics/constants.js +1 -1
- package/dist/es/core/Analytics/constants.js.map +1 -1
- package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
- package/dist/es/core/Errors/SRPanel.js.map +1 -1
- package/dist/es/core/Errors/constants.js +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/Errors/utils.js +1 -1
- package/dist/es/core/RiskModule/RiskModule.js.map +1 -1
- package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/index.d.ts +68 -30
- package/dist/es-legacy/adyen.css +2 -2
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +1 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/services/types.js +1 -1
- package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/Donation/components/CampaignContent.js +1 -1
- package/dist/es-legacy/components/Donation/components/CampaignContent.js.map +1 -1
- package/dist/es-legacy/components/Donation/components/CampaignInfo.js +2 -0
- package/dist/es-legacy/components/Donation/components/CampaignInfo.js.map +1 -0
- package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
- package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.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/Multibanco/Multibanco.js.map +1 -1
- package/dist/es-legacy/components/OnlineBankingCZ/index.js +1 -1
- package/dist/es-legacy/components/OnlineBankingCZ/index.js.map +1 -1
- package/dist/es-legacy/components/OnlineBankingSK/index.js +1 -1
- package/dist/es-legacy/components/OnlineBankingSK/index.js.map +1 -1
- package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
- package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
- package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
- package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
- package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
- package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
- package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
- package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
- package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/components/CountryField.js +1 -1
- package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
- package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/components/StateField.js +1 -1
- package/dist/es-legacy/components/internal/Address/components/StateField.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.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/components/tx-variants.js +1 -1
- package/dist/es-legacy/components/tx-variants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
- package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
- package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
- package/dist/es-legacy/core/Analytics/constants.js +1 -1
- package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
- package/dist/es-legacy/core/Errors/constants.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/Errors/utils.js +1 -1
- package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
- package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/package.json +12 -12
- package/styles/adyen.css +2 -2
- package/dist/es/components/Donation/components/CampaignContainer.js +0 -2
- package/dist/es/components/Donation/components/CampaignContainer.js.map +0 -1
- package/dist/es-legacy/components/Donation/components/CampaignContainer.js +0 -2
- package/dist/es-legacy/components/Donation/components/CampaignContainer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', srPanelResp.fieldToFocus);\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","props","_object_without_properties","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","IssuerListInputTypes","defaultProps"],"mappings":"+hDA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAaF,QAAAA,EAAAA,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,WAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,gBAShB,SAASC,EAAWC,GAAA,IAAAf,MAAEA,EAAKgB,YAAEA,EAAWjB,OAAEA,EAAMkB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,GAA1EJ,EAA6FK,EAA7FC,EAAAN,EAAA,CAAEf,QAAOgB,cAAajB,SAAQkB,iBAAqBC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IAAqB1E,EAAM2E,QAC/B,CAACC,EAAMC,KACC5D,EAAe6D,SAASD,EAAKxE,KAAKuE,EAAKF,iBAAiBK,2UAAKC,CAAKH,GAAAA,IAC/DD,IAEX,CAAEF,iBAAkB,KAGxB,OACIO,EAACC,MAAAA,CAAIC,UAAU,iCACRT,GAAiB/D,QAChBsE,EAACG,OACGH,EAACI,EAAAA,CACGC,iBAAmE7D,IAAjDU,EAAiDV,EAAK,OAAY,KACpFzB,MAAO0E,GACPR,SAAUvB,EAAAA,KAEdsC,EAACM,SAITN,EAACO,EAAAA,CACGC,MAAOxF,EAAKM,IAAI,gCAChBK,cAnEY8E,GAmEkB/D,EAAO5B,OAnEf2F,IAASA,GAAM9E,aAAeX,EAAKM,IAAImF,GAAM9E,gBAAkB8E,IAoErFC,mBAAoB,CAAC,eACrBrF,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhB8D,EAACW,EAAAA,CACG5F,MAAOA,EACP6F,cAA6DpE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACN6E,UAAW,wCACXjB,SAAUvB,EAAAA,GACVmD,aAAcxC,EACdyC,QAASlC,MAIhBzC,EAAM4E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAASjG,EAAKM,IAAIa,EAAM4E,mBAAmBG,gBAAiBC,KAAMhF,EAAM4E,mBAAmBI,QAIrHhF,EAAMiF,eACHjF,EAAMkF,UAAU,CACZtE,SACAyD,MAAO3F,EAAe,CAAEC,OAAQ0B,EAAc,OAAEzB,MAAO,IAAIA,KAAU0E,KAAqBzE,MA9FlFyF,IAAAA,EAkG5B,EApHKa,SAAAA,+DAAAA,CAAAA,IAAAA,EAAAA,CAAAA,IAsHLzF,EAAW0F,aAAe,CACtBtC,SAAU"}
|
|
1
|
+
{"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', srPanelResp.fieldToFocus);\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","props","_object_without_properties","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"+hDA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAaF,QAAAA,EAAAA,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,WAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAAEA,EAAKgB,YAAEA,EAAWjB,OAAEA,EAAMkB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,GAA1EJ,EAA6FK,EAA7FC,EAAAN,EAAA,CAAEf,QAAOgB,cAAajB,SAAQkB,iBAAqBC,wBAAuBC,mBAC1F,MAAMlB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFrB,SACAsB,YAAa,CAAE/B,UACfgC,MAAOtB,KAEJuB,EAAQC,GAAaC,EAAS,UAC9BC,EAAWC,GAAgBF,EAAAA,I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,IAAjDU,EAAiDV,EAAK,OAAY,KACpFzB,MAAO0E,GACPR,SAAUvB,EAAAA,KAEdsC,EAACM,SAITN,EAACO,EAAAA,CACGC,MAAOxF,EAAKM,IAAI,gCAChBK,cAnEY8E,GAmEkB/D,EAAO5B,OAnEf2F,IAASA,GAAM9E,aAAeX,EAAKM,IAAImF,GAAM9E,gBAAkB8E,IAoErFC,mBAAoB,CAAC,eACrBrF,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhB8D,EAACW,EAAAA,CACG5F,MAAOA,EACP6F,cAA6DpE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACN6E,UAAW,wCACXjB,SAAUvB,EAAAA,GACVmD,aAAcxC,EACdyC,QAASlC,MAIhBzC,EAAM4E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAASjG,EAAKM,IAAIa,EAAM4E,mBAAmBG,gBAAiBC,KAAMhF,EAAM4E,mBAAmBI,QAIrHhF,EAAMiF,eACHjF,EAAMkF,UAAU,CACZtE,SACAyD,MAAO3F,EAAe,CAAEC,OAAQ0B,EAAc,OAAEzB,MAAO,IAAIA,KAAU0E,KAAqBzE,MA9FlFyF,IAAAA,EAkG5B,CAEA5E,EAAWyF,aAAe,CACtBrC,SAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyPersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/ReadOnlyPersonalDetails.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport Fieldset from '../FormFields/Fieldset';\nimport { ReadOnlyPersonalDetailsProps } from './types';\n\nconst ReadOnlyPersonalDetails = ({ data }) => {\n const { firstName, lastName, shopperEmail, telephoneNumber }: ReadOnlyPersonalDetailsProps = data;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label=\"personalDetails\" readonly>\n {firstName && `${firstName} `}\n {lastName && `${lastName} `}\n {shopperEmail && (\n <Fragment>\n <br />\n {shopperEmail}\n </Fragment>\n )}\n {telephoneNumber && (\n <Fragment>\n <br />\n {telephoneNumber}\n </Fragment>\n )}\n </Fieldset>\n );\n};\n\nexport default ReadOnlyPersonalDetails;\n"],"names":["ReadOnlyPersonalDetails","data","firstName","lastName","shopperEmail","telephoneNumber","h","Fieldset","classNameModifiers","label","readonly","Fragment","br"],"mappings":"wIAIA,MAAMA,EAA0B,EAAGC,WAC/B,MAAMC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,EAAYC,gBAAEA,GAAkDJ,EAE7F,OACIK,EAACC,EAAAA,CAASC,mBAAoB,CAAC,mBAAoBC,MAAM,kBAAkBC,UAAAA,GACtER,GAAa,GAAGA,KAChBC,GAAY,GAAGA,KACfC,GACGE,EAACK,
|
|
1
|
+
{"version":3,"file":"ReadOnlyPersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/ReadOnlyPersonalDetails.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport Fieldset from '../FormFields/Fieldset';\nimport { ReadOnlyPersonalDetailsProps } from './types';\n\nconst ReadOnlyPersonalDetails = ({ data }) => {\n const { firstName, lastName, shopperEmail, telephoneNumber }: ReadOnlyPersonalDetailsProps = data;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label=\"personalDetails\" readonly>\n {firstName && `${firstName} `}\n {lastName && `${lastName} `}\n {shopperEmail && (\n <Fragment>\n <br />\n {shopperEmail}\n </Fragment>\n )}\n {telephoneNumber && (\n <Fragment>\n <br />\n {telephoneNumber}\n </Fragment>\n )}\n </Fieldset>\n );\n};\n\nexport default ReadOnlyPersonalDetails;\n"],"names":["ReadOnlyPersonalDetails","data","firstName","lastName","shopperEmail","telephoneNumber","h","Fieldset","classNameModifiers","label","readonly","Fragment","br"],"mappings":"wIAIA,MAAMA,EAA0B,EAAGC,WAC/B,MAAMC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,EAAYC,gBAAEA,GAAkDJ,EAE7F,OACIK,EAACC,EAAAA,CAASC,mBAAoB,CAAC,mBAAoBC,MAAM,kBAAkBC,UAAAA,GACtER,GAAa,GAAGA,KAChBC,GAAY,GAAGA,KACfC,GACGE,EAACK,OACGL,EAACM,KAAAA,MACAR,GAGRC,GACGC,EAACK,EACG,KAAAL,EAACM,KACAP,MAAAA,GAAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_DOWNLOAD_STR as h,ANALYTICS_QR_CODE_DOWNLOAD as _}from"../../../core/Analytics/constants.js";import{PREFIX as y}from"../Icon/constants.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class f extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:g,type:f,onActionHandled:k},{expired:v,completed:q,loading:b}){var C,N,w,T;const{i18n:I,loadingContext:j}=p(),S=l(),x=this.props.qrCodeData?`${j}barcode.
|
|
1
|
+
import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_DOWNLOAD_STR as h,ANALYTICS_QR_CODE_DOWNLOAD as _}from"../../../core/Analytics/constants.js";import{PREFIX as y}from"../Icon/constants.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class f extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:g,type:f,onActionHandled:k},{expired:v,completed:q,loading:b}){var C,N,w,T;const{i18n:I,loadingContext:j}=p(),S=l(),x=this.props.qrCodeData?`${j}utility/v1/barcode.png?type=qrCode&data=${this.props.qrCodeData}&clientKey=${this.props.clientKey}`:this.props.qrCodeImage,E=(t,o)=>{const r=I.get(o);return m(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:S({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(v)return E("error","error.subtitle.payment");if(q)return E("success","creditCard.success");if(b)return e("div",{className:"adyen-checkout__qr-loader"},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:c,src:i,className:"adyen-checkout__qr-loader__brand-logo"})),e(s,null));const P=I.get(this.props.timeToPay).split("%@"),D=u(),A=this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`));return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${f} ${A.join(" ")}`},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:i,alt:c,className:"adyen-checkout__qr-loader__brand-logo"})),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},I.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("div",{className:"adyen-checkout__qr-loader__subtitle"},I.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:I.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:D,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?I.get(this.props.introduction):null===(C=(N=this.props).introduction)||void 0===C?void 0:C.call(N)),e("img",{src:x,alt:I.get("wechatpay.scanqrcode"),onLoad:()=>{null==k||k({componentType:this.props.type,actionDescription:"qr-code-loaded"})}}),e("div",{className:"adyen-checkout__qr-loader__progress"},e("span",{className:"adyen-checkout__qr-loader__percentage",style:{width:`${this.state.percentage}%`}})),e("div",{className:"adyen-checkout__qr-loader__countdown"},P[0]," ",e(o,{minutesFromNow:g,onTick:this.onTick,onCompleted:this.onTimeUp})," ",P[1]),this.props.instructions&&e("div",{className:"adyen-checkout__qr-loader__instructions"},"string"==typeof this.props.instructions?I.get(this.props.instructions):null===(w=(T=this.props).instructions)||void 0===w?void 0:w.call(T)),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{n(this.props.qrCodeData),this.props.onSubmitAnalytics({type:h,target:_}),e()},icon:S({imageFolder:"components/"})(`${y}copy`),label:I.get("button.copy")})))}constructor(t){super(t),g(this,"timeoutId",void 0),g(this,"redirectToApp",(t=>{window.location.assign(t)})),g(this,"statusInterval",((t=0)=>{if(this.state.expired||this.state.completed)return;this.setState((e=>({timePassed:e.timePassed+this.props.delay+t})));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)})),g(this,"onTick",(t=>{this.setState({percentage:t.percentage})})),g(this,"onTimeUp",(()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))})),g(this,"onComplete",(t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)})),g(this,"onError",(t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new c("ERROR","error result with no payload in response");return this.props.onError(e)})),g(this,"checkStatus",(()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(i).catch((t=>({type:"network-error",props:t}))).then((t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t}))})),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}g(f,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"});export{f as default};
|
|
2
2
|
//# sourceMappingURL=QRLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\n\nconst QRCODE_URL = 'barcode.shtml?barcodeType=qrCode&fileType=png&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const qrCodeImage = this.props.qrCodeData ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}` : this.props.qrCodeImage;\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]} \n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n {timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","_this_props_introduction","_this_props","_this_props_instructions","_this_props1","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","call","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","clientKey","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"mgCAsBA,MAAMA,UAAiBC,EA8BnBC,iBAAAA,GACIC,KAAKC,gBACT,CAEAC,oBAAAA,GACIC,aAAaH,KAAKI,UACtB,CAiBQC,UAAAA,CAAWC,GACfH,aAAaH,KAAKI,WAGlBJ,KAAKI,UAAYG,YAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBX,KAAKY,cACX,MAAMC,EAAMH,YAAYC,MACxBX,KAAKC,eAAea,KAAKC,MAAMF,EAAMJ,GAAAA,GACtCH,EACP,CAiEAU,MAAAA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,UAAEA,EAASC,cAAEA,EAAaC,KAAEA,EAAIC,gBAAEA,IAAkCC,QAAEA,EAAOC,UAAEA,EAASC,QAAEA,IAqEtB,IAAAC,EAAAC,EA0BIC,EAAAC,EA9FnG,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IACXC,EAAcpC,KAAKqC,MAAMC,WAAa,GAAGN,uDAA8BhC,KAAKqC,MAAMC,aAAetC,KAAKqC,MAAMD,YAC5GG,EAAa,CAACC,EAAOC,KACvB,MAAMC,EAASX,EAAKY,IAAIF,GAExB,OADAG,EAAgBF,GAEZG,EAACC,MAAAA,CAAIC,UAAU,+DACXF,EAACG,MAAAA,CACGD,UAAU,0EACVE,IAAKf,EAAS,CAAEgB,YAAa,eAAxBhB,CAAyCM,GAC9CW,IAAKT,IAETG,EAACC,MAAAA,CAAIC,UAAU,uCAAuCL,GAAAA,EAKlE,GAAIlB,EACA,OAAOe,EAAW,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A,EAAWE,UAAEA,EAAS5F,eAAEA,EAAckF,kBAAEA,GAAsBlH,KAAKqC,MAE3E,OAAOwF,EAAmBH,EAAaE,EAAW5F,EAAgBkF,GAC7DY,KAAKC,GACLC,OAAMC,IAAa,CAAE3G,KAAM,gBAAiBe,MAAO4F,MACnDH,MAAMpF,IACH,OAAQA,EAAOpB,MACX,IAAK,UACDtB,KAAKsH,WAAW5E,GAChB,MACJ,IAAK,QACD1C,KAAKoH,QAAQ1E,GACb,MACJ,QACI1C,KAAK6G,SAAS,CAAEnF,SAAS,IAEjC,OAAOgB,CAAAA,GACX,IAzHJ1C,KAAKkF,MAAQ,CACTgD,aAAc,UACdzG,WAAW,EACXnB,MAAO+B,EAAM/B,MACbkB,SAAS,EACTE,SAAS,EACTyD,WAAY,IACZ4B,WAAY,EAEpB,EAEAP,EAjBE3G,EAiBYsI,eAAe,CACzB7H,MAAO,IACPe,cAAe,GACf+F,QAAS,OACTE,WAAY,OACZL,aAAc,IACdtD,mBAAoB,GACpBuD,kBAAmB,IACnBxC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
|
|
1
|
+
{"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n\n const qrCodeImage = this.props.qrCodeData\n ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}&clientKey=${this.props.clientKey}`\n : this.props.qrCodeImage;\n\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]} \n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n {timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","_this_props_introduction","_this_props","_this_props_instructions","_this_props1","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","clientKey","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","call","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mapp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,GAChB,MACJ,IAAK,QACD3C,KAAKqH,QAAQ1E,GACb,MACJ,QACI3C,KAAK8G,SAAS,CAAEpF,SAAS,IAEjC,OAAOiB,CAAAA,GACX,IAzHJ3C,KAAKmF,MAAQ,CACT+C,aAAc,UACdzG,WAAW,EACXnB,MAAO+B,EAAM/B,MACbkB,SAAS,EACTE,SAAS,EACT0D,WAAY,IACZ4B,WAAY,EAEpB,EAEAP,EAjBE5G,EAiBYsI,eAAe,CACzB7H,MAAO,IACPe,cAAe,GACfgG,QAAS,OACTE,WAAY,OACZL,aAAc,IACdtD,mBAAoB,GACpBuD,kBAAmB,IACnBxC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","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AE3BtE,KAAKqE,MAAQkF,EAEbvJ,KAAK0B,mBAAqB,KAC1B1B,KAAKqF,qBAAuB,IAE5BrF,KAAK2B,qBAAuB,KAC5B3B,KAAKqJ,uBAAyB,KAE9BrJ,KAAKY,gBAAkB,GAGvBZ,KAAK8C,aAAe8G,EAAS9G,aAAa+G,KAAK7J,MAC/CA,KAAKgD,sBAAwB4G,EAAS5G,sBAAsB6G,KAAK7J,MACjEA,KAAKkD,mBAAqB0G,EAAS1G,mBAAmB2G,KAAK7J,MAC3DA,KAAKoD,iBAAmBwG,EAASxG,iBAAiByG,KAAK7J,MACvDA,KAAKsD,cAAgBsG,EAAStG,cAAcuG,KAAK7J,MACjDA,KAAK0D,YAAckG,EAASlG,YAAYmG,KAAK7J,MAC7CA,KAAKwD,cAAgBoG,EAASpG,cAAcqG,KAAK7J,MACjDA,KAAKoB,uBAAyBwI,EAASxI,uBAAuByI,KAAK7J,MACnEA,KAAK6D,qBAAuB+F,EAAS/F,qBAAqBgG,KAAK7J,MAC/DA,KAAKiE,sBAAwB2F,EAAS3F,sBAAsB4F,KAAK7J,MACjEA,KAAKmE,iBAAmByF,EAASzF,iBAAiB0F,KAAK7J,MAEvDA,KAAKwI,yBAA2BxI,KAAKwI,yBAAyBqB,KAAK7J,MAGnEA,KAAKgH,WAAahH,KAAKgH,WAAW6C,KAAK7J,MACvCA,KAAKmH,aAAenH,KAAKmH,aAAa0C,KAAK7J,MAC3CA,KAAKyG,sBAAwBzG,KAAKyG,sBAAsBoD,KAAK7J,MAC7DA,KAAKuH,eAAiBvH,KAAKuH,eAAesC,KAAK7J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQ2I,KAAK7J,KACrC,EAEAoJ,EAvEEvJ,EAuEYiK,eAAeA"}
|
|
1
|
+
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAC,GAEjDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAaz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,sBAAsB4F,KAAK7J,MACjEA,KAAKmE,iBAAmByF,EAASzF,iBAAiB0F,KAAK7J,MAEvDA,KAAKwI,yBAA2BxI,KAAKwI,yBAAyBqB,KAAK7J,MAGnEA,KAAKgH,WAAahH,KAAKgH,WAAW6C,KAAK7J,MACvCA,KAAKmH,aAAenH,KAAKmH,aAAa0C,KAAK7J,MAC3CA,KAAKyG,sBAAwBzG,KAAKyG,sBAAsBoD,KAAK7J,MAC7DA,KAAKuH,eAAiBvH,KAAKuH,eAAesC,KAAK7J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQ2I,KAAK7J,KACrC,EAEAoJ,EAvEEvJ,EAuEYiK,eAAeA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../../external/preact/dist/preact.js";import e from"../BaseElement/BaseElement.js";import s from"../PayButton/PayButton.js";import{assertIsDropin as i,getRegulatoryDefaults as n,sanitizeResponse as o,verifyPaymentDidNotFail as r,cleanupFinalResult as a}from"./utils.js";import l from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as h}from"../../../utils/hasOwnProperty.js";import{ANALYTICS_SUBMIT_STR as d}from"../../../core/Analytics/constants.js";import c from"../../../core/Errors/CancelError.js";function p(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function m(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),i.forEach((function(e){p(t,e,s[e])}))}return t}function u(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class y extends e{buildElementProps(t){const e=m({showPayButton:!0},this.core.getCorePropsForComponent(),!!(null==t?void 0:t.isStoredPaymentMethod)?{}:this.core.paymentMethodsResponse.find((null==t?void 0:t.type)||this.constructor.type),t),s=i(this);this.props=this.formatProps(m({},this.constructor.defaultProps,n(this.core.options.countryCode,s),e))}storeElementRefOnCore(t){(null==t?void 0:t.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(t){this.state=m({},this.state,t),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(t,e){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(t,e),this}setStatus(t,e){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(t,e),this}onChange(){var t,e;null===(t=(e=this.props).onChange)||void 0===t||t.call(e,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}setUpAnalytics(t){var e;const s=null===(e=this.props.session)||void 0===e?void 0:e.id;return this.props.modules.analytics.setUp(m({},t,s&&{sessionId:s}))}submitAnalytics(t,e){try{
|
|
1
|
+
import{createElement as t}from"../../../external/preact/dist/preact.js";import e from"../BaseElement/BaseElement.js";import s from"../PayButton/PayButton.js";import{assertIsDropin as i,getRegulatoryDefaults as n,sanitizeResponse as o,verifyPaymentDidNotFail as r,cleanupFinalResult as a}from"./utils.js";import l from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as h}from"../../../utils/hasOwnProperty.js";import{ANALYTICS_SUBMIT_STR as d}from"../../../core/Analytics/constants.js";import c from"../../../core/Errors/CancelError.js";function p(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function m(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter((function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable})))),i.forEach((function(e){p(t,e,s[e])}))}return t}function u(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))})),t}class y extends e{buildElementProps(t){const e=m({showPayButton:!0},this.core.getCorePropsForComponent(),!!(null==t?void 0:t.isStoredPaymentMethod)?{}:this.core.paymentMethodsResponse.find((null==t?void 0:t.type)||this.constructor.type),t),s=i(this);this.props=this.formatProps(m({},this.constructor.defaultProps,n(this.core.options.countryCode,s),e))}storeElementRefOnCore(t){(null==t?void 0:t.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(t){this.state=m({},this.state,t),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(t,e){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(t,e),this}setStatus(t,e){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(t,e),this}onChange(){var t,e;null===(t=(e=this.props).onChange)||void 0===t||t.call(e,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}setUpAnalytics(t){var e;const s=null===(e=this.props.session)||void 0===e?void 0:e.id;return this.props.modules.analytics.setUp(m({},t,s&&{sessionId:s}))}submitAnalytics(t,e){try{this.props.modules.analytics.sendAnalytics(this.getComponent(t),t,e)}catch(t){console.warn("Failed to submit the analytics event. Error:",t)}}getComponent({component:t}){return t||(this.constructor.analyticsType?this.constructor.analyticsType:"scheme"===this.constructor.type||"bcmc"===this.constructor.type?this.constructor.type:this.props.type)}submit(){this.isValid?this.makePaymentsCall().then(o).then(r).then(this.handleResponse).catch((t=>{t instanceof c?this.setElementStatus("ready"):this.handleFailedResult(t)})):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise(((t,e)=>this.props.beforeSubmit(this.data,this.elementRef,{resolve:t,reject:()=>e(new c("beforeSubmitRejected"))}))):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new l("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){return new Promise(((t,e)=>{this.submitAnalytics({type:d}),this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:t,reject:e})}))}async submitUsingSessionsFlow(t){this.submitAnalytics({type:d});try{return await this.core.session.submitPayment(t)}catch(t){return t instanceof l?this.handleError(t):this.handleError(new l("ERROR","Error when making /payments call",{cause:t})),Promise.reject(t)}}onComplete(t){this.props.onComplete&&this.props.onComplete(t,this.elementRef)}handleAdditionalDetails(t){this.makeAdditionalDetailsCall(t).then(o).then(r).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(t){return this.props.onAdditionalDetails?new Promise(((e,s)=>{this.props.onAdditionalDetails(t,this.elementRef,{resolve:e,reject:s})})):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(t.data):void this.handleError(new l("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(t){try{return await this.core.session.submitDetails(t)}catch(t){return t instanceof l?this.handleError(t):this.handleError(new l("ERROR","Error when making /details call",{cause:t})),Promise.reject(t)}}handleAction(t,e={}){if(!t||!t.type){if(h(t,"action")&&h(t,"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(t,u(m({},this.elementRef.props,e),{onAdditionalDetails:this.handleAdditionalDetails}));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(t){var e,s;null===(s=this.props)||void 0===s||null===(e=s.onActionHandled)||void 0===e||e.call(s,m({originalAction:this.props.originalAction},t))}handleResponse(t){var e,s;const i=o(t);i.action?this.elementRef.handleAction(i.action):(null===(s=i.order)||void 0===s||null===(e=s.remainingAmount)||void 0===e?void 0:e.value)>0?this.handleOrder(i):this.handleSuccessResult(i)}handleKeyPress(t){var e;"Enter"!==t.key&&"Enter"!==t.code||(t.preventDefault(),this.onEnterKeyPressed(null===(e=document)||void 0===e?void 0:e.activeElement,this))}onEnterKeyPressed(t,e){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(t,e):(t.blur(),this.submit())}updateParent(t={}){return this.elementRef.core.update(t)}get isValid(){return!1}get icon(){const t=this.props.paymentMethodType||this.type;var e;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()(t)}get displayName(){var t,e;const s=null===(e=this.core.paymentMethodsResponse)||void 0===e||null===(t=e.paymentMethods)||void 0===t?void 0:t.find((t=>t.type===this.type));return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(t,e){return new Promise(((e,s)=>{if(!this.props.onPaymentMethodsRequest)return e();this.props.onPaymentMethodsRequest(u(m({},t&&{order:{orderData:t.orderData,pspReference:t.pspReference}}),{locale:this.core.options.locale}),{resolve:e,reject:s})})).catch((t=>{this.handleError(new l("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:t}))})).then((s=>this.core.update(u(m({},s&&{paymentMethodsResponse:s}),{order:t,amount:t?t.remainingAmount:e}))))}constructor(e,n){super(e,n),p(this,"componentRef",void 0),p(this,"resources",void 0),p(this,"elementRef",void 0),p(this,"handleError",(t=>{this.setElementStatus("ready"),this.props.onError&&this.props.onError(t,this.elementRef)})),p(this,"handleOrder",(t=>{const{order:e}=t;(this.core.session?this.core.update({order:e}):this.handleAdvanceFlowPaymentMethodsUpdate(e)).then((()=>{var t,s;null===(t=(s=this.props).onOrderUpdated)||void 0===t||t.call(s,{order:e})}))})),p(this,"handleFailedResult",(t=>{var e,s;i(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),a(t),null===(e=(s=this.props).onPaymentFailed)||void 0===e||e.call(s,t,this.elementRef)})),p(this,"handleSuccessResult",(t=>{var e,s;i(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),a(t),null===(e=(s=this.props).onPaymentCompleted)||void 0===e||e.call(s,t,this.elementRef)})),p(this,"setComponentRef",(t=>{this.componentRef=t})),p(this,"payButton",(e=>t(s,u(m({},e),{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=n&&n.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)}}p(y,"type",void 0),p(y,"txVariants",[]);export{y as UIElement,y 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 BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport { Resources } from '../../../core/Context/Resources';\nimport { ANALYTICS_SUBMIT_STR } from '../../../core/Analytics/constants';\n\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from '../../../core/types';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementProps, UIElementStatus } from './types';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentResponse\n} from '../../../types/global-types';\nimport type { IDropin } from '../../Dropin/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\n\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\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n const isStoredPaymentMethod = !!componentProps?.isStoredPaymentMethod;\n const paymentMethodsResponseProps = isStoredPaymentMethod\n ? {}\n : this.core.paymentMethodsResponse.find(componentProps?.type || this.constructor['type']);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodsResponseProps,\n ...componentProps\n };\n\n const isDropin = assertIsDropin(this as unknown as IDropin);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropin), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\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 public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\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 // Only called once, for UIElements (including Dropin), as they are being mounted\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n const sessionId = this.props.session?.id;\n\n return this.props.modules.analytics.setUp({\n ...setUpAnalyticsObj,\n ...(sessionId && { sessionId })\n });\n }\n\n /**\n * A function for all UIElements, or BaseElement, to use to create an analytics action for when it's been:\n * - mounted,\n * - a PM has been selected\n * - onSubmit has been called (as a result of the pay button being pressed)\n *\n * In some other cases e.g. 3DS2 components, this function is overridden to allow more specific analytics actions to be created\n */\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject, uiElementProps?) {\n /** Work out what the component's \"type\" is:\n * - first check for a dedicated \"analyticsType\" (currently only applies to custom-cards)\n * - otherwise, distinguish cards from non-cards: cards will use their static type property, everything else will use props.type\n */\n try {\n let component = this.constructor['analyticsType'];\n if (!component) {\n component = this.constructor['type'] === 'scheme' || this.constructor['type'] === 'bcmc' ? this.constructor['type'] : this.props.type;\n }\n\n this.props.modules.analytics.sendAnalytics(component, analyticsObj, uiElementProps);\n } catch (error) {\n console.warn('Failed to submit the analytics event. Error:', error);\n }\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 return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n // Call analytics endpoint\n this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\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 this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\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/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvLs1Dlgo1ZrfkQRzaNiuVM8ejRG0IWE1bGThJzY+sJvZZHvlDMXIlxhZcDoQvsMj/WwE6+nFJxBiC3oRzmvVn3AbkLQGtvwq16UUSfYbPzG9dXypJMtcrZAQYq2g/2+BSibCcmee9AXq/wij11BERrYmjbDt5NkkdUnDVgAB7pdqbnWX0A2sxBKeYtLSP2kxp+5LoU/Wty3fmcVA3VKVkHfgmIihkeL8lY++5hvHjnkzOE4tyx/sheiKS4zqoWE43TD6n8mpFskAzwMHq4G2o6vkXqvaKFEq7y/R2fVrCypenm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qFtIr/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 if (this.props.onComplete) this.props.onComplete(state, this.elementRef);\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 (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 onAdditionalDetails: this.handleAdditionalDetails\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 * @param rawResponse -\n */\n protected handleResponse(rawResponse: RawPaymentResponse): void {\n const response = sanitizeResponse(rawResponse);\n\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\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\nexport default UIElement;\n"],"names":["UIElement","BaseElement","buildElementProps","componentProps","finalProps","_object_spread","showPayButton","this","core","getCorePropsForComponent","isStoredPaymentMethod","paymentMethodsResponse","find","type","constructor","isDropin","assertIsDropin","props","formatProps","getRegulatoryDefaults","options","countryCode","storeElementRefOnCore","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","setElementStatus","status","_this_elementRef","elementRef","setStatus","_this_componentRef","_this_props_onChange","_this_props","call","data","isValid","errors","valid","setUpAnalytics","setUpAnalyticsObj","_this_props_session","sessionId","session","id","modules","analytics","setUp","submitAnalytics","analyticsObj","uiElementProps","component","sendAnalytics","error","console","warn","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","ANALYTICS_SUBMIT_STR","submitPayment","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","_object_spread_props","unmount","mount","_node","onActionHandled","actionHandledObj","_this_props_onActionHandled","originalAction","rawResponse","response","order","remainingAmount","value","handleOrder","handleSuccessResult","handleKeyPress","document","key","code","preventDefault","onEnterKeyPressed","activeElement","blur","updateParent","update","icon","paymentMethodType","_this_props_icon","resources","getImage","displayName","_this_core_paymentMethodsResponse_paymentMethods","_this_core_paymentMethodsResponse","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","amount","onPaymentMethodsRequest","orderData","pspReference","locale","checkout","super","_define_property","onError","_this_props_onOrderUpdated","onOrderUpdated","result","_this_props_onPaymentFailed","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","_this_props_onPaymentCompleted","onPaymentCompleted","setComponentRef","ref","payButton","h","PayButton","secondaryAmount","onClick","register","bind","undefined","txVariants"],"mappings":"01CA8BO,MAAeA,UAA6DC,EAyC5DC,iBAAAA,CAAkBC,GACjC,MAMMC,EAAaC,EAAA,CACfC,eAAe,GAPKC,KAAKC,KAAKC,8BACFN,aAAAA,EAAAA,EAAgBO,uBAE1C,GACAH,KAAKC,KAAKG,uBAAuBC,MAAKT,eAAAA,EAAgBU,OAAQN,KAA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KAAKwD,OAASxD,KAAKwD,OAAOkG,KAAK1J,MAC/BA,KAAKoB,SAAWpB,KAAKoB,SAASsI,KAAK1J,MACnCA,KAAK4E,WAAa5E,KAAK4E,WAAW8E,KAAK1J,MACvCA,KAAKkF,aAAelF,KAAKkF,aAAawE,KAAK1J,MAC3CA,KAAKqG,YAAcrG,KAAKqG,YAAYqD,KAAK1J,MACzCA,KAAK6E,wBAA0B7E,KAAK6E,wBAAwB6E,KAAK1J,MACjEA,KAAK6D,eAAiB7D,KAAK6D,eAAe6F,KAAK1J,MAC/CA,KAAK0B,iBAAmB1B,KAAK0B,iBAAiBgI,KAAK1J,MACnDA,KAAKgD,gBAAkBhD,KAAKgD,gBAAgB0G,KAAK1J,MACjDA,KAAKyD,iBAAmBzD,KAAKyD,iBAAiBiG,KAAK1J,MACnDA,KAAK8E,0BAA4B9E,KAAK8E,0BAA0B4E,KAAK1J,MACrEA,KAAKsE,wBAA0BtE,KAAKsE,wBAAwBoF,KAAK1J,MAEjEA,KAAK6B,WAAcnB,GAASA,EAAMmB,YAAe7B,KACjDA,KAAKoH,UAAYpH,KAAKU,MAAMmC,QAAU7C,KAAKU,MAAMmC,QAAQuE,eAAYuC,EAErE3J,KAAKe,sBAAsBf,KAAKU,OAEhCV,KAAK4G,kBAAoB5G,KAAK4G,kBAAkB8C,KAAK1J,MACrDA,KAAK4F,gBAAkB5F,KAAK4F,gBAAgB8D,KAAK1J,KACrD,EAhCAuI,EAPkB9I,EAOJa,YAAOqJ,GAKrBpB,EAZkB9I,EAYJmK,aAAuB"}
|
|
1
|
+
{"version":3,"file":"UIElement.js","sources":["../../../../../src/components/internal/UIElement/UIElement.tsx"],"sourcesContent":["import { h } from 'preact';\nimport BaseElement from '../BaseElement/BaseElement';\nimport PayButton from '../PayButton';\nimport { assertIsDropin, cleanupFinalResult, getRegulatoryDefaults, sanitizeResponse, verifyPaymentDidNotFail } from './utils';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { hasOwnProperty } from '../../../utils/hasOwnProperty';\nimport { Resources } from '../../../core/Context/Resources';\nimport { ANALYTICS_SUBMIT_STR } from '../../../core/Analytics/constants';\n\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport type { CoreConfiguration, ICore, AdditionalDetailsData } from '../../../core/types';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementProps, UIElementStatus } from './types';\nimport type { CheckoutSessionDetailsResponse, CheckoutSessionPaymentResponse } from '../../../core/CheckoutSession/types';\nimport type {\n ActionHandledReturnObject,\n CheckoutAdvancedFlowResponse,\n Order,\n PaymentAction,\n PaymentAmount,\n PaymentData,\n PaymentMethodsResponse,\n PaymentResponseData,\n RawPaymentResponse\n} from '../../../types/global-types';\nimport type { IDropin } from '../../Dropin/types';\nimport type { NewableComponent } from '../../../core/core.registry';\nimport CancelError from '../../../core/Errors/CancelError';\n\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\n protected override buildElementProps(componentProps?: P) {\n const globalCoreProps = this.core.getCorePropsForComponent();\n const isStoredPaymentMethod = !!componentProps?.isStoredPaymentMethod;\n const paymentMethodsResponseProps = isStoredPaymentMethod\n ? {}\n : this.core.paymentMethodsResponse.find(componentProps?.type || this.constructor['type']);\n\n const finalProps = {\n showPayButton: true,\n ...globalCoreProps,\n ...paymentMethodsResponseProps,\n ...componentProps\n };\n\n const isDropin = assertIsDropin(this as unknown as IDropin);\n\n this.props = this.formatProps({\n ...this.constructor['defaultProps'], // component defaults\n ...getRegulatoryDefaults(this.core.options.countryCode, isDropin), // regulatory defaults\n ...finalProps // the rest (inc. merchant defined config)\n });\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 public setElementStatus(status: UIElementStatus, props?: any): this {\n this.elementRef?.setStatus(status, props);\n return this;\n }\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 // Only called once, for UIElements (including Dropin), as they are being mounted\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n const sessionId = this.props.session?.id;\n\n return this.props.modules.analytics.setUp({\n ...setUpAnalyticsObj,\n ...(sessionId && { sessionId })\n });\n }\n\n /**\n * A function for all UIElements, or BaseElement, to use to create an analytics action for when it's been:\n * - mounted,\n * - a PM has been selected\n * - onSubmit has been called (as a result of the pay button being pressed)\n *\n * In some other cases e.g. 3DS2 components, this function is overridden to allow more specific analytics actions to be created\n */\n\n protected submitAnalytics(analyticsObj: SendAnalyticsObject, uiElementProps?) {\n /** Work out what the component's \"type\" is:\n * - first check for a dedicated \"analyticsType\" (currently only applies to custom-cards)\n * - otherwise, distinguish cards from non-cards: cards will use their static type property, everything else will use props.type\n */\n try {\n this.props.modules.analytics.sendAnalytics(this.getComponent(analyticsObj), analyticsObj, uiElementProps);\n } catch (error) {\n console.warn('Failed to submit the analytics event. Error:', error);\n }\n }\n\n private getComponent({ component }: SendAnalyticsObject): string {\n if (component) {\n return component;\n }\n if (this.constructor['analyticsType']) {\n return this.constructor['analyticsType'];\n }\n if (this.constructor['type'] === 'scheme' || this.constructor['type'] === 'bcmc') {\n return this.constructor['type'];\n }\n return this.props.type;\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 return new Promise<CheckoutAdvancedFlowResponse>((resolve, reject) => {\n // Call analytics endpoint\n this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\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 this.submitAnalytics({ type: ANALYTICS_SUBMIT_STR });\n\n try {\n return await this.core.session.submitPayment(data);\n } catch (error: unknown) {\n if (error instanceof AdyenCheckoutError) this.handleError(error);\n else this.handleError(new AdyenCheckoutError('ERROR', 'Error when making /payments call', { cause: error }));\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/0leR88qkV24vtIkjsIsbJTDB78Pd8wX8MEDsXhaAdEIyX9E8eqxuQ3bwPbvLs1Dlgo1ZrfkQRzaNiuVM8ejRG0IWE1bGThJzY+sJvZZHvlDMXIlxhZcDoQvsMj/WwE6+nFJxBiC3oRzmvVn3AbkLQGtvwq16UUSfYbPzG9dXypJMtcrZAQYq2g/2+BSibCcmee9AXq/wij11BERrYmjbDt5NkkdUnDVgAB7pdqbnWX0A2sxBKeYtLSP2kxp+5LoU/Wty3fmcVA3VKVkHfgmIihkeL8lY++5hvHjnkzOE4tyx/sheiKS4zqoWE43TD6n8mpFskAzwMHq4G2o6vkXqvaKFEq7y/R2fVrCypenmRhkPASizpM265rKLU+L4E/C+LMHfN0LYKRMCrLr0gI2GAp+1PZLHgh0tCtiJC/zcJJtJs6sH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QeTJm7dp+PYKMkUNvQRpnSXMj6Kz7rvAMzhzJgK62ltN2idqKxLC7WtivCUgejuQUvNreCYBQCaKwTwP02lZsJpGF9yw8gbyuoB+2aB7IZmgIB8GP4qVQ/ht5B9z/FLohK/8cSPV/4i32SNNdcwhV',\n // sessionResult:\n // 'X3XtfGC7!H4sIAAAAAAAA/6tWykxRslJyDjaxNDMyM3E2MXIyNDUys3RU0lHKTS1KzkjMK3FMTs4vzSsBKgtJLS7xhYo6Z6QmZ+eXlgAVFpcklpQWA+WLUtNKi1NTlGoBMEEbz1cAAAA=iMsCaEJ5LcnsqIUtmNxjm8HtfQ8gZW8JewEU3wHz4qg='\n // };\n }\n\n protected onComplete(state): void {\n if (this.props.onComplete) this.props.onComplete(state, this.elementRef);\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 (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 onAdditionalDetails: this.handleAdditionalDetails\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 * @param rawResponse -\n */\n protected handleResponse(rawResponse: RawPaymentResponse): void {\n const response = sanitizeResponse(rawResponse);\n\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\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\nexport default UIElement;\n"],"names":["UIElement","BaseElement","buildElementProps","componentProps","finalProps","_object_spread","showPayButton","this","core","getCorePropsForComponent","isStoredPaymentMethod","paymentMethodsResponse","find","type","constructor","isDropin","assertIsDropin","props","formatProps","getRegulatoryDefaults","options","countryCode","storeElementRefOnCore","storeElementReference","isAvailable","Promise","resolve","setState","newState","state","onChange","showValidation","componentRef","setElementStatus","status","_this_elementRef","elementRef","setStatus","_this_componentRef","_this_props_onChange","_this_props","call","data","isValid","errors","valid","setUpAnalytics","setUpAnalyticsObj","_this_props_session","sessionId","session","id","modules","analytics","setUp","submitAnalytics","analyticsObj","uiElementProps","sendAnalytics","getComponent","error","console","warn","component","submit","makePaymentsCall","then","sanitizeResponse","verifyPaymentDidNotFail","handleResponse","catch","e","CancelError","handleFailedResult","onSubmit","submitUsingAdvancedFlow","beforeSubmit","reject","submitUsingSessionsFlow","handleError","AdyenCheckoutError","ANALYTICS_SUBMIT_STR","submitPayment","cause","onComplete","handleAdditionalDetails","makeAdditionalDetailsCall","onAdditionalDetails","submitAdditionalDetailsUsingSessionsFlow","submitDetails","handleAction","action","hasOwnProperty","Error","paymentAction","createFromAction","_object_spread_props","unmount","mount","_node","onActionHandled","actionHandledObj","_this_props_onActionHandled","originalAction","rawResponse","response","order","remainingAmount","value","handleOrder","handleSuccessResult","handleKeyPress","document","key","code","preventDefault","onEnterKeyPressed","activeElement","blur","updateParent","update","icon","paymentMethodType","_this_props_icon","resources","getImage","displayName","_this_core_paymentMethodsResponse_paymentMethods","_this_core_paymentMethodsResponse","paymentMethodFromResponse","paymentMethods","pm","name","accessibleName","additionalInfo","handleAdvanceFlowPaymentMethodsUpdate","amount","onPaymentMethodsRequest","orderData","pspReference","locale","checkout","super","_define_property","onError","_this_props_onOrderUpdated","onOrderUpdated","result","_this_props_onPaymentFailed","displayFinalAnimation","cleanupFinalResult","onPaymentFailed","_this_props_onPaymentCompleted","onPaymentCompleted","setComponentRef","ref","payButton","h","PayButton","secondaryAmount","onClick","register","bind","undefined","txVariants"],"mappings":"01CA8BO,MAAeA,UAA6DC,EAyC5DC,iBAAAA,CAAkBC,GACjC,MAMMC,EAAaC,EAAA,CACfC,eAAe,GAPKC,KAAKC,KAAKC,8BACFN,aAAAA,EAAAA,EAAgBO,uBAE1C,GACAH,KAAKC,KAAKG,uBAAuBC,MAAKT,eAAAA,EAAgBU,OAAQN,KAAKO,YAAmB,MAMrFX,GAGDY,EAAWC,EAAeT,MAEhCA,KAAKU,MAAQV,KAAKW,YAAY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