@adyen/adyen-web 6.30.0 → 6.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- 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 +802 -714
- 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/Ach.js +1 -1
- package/dist/es/components/Ach/Ach.js.map +1 -1
- package/dist/es/components/Ach/components/AccountTypeSelector.js.map +1 -1
- package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
- package/dist/es/components/Affirm/Affirm.js.map +1 -1
- package/dist/es/components/AfterPay/AfterPay.js.map +1 -1
- package/dist/es/components/AfterPay/AfterPayB2B.js.map +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayButton.js +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayComponent.js +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
- package/dist/es/components/AmazonPay/components/OrderButton.js +1 -1
- package/dist/es/components/AmazonPay/components/OrderButton.js.map +1 -1
- package/dist/es/components/AmazonPay/utils.js +1 -1
- package/dist/es/components/AmazonPay/utils.js.map +1 -1
- package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es/components/ApplePay/services/ApplePaySdkLoader.js.map +1 -1
- package/dist/es/components/ApplePay/services/ApplePayService.js +1 -1
- package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -1
- package/dist/es/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js.map +1 -1
- package/dist/es/components/ApplePay/utils/payment-request.js.map +1 -1
- package/dist/es/components/Atome/Atome.js.map +1 -1
- package/dist/es/components/BacsDD/BacsDD.js +1 -1
- package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
- package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
- package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
- package/dist/es/components/Blik/Blik.js +1 -1
- package/dist/es/components/Blik/Blik.js.map +1 -1
- package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/handlers.js +1 -1
- package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/Card/components/ClickToPayWrapper.js +1 -1
- package/dist/es/components/Card/components/ClickToPayWrapper.js.map +1 -1
- package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
- package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
- package/dist/es/components/CashAppPay/services/CashAppSdkLoader.js.map +1 -1
- package/dist/es/components/CashAppPay/services/CashAppService.js +1 -1
- package/dist/es/components/CashAppPay/services/CashAppService.js.map +1 -1
- package/dist/es/components/CashAppPay/services/types.js.map +1 -1
- package/dist/es/components/ClickToPay/ClickToPay.js +1 -1
- package/dist/es/components/ClickToPay/ClickToPay.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
- package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinSuccessState.js +2 -0
- package/dist/es/components/Dropin/components/DropinSuccessState.js.map +1 -0
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
- package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardResult.js +1 -1
- package/dist/es/components/Giftcard/components/GiftcardResult.js.map +1 -1
- package/dist/es/components/Giftcard/components/useSRPanelForGiftcardErrors.js +1 -1
- package/dist/es/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es/components/Iris/Iris.js +1 -1
- package/dist/es/components/Iris/Iris.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.map +1 -1
- package/dist/es/components/Multibanco/Multibanco.js +1 -1
- package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
- package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
- package/dist/es/components/PayByBankPix/services/PasskeySdkLoader.js.map +1 -1
- package/dist/es/components/PayByBankPix/services/PasskeyService.js.map +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
- package/dist/es/components/PayPalFastlane/components/FastlaneComponent.js.map +1 -1
- package/dist/es/components/PayTo/PayTo.js +1 -1
- package/dist/es/components/PayTo/PayTo.js.map +1 -1
- package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
- package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
- package/dist/es/components/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
- package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
- package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +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/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 +1 -1
- package/dist/es/components/Twint/Twint.js.map +1 -1
- package/dist/es/components/UPI/UPI.js +1 -1
- package/dist/es/components/UPI/UPI.js.map +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
- package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
- package/dist/es/components/internal/Address/Specifications.js.map +1 -1
- package/dist/es/components/internal/Await/Await.js +1 -1
- package/dist/es/components/internal/Await/Await.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayContext.js +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayContext.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/sdks/SrcSdkLoader.js.map +1 -1
- package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
- package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
- package/dist/es/components/internal/Countdown/CountdownA11yReporter.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es/components/internal/PayButton/utils.js +1 -1
- package/dist/es/components/internal/PayButton/utils.js.map +1 -1
- package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es/components/internal/PersonalDetails/PersonalDetails.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/RedirectButton/RedirectButton.js +1 -1
- package/dist/es/components/internal/RedirectButton/RedirectButton.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/utils.js.map +1 -1
- package/dist/es/components/internal/SendCopyToEmail/SendCopyToEmail.js +1 -1
- package/dist/es/components/internal/SendCopyToEmail/SendCopyToEmail.js.map +1 -1
- package/dist/es/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js +1 -1
- package/dist/es/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/AnalyticsService.js.map +1 -1
- package/dist/es/core/Analytics/events/AbstractAnalyticsEvent.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
- package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
- package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
- package/dist/es/core/Analytics/utils.js +1 -1
- package/dist/es/core/Analytics/utils.js.map +1 -1
- package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
- package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
- package/dist/es/core/Context/AmountProvider.js +2 -0
- package/dist/es/core/Context/AmountProvider.js.map +1 -0
- package/dist/es/core/Context/Resources.js.map +1 -1
- package/dist/es/core/Errors/SRPanel.js.map +1 -1
- package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/external/preact/compat/dist/compat.js +1 -1
- package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es/index.d.ts +802 -714
- package/dist/es/language/Language.js.map +1 -1
- package/dist/es/utils/Script.js.map +1 -1
- package/dist/es/utils/Storage.js +1 -1
- package/dist/es/utils/Storage.js.map +1 -1
- package/dist/es/utils/Validator/ValidationRuleResult.js.map +1 -1
- package/dist/es/utils/Validator/Validator.js.map +1 -1
- package/dist/es/utils/amount-util.js +1 -1
- package/dist/es/utils/amount-util.js.map +1 -1
- package/dist/es/utils/browserInfo.js +1 -1
- package/dist/es/utils/browserInfo.js.map +1 -1
- package/dist/es/utils/constants/currency-minor-units.js.map +1 -1
- package/dist/es/utils/createSdkData.js.map +1 -1
- package/dist/es/utils/getErrorMessage.js.map +1 -1
- package/dist/es/utils/getProp.js +1 -1
- package/dist/es/utils/getProp.js.map +1 -1
- package/dist/es/utils/hasOwnProperty.js.map +1 -1
- package/dist/es/utils/isValidURL.js.map +1 -1
- package/dist/es/utils/listenerUtils.js.map +1 -1
- package/dist/es/utils/promiseTimeout.js.map +1 -1
- package/dist/es/utils/setFocus.js +1 -1
- package/dist/es/utils/setFocus.js.map +1 -1
- package/dist/es/utils/textUtils.js.map +1 -1
- package/dist/es/utils/validator-utils.js.map +1 -1
- package/dist/es/utils/windowScrollTo.js +2 -0
- package/dist/es/utils/windowScrollTo.js.map +1 -0
- 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/Ach.js +1 -1
- package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
- package/dist/es-legacy/components/Affirm/Affirm.js.map +1 -1
- package/dist/es-legacy/components/AfterPay/AfterPay.js.map +1 -1
- package/dist/es-legacy/components/AfterPay/AfterPayB2B.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/components/OrderButton.js +1 -1
- package/dist/es-legacy/components/AmazonPay/components/OrderButton.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
- package/dist/es-legacy/components/AmazonPay/utils.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/services/ApplePaySdkLoader.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/services/ApplePayService.js +1 -1
- package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/utils/map-adyen-brands-to-applepay-brands.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -1
- package/dist/es-legacy/components/Atome/Atome.js.map +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
- package/dist/es-legacy/components/Blik/Blik.js +1 -1
- package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/handlers.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/Card/components/ClickToPayWrapper.js +1 -1
- package/dist/es-legacy/components/Card/components/ClickToPayWrapper.js.map +1 -1
- package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
- package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/services/CashAppSdkLoader.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/services/CashAppService.js +1 -1
- package/dist/es-legacy/components/CashAppPay/services/CashAppService.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
- package/dist/es-legacy/components/ClickToPay/ClickToPay.js +1 -1
- package/dist/es-legacy/components/ClickToPay/ClickToPay.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
- package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
- package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/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/DropinSuccessState.js +2 -0
- package/dist/es-legacy/components/Dropin/components/DropinSuccessState.js.map +1 -0
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardResult.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardResult.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/useSRPanelForGiftcardErrors.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es-legacy/components/Iris/Iris.js +1 -1
- package/dist/es-legacy/components/Iris/Iris.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.map +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
- package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
- package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/services/PasskeySdkLoader.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/services/PasskeyService.js.map +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
- package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
- package/dist/es-legacy/components/PayPalFastlane/components/FastlaneComponent.js.map +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
- package/dist/es-legacy/components/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
- package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +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/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 +1 -1
- package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
- package/dist/es-legacy/components/UPI/UPI.js +1 -1
- package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Specifications.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/Await/Await.js +1 -1
- package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayContext.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayContext.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/create-clicktopay-service.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrcSdkLoader.js.map +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/Countdown/CountdownA11yReporter.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.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.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
- package/dist/es-legacy/components/internal/PayButton/utils.js +1 -1
- package/dist/es-legacy/components/internal/PayButton/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.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/RedirectButton/RedirectButton.js +1 -1
- package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/SendCopyToEmail/SendCopyToEmail.js +1 -1
- package/dist/es-legacy/components/internal/SendCopyToEmail/SendCopyToEmail.js.map +1 -1
- package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js +1 -1
- package/dist/es-legacy/components/internal/SocialSecurityNumberBrazil/SocialSecurityNumberBrazil.js.map +1 -1
- package/dist/es-legacy/components/internal/Tooltip/Tooltip.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/AnalyticsService.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AbstractAnalyticsEvent.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js +1 -1
- package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
- package/dist/es-legacy/core/Context/AmountProvider.js +2 -0
- package/dist/es-legacy/core/Context/AmountProvider.js.map +1 -0
- package/dist/es-legacy/core/Context/Resources.js.map +1 -1
- package/dist/es-legacy/core/Environment/Environment.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
- package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
- package/dist/es-legacy/core/Services/http.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
- package/dist/es-legacy/language/Language.js.map +1 -1
- package/dist/es-legacy/utils/Script.js.map +1 -1
- package/dist/es-legacy/utils/Storage.js +1 -1
- package/dist/es-legacy/utils/Storage.js.map +1 -1
- package/dist/es-legacy/utils/Validator/ValidationRuleResult.js.map +1 -1
- package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
- package/dist/es-legacy/utils/amount-util.js +1 -1
- package/dist/es-legacy/utils/amount-util.js.map +1 -1
- package/dist/es-legacy/utils/browserInfo.js +1 -1
- package/dist/es-legacy/utils/browserInfo.js.map +1 -1
- package/dist/es-legacy/utils/constants/currency-minor-units.js.map +1 -1
- package/dist/es-legacy/utils/createSdkData.js.map +1 -1
- package/dist/es-legacy/utils/getConsentUrl.js.map +1 -1
- package/dist/es-legacy/utils/getErrorMessage.js.map +1 -1
- package/dist/es-legacy/utils/getProp.js +1 -1
- package/dist/es-legacy/utils/getProp.js.map +1 -1
- package/dist/es-legacy/utils/hasOwnProperty.js.map +1 -1
- package/dist/es-legacy/utils/isValidURL.js.map +1 -1
- package/dist/es-legacy/utils/listenerUtils.js.map +1 -1
- package/dist/es-legacy/utils/promiseTimeout.js.map +1 -1
- package/dist/es-legacy/utils/setFocus.js +1 -1
- package/dist/es-legacy/utils/setFocus.js.map +1 -1
- package/dist/es-legacy/utils/textUtils.js.map +1 -1
- package/dist/es-legacy/utils/useAutoFocus.js.map +1 -1
- package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
- package/dist/es-legacy/utils/validator-utils.js.map +1 -1
- package/dist/es-legacy/utils/windowScrollTo.js +2 -0
- package/dist/es-legacy/utils/windowScrollTo.js.map +1 -0
- package/package.json +11 -11
- package/styles/adyen.css +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport {\n usePaymentStatusTimer,\n DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS\n} from '../../../hooks/usePaymentStatusTimer';\nimport Spinner from '../../internal/Spinner';\nimport Button from '../Button';\nimport ContentSeparator from '../ContentSeparator';\nimport Countdown from '../Countdown';\nimport { AwaitFinalState } from './components/AwaitFinalState';\nimport { AwaitComponentProps } from './types';\nimport { redirectToApp } from '../../../utils/urls';\nimport './Await.scss';\n\nexport function Await(props: AwaitComponentProps) {\n const { i18n, loadingContext } = useCoreContext();\n\n const { state: timerState, actions: timerActions } = usePaymentStatusTimer({\n loadingContext,\n paymentData: props.paymentData,\n clientKey: props.clientKey,\n delay: props.delay,\n throttleTime: props.throttleTime,\n throttleInterval: props.throttleInterval,\n type: props.type,\n onError: props.onError,\n onComplete: props.onComplete,\n pollStatus: props.pollStatus,\n onActionHandled: props.onActionHandled\n });\n\n const { completed, expired, loading, percentage } = timerState;\n const { onTick, onTimeUp } = timerActions;\n
|
|
1
|
+
{"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport {\n usePaymentStatusTimer,\n DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS\n} from '../../../hooks/usePaymentStatusTimer';\nimport Spinner from '../../internal/Spinner';\nimport Button from '../Button';\nimport ContentSeparator from '../ContentSeparator';\nimport Countdown from '../Countdown';\nimport { AwaitFinalState } from './components/AwaitFinalState';\nimport { AwaitComponentProps } from './types';\nimport { redirectToApp } from '../../../utils/urls';\nimport './Await.scss';\nimport { useAmount } from '../../../core/Context/AmountProvider';\n\nexport function Await(props: AwaitComponentProps) {\n const { i18n, loadingContext } = useCoreContext();\n\n const { state: timerState, actions: timerActions } = usePaymentStatusTimer({\n loadingContext,\n paymentData: props.paymentData,\n clientKey: props.clientKey,\n delay: props.delay,\n throttleTime: props.throttleTime,\n throttleInterval: props.throttleInterval,\n type: props.type,\n onError: props.onError,\n onComplete: props.onComplete,\n pollStatus: props.pollStatus,\n onActionHandled: props.onActionHandled\n });\n\n const { completed, expired, loading, percentage } = timerState;\n const { onTick, onTimeUp } = timerActions;\n const { amount } = useAmount();\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n if (expired) {\n return <AwaitFinalState image=\"error\" message={i18n.get('error.subtitle.payment')} />;\n }\n\n if (completed) {\n return <AwaitFinalState image=\"success\" message={i18n.get('creditCard.success')} />;\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]} \n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n {timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n delay: DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n throttleTime: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS,\n throttleInterval: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n onError: () => {},\n onComplete: () => {},\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","state","timerState","actions","timerActions","usePaymentStatusTimer","paymentData","clientKey","delay","throttleTime","throttleInterval","type","onError","onComplete","pollStatus","onActionHandled","completed","expired","loading","percentage","onTick","onTimeUp","amount","useAmount","useEffect","shouldRedirectAutomatically","url","redirectToApp","h","AwaitFinalState","image","message","get","div","className","brandLogo","img","src","alt","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","awaitText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps","DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN","DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS","DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS","DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS"],"mappings":"k9BAqBO,SAASA,EAAMC,GAClB,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,KAEzBC,MAAOC,EAAYC,QAASC,GAAiBC,EAAsB,CACvEN,iBACAO,YAAaT,EAAMS,YACnBC,UAAWV,EAAMU,UACjBC,MAAOX,EAAMW,MACbC,aAAcZ,EAAMY,aACpBC,iBAAkBb,EAAMa,iBACxBC,KAAMd,EAAMc,KACZC,QAASf,EAAMe,QACfC,WAAYhB,EAAMgB,WAClBC,WAAYjB,EAAMiB,WAClBC,gBAAiBlB,EAAMkB,mBAGrBC,UAAEA,EAASC,QAAEA,EAAOC,QAAEA,EAAOC,WAAEA,GAAejB,GAC9CkB,OAAEA,EAAMC,SAAEA,GAAajB,GACvBkB,OAAEA,GAAWC,IAQnB,GANAC,EAAU,KACF3B,EAAM4B,6BAA+B5B,EAAM6B,KAC3CC,EAAc9B,EAAM6B,MAEzB,CAAC7B,EAAM4B,4BAA6B5B,EAAM6B,MAEzCT,EACA,OAAOW,EAACC,EAAAA,CAAgBC,MAAM,QAAQC,QAASjC,EAAKkC,IAAI,4BAG5D,GAAIhB,EACA,OAAOY,EAACC,EAAAA,CAAgBC,MAAM,UAAUC,QAASjC,EAAKkC,IAAI,wBAG9D,GAAId,EACA,OACIU,EAACK,MAAAA,CAAIC,UAAU,yBACVrC,EAAMsC,WAAaP,EAACQ,MAAAA,CAAIC,IAAKxC,EAAMsC,UAAWG,IAAKzC,EAAMc,KAAMuB,UAAU,sCAC1EN,EAACW,EAAAA,CAAQC,QAAQ,EAAOC,KAAK,W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AIC,UAAU,uCACoB,iBAAvBrC,EAAMoE,aAA4BnE,EAAKkC,IAAInC,EAAMoE,cAAgBpE,EAAMoE,kBAItFpE,EAAMqE,SAAWtC,EAACK,MAAAA,CAAIC,UAAU,mCAAmCrC,EAAMqE,WAGtF,CAEAtE,EAAMuE,aAAe,CACjBR,cAAeS,EACf5D,MAAO6D,EACP5D,aAAc6D,EACd5D,iBAAkB6D,EAClB3D,QAAS,OACTC,WAAY,OACZwC,oBAAoB,EACpBR,mBAAoB,GACpBnB,IAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData);\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","order","componentData","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","sdkData","createSdkData","paymentMethod","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"qeAsBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,gBAAo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MAAMhC,KAAKqC,MACrC,CAKA,OAAAC,GAQI,OANAI,EAAI1C,KAAKqC,MAAO,WAAYrC,KAAKO,gBAE7BP,KAAKqC,OACLP,EAAO,KAAM9B,KAAKqC,OAGfrC,IACX,CAMA,MAAA2C,GACI3C,KAAKsC,UAEDtC,KAAKgB,MACLhB,KAAKgB,KAAK2B,OAAO3C,KAEzB,CA7JA,WAAAG,CAAYyC,EAAiB3C,GAX7B4C,EAAA7C,KAAgB8C,MAAM,GAAG9C,KAAKG,YAAY,QAAW4C,OACrDF,EAAA7C,KAAgBgB,
|
|
1
|
+
{"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData);\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","order","componentData","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","sdkData","createSdkData","paymentMethod","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"qeAsBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,g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AUN,MAAMhC,KAAKqC,MACrC,CAKA,OAAAC,GAQI,OANAI,EAAI1C,KAAKqC,MAAO,WAAYrC,KAAKO,gBAE7BP,KAAKqC,OACLP,EAAO,KAAM9B,KAAKqC,OAGfrC,IACX,CAMA,MAAA2C,GACI3C,KAAKsC,UAEDtC,KAAKgB,MACLhB,KAAKgB,KAAK2B,OAAO3C,KAEzB,CA7JA,WAAAG,CAAYyC,EAAiB3C,GAX7B4C,EAAA7C,KAAgB8C,MAAM,GAAG9C,KAAKG,YAAY,QAAW4C,OACrDF,EAAA7C,KAAgBgB,eAEhB6B,EAAA7C,KAAOC,gBACP4C,EAAA7C,KAAOW,QAAa,IACpBkC,EAAA7C,KAAOwC,qBAEPK,EAAA7C,KAAUqC,QAAqB,MAK3B,MAAMW,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuCpD,KAAKG,YAAY,6DAIhEH,KAAKgB,KAAO4B,EACZ5C,KAAKF,kBAAkBG,GAEvBD,KAAKO,eAAiBP,KAAKO,eAAe8C,KAAKrD,KACnD,EAhBA6C,EAVWhD,EAUMyD,eAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class s extends e{render(){const{classNameModifiers:e=[],disabled:i,href:s,icon:r,onClickCompletedIcon:l,inline:c,label:d,ariaLabel:u,ariaDescribedBy:p,status:m,variant:b,buttonRef:h,onClickCompletedLabel:_,onMouseEnter:y,onMouseLeave:f,onFocus:g,onBlur:k,onKeyDown:C,onKeyPress:v}=this.props,{completed:N}=this.state,{i18n:S}=o(),x=l||r?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed?l??r:r,alt:"","aria-hidden":"true"}):"",L=[...e,..."primary"
|
|
1
|
+
import{Component as e,createElement as t}from"../../../external/preact/dist/preact.js";import a from"../../../_virtual/index.js";import n from"../Spinner/Spinner.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";function i(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class s extends e{render(){const{classNameModifiers:e=[],disabled:i,href:s,icon:r,onClickCompletedIcon:l,inline:c,label:d,ariaLabel:u,ariaDescribedBy:p,status:m,variant:b,buttonRef:h,onClickCompletedLabel:_,onMouseEnter:y,onMouseLeave:f,onFocus:g,onBlur:k,onKeyDown:C,onKeyPress:v}=this.props,{completed:N}=this.state,{i18n:S}=o(),x=l||r?t("img",{className:"adyen-checkout__button__icon",src:this.state.completed?l??r:r,alt:"","aria-hidden":"true"}):"",L=[...e,..."primary"===b?[]:[b],...c?["inline"]:[],...N?["completed"]:[],..."loading"===m||"redirect"===m?["loading"]:[]],j=a(["adyen-checkout__button",...L.map(e=>`adyen-checkout__button--${e}`)]),B={loading:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0})),redirect:t("span",{"aria-hidden":"true",className:"adyen-checkout__button__content"},t(n,{size:"medium",inline:!0}),S.get("payButton.redirecting")),default:t("span",{className:"adyen-checkout__button__content"},x,t("span",{className:"adyen-checkout__button__text"},this.state.completed?_??d:d))},D=B[m]||B.default;return s?t("a",{className:j,href:s,target:this.props.target,rel:this.props.rel,"aria-disabled":i,onClick:e=>{i&&e.preventDefault()}},D):t("button",{ref:h,className:j,type:"button",disabled:i,onClick:this.onClick,"aria-label":u,"aria-describedby":p,onMouseEnter:y,onMouseLeave:f,onKeyDown:C,onFocus:g,onBlur:k,onKeyPress:v},D,"loading"!==m&&"redirect"!==m&&this.props.children,t("span",{role:"status","aria-live":"polite",className:"adyen-checkout__button__text--sr-only"},S.get(this.buttonStatusSRLabel(m))))}constructor(...e){super(...e),i(this,"onClick",e=>{e.preventDefault(),this.props.disabled||this.props.onClick?.(e,{complete:this.complete})}),i(this,"complete",(e=1e3)=>{this.setState({completed:!0}),setTimeout(()=>{this.setState({completed:!1})},e)}),i(this,"buttonStatusSRLabel",e=>({loading:"loading",redirect:"payButton.redirecting"}[e]||""))}}i(s,"defaultProps",{status:"default",variant:"primary",disabled:!1,label:"",inline:!1,target:"_self"});export{s as default};
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e:
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../src/components/internal/Button/Button.tsx"],"sourcesContent":["import { Component, h, TargetedMouseEvent } from 'preact';\nimport classNames from 'classnames';\nimport Spinner from '../Spinner';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps, ButtonState } from './types';\nimport './Button.scss';\n\nclass Button extends Component<ButtonProps, ButtonState> {\n public static readonly defaultProps = {\n status: 'default',\n variant: 'primary',\n disabled: false,\n label: '',\n inline: false,\n target: '_self'\n };\n\n public onClick = (e: TargetedMouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n\n if (!this.props.disabled) {\n this.props.onClick?.(e, { complete: this.complete });\n }\n };\n\n public complete = (delay = 1_000) => {\n this.setState({ completed: true });\n setTimeout(() => {\n this.setState({ completed: false });\n }, delay);\n };\n\n private readonly buttonStatusSRLabel = (status: string): string => {\n const srLabels: Record<string, string> = {\n loading: 'loading',\n redirect: 'payButton.redirecting'\n };\n\n return srLabels[status] || '';\n };\n\n render() {\n const {\n classNameModifiers = [],\n disabled,\n href,\n icon,\n onClickCompletedIcon,\n inline,\n label,\n ariaLabel,\n ariaDescribedBy,\n status,\n variant,\n buttonRef,\n onClickCompletedLabel,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyPress\n }: ButtonProps = this.props;\n const { completed } = this.state;\n const { i18n } = useCoreContext();\n\n const buttonIcon =\n onClickCompletedIcon || icon ? (\n <img\n className=\"adyen-checkout__button__icon\"\n src={this.state.completed ? (onClickCompletedIcon ?? icon) : icon}\n alt=\"\"\n aria-hidden=\"true\"\n />\n ) : (\n ''\n );\n\n const modifiers = [\n ...classNameModifiers,\n ...(variant === 'primary' ? [] : [variant]),\n ...(inline ? ['inline'] : []),\n ...(completed ? ['completed'] : []),\n ...(status === 'loading' || status === 'redirect' ? ['loading'] : [])\n ];\n\n const buttonClasses = classNames(['adyen-checkout__button', ...modifiers.map(m => `adyen-checkout__button--${m}`)]);\n\n const buttonStates = {\n loading: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n </span>\n ),\n redirect: (\n <span aria-hidden=\"true\" className=\"adyen-checkout__button__content\">\n <Spinner size=\"medium\" inline />\n {i18n.get('payButton.redirecting')}\n </span>\n ),\n default: (\n <span className=\"adyen-checkout__button__content\">\n {buttonIcon}\n <span className=\"adyen-checkout__button__text\">{this.state.completed ? (onClickCompletedLabel ?? label) : label}</span>\n </span>\n )\n };\n\n const buttonText = buttonStates[status] || buttonStates.default;\n\n if (href) {\n return (\n <a\n className={buttonClasses}\n href={href}\n target={this.props.target}\n rel={this.props.rel}\n aria-disabled={disabled}\n onClick={(e: TargetedMouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n e.preventDefault();\n }\n }}\n >\n {buttonText}\n </a>\n );\n }\n\n return (\n <button\n ref={buttonRef}\n className={buttonClasses}\n type=\"button\"\n disabled={disabled}\n onClick={this.onClick}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={onKeyPress}\n >\n {buttonText}\n {status !== 'loading' && status !== 'redirect' && this.props.children}\n <span role=\"status\" aria-live=\"polite\" className=\"adyen-checkout__button__text--sr-only\">\n {i18n.get(this.buttonStatusSRLabel(status))}\n </span>\n </button>\n );\n }\n}\n\nexport default Button;\n"],"names":["Button","Component","render","classNameModifiers","disabled","href","icon","onClickCompletedIcon","inline","label","ariaLabel","ariaDescribedBy","status","variant","buttonRef","onClickCompletedLabel","onMouseEnter","onMouseLeave","onFocus","onBlur","onKeyDown","onKeyPress","this","props","completed","state","i18n","useCoreContext","buttonIcon","h","img","className","src","alt","aria-hidden","modifiers","buttonClasses","classNames","map","m","buttonStates","loading","span","Spinner","size","redirect","get","default","buttonText","a","target","rel","aria-disabled","onClick","e","preventDefault","button","ref","type","aria-label","aria-describedby","children","role","aria-live","buttonStatusSRLabel","super","args","_define_property","complete","delay","setState","setTimeout","defaultProps"],"mappings":"qWAOA,MAAMA,UAAeC,EAkCjBC,MAAAA,GACI,MAAMC,mBACFA,EAAqB,GAAEC,SACvBA,EAAQC,KACRA,EAAIC,KACJA,EAAIC,qBACJA,EAAoBC,OACpBA,EAAMC,MACNA,EAAKC,UACLA,EAASC,gBACTA,EAAeC,OACfA,EAAMC,QACNA,EAAOC,UACPA,EAASC,sBACTA,EAAqBC,aACrBA,EAAYC,aACZA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,WACTA,GACaC,KAAKC,OAChBC,UAAEA,GAAcF,KAAKG,OACrBC,KAAEA,GAASC,IAEXC,EACFrB,GAAwBD,EACpBuB,EAACC,MAAAA,CACGC,UAAU,+BACVC,IAAKV,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C,UAAU,yCAC5CL,EAAKoB,IAAIxB,KAAK0C,oBAAoBpD,KAInD,mBAjJJqD,SAAAC,GAUIC,EAAA7C,KAAO+B,UAAWC,IACdA,EAAEC,iBAEGjC,KAAKC,MAAMnB,UACZkB,KAAKC,MAAM8B,UAAUC,EAAG,CAAEc,SAAU9C,KAAK8C,aAIjDD,EAAA7C,KAAO8C,WAAW,CAACC,EAAQ,OACvB/C,KAAKgD,SAAS,CAAE9C,WAAW,IAC3B+C,WAAW,KACPjD,KAAKgD,SAAS,CAAE9C,WAAW,KAC5B6C,KAGPF,EAAA7C,KAAiB0C,sBAAuBpD,IACK,CACrC6B,QAAS,UACTI,SAAU,yBAGEjC,IAAW,MA9B/BuD,EADEnE,EACqBwE,eAAe,CAClC5D,OAAQ,UACRC,QAAS,UACTT,UAAU,EACVK,MAAO,GACPD,QAAQ,EACR0C,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as r,useEffect as o,useCallback as s}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../context/useClickToPayContext.js";import a from"./CtPSingleCard/CtPSingleCard.js";import i from"../../../PayButton/PayButton.js";import{amountLabel as c}from"../../../PayButton/utils.js";import m from"./CtPCardsList/CtPCardsList.js";import l from"../../services/sdks/SrciError.js";import u from"../CtPSection/CtPSection.js";import{CTP_IFRAME_NAME as d}from"../../services/utils.js";import p from"../../../IFrame/Iframe.js";import f from"../../../../../core/Context/useImage.js";import{useCoreContext as C}from"../../../../../core/Context/CoreProvider.js";import g from"../../../../../utils/isMobile.js";import h from"../../../../../core/Errors/AdyenCheckoutError.js";import{PREFIX as y}from"../../../Icon/constants.js";function
|
|
1
|
+
import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as r,useEffect as o,useCallback as s}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../context/useClickToPayContext.js";import a from"./CtPSingleCard/CtPSingleCard.js";import i from"../../../PayButton/PayButton.js";import{amountLabel as c}from"../../../PayButton/utils.js";import m from"./CtPCardsList/CtPCardsList.js";import l from"../../services/sdks/SrciError.js";import u from"../CtPSection/CtPSection.js";import{CTP_IFRAME_NAME as d}from"../../services/utils.js";import p from"../../../IFrame/Iframe.js";import f from"../../../../../core/Context/useImage.js";import{useCoreContext as C}from"../../../../../core/Context/CoreProvider.js";import g from"../../../../../utils/isMobile.js";import h from"../../../../../core/Errors/AdyenCheckoutError.js";import{PREFIX as y}from"../../../Icon/constants.js";import{useAmount as P}from"../../../../../core/Context/AmountProvider.js";function j(t,e){if(!t)return null;const r=e.get(`ctp.errors.${t}`);return r.includes("ctp.errors")?e.get("ctp.errors.UNKNOWN_ERROR"):r}function k(t,e,r){return r?g()?null:t.get("payButton.with",{values:{value:c(t,e),maskedData:`•••• ${r?.panLastFour}`}}):t.get("payButton")}const E=({onDisplayCardComponent:c})=>{const{i18n:g}=C(),E=f(),{cards:S,checkout:x,isCtpPrimaryPaymentMethod:v,status:b,onSubmit:R,onSetStatus:$,onError:w}=n(),[B,M]=r(S.find(t=>!t.isExpired)||S[0]),[N,D]=r(null),F=S.every(t=>t.isExpired),[I,_]=r(!1),{amount:L}=P();o(()=>{(0===S.length||F)&&c?.()},[c,F,S]);const O=s(async()=>{if(B)try{_(!0),D(null),$("loading");const t=await x(B);R(t)}catch(t){t instanceof l&&(D(t?.reason),console.warn(`CtP - Checkout: Reason: ${t?.reason} / Source: ${t?.source} / Scheme: ${t?.scheme}`)),_(!1),w(t instanceof h?t:new h("ERROR","Error during ClickToPay checkout",{cause:t}))}},[x,B]),T=s(t=>{M(t)},[]),A=I&&"loading"===b&&B?.isDcfPopupEmbedded,K="loading"!==b||!A,U=s(t=>{"Enter"===t.key&&O()},[O]);return t(e,null,t(p,{name:d,height:"380",width:"100%",classNameModifiers:[A?"":"hidden"]}),K&&t(e,null,t(u.Title,null,g.get("ctp.cards.title")),0===S.length&&t("div",{className:"adyen-checkout-ctp__empty-cards"},g.get("ctp.emptyProfile.message")),1===S.length&&t(a,{card:S[0],errorMessage:j(N,g)}),S.length>1&&t(m,{cardSelected:B,cards:S,onChangeCard:T,errorMessage:j(N,g)}),t(i,{disabled:F,label:k(g,L,B),status:b,variant:v?"primary":"secondary",icon:0!==S.length&&E({imageFolder:"components/"})(v?`${y}lock`:`${y}lock_black`),onClick:O,onKeyDown:U})))};export{E as default};
|
|
2
2
|
//# sourceMappingURL=CtPCards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPCards.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCards.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPSingleCard from './CtPSingleCard/CtPSingleCard';\nimport PayButton from '../../../PayButton';\nimport { amountLabel } from '../../../PayButton/utils';\nimport CtPCardsList from './CtPCardsList';\nimport ShopperCard from '../../models/ShopperCard';\nimport SrciError from '../../services/sdks/SrciError';\nimport CtPSection from '../CtPSection';\nimport { CTP_IFRAME_NAME } from '../../services/utils';\nimport Iframe from '../../../../internal/IFrame';\nimport useImage from '../../../../../core/Context/useImage';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport isMobile from '../../../../../utils/isMobile';\nimport Language from '../../../../../language';\nimport { PaymentAmount } from '../../../../../types/global-types';\nimport './CtPCards.scss';\nimport AdyenCheckoutError from '../../../../../core/Errors/AdyenCheckoutError';\nimport { PREFIX } from '../../../Icon/constants';\n\ntype CtPCardsProps = {\n onDisplayCardComponent?(): void;\n};\n\nfunction getErrorLabel(errorCode: string, i18n: Language): string {\n if (!errorCode) return null;\n\n const errorLabel = i18n.get(`ctp.errors.${errorCode}`);\n if (errorLabel.includes('ctp.errors')) return i18n.get(`ctp.errors.UNKNOWN_ERROR`);\n return errorLabel;\n}\n\nfunction getPayButtonLabel(i18n: Language, amount: PaymentAmount, checkoutCard?: ShopperCard): string | null {\n if (!checkoutCard) return i18n.get('payButton');\n if (!isMobile())\n return i18n.get('payButton.with', {\n values: { value: amountLabel(i18n, amount), maskedData: `•••• ${checkoutCard?.panLastFour}` }\n });\n return null;\n}\n\nconst CtPCards = ({ onDisplayCardComponent }: CtPCardsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const {
|
|
1
|
+
{"version":3,"file":"CtPCards.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCards.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPSingleCard from './CtPSingleCard/CtPSingleCard';\nimport PayButton from '../../../PayButton';\nimport { amountLabel } from '../../../PayButton/utils';\nimport CtPCardsList from './CtPCardsList';\nimport ShopperCard from '../../models/ShopperCard';\nimport SrciError from '../../services/sdks/SrciError';\nimport CtPSection from '../CtPSection';\nimport { CTP_IFRAME_NAME } from '../../services/utils';\nimport Iframe from '../../../../internal/IFrame';\nimport useImage from '../../../../../core/Context/useImage';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport isMobile from '../../../../../utils/isMobile';\nimport Language from '../../../../../language';\nimport { PaymentAmount } from '../../../../../types/global-types';\nimport './CtPCards.scss';\nimport AdyenCheckoutError from '../../../../../core/Errors/AdyenCheckoutError';\nimport { PREFIX } from '../../../Icon/constants';\nimport { useAmount } from '../../../../../core/Context/AmountProvider';\n\ntype CtPCardsProps = {\n onDisplayCardComponent?(): void;\n};\n\nfunction getErrorLabel(errorCode: string, i18n: Language): string {\n if (!errorCode) return null;\n\n const errorLabel = i18n.get(`ctp.errors.${errorCode}`);\n if (errorLabel.includes('ctp.errors')) return i18n.get(`ctp.errors.UNKNOWN_ERROR`);\n return errorLabel;\n}\n\nfunction getPayButtonLabel(i18n: Language, amount: PaymentAmount, checkoutCard?: ShopperCard): string | null {\n if (!checkoutCard) return i18n.get('payButton');\n if (!isMobile())\n return i18n.get('payButton.with', {\n values: { value: amountLabel(i18n, amount), maskedData: `•••• ${checkoutCard?.panLastFour}` }\n });\n return null;\n}\n\nconst CtPCards = ({ onDisplayCardComponent }: CtPCardsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { cards, checkout, isCtpPrimaryPaymentMethod, status, onSubmit, onSetStatus, onError } = useClickToPayContext();\n const [checkoutCard, setCheckoutCard] = useState<ShopperCard | undefined>(cards.find(card => !card.isExpired) || cards[0]);\n const [errorCode, setErrorCode] = useState<string>(null);\n const isEveryCardExpired = cards.every(card => card.isExpired);\n const [isShopperCheckingOutWithCtp, setIsShopperCheckingOutWithCtp] = useState<boolean>(false);\n const { amount } = useAmount();\n\n useEffect(() => {\n if (cards.length === 0 || isEveryCardExpired) {\n onDisplayCardComponent?.();\n }\n }, [onDisplayCardComponent, isEveryCardExpired, cards]);\n\n const doCheckout = useCallback(async () => {\n if (!checkoutCard) return;\n\n try {\n setIsShopperCheckingOutWithCtp(true);\n setErrorCode(null);\n onSetStatus('loading');\n const payload = await checkout(checkoutCard);\n onSubmit(payload);\n } catch (error: unknown) {\n if (error instanceof SrciError) {\n setErrorCode(error?.reason);\n console.warn(`CtP - Checkout: Reason: ${error?.reason} / Source: ${error?.source} / Scheme: ${error?.scheme}`);\n }\n setIsShopperCheckingOutWithCtp(false);\n\n if (error instanceof AdyenCheckoutError) onError(error);\n else onError(new AdyenCheckoutError('ERROR', 'Error during ClickToPay checkout', { cause: error }));\n }\n }, [checkout, checkoutCard]);\n\n const handleOnChangeCard = useCallback((card: ShopperCard) => {\n setCheckoutCard(card);\n }, []);\n\n /**\n * If shopper submits the payment using the default Card component while CtP is rendered, the status here will be updated\n * and that can potentially display an iframe.\n *\n * Therefore, we use the flag 'isShopperCheckingOutWithCtp' to flag that the iframe should be displayed only in case the\n * Shopper is checking out with Click to Pay.\n */\n const displayNetworkDcf = isShopperCheckingOutWithCtp && status === 'loading' && checkoutCard?.isDcfPopupEmbedded;\n const displayCardCheckoutView = status !== 'loading' || !displayNetworkDcf;\n\n const handlePayButtonKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n void doCheckout();\n }\n },\n [doCheckout]\n );\n\n return (\n <Fragment>\n <Iframe name={CTP_IFRAME_NAME} height=\"380\" width=\"100%\" classNameModifiers={[displayNetworkDcf ? '' : 'hidden']} />\n\n {displayCardCheckoutView && (\n <Fragment>\n <CtPSection.Title>{i18n.get('ctp.cards.title')}</CtPSection.Title>\n {cards.length === 0 && <div className=\"adyen-checkout-ctp__empty-cards\">{i18n.get('ctp.emptyProfile.message')}</div>}\n {cards.length === 1 && <CtPSingleCard card={cards[0]} errorMessage={getErrorLabel(errorCode, i18n)} />}\n {cards.length > 1 && (\n <CtPCardsList\n cardSelected={checkoutCard}\n cards={cards}\n onChangeCard={handleOnChangeCard}\n errorMessage={getErrorLabel(errorCode, i18n)}\n />\n )}\n\n <PayButton\n disabled={isEveryCardExpired}\n label={getPayButtonLabel(i18n, amount, checkoutCard)}\n status={status}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n icon={\n cards.length !== 0 &&\n getImage({ imageFolder: 'components/' })(isCtpPrimaryPaymentMethod ? `${PREFIX}lock` : `${PREFIX}lock_black`)\n }\n onClick={doCheckout}\n onKeyDown={handlePayButtonKeyDown}\n />\n </Fragment>\n )}\n </Fragment>\n );\n};\n\nexport default CtPCards;\n"],"names":["getErrorLabel","errorCode","i18n","errorLabel","get","includes","getPayButtonLabel","amount","checkoutCard","isMobile","values","value","amountLabel","maskedData","panLastFour","CtPCards","onDisplayCardComponent","useCoreContext","getImage","useImage","cards","checkout","isCtpPrimaryPaymentMethod","status","onSubmit","onSetStatus","onError","useClickToPayContext","setCheckoutCard","useState","find","card","isExpired","setErrorCode","isEveryCardExpired","every","isShopperCheckingOutWithCtp","setIsShopperCheckingOutWithCtp","useAmount","useEffect","length","doCheckout","useCallback","async","payload","error","SrciError","reason","console","warn","source","scheme","AdyenCheckoutError","cause","handleOnChangeCard","displayNetworkDcf","isDcfPopupEmbedded","displayCardCheckoutView","handlePayButtonKeyDown","event","key","h","Fragment","Iframe","name","CTP_IFRAME_NAME","height","width","classNameModifiers","CtPSection","Title","div","className","CtPSingleCard","errorMessage","CtPCardsList","cardSelected","onChangeCard","PayButton","disabled","label","variant","icon","imageFolder","PREFIX","onClick","onKeyDown"],"mappings":"s/BA0BA,SAASA,EAAcC,EAAmBC,GACtC,IAAKD,EAAW,OAAO,KAEvB,MAAME,EAAaD,EAAKE,IAAI,cAAcH,KAC1C,OAAIE,EAAWE,SAAS,cAAsBH,EAAKE,IAAI,4BAChDD,CACX,CAEA,SAASG,EAAkBJ,EAAgBK,EAAuBC,GAC9D,OAAKA,EACAC,IAIE,KAHIP,EAAKE,IAAI,iBAAkB,CAC9BM,OAAQ,CAAEC,MAAOC,EAAYV,EAAMK,GAASM,WAAY,QAAQL,GAAcM,iBAH5DZ,EAAKE,IAAI,YAMvC,CAEA,MAAMW,EAAW,EAAGC,6BAChB,MAAMd,KAAEA,GAASe,IACXC,EAAWC,KACXC,MAAEA,EAAKC,SAAEA,EAAQC,0BAAEA,EAAyBC,OAAEA,EAAMC,SAAEA,EAAQC,YAAEA,EAAWC,QAAEA,GAAYC,KACxFnB,EAAcoB,GAAmBC,EAAkCT,EAAMU,KAAKC,IAASA,EAAKC,YAAcZ,EAAM,KAChHnB,EAAWgC,GAAgBJ,EAAiB,MAC7CK,EAAqBd,EAAMe,MAAMJ,GAAQA,EAAKC,YAC7CI,EAA6BC,GAAkCR,GAAkB,IAClFtB,OAAEA,GAAW+B,IAEnBC,EAAU,MACe,IAAjBnB,EAAMoB,QAAgBN,IACtBlB,OAEL,CAACA,EAAwBkB,EAAoBd,IAEhD,MAAMqB,EAAaC,EAAYC,UAC3B,GAAKnC,EAEL,IACI6B,GAA+B,GAC/BJ,EAAa,MACbR,EAAY,WACZ,MAAMmB,QAAgBvB,EAASb,GAC/BgB,EAASoB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CtPInfo/CtPInfoModal/CtPInfoModal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../../../../external/preact/dist/preact.js";import{useRef as o}from"../../../../../../external/preact/hooks/dist/hooks.js";import{CtPBrand as s}from"../../CtPBrand/CtPBrand.js";import{useCoreContext as a}from"../../../../../../core/Context/CoreProvider.js";import
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../../../../external/preact/dist/preact.js";import{useRef as o}from"../../../../../../external/preact/hooks/dist/hooks.js";import{CtPBrand as s}from"../../CtPBrand/CtPBrand.js";import{useCoreContext as a}from"../../../../../../core/Context/CoreProvider.js";import l from"../../../../../../core/Context/useImage.js";import{Modal as n}from"../../../../Modal/Modal.js";import c from"../../../../Img/Img.js";import r from"../../../../Button/Button.js";let i=Date.now();function p(){return i+=1,`adyen-${i}`}const m=({isOpen:i,onClose:m,focusAfterClose:d})=>{const u=o(),{i18n:f}=a(),g=l(),C=p(),_=p();return e(n,{onClose:m,isOpen:i,classNameModifiers:["ctp"],labelledBy:C,describedBy:_,focusFirst:u.current,focusAfterClose:d},({onCloseModal:o})=>e(t,null,e(c,{className:"adyen-checkout__ctp-modal-header-image",src:g({imageFolder:"components/"})("ctp_landscape"),alt:""}),e("h1",{id:C,className:"adyen-checkout__ctp-modal-title"},f.get("ctp.infoPopup.title")),e("div",{id:_},e("p",{tabIndex:-1,ref:u,className:"adyen-checkout__ctp-modal-text"},f.get("ctp.infoPopup.subtitle")),e("ul",{className:"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits"},e("li",null,f.get("ctp.infoPopup.benefit1")),e("li",null,f.get("ctp.infoPopup.benefit2")),e("li",null,f.get("ctp.infoPopup.benefit3"))),e(s,{classNameModifiers:["popup"]})),e(r,{onClick:o,label:f.get("close")})))};export{m as CtPInfoModal};
|
|
2
2
|
//# sourceMappingURL=CtPInfoModal.js.map
|
package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CtPInfoModal.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useRef } from 'preact/hooks';\nimport { CtPBrand } from '../../CtPBrand';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useImage from '../../../../../../core/Context/useImage';\nimport { Modal } from '../../../../Modal';\nimport Img from '../../../../Img';\nimport Button from '../../../../Button';\nimport './CtPInfoModal.scss';\n\nlet idGenerator = Date.now();\n\nfunction getUniqueId() {\n idGenerator += 1;\n return `adyen-${idGenerator}`;\n}\n\ntype CtPInfoModalProps = {\n isOpen: boolean;\n onClose(): void;\n focusAfterClose: HTMLElement;\n};\n\nconst CtPInfoModal = ({ isOpen, onClose, focusAfterClose }: CtPInfoModalProps) => {\n const focusFirstElement = useRef<HTMLParagraphElement>();\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const labelledBy = getUniqueId();\n const describedBy = getUniqueId();\n\n return (\n <Modal\n onClose={onClose}\n isOpen={isOpen}\n classNameModifiers={['ctp']}\n labelledBy={labelledBy}\n describedBy={describedBy}\n focusFirst={focusFirstElement.current}\n focusAfterClose={focusAfterClose}\n >\n {({ onCloseModal }) => (\n <Fragment>\n <Img className=\"adyen-checkout__ctp-modal-header-image\" src={getImage({ imageFolder: 'components/' })('ctp_landscape')} alt=\"\" />\n <h1 id={labelledBy} className=\"adyen-checkout__ctp-modal-title\">\n {i18n.get('ctp.infoPopup.title')}\n </h1>\n\n <div id={describedBy}>\n <p tabIndex={-1} ref={focusFirstElement} className=\"adyen-checkout__ctp-modal-text\">\n {i18n.get('ctp.infoPopup.subtitle')}\n </p>\n\n <ul className=\"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits\"
|
|
1
|
+
{"version":3,"file":"CtPInfoModal.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useRef } from 'preact/hooks';\nimport { CtPBrand } from '../../CtPBrand';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useImage from '../../../../../../core/Context/useImage';\nimport { Modal } from '../../../../Modal';\nimport Img from '../../../../Img';\nimport Button from '../../../../Button';\nimport './CtPInfoModal.scss';\n\nlet idGenerator = Date.now();\n\nfunction getUniqueId() {\n idGenerator += 1;\n return `adyen-${idGenerator}`;\n}\n\ntype CtPInfoModalProps = {\n isOpen: boolean;\n onClose(): void;\n focusAfterClose: HTMLElement;\n};\n\nconst CtPInfoModal = ({ isOpen, onClose, focusAfterClose }: CtPInfoModalProps) => {\n const focusFirstElement = useRef<HTMLParagraphElement>();\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n const labelledBy = getUniqueId();\n const describedBy = getUniqueId();\n\n return (\n <Modal\n onClose={onClose}\n isOpen={isOpen}\n classNameModifiers={['ctp']}\n labelledBy={labelledBy}\n describedBy={describedBy}\n focusFirst={focusFirstElement.current}\n focusAfterClose={focusAfterClose}\n >\n {({ onCloseModal }) => (\n <Fragment>\n <Img className=\"adyen-checkout__ctp-modal-header-image\" src={getImage({ imageFolder: 'components/' })('ctp_landscape')} alt=\"\" />\n <h1 id={labelledBy} className=\"adyen-checkout__ctp-modal-title\">\n {i18n.get('ctp.infoPopup.title')}\n </h1>\n\n <div id={describedBy}>\n <p tabIndex={-1} ref={focusFirstElement} className=\"adyen-checkout__ctp-modal-text\">\n {i18n.get('ctp.infoPopup.subtitle')}\n </p>\n\n <ul className=\"adyen-checkout__ctp-modal-text adyen-checkout__ctp-modal-benefits\">\n <li>{i18n.get('ctp.infoPopup.benefit1')}</li>\n <li>{i18n.get('ctp.infoPopup.benefit2')}</li>\n <li>{i18n.get('ctp.infoPopup.benefit3')}</li>\n </ul>\n\n <CtPBrand classNameModifiers={['popup']} />\n </div>\n\n <Button onClick={onCloseModal} label={i18n.get('close')} />\n </Fragment>\n )}\n </Modal>\n );\n};\n\nexport { CtPInfoModal };\n"],"names":["idGenerator","Date","now","getUniqueId","CtPInfoModal","isOpen","onClose","focusAfterClose","focusFirstElement","useRef","i18n","useCoreContext","getImage","useImage","labelledBy","describedBy","h","Modal","classNameModifiers","focusFirst","current","onCloseModal","Fragment","Img","className","src","imageFolder","alt","h1","id","get","div","p","tabIndex","ref","ul","li","CtPBrand","Button","onClick","label"],"mappings":"mfAUA,IAAIA,EAAcC,KAAKC,MAEvB,SAASC,IAEL,OADAH,GAAe,EACR,SAASA,GACpB,CAQA,MAAMI,EAAe,EAAGC,SAAQC,UAASC,sBACrC,MAAMC,EAAoBC,KACpBC,KAAEA,GAASC,IACXC,EAAWC,IAEXC,EAAaX,IACbY,EAAcZ,IAEpB,OACIa,EAACC,EAAAA,CACGX,QAASA,EACTD,OAAQA,EACRa,mBAAoB,CAAC,OACrBJ,WAAYA,EACZC,YAAaA,EACbI,WAAYX,EAAkBY,QAC9Bb,gBAAiBA,GAEhB,EAAGc,kBACAL,EAACM,OACGN,EAACO,EAAAA,CAAIC,UAAU,yCAAyCC,IAAKb,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,iBAAkBe,IAAI,KAC5HX,EAACY,KAAAA,CAAGC,GAAIf,EAAYU,UAAU,mCACzBd,EAAKoB,IAAI,wBAGdd,EAACe,MAAAA,CAAIF,GAAId,GACLC,EAACgB,IAAAA,CAAEC,UAAU,EAAIC,IAAK1B,EAAmBgB,UAAU,kCAC9Cd,EAAKoB,IAAI,2BAGdd,EAACmB,KAAAA,CAAGX,UAAU,qEACVR,EAACoB,UAAI1B,EAAKoB,IAAI,2BACdd,EAACoB,KAAAA,KAAI1B,EAAKoB,IAAI,2BACdd,EAACoB,KAAAA,KAAI1B,EAAKoB,IAAI,4BAGlBd,EAACqB,EAAAA,CAASnB,mBAAoB,CAAC,YAGnCF,EAACsB,EAAAA,CAAOC,QAASlB,EAAcmB,MAAO9B,EAAKoB,IAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createContext as t}from"../../../../external/preact/dist/preact.js";const l=t({status:null,onSubmit:null,onSetStatus:null,onError:null,onReady:null,
|
|
1
|
+
import{createContext as t}from"../../../../external/preact/dist/preact.js";const l=t({status:null,onSubmit:null,onSetStatus:null,onError:null,onReady:null,configuration:null,isStandaloneComponent:null,isCtpPrimaryPaymentMethod:null,isStoringCookies:!1,setIsCtpPrimaryPaymentMethod:null,logoutShopper:null,updateStoreCookiesConsent:null,ctpState:null,cards:[],schemes:[],otpMaskedContact:null,otpNetwork:null,checkout:null,verifyIfShopperIsEnrolled:null,startIdentityValidation:null,finishIdentityValidation:null});export{l as ClickToPayContext};
|
|
2
2
|
//# sourceMappingURL=ClickToPayContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayContext.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayContext.ts"],"sourcesContent":["import { createContext } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport
|
|
1
|
+
{"version":3,"file":"ClickToPayContext.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayContext.ts"],"sourcesContent":["import { createContext } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayCheckoutPayload, IClickToPayService } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { UIElementStatus } from '../../UIElement/types';\n\nexport interface IClickToPayContext extends Pick<\n IClickToPayService,\n 'checkout' | 'startIdentityValidation' | 'finishIdentityValidation' | 'verifyIfShopperIsEnrolled'\n> {\n isStandaloneComponent: boolean;\n isCtpPrimaryPaymentMethod: boolean;\n isStoringCookies: boolean;\n setIsCtpPrimaryPaymentMethod(isPrimary: boolean): void;\n logoutShopper(): Promise<void>;\n updateStoreCookiesConsent(shouldStore: boolean): void;\n ctpState: CtpState;\n cards: ShopperCard[];\n schemes: string[];\n otpMaskedContact: string;\n otpNetwork: string;\n configuration: ClickToPayProps;\n status: UIElementStatus;\n onSubmit(payload: ClickToPayCheckoutPayload): void;\n onSetStatus(status: UIElementStatus): void;\n onError(error: AdyenCheckoutError): void;\n onReady(): void;\n}\n\nconst ClickToPayContext = createContext<IClickToPayContext>({\n status: null,\n onSubmit: null,\n onSetStatus: null,\n onError: null,\n onReady: null,\n configuration: null,\n isStandaloneComponent: null,\n isCtpPrimaryPaymentMethod: null,\n isStoringCookies: false,\n setIsCtpPrimaryPaymentMethod: null,\n logoutShopper: null,\n updateStoreCookiesConsent: null,\n ctpState: null,\n cards: [],\n schemes: [],\n otpMaskedContact: null,\n otpNetwork: null,\n checkout: null,\n verifyIfShopperIsEnrolled: null,\n startIdentityValidation: null,\n finishIdentityValidation: null\n});\n\nexport { ClickToPayContext };\n"],"names":["ClickToPayContext","createContext","status","onSubmit","onSetStatus","onError","onReady","configuration","isStandaloneComponent","isCtpPrimaryPaymentMethod","isStoringCookies","setIsCtpPrimaryPaymentMethod","logoutShopper","updateStoreCookiesConsent","ctpState","cards","schemes","otpMaskedContact","otpNetwork","checkout","verifyIfShopperIsEnrolled","startIdentityValidation","finishIdentityValidation"],"mappings":"2EA+BA,MAAMA,EAAoBC,EAAkC,CACxDC,OAAQ,KACRC,SAAU,KACVC,YAAa,KACbC,QAAS,KACTC,QAAS,KACTC,cAAe,KACfC,sBAAuB,KACvBC,0BAA2B,KAC3BC,kBAAkB,EAClBC,6BAA8B,KAC9BC,cAAe,KACfC,0BAA2B,KAC3BC,SAAU,KACVC,MAAO,GACPC,QAAS,GACTC,iBAAkB,KAClBC,WAAY,KACZC,SAAU,KACVC,0BAA2B,KAC3BC,wBAAyB,KACzBC,yBAA0B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{CtpState as e}from"../services/ClickToPayService.js";import{ClickToPayContext as a}from"./ClickToPayContext.js";import{useState as o,useRef as
|
|
1
|
+
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{CtpState as e}from"../services/ClickToPayService.js";import{ClickToPayContext as a}from"./ClickToPayContext.js";import{useState as o,useRef as s,useEffect as n,useCallback as i}from"../../../../external/preact/hooks/dist/hooks.js";const r=({isStandaloneComponent:r=!1,clickToPayService:c,configuration:d,children:l,setClickToPayRef:p,onSubmit:u,onSetStatus:y,onError:S})=>{const[m]=o(c),[C,f]=o(c?.state||e.NotAvailable),[h,k]=o(!0),[I,P]=o("ready"),v=s({}),w=s(!1);n(()=>{p(v.current),v.current.setStatus=P},[]),n(()=>{m?.subscribeOnStateChange(t=>f(t))},[m]);const b=i(()=>{w.current||(d.onReady?.(),w.current=!0)},[d?.onReady]),g=i(async t=>{await(m?.finishIdentityValidation(t))},[m]),E=i(async()=>await(m?.startIdentityValidation()),[m]),V=i(async t=>await(m?.checkout(t)),[m]),R=i(async t=>await(m?.verifyIfShopperIsEnrolled(t)),[m]),j=i(async()=>{await(m?.logout())},[m]),x=i(t=>{m.updateStoreCookiesConsent(t)},[m]);return t(a.Provider,{value:{status:I,onSubmit:u,onError:S,onSetStatus:y,configuration:d,isStoringCookies:m?.storeCookies,isStandaloneComponent:r,isCtpPrimaryPaymentMethod:h,setIsCtpPrimaryPaymentMethod:k,ctpState:C,verifyIfShopperIsEnrolled:R,cards:m?.shopperCards,schemes:m?.schemes,otpMaskedContact:m?.identityValidationData?.maskedShopperContact,otpNetwork:m?.identityValidationData?.selectedNetwork,checkout:V,logoutShopper:j,startIdentityValidation:E,finishIdentityValidation:g,updateStoreCookiesConsent:x,onReady:b}},l)};export{r as default};
|
|
2
2
|
//# sourceMappingURL=ClickToPayProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayProvider.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayProvider.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayContext } from './ClickToPayContext';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { ClickToPayCheckoutPayload, IClickToPayService, IdentityLookupParams } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport {
|
|
1
|
+
{"version":3,"file":"ClickToPayProvider.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayProvider.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayContext } from './ClickToPayContext';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { ClickToPayCheckoutPayload, IClickToPayService, IdentityLookupParams } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { UIElementStatus } from '../../UIElement/types';\n\ntype ClickToPayProviderRef = {\n setStatus?(status: UIElementStatus): void;\n};\n\nexport type ClickToPayProviderProps = {\n isStandaloneComponent: boolean;\n clickToPayService: IClickToPayService | null;\n configuration: ClickToPayProps;\n children: any;\n setClickToPayRef(ref): void;\n onSubmit(payload: ClickToPayCheckoutPayload): void;\n onSetStatus(status: UIElementStatus): void;\n onError(error: AdyenCheckoutError): void;\n};\n\nconst ClickToPayProvider = ({\n isStandaloneComponent = false,\n clickToPayService,\n configuration,\n children,\n setClickToPayRef,\n onSubmit,\n onSetStatus,\n onError\n}: ClickToPayProviderProps) => {\n const [ctpService] = useState<IClickToPayService | null>(clickToPayService);\n const [ctpState, setCtpState] = useState<CtpState>(clickToPayService?.state || CtpState.NotAvailable);\n const [isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod] = useState<boolean>(true);\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const clickToPayRef = useRef<ClickToPayProviderRef>({});\n const isOnReadyInvoked = useRef<boolean>(false);\n\n useEffect(() => {\n setClickToPayRef(clickToPayRef.current);\n clickToPayRef.current.setStatus = setStatus;\n }, []);\n\n useEffect(() => {\n ctpService?.subscribeOnStateChange(status => setCtpState(status));\n }, [ctpService]);\n\n const onReady = useCallback(() => {\n if (isOnReadyInvoked.current) {\n return;\n }\n configuration.onReady?.();\n isOnReadyInvoked.current = true;\n }, [configuration?.onReady]);\n\n const finishIdentityValidation = useCallback(\n async (otpValue: string) => {\n await ctpService?.finishIdentityValidation(otpValue);\n },\n [ctpService]\n );\n\n const startIdentityValidation = useCallback(async () => {\n const data = await ctpService?.startIdentityValidation();\n return data;\n }, [ctpService]);\n\n const checkout = useCallback(\n async (card: ShopperCard) => {\n return await ctpService?.checkout(card);\n },\n [ctpService]\n );\n\n const verifyIfShopperIsEnrolled = useCallback(\n async (shopperIdentity: IdentityLookupParams) => {\n return await ctpService?.verifyIfShopperIsEnrolled(shopperIdentity);\n },\n [ctpService]\n );\n\n const logoutShopper = useCallback(async () => {\n await ctpService?.logout();\n }, [ctpService]);\n\n const updateStoreCookiesConsent = useCallback(\n (shouldStore: boolean) => {\n ctpService.updateStoreCookiesConsent(shouldStore);\n },\n [ctpService]\n );\n\n return (\n <ClickToPayContext.Provider\n value={{\n status,\n onSubmit,\n onError,\n onSetStatus,\n configuration,\n isStoringCookies: ctpService?.storeCookies,\n isStandaloneComponent,\n isCtpPrimaryPaymentMethod,\n setIsCtpPrimaryPaymentMethod,\n ctpState,\n verifyIfShopperIsEnrolled,\n cards: ctpService?.shopperCards,\n schemes: ctpService?.schemes,\n otpMaskedContact: ctpService?.identityValidationData?.maskedShopperContact,\n otpNetwork: ctpService?.identityValidationData?.selectedNetwork,\n checkout,\n logoutShopper,\n startIdentityValidation,\n finishIdentityValidation,\n updateStoreCookiesConsent,\n onReady\n }}\n >\n {children}\n </ClickToPayContext.Provider>\n );\n};\n\nexport default ClickToPayProvider;\n"],"names":["ClickToPayProvider","isStandaloneComponent","clickToPayService","configuration","children","setClickToPayRef","onSubmit","onSetStatus","onError","ctpService","useState","ctpState","setCtpState","state","CtpState","NotAvailable","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","status","setStatus","clickToPayRef","useRef","isOnReadyInvoked","useEffect","current","subscribeOnStateChange","onReady","useCallback","finishIdentityValidation","async","otpValue","startIdentityValidation","checkout","card","verifyIfShopperIsEnrolled","shopperIdentity","logoutShopper","logout","updateStoreCookiesConsent","shouldStore","h","ClickToPayContext","Provider","value","isStoringCookies","storeCookies","cards","shopperCards","schemes","otpMaskedContact","identityValidationData","maskedShopperContact","otpNetwork","selectedNetwork"],"mappings":"yTAyBA,MAAMA,EAAqB,EACvBC,yBAAwB,EACxBC,oBACAC,gBACAC,WACAC,mBACAC,WACAC,cACAC,cAEA,MAAOC,GAAcC,EAAoCR,IAClDS,EAAUC,GAAeF,EAAmBR,GAAmBW,OAASC,EAASC,eACjFC,EAA2BC,GAAgCP,GAAkB,IAC7EQ,EAAQC,GAAaT,EAA0B,SAChDU,EAAgBC,EAA8B,IAC9CC,EAAmBD,GAAgB,GAEzCE,EAAU,KACNlB,EAAiBe,EAAcI,SAC/BJ,EAAcI,QAAQL,UAAYA,GACnC,IAEHI,EAAU,KACNd,GAAYgB,uBAAuBP,GAAUN,EAAYM,KAC1D,CAACT,IAEJ,MAAMiB,EAAUC,EAAY,KACpBL,EAAiBE,UAGrBrB,EAAcuB,YACdJ,EAAiBE,SAAU,IAC5B,CAACrB,GAAeuB,UAEbE,EAA2BD,EAC7BE,MAAOC,UACGrB,GAAYmB,yBAAyBE,KAE/C,CAACrB,IAGCsB,EAA0BJ,EAAYE,eACrBpB,GAAYsB,2BAEhC,CAACtB,IAEEuB,EAAWL,EACbE,MAAOI,SACUxB,GAAYuB,SAASC,IAEtC,CAACxB,IAGCyB,EAA4BP,EAC9BE,MAAOM,SACU1B,GAAYyB,0BAA0BC,IAEvD,CAAC1B,IAGC2B,EAAgBT,EAAYE,gBACxBpB,GAAY4B,WACnB,CAAC5B,IAEE6B,EAA4BX,EAC7BY,IACG9B,EAAW6B,0BAA0BC,IAEzC,CAAC9B,IAGL,OACI+B,EAACC,EAAkBC,SAAQ,CACvBC,MAAO,CACHzB,SACAZ,WACAE,UACAD,cACAJ,gBACAyC,iBAAkBnC,GAAYoC,aAC9B5C,wBACAe,4BACAC,+BACAN,WACAuB,4BACAY,MAAOrC,GAAYsC,aACnBC,QAASvC,GAAYuC,QACrBC,iBAAkBxC,GAAYyC,wBAAwBC,qBACtDC,WAAY3C,GAAYyC,wBAAwBG,gBAChDrB,WACAI,gBACAL,0BACAH,2BACAU,4BACAZ,YAGHtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopperCard.js","sources":["../../../../../../src/components/internal/ClickToPay/models/ShopperCard.ts"],"sourcesContent":["import { DigitalCardStatus, SrcCard } from '../services/sdks/types';\nimport { SchemeNames } from '../services/sdks/utils';\nimport { ClickToPayScheme } from '../types';\n\nclass ShopperCard {\n public dateOfCardLastUsed?: string;\n public dateOfCardCreated: string;\n public panLastFour: string;\n public srcDigitalCardId: string;\n public scheme: ClickToPayScheme;\n public artUri: string;\n public srcCorrelationId: string;\n public tokenId?: string;\n public isExpired: boolean;\n\n private readonly panExpirationMonth: string;\n private readonly panExpirationYear: string;\n private readonly descriptorName?: string;\n private readonly status?: DigitalCardStatus = null;\n\n constructor(maskedCard: SrcCard, scheme: ClickToPayScheme, srcCorrelationId: string) {\n this.dateOfCardLastUsed = maskedCard.dateOfCardLastUsed;\n this.dateOfCardCreated = maskedCard.dateOfCardCreated;\n this.panLastFour = maskedCard.panLastFour;\n this.srcDigitalCardId = maskedCard.srcDigitalCardId;\n this.descriptorName = maskedCard.digitalCardData.descriptorName;\n this.tokenId = maskedCard.tokenId;\n this.scheme = scheme;\n this.artUri = maskedCard.digitalCardData.artUri;\n this.srcCorrelationId = srcCorrelationId;\n this.panExpirationMonth = maskedCard.panExpirationMonth;\n this.panExpirationYear = maskedCard.panExpirationYear;\n this.status = maskedCard.digitalCardData.status;\n\n this.isExpired = this.confirmCardIsExpired();\n }\n\n get title() {\n return this.scheme === 'visa' ? SchemeNames[this.scheme] : this.descriptorName || SchemeNames[this.scheme];\n }\n\n get isDcfPopupEmbedded(): boolean {\n return this.scheme === 'mc';\n }\n\n private confirmCardIsExpired(): boolean {\n if (!['ACTIVE', 'PENDING'].includes(this.status)) return true;\n\n if (!this.panExpirationYear && !this.panExpirationMonth) return false;\n\n const [currentMonth, currentYear] = [new Date().getMonth() + 1, new Date().getFullYear()];\n if (Number(this.panExpirationYear) > currentYear) return false;\n if (Number(this.panExpirationYear) === currentYear && Number(this.panExpirationMonth) >= currentMonth) return false;\n\n return true;\n }\n}\n\nexport default ShopperCard;\n"],"names":["ShopperCard","title","this","scheme","SchemeNames","descriptorName","isDcfPopupEmbedded","confirmCardIsExpired","includes","status","panExpirationYear","panExpirationMonth","currentMonth","currentYear","Date","getMonth","getFullYear","Number","constructor","maskedCard","srcCorrelationId","_define_property","dateOfCardLastUsed","dateOfCardCreated","panLastFour","srcDigitalCardId","artUri","tokenId","isExpired","digitalCardData"],"mappings":"gLAIA,MAAMA,EAiCF,SAAIC,GACA,MAAuB,SAAhBC,KAAKC,OAAoBC,EAAYF,KAAKC,QAAUD,KAAKG,gBAAkBD,EAAYF,KAAKC,OACvG,CAEA,sBAAIG,GACA,MAAuB,OAAhBJ,KAAKC,MAChB,CAEQI,oBAAAA,GACJ,IAAK,CAAC,SAAU,WAAWC,SAASN,KAAKO,QAAS,OAAO,EAEzD,IAAKP,KAAKQ,oBAAsBR,KAAKS,mBAAoB,OAAO,EAEhE,MAAOC,EAAcC,GAAe,EAAC,IAAIC,MAAOC,WAAa,GAAG,IAAID,MAAOE,eAC3E,QAAIC,OAAOf,KAAKQ,mBAAqBG,MACjCI,OAAOf,KAAKQ,qBAAuBG,GAAeI,OAAOf,KAAKS,qBAAuBC,EAG7F,CAnCA,WAAAM,CAAYC,EAAqBhB,EAA0BiB,GAf3DC,EAAAnB,KAAOoB,
|
|
1
|
+
{"version":3,"file":"ShopperCard.js","sources":["../../../../../../src/components/internal/ClickToPay/models/ShopperCard.ts"],"sourcesContent":["import { DigitalCardStatus, SrcCard } from '../services/sdks/types';\nimport { SchemeNames } from '../services/sdks/utils';\nimport { ClickToPayScheme } from '../types';\n\nclass ShopperCard {\n public dateOfCardLastUsed?: string;\n public dateOfCardCreated: string;\n public panLastFour: string;\n public srcDigitalCardId: string;\n public scheme: ClickToPayScheme;\n public artUri: string;\n public srcCorrelationId: string;\n public tokenId?: string;\n public isExpired: boolean;\n\n private readonly panExpirationMonth: string;\n private readonly panExpirationYear: string;\n private readonly descriptorName?: string;\n private readonly status?: DigitalCardStatus = null;\n\n constructor(maskedCard: SrcCard, scheme: ClickToPayScheme, srcCorrelationId: string) {\n this.dateOfCardLastUsed = maskedCard.dateOfCardLastUsed;\n this.dateOfCardCreated = maskedCard.dateOfCardCreated;\n this.panLastFour = maskedCard.panLastFour;\n this.srcDigitalCardId = maskedCard.srcDigitalCardId;\n this.descriptorName = maskedCard.digitalCardData.descriptorName;\n this.tokenId = maskedCard.tokenId;\n this.scheme = scheme;\n this.artUri = maskedCard.digitalCardData.artUri;\n this.srcCorrelationId = srcCorrelationId;\n this.panExpirationMonth = maskedCard.panExpirationMonth;\n this.panExpirationYear = maskedCard.panExpirationYear;\n this.status = maskedCard.digitalCardData.status;\n\n this.isExpired = this.confirmCardIsExpired();\n }\n\n get title() {\n return this.scheme === 'visa' ? SchemeNames[this.scheme] : this.descriptorName || SchemeNames[this.scheme];\n }\n\n get isDcfPopupEmbedded(): boolean {\n return this.scheme === 'mc';\n }\n\n private confirmCardIsExpired(): boolean {\n if (!['ACTIVE', 'PENDING'].includes(this.status)) return true;\n\n if (!this.panExpirationYear && !this.panExpirationMonth) return false;\n\n const [currentMonth, currentYear] = [new Date().getMonth() + 1, new Date().getFullYear()];\n if (Number(this.panExpirationYear) > currentYear) return false;\n if (Number(this.panExpirationYear) === currentYear && Number(this.panExpirationMonth) >= currentMonth) return false;\n\n return true;\n }\n}\n\nexport default ShopperCard;\n"],"names":["ShopperCard","title","this","scheme","SchemeNames","descriptorName","isDcfPopupEmbedded","confirmCardIsExpired","includes","status","panExpirationYear","panExpirationMonth","currentMonth","currentYear","Date","getMonth","getFullYear","Number","constructor","maskedCard","srcCorrelationId","_define_property","dateOfCardLastUsed","dateOfCardCreated","panLastFour","srcDigitalCardId","artUri","tokenId","isExpired","digitalCardData"],"mappings":"gLAIA,MAAMA,EAiCF,SAAIC,GACA,MAAuB,SAAhBC,KAAKC,OAAoBC,EAAYF,KAAKC,QAAUD,KAAKG,gBAAkBD,EAAYF,KAAKC,OACvG,CAEA,sBAAIG,GACA,MAAuB,OAAhBJ,KAAKC,MAChB,CAEQI,oBAAAA,GACJ,IAAK,CAAC,SAAU,WAAWC,SAASN,KAAKO,QAAS,OAAO,EAEzD,IAAKP,KAAKQ,oBAAsBR,KAAKS,mBAAoB,OAAO,EAEhE,MAAOC,EAAcC,GAAe,EAAC,IAAIC,MAAOC,WAAa,GAAG,IAAID,MAAOE,eAC3E,QAAIC,OAAOf,KAAKQ,mBAAqBG,MACjCI,OAAOf,KAAKQ,qBAAuBG,GAAeI,OAAOf,KAAKS,qBAAuBC,EAG7F,CAnCA,WAAAM,CAAYC,EAAqBhB,EAA0BiB,GAf3DC,EAAAnB,KAAOoB,6BACPD,EAAAnB,KAAOqB,4BACPF,EAAAnB,KAAOsB,sBACPH,EAAAnB,KAAOuB,2BACPJ,EAAAnB,KAAOC,iBACPkB,EAAAnB,KAAOwB,iBACPL,EAAAnB,KAAOkB,2BACPC,EAAAnB,KAAOyB,kBACPN,EAAAnB,KAAO0B,oBAEPP,EAAAnB,KAAiBS,6BACjBU,EAAAnB,KAAiBQ,4BACjBW,EAAAnB,KAAiBG,yBACjBgB,EAAAnB,KAAiBO,SAA6B,MAG1CP,KAAKoB,mBAAqBH,EAAWG,mBACrCpB,KAAKqB,kBAAoBJ,EAAWI,kBACpCrB,KAAKsB,YAAcL,EAAWK,YAC9BtB,KAAKuB,iBAAmBN,EAAWM,iBACnCvB,KAAKG,eAAiBc,EAAWU,gBAAgBxB,eACjDH,KAAKyB,QAAUR,EAAWQ,QAC1BzB,KAAKC,OAASA,EACdD,KAAKwB,OAASP,EAAWU,gBAAgBH,OACzCxB,KAAKkB,iBAAmBA,EACxBlB,KAAKS,mBAAqBQ,EAAWR,mBACrCT,KAAKQ,kBAAoBS,EAAWT,kBACpCR,KAAKO,OAASU,EAAWU,gBAAgBpB,OAEzCP,KAAK0B,UAAY1B,KAAKK,sBAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayService.js","sources":["../../../../../../src/components/internal/ClickToPay/services/ClickToPayService.ts"],"sourcesContent":["import { ISrcInitiator } from './sdks/AbstractSrcInitiator';\nimport {\n CallbackStateSubscriber,\n IClickToPayService,\n IdentityLookupParams,\n ClickToPayCheckoutPayload,\n SrcProfileWithScheme,\n SchemesConfiguration,\n IdentityValidationData\n} from './types';\nimport { ISrcSdkLoader } from './sdks/SrcSdkLoader';\nimport { createCheckoutPayloadBasedOnScheme, createShopperCardsList, CTP_IFRAME_NAME } from './utils';\nimport { SrciIdentityLookupResponse, SrciIsRecognizedResponse, SrcProfile } from './sdks/types';\nimport SrciError from './sdks/SrciError';\nimport { SchemeNames } from './sdks/utils';\nimport ShopperCard from '../models/ShopperCard';\nimport uuidv4 from '../../../../utils/uuid';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { isFulfilled, isRejected } from '../../../../utils/promise-util';\nimport TimeoutError from '../errors/TimeoutError';\nimport { executeWithTimeout } from './execute-with-timeout';\nimport type { IAnalytics } from '../../../../core/Analytics/Analytics';\n\nexport enum CtpState {\n Idle = 'Idle',\n Loading = 'Loading',\n ShopperIdentified = 'ShopperIdentified',\n OneTimePassword = 'OneTimePassword',\n Ready = 'Ready',\n Login = 'Login',\n NotAvailable = 'NotAvailable'\n}\n\nclass ClickToPayService implements IClickToPayService {\n private readonly sdkLoader: ISrcSdkLoader;\n private readonly schemesConfig: SchemesConfiguration;\n private readonly shopperIdentity?: IdentityLookupParams;\n private readonly environment: string;\n private readonly analytics: IAnalytics;\n\n private readonly onTimeout?: (error: TimeoutError) => void;\n\n /**\n * Mandatory unique ID passed to all the networks (Click to Pay systems), used to track user journey\n */\n private readonly srciTransactionId: string = uuidv4();\n\n private sdks: ISrcInitiator[];\n private validationSchemeSdk: ISrcInitiator = null;\n private stateSubscriber: CallbackStateSubscriber;\n\n public state: CtpState = CtpState.Idle;\n public shopperCards: ShopperCard[] = null;\n public identityValidationData: IdentityValidationData = null;\n\n /**\n * Indicates if the shopper opted for saving cookies during the transaction\n */\n public storeCookies = false;\n\n constructor(\n schemesConfig: SchemesConfiguration,\n sdkLoader: ISrcSdkLoader,\n environment: string,\n analytics: IAnalytics,\n shopperIdentity?: IdentityLookupParams,\n onTimeout?: (error: TimeoutError) => void\n ) {\n this.sdkLoader = sdkLoader;\n this.schemesConfig = schemesConfig;\n this.shopperIdentity = shopperIdentity;\n this.environment = environment;\n this.onTimeout = onTimeout;\n this.analytics = analytics;\n }\n\n public get shopperAccountFound(): boolean {\n return [CtpState.Ready, CtpState.ShopperIdentified].includes(this.state);\n }\n\n public get schemes(): string[] {\n return this.sdkLoader.schemes;\n }\n\n public updateStoreCookiesConsent(shouldStore: boolean) {\n this.storeCookies = shouldStore;\n }\n\n public async initialize(): Promise<void> {\n this.setState(CtpState.Loading);\n\n try {\n this.sdks = await this.sdkLoader.load(this.environment, this.analytics);\n await this.initiateSdks();\n\n const { recognized = false, idTokens = null } = await this.verifyIfShopperIsRecognized();\n\n if (recognized) {\n await this.getShopperProfile(idTokens);\n this.setState(CtpState.Ready);\n return;\n }\n\n if (!this.shopperIdentity) {\n this.setState(CtpState.NotAvailable);\n return;\n }\n\n const { isEnrolled } = await this.verifyIfShopperIsEnrolled(this.shopperIdentity);\n if (isEnrolled) {\n this.setState(CtpState.ShopperIdentified);\n return;\n }\n\n this.setState(CtpState.NotAvailable);\n } catch (error) {\n if ((error instanceof SrciError && error?.reason === 'REQUEST_TIMEOUT') || error instanceof TimeoutError) {\n this.handleTimeout(error);\n } else if (error instanceof SrciError) {\n console.warn(`Error at ClickToPayService # init: ${error.toString()}`);\n } else {\n console.warn(error);\n }\n\n this.setState(CtpState.NotAvailable);\n }\n }\n\n /**\n * Set the callback for notifying when the CtPState changes\n */\n public subscribeOnStateChange(callback: CallbackStateSubscriber): void {\n this.stateSubscriber = callback;\n }\n\n /**\n * Initiates Consumer Identity validation with one Click to Pay System.\n * The Click to Pay System sends a one-time-password (OTP) to the registered email address or mobile number.\n **/\n public async startIdentityValidation(): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('startIdentityValidation: No ValidationSDK set for the validation process');\n }\n try {\n const { maskedValidationChannel } = await this.validationSchemeSdk.initiateIdentityValidation();\n\n this.identityValidationData = {\n maskedShopperContact: maskedValidationChannel.replace(/\\*/g, '•'),\n selectedNetwork: SchemeNames[this.validationSchemeSdk.schemeName]\n };\n\n this.setState(CtpState.OneTimePassword);\n } catch (error: unknown) {\n // If there is an error when 'startIdentityValidation' (Ex: account is blocked), we reset the scheme chosen to perform this step\n this.validationSchemeSdk = null;\n throw error;\n }\n }\n\n /**\n * Completes the validation of the Shopper by evaluating the supplied OTP.\n */\n public async finishIdentityValidation(otpCode: string): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('finishIdentityValidation: No ValidationSDK set for the validation process');\n }\n\n const validationToken = await this.validationSchemeSdk.completeIdentityValidation(otpCode);\n await this.getShopperProfile([validationToken.idToken]);\n this.setState(CtpState.Ready);\n this.validationSchemeSdk = null;\n }\n\n /**\n * This method performs checkout using the selected card\n */\n public async checkout(card: ShopperCard): Promise<ClickToPayCheckoutPayload> {\n if (!card) {\n throw Error('ClickToPayService # checkout: Missing card data');\n }\n\n const checkoutSdk = this.sdks.find(sdk => sdk.schemeName === card.scheme);\n\n const checkoutResponse = await checkoutSdk.checkout({\n srcDigitalCardId: card.srcDigitalCardId,\n srcCorrelationId: card.srcCorrelationId,\n ...(card.isDcfPopupEmbedded && { windowRef: window.frames[CTP_IFRAME_NAME] }),\n ...(this.storeCookies && { complianceSettings: { complianceResources: [{ complianceType: 'REMEMBER_ME', uri: '' }] } })\n });\n\n if (checkoutResponse.dcfActionCode !== 'COMPLETE') {\n throw new AdyenCheckoutError(\n 'ERROR',\n `Checkout through Scheme DCF did not complete. DCF Action code received: ${checkoutResponse.dcfActionCode}`\n );\n }\n\n return createCheckoutPayloadBasedOnScheme(card, checkoutResponse, this.environment);\n }\n\n /**\n * Call the 'unbindAppInstance()' method of each SRC SDK in order to remove the shopper cookies.\n * Besides, it deletes all information stored about the shopper.\n */\n public async logout(): Promise<void> {\n if (!this.sdks) {\n throw new AdyenCheckoutError('ERROR', 'ClickToPayService is not initialized');\n }\n\n try {\n const logoutPromises = this.sdks.map(sdk => sdk.unbindAppInstance());\n await Promise.all(logoutPromises);\n } catch (error) {\n if (error instanceof SrciError) console.warn(`Error at ClickToPayService # logout: ${error.toString()}`);\n else console.warn(error);\n }\n\n this.shopperCards = null;\n this.identityValidationData = null;\n this.validationSchemeSdk = null;\n\n this.setState(CtpState.Login);\n }\n\n /**\n * Call the 'identityLookup()' method of each SRC SDK in order to verify if the shopper has an account.\n *\n * Based on the responses from the Click to Pay Systems, we should do the validation process using the SDK that\n * that responds faster with 'consumerPresent=true'\n */\n public verifyIfShopperIsEnrolled(shopperIdentity: IdentityLookupParams): Promise<{ isEnrolled: boolean }> {\n const { shopperEmail } = shopperIdentity;\n\n return new Promise((resolve, reject) => {\n const lookupPromises = this.sdks.map(sdk => {\n const identityLookupPromise = executeWithTimeout<SrciIdentityLookupResponse>(\n () => sdk.identityLookup({ identityValue: shopperEmail, type: 'email' }),\n 5000,\n new TimeoutError({\n source: 'identityLookup',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n\n return identityLookupPromise\n .then(response => {\n if (response.consumerPresent && !this.validationSchemeSdk) {\n this.setSdkForPerformingShopperIdentityValidation(sdk);\n resolve({ isEnrolled: true });\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n\n void Promise.allSettled(lookupPromises).then(() => {\n resolve({ isEnrolled: false });\n });\n });\n }\n\n private setState(state: CtpState): void {\n this.state = state;\n this.stateSubscriber?.(this.state);\n }\n\n private setSdkForPerformingShopperIdentityValidation(sdk: ISrcInitiator) {\n this.validationSchemeSdk = sdk;\n }\n\n private handleTimeout(error: SrciError | TimeoutError) {\n // If the timeout error was thrown directly by the scheme SDK, we convert it to TimeoutError\n // If the timeout error was thrown by our internal timeout mechanism, we don't do anything\n const timeoutError =\n error instanceof SrciError\n ? new TimeoutError({ source: error.source, scheme: error.scheme, isTimeoutTriggeredBySchemeSdk: true })\n : error;\n\n if (timeoutError.scheme === 'visa') {\n timeoutError.setCorrelationId(window.VISA_SDK?.correlationId);\n\n // Visa srciDpaId must be passed when there is no correlation ID available\n if (window.VISA_SDK?.correlationId) window.VISA_SDK?.buildClientProfile?.();\n else window.VISA_SDK?.buildClientProfile?.(this.schemesConfig.visa.srciDpaId);\n }\n this.onTimeout?.(timeoutError);\n }\n\n /**\n * Based on the given 'idToken', this method goes through each SRCi SDK and fetches the shopper\n * profile with his cards.\n */\n private async getShopperProfile(idTokens: string[]): Promise<void> {\n return new Promise((resolve, reject) => {\n const srcProfilesPromises = this.sdks.map(sdk => sdk.getSrcProfile(idTokens));\n\n void Promise.allSettled(srcProfilesPromises).then(srcProfilesResponses => {\n if (srcProfilesResponses.every(isRejected)) {\n reject(srcProfilesResponses[0].reason);\n }\n\n const createProfileWithScheme = (promiseResult: PromiseSettledResult<SrcProfile>, index) =>\n isFulfilled(promiseResult) && { ...promiseResult.value, scheme: this.sdks[index].schemeName };\n\n const profilesWithScheme: SrcProfileWithScheme[] = srcProfilesResponses.map(createProfileWithScheme).filter(profile => !!profile);\n\n this.shopperCards = createShopperCardsList(profilesWithScheme);\n resolve();\n });\n });\n }\n\n /**\n * Calls the 'isRecognized()' method of each SRC SDK in order to verify if the shopper is\n * recognized on the device. The shopper is recognized if he/she has the Cookies stored\n * on their browser\n */\n private verifyIfShopperIsRecognized(): Promise<SrciIsRecognizedResponse> {\n return new Promise((resolve, reject) => {\n const promises = this.sdks.map(sdk => {\n const isRecognizedPromise = executeWithTimeout<SrciIsRecognizedResponse>(\n () => sdk.isRecognized(),\n 5000,\n new TimeoutError({\n source: 'isRecognized',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n\n return isRecognizedPromise\n .then(response => {\n if (response.recognized) resolve(response);\n })\n .catch(error => {\n reject(error);\n });\n });\n\n // If the 'resolve' didn't happen until this point, then shopper is not recognized\n void Promise.allSettled(promises).then(() => {\n resolve({ recognized: false });\n });\n });\n }\n\n private initiateSdks(): Promise<void[]> {\n const initPromises = this.sdks.map(sdk => {\n const cfg = this.schemesConfig[sdk.schemeName];\n\n return executeWithTimeout<void>(\n () => sdk.init(cfg, this.srciTransactionId),\n 5000,\n new TimeoutError({\n source: 'init',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n });\n\n return Promise.all(initPromises);\n }\n}\n\nexport default ClickToPayService;\n"],"names":["CtpState","ClickToPayService","shopperAccountFound","includes","this","state","schemes","sdkLoader","updateStoreCookiesConsent","shouldStore","storeCookies","initialize","setState","sdks","load","environment","analytics","initiateSdks","recognized","idTokens","verifyIfShopperIsRecognized","getShopperProfile","shopperIdentity","isEnrolled","verifyIfShopperIsEnrolled","error","SrciError","reason","TimeoutError","handleTimeout","console","warn","toString","subscribeOnStateChange","callback","stateSubscriber","startIdentityValidation","validationSchemeSdk","Error","maskedValidationChannel","initiateIdentityValidation","identityValidationData","maskedShopperContact","replace","selectedNetwork","SchemeNames","schemeName","finishIdentityValidation","otpCode","validationToken","completeIdentityValidation","idToken","checkout","card","checkoutSdk","find","sdk","scheme","checkoutResponse","srcDigitalCardId","srcCorrelationId","isDcfPopupEmbedded","windowRef","window","frames","CTP_IFRAME_NAME","complianceSettings","complianceResources","complianceType","uri","dcfActionCode","AdyenCheckoutError","createCheckoutPayloadBasedOnScheme","logout","logoutPromises","map","unbindAppInstance","Promise","all","shopperCards","shopperEmail","resolve","reject","lookupPromises","executeWithTimeout","identityLookup","identityValue","type","source","isTimeoutTriggeredBySchemeSdk","then","response","consumerPresent","setSdkForPerformingShopperIdentityValidation","catch","allSettled","timeoutError","setCorrelationId","VISA_SDK","correlationId","buildClientProfile","schemesConfig","visa","srciDpaId","onTimeout","srcProfilesPromises","getSrcProfile","srcProfilesResponses","every","isRejected","profilesWithScheme","promiseResult","index","isFulfilled","value","filter","profile","createShopperCardsList","promises","isRecognized","initPromises","cfg","init","srciTransactionId","constructor","_define_property","uuidv4"],"mappings":"wlBAuBO,IAAAA,EAAKA,SAAAA,GAAAA,mLAAAA,CAQX,CARWA,CAQX,CAAA,GAED,MAAMC,EA2CF,uBAAWC,GACP,MAAO,8BAA6CC,SAASC,KAAKC,MACtE,CAEA,WAAWC,GACP,OAAOF,KAAKG,UAAUD,OAC1B,CAEOE,yBAAAA,CAA0BC,GAC7BL,KAAKM,aAAeD,CACxB,CAEA,gBAAaE,GACTP,KAAKQ,SAAQ,WAEb,IACIR,KAAKS,WAAaT,KAAKG,UAAUO,KAAKV,KAAKW,YAAaX,KAAKY,iBACvDZ,KAAKa,eAEX,MAAMC,WAAEA,GAAa,EAAKC,SAAEA,EAAW,YAAef,KAAKgB,8BAE3D,GAAIF,EAGA,aAFMd,KAAKiB,kBAAkBF,QAC7Bf,KAAKQ,SAAQ,SAIjB,IAAKR,KAAKkB,gBAEN,YADAlB,KAAKQ,SAAQ,gBAIjB,MAAMW,WAAEA,SAAqBnB,KAAKoB,0BAA0BpB,KAAKkB,iBACjE,GAAIC,EAEA,YADAnB,KAAKQ,SA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OAAQ,OACR/B,OAAQD,EAAIV,WACZ2C,+BAA+B,OAK3C,OAAOZ,QAAQC,IAAI0C,EACvB,CAhTA,WAAAI,CACIvB,EACA9F,EACAQ,EACAC,EACAM,EACAkF,GAhCJqB,EAAAzH,KAAiBG,iBAAjB,GACAsH,EAAAzH,KAAiBiG,qBAAjB,GACAwB,EAAAzH,KAAiBkB,uBAAjB,GACAuG,EAAAzH,KAAiBW,mBAAjB,GACA8G,EAAAzH,KAAiBY,iBAAjB,GAEA6G,EAAAzH,KAAiBoG,iBAAjB,GAKAqB,OAAiBF,oBAA4BG,KAE7CD,EAAAzH,KAAQS,YAAR,GACAgH,EAAAzH,KAAQiC,sBAAqC,MAC7CwF,EAAAzH,KAAQ+B,uBAAR,GAEA0F,EAAAzH,KAAOC,QAAAA,QACPwH,EAAAzH,KAAO2E,eAA8B,MACrC8C,EAAAzH,KAAOqC,yBAAiD,MAKxDoF,OAAOnH,gBAAe,GAUlBN,KAAKG,UAAYA,EACjBH,KAAKiG,cAAgBA,EACrBjG,KAAKkB,gBAAkBA,EACvBlB,KAAKW,YAAcA,EACnBX,KAAKoG,UAAYA,EACjBpG,KAAKY,UAAYA,CACrB"}
|
|
1
|
+
{"version":3,"file":"ClickToPayService.js","sources":["../../../../../../src/components/internal/ClickToPay/services/ClickToPayService.ts"],"sourcesContent":["import { ISrcInitiator } from './sdks/AbstractSrcInitiator';\nimport {\n CallbackStateSubscriber,\n IClickToPayService,\n IdentityLookupParams,\n ClickToPayCheckoutPayload,\n SrcProfileWithScheme,\n SchemesConfiguration,\n IdentityValidationData\n} from './types';\nimport { ISrcSdkLoader } from './sdks/SrcSdkLoader';\nimport { createCheckoutPayloadBasedOnScheme, createShopperCardsList, CTP_IFRAME_NAME } from './utils';\nimport { SrciIdentityLookupResponse, SrciIsRecognizedResponse, SrcProfile } from './sdks/types';\nimport SrciError from './sdks/SrciError';\nimport { SchemeNames } from './sdks/utils';\nimport ShopperCard from '../models/ShopperCard';\nimport uuidv4 from '../../../../utils/uuid';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { isFulfilled, isRejected } from '../../../../utils/promise-util';\nimport TimeoutError from '../errors/TimeoutError';\nimport { executeWithTimeout } from './execute-with-timeout';\nimport type { IAnalytics } from '../../../../core/Analytics/Analytics';\n\nexport enum CtpState {\n Idle = 'Idle',\n Loading = 'Loading',\n ShopperIdentified = 'ShopperIdentified',\n OneTimePassword = 'OneTimePassword',\n Ready = 'Ready',\n Login = 'Login',\n NotAvailable = 'NotAvailable'\n}\n\nclass ClickToPayService implements IClickToPayService {\n private readonly sdkLoader: ISrcSdkLoader;\n private readonly schemesConfig: SchemesConfiguration;\n private readonly shopperIdentity?: IdentityLookupParams;\n private readonly environment: string;\n private readonly analytics: IAnalytics;\n\n private readonly onTimeout?: (error: TimeoutError) => void;\n\n /**\n * Mandatory unique ID passed to all the networks (Click to Pay systems), used to track user journey\n */\n private readonly srciTransactionId: string = uuidv4();\n\n private sdks: ISrcInitiator[];\n private validationSchemeSdk: ISrcInitiator = null;\n private stateSubscriber: CallbackStateSubscriber;\n\n public state: CtpState = CtpState.Idle;\n public shopperCards: ShopperCard[] = null;\n public identityValidationData: IdentityValidationData = null;\n\n /**\n * Indicates if the shopper opted for saving cookies during the transaction\n */\n public storeCookies = false;\n\n constructor(\n schemesConfig: SchemesConfiguration,\n sdkLoader: ISrcSdkLoader,\n environment: string,\n analytics: IAnalytics,\n shopperIdentity?: IdentityLookupParams,\n onTimeout?: (error: TimeoutError) => void\n ) {\n this.sdkLoader = sdkLoader;\n this.schemesConfig = schemesConfig;\n this.shopperIdentity = shopperIdentity;\n this.environment = environment;\n this.onTimeout = onTimeout;\n this.analytics = analytics;\n }\n\n public get shopperAccountFound(): boolean {\n return [CtpState.Ready, CtpState.ShopperIdentified].includes(this.state);\n }\n\n public get schemes(): string[] {\n return this.sdkLoader.schemes;\n }\n\n public updateStoreCookiesConsent(shouldStore: boolean) {\n this.storeCookies = shouldStore;\n }\n\n public async initialize(): Promise<void> {\n this.setState(CtpState.Loading);\n\n try {\n this.sdks = await this.sdkLoader.load(this.environment, this.analytics);\n await this.initiateSdks();\n\n const { recognized = false, idTokens = null } = await this.verifyIfShopperIsRecognized();\n\n if (recognized) {\n await this.getShopperProfile(idTokens);\n this.setState(CtpState.Ready);\n return;\n }\n\n if (!this.shopperIdentity) {\n this.setState(CtpState.NotAvailable);\n return;\n }\n\n const { isEnrolled } = await this.verifyIfShopperIsEnrolled(this.shopperIdentity);\n if (isEnrolled) {\n this.setState(CtpState.ShopperIdentified);\n return;\n }\n\n this.setState(CtpState.NotAvailable);\n } catch (error) {\n if ((error instanceof SrciError && error?.reason === 'REQUEST_TIMEOUT') || error instanceof TimeoutError) {\n this.handleTimeout(error);\n } else if (error instanceof SrciError) {\n console.warn(`Error at ClickToPayService # init: ${error.toString()}`);\n } else {\n console.warn(error);\n }\n\n this.setState(CtpState.NotAvailable);\n }\n }\n\n /**\n * Set the callback for notifying when the CtPState changes\n */\n public subscribeOnStateChange(callback: CallbackStateSubscriber): void {\n this.stateSubscriber = callback;\n }\n\n /**\n * Initiates Consumer Identity validation with one Click to Pay System.\n * The Click to Pay System sends a one-time-password (OTP) to the registered email address or mobile number.\n **/\n public async startIdentityValidation(): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('startIdentityValidation: No ValidationSDK set for the validation process');\n }\n try {\n const { maskedValidationChannel } = await this.validationSchemeSdk.initiateIdentityValidation();\n\n this.identityValidationData = {\n maskedShopperContact: maskedValidationChannel.replace(/\\*/g, '•'),\n selectedNetwork: SchemeNames[this.validationSchemeSdk.schemeName]\n };\n\n this.setState(CtpState.OneTimePassword);\n } catch (error: unknown) {\n // If there is an error when 'startIdentityValidation' (Ex: account is blocked), we reset the scheme chosen to perform this step\n this.validationSchemeSdk = null;\n throw error;\n }\n }\n\n /**\n * Completes the validation of the Shopper by evaluating the supplied OTP.\n */\n public async finishIdentityValidation(otpCode: string): Promise<void> {\n if (!this.validationSchemeSdk) {\n throw Error('finishIdentityValidation: No ValidationSDK set for the validation process');\n }\n\n const validationToken = await this.validationSchemeSdk.completeIdentityValidation(otpCode);\n await this.getShopperProfile([validationToken.idToken]);\n this.setState(CtpState.Ready);\n this.validationSchemeSdk = null;\n }\n\n /**\n * This method performs checkout using the selected card\n */\n public async checkout(card: ShopperCard): Promise<ClickToPayCheckoutPayload> {\n if (!card) {\n throw Error('ClickToPayService # checkout: Missing card data');\n }\n\n const checkoutSdk = this.sdks.find(sdk => sdk.schemeName === card.scheme);\n\n const checkoutResponse = await checkoutSdk.checkout({\n srcDigitalCardId: card.srcDigitalCardId,\n srcCorrelationId: card.srcCorrelationId,\n ...(card.isDcfPopupEmbedded && { windowRef: window.frames[CTP_IFRAME_NAME] }),\n ...(this.storeCookies && { complianceSettings: { complianceResources: [{ complianceType: 'REMEMBER_ME', uri: '' }] } })\n });\n\n if (checkoutResponse.dcfActionCode !== 'COMPLETE') {\n throw new AdyenCheckoutError(\n 'ERROR',\n `Checkout through Scheme DCF did not complete. DCF Action code received: ${checkoutResponse.dcfActionCode}`\n );\n }\n\n return createCheckoutPayloadBasedOnScheme(card, checkoutResponse, this.environment);\n }\n\n /**\n * Call the 'unbindAppInstance()' method of each SRC SDK in order to remove the shopper cookies.\n * Besides, it deletes all information stored about the shopper.\n */\n public async logout(): Promise<void> {\n if (!this.sdks) {\n throw new AdyenCheckoutError('ERROR', 'ClickToPayService is not initialized');\n }\n\n try {\n const logoutPromises = this.sdks.map(sdk => sdk.unbindAppInstance());\n await Promise.all(logoutPromises);\n } catch (error) {\n if (error instanceof SrciError) console.warn(`Error at ClickToPayService # logout: ${error.toString()}`);\n else console.warn(error);\n }\n\n this.shopperCards = null;\n this.identityValidationData = null;\n this.validationSchemeSdk = null;\n\n this.setState(CtpState.Login);\n }\n\n /**\n * Call the 'identityLookup()' method of each SRC SDK in order to verify if the shopper has an account.\n *\n * Based on the responses from the Click to Pay Systems, we should do the validation process using the SDK that\n * that responds faster with 'consumerPresent=true'\n */\n public verifyIfShopperIsEnrolled(shopperIdentity: IdentityLookupParams): Promise<{ isEnrolled: boolean }> {\n const { shopperEmail } = shopperIdentity;\n\n return new Promise((resolve, reject) => {\n const lookupPromises = this.sdks.map(sdk => {\n const identityLookupPromise = executeWithTimeout<SrciIdentityLookupResponse>(\n () => sdk.identityLookup({ identityValue: shopperEmail, type: 'email' }),\n 5000,\n new TimeoutError({\n source: 'identityLookup',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n\n return identityLookupPromise\n .then(response => {\n if (response.consumerPresent && !this.validationSchemeSdk) {\n this.setSdkForPerformingShopperIdentityValidation(sdk);\n resolve({ isEnrolled: true });\n }\n })\n .catch(error => {\n reject(error);\n });\n });\n\n void Promise.allSettled(lookupPromises).then(() => {\n resolve({ isEnrolled: false });\n });\n });\n }\n\n private setState(state: CtpState): void {\n this.state = state;\n this.stateSubscriber?.(this.state);\n }\n\n private setSdkForPerformingShopperIdentityValidation(sdk: ISrcInitiator) {\n this.validationSchemeSdk = sdk;\n }\n\n private handleTimeout(error: SrciError | TimeoutError) {\n // If the timeout error was thrown directly by the scheme SDK, we convert it to TimeoutError\n // If the timeout error was thrown by our internal timeout mechanism, we don't do anything\n const timeoutError =\n error instanceof SrciError\n ? new TimeoutError({ source: error.source, scheme: error.scheme, isTimeoutTriggeredBySchemeSdk: true })\n : error;\n\n if (timeoutError.scheme === 'visa') {\n timeoutError.setCorrelationId(window.VISA_SDK?.correlationId);\n\n // Visa srciDpaId must be passed when there is no correlation ID available\n if (window.VISA_SDK?.correlationId) window.VISA_SDK?.buildClientProfile?.();\n else window.VISA_SDK?.buildClientProfile?.(this.schemesConfig.visa.srciDpaId);\n }\n this.onTimeout?.(timeoutError);\n }\n\n /**\n * Based on the given 'idToken', this method goes through each SRCi SDK and fetches the shopper\n * profile with his cards.\n */\n private async getShopperProfile(idTokens: string[]): Promise<void> {\n return new Promise((resolve, reject) => {\n const srcProfilesPromises = this.sdks.map(sdk => sdk.getSrcProfile(idTokens));\n\n void Promise.allSettled(srcProfilesPromises).then(srcProfilesResponses => {\n if (srcProfilesResponses.every(isRejected)) {\n reject(srcProfilesResponses[0].reason);\n }\n\n const createProfileWithScheme = (promiseResult: PromiseSettledResult<SrcProfile>, index) =>\n isFulfilled(promiseResult) && { ...promiseResult.value, scheme: this.sdks[index].schemeName };\n\n const profilesWithScheme: SrcProfileWithScheme[] = srcProfilesResponses.map(createProfileWithScheme).filter(profile => !!profile);\n\n this.shopperCards = createShopperCardsList(profilesWithScheme);\n resolve();\n });\n });\n }\n\n /**\n * Calls the 'isRecognized()' method of each SRC SDK in order to verify if the shopper is\n * recognized on the device. The shopper is recognized if he/she has the Cookies stored\n * on their browser\n */\n private verifyIfShopperIsRecognized(): Promise<SrciIsRecognizedResponse> {\n return new Promise((resolve, reject) => {\n const promises = this.sdks.map(sdk => {\n const isRecognizedPromise = executeWithTimeout<SrciIsRecognizedResponse>(\n () => sdk.isRecognized(),\n 5000,\n new TimeoutError({\n source: 'isRecognized',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n\n return isRecognizedPromise\n .then(response => {\n if (response.recognized) resolve(response);\n })\n .catch(error => {\n reject(error);\n });\n });\n\n // If the 'resolve' didn't happen until this point, then shopper is not recognized\n void Promise.allSettled(promises).then(() => {\n resolve({ recognized: false });\n });\n });\n }\n\n private initiateSdks(): Promise<void[]> {\n const initPromises = this.sdks.map(sdk => {\n const cfg = this.schemesConfig[sdk.schemeName];\n\n return executeWithTimeout<void>(\n () => sdk.init(cfg, this.srciTransactionId),\n 5000,\n new TimeoutError({\n source: 'init',\n scheme: sdk.schemeName,\n isTimeoutTriggeredBySchemeSdk: false\n })\n );\n });\n\n return Promise.all(initPromises);\n }\n}\n\nexport default ClickToPayService;\n"],"names":["CtpState","ClickToPayService","shopperAccountFound","includes","this","state","schemes","sdkLoader","updateStoreCookiesConsent","shouldStore","storeCookies","initialize","setState","sdks","load","environment","analytics","initiateSdks","recognized","idTokens","verifyIfShopperIsRecognized","getShopperProfile","shopperIdentity","isEnrolled","verifyIfShopperIsEnrolled","error","SrciError","reason","TimeoutError","handleTimeout","console","warn","toString","subscribeOnStateChange","callback","stateSubscriber","startIdentityValidation","validationSchemeSdk","Error","maskedValidationChannel","initiateIdentityValidation","identityValidationData","maskedShopperContact","replace","selectedNetwork","SchemeNames","schemeName","finishIdentityValidation","otpCode","validationToken","completeIdentityValidation","idToken","checkout","card","checkoutSdk","find","sdk","scheme","checkoutResponse","srcDigitalCardId","srcCorrelationId","isDcfPopupEmbedded","windowRef","window","frames","CTP_IFRAME_NAME","complianceSettings","complianceResources","complianceType","uri","dcfActionCode","AdyenCheckoutError","createCheckoutPayloadBasedOnScheme","logout","logoutPromises","map","unbindAppInstance","Promise","all","shopperCards","shopperEmail","resolve","reject","lookupPromises","executeWithTimeout","identityLookup","identityValue","type","source","isTimeoutTriggeredBySchemeSdk","then","response","consumerPresent","setSdkForPerformingShopperIdentityValidation","catch","allSettled","timeoutError","setCorrelationId","VISA_SDK","correlationId","buildClientProfile","schemesConfig","visa","srciDpaId","onTimeout","srcProfilesPromises","getSrcProfile","srcProfilesResponses","every","isRejected","profilesWithScheme","promiseResult","index","isFulfilled","value","filter","profile","createShopperCardsList","promises","isRecognized","initPromises","cfg","init","srciTransactionId","constructor","_define_property","uuidv4"],"mappings":"wlBAuBO,IAAAA,EAAKA,SAAAA,GAAAA,mLAAAA,CAQX,CARWA,CAQX,CAAA,GAED,MAAMC,EA2CF,uBAAWC,GACP,MAAO,8BAA6CC,SAASC,KAAKC,MACtE,CAEA,WAAWC,GACP,OAAOF,KAAKG,UAAUD,OAC1B,CAEOE,yBAAAA,CAA0BC,GAC7BL,KAAKM,aAAeD,CACxB,CAEA,gBAAaE,GACTP,KAAKQ,SAAQ,WAEb,IACIR,KAAKS,WAAaT,KAAKG,UAAUO,KAAKV,KAAKW,YAAaX,KAAKY,iBACvDZ,KAAKa,eAEX,MAAMC,WAAEA,G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B,WAAWuB,GAAU5B,KAAK,KACnCT,EAAQ,CAAE/D,YAAY,OAGlC,CAEQD,YAAAA,GACJ,MAAMuG,EAAepH,KAAKS,KAAK8D,IAAInB,IAC/B,MAAMiE,EAAMrH,KAAKiG,cAAc7C,EAAIV,YAEnC,OAAOsC,EACH,IAAM5B,EAAIkE,KAAKD,EAAKrH,KAAKuH,mBACzB,IACA,IAAI/F,EAAa,CACb4D,OAAQ,OACR/B,OAAQD,EAAIV,WACZ2C,+BAA+B,OAK3C,OAAOZ,QAAQC,IAAI0C,EACvB,CAhTA,WAAAI,CACIvB,EACA9F,EACAQ,EACAC,EACAM,EACAkF,GAhCJqB,EAAAzH,KAAiBG,oBACjBsH,EAAAzH,KAAiBiG,wBACjBwB,EAAAzH,KAAiBkB,0BACjBuG,EAAAzH,KAAiBW,sBACjB8G,EAAAzH,KAAiBY,oBAEjB6G,EAAAzH,KAAiBoG,oBAKjBqB,OAAiBF,oBAA4BG,KAE7CD,EAAAzH,KAAQS,eACRgH,EAAAzH,KAAQiC,sBAAqC,MAC7CwF,EAAAzH,KAAQ+B,0BAER0F,EAAAzH,KAAOC,QAAAA,QACPwH,EAAAzH,KAAO2E,eAA8B,MACrC8C,EAAAzH,KAAOqC,yBAAiD,MAKxDoF,OAAOnH,gBAAe,GAUlBN,KAAKG,UAAYA,EACjBH,KAAKiG,cAAgBA,EACrBjG,KAAKkB,gBAAkBA,EACvBlB,KAAKW,YAAcA,EACnBX,KAAKoG,UAAYA,EACjBpG,KAAKY,UAAYA,CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSrcInitiator.js","sources":["../../../../../../../src/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.ts"],"sourcesContent":["import {\n CustomSdkConfiguration,\n SrcCheckoutParams,\n SrciCheckoutResponse,\n SrciCompleteIdentityValidationResponse,\n SrcIdentityLookupParams,\n SrciIdentityLookupResponse,\n SrciInitiateIdentityValidationResponse,\n SrciIsRecognizedResponse,\n SrcInitParams,\n SrcProfile\n} from './types';\nimport SrciError, { MastercardError, VisaError } from './SrciError';\nimport { ClickToPayScheme } from '../../types';\nimport Script from '../../../../../utils/Script';\nimport { IAnalytics } from '../../../../../core/Analytics/Analytics';\n\nexport interface ISrcInitiator {\n schemeName: ClickToPayScheme;\n // Loading 3rd party library\n loadSdkScript(): Promise<void>;\n removeSdkScript(): void;\n // SRCi specification methods\n init(params: SrcInitParams, srciTransactionId: string): Promise<void>;\n isRecognized(): Promise<SrciIsRecognizedResponse>;\n identityLookup(params: SrcIdentityLookupParams): Promise<SrciIdentityLookupResponse>;\n initiateIdentityValidation(): Promise<SrciInitiateIdentityValidationResponse>;\n completeIdentityValidation(validationData: string): Promise<SrciCompleteIdentityValidationResponse>;\n getSrcProfile(idTokens: string[]): Promise<SrcProfile>;\n checkout(params: SrcCheckoutParams): Promise<SrciCheckoutResponse>;\n unbindAppInstance(): Promise<void>;\n}\n\nexport default abstract class AbstractSrcInitiator implements ISrcInitiator {\n public schemeSdk: any;\n public abstract readonly schemeName: ClickToPayScheme;\n\n protected readonly customSdkConfiguration: CustomSdkConfiguration;\n\n private readonly analytics: IAnalytics;\n private readonly sdkUrl: string;\n private scriptElement: Script | null = null;\n\n protected constructor(sdkUrl: string, customSdkConfiguration: CustomSdkConfiguration, analytics: IAnalytics) {\n if (!sdkUrl) throw Error('AbstractSrcInitiator: Invalid SDK URL');\n\n this.sdkUrl = sdkUrl;\n this.customSdkConfiguration = customSdkConfiguration;\n this.analytics = analytics;\n }\n\n public async loadSdkScript(): Promise<void> {\n if (!this.isSdkIsAvailableOnWindow()) {\n this.scriptElement = new Script({\n src: this.sdkUrl,\n component: 'clicktopay',\n analytics: this.analytics\n });\n\n await this.scriptElement.load();\n }\n this.assignSdkReference();\n }\n\n public removeSdkScript(): void {\n this.scriptElement.remove();\n }\n\n /**\n * Verifies if SDK is already loaded on the window object.\n * Example: Merchant can preload the SDK to speed up the loading time\n */\n protected abstract isSdkIsAvailableOnWindow(): boolean;\n\n /**\n * Assign SchemeSDK object to 'schemeSdk' property.\n * Each scheme creates its own object reference on 'window' using different naming,\n * therefore this method should be implemented by the subclass to assign the property\n * accordingly\n */\n protected abstract assignSdkReference(): void;\n\n /**\n * Initializes the app with common state. The init method must be called before any other methods.\n */\n public abstract init(params: SrcInitParams, srciTransactionId: string): Promise<void>;\n\n /**\n * This method performs checkout using the specified card. If successful, the\n * response contains summary checkout information.\n */\n public async checkout(params: SrcCheckoutParams): Promise<SrciCheckoutResponse> {\n try {\n const checkoutResponse = await this.schemeSdk.checkout(params);\n return checkoutResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'checkout', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * This method disassociates the Consumer application / Consumer Device from the Consumer’s SRC Profile.\n */\n public async unbindAppInstance(): Promise<void> {\n try {\n await this.schemeSdk.unbindAppInstance();\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'unbindAppInstance', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Determines whether the consumer is recognized, e.g. by detecting the presence of a local cookie in\n * the browser environment.\n */\n public async isRecognized(): Promise<SrciIsRecognizedResponse> {\n try {\n const isRecognizedResponse = await this.schemeSdk.isRecognized();\n return isRecognizedResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'isRecognized', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Sends a validation code to the specified consumer.\n * This method sends a one-time password (OTP) to the consumer to start validation\n */\n public async initiateIdentityValidation(): Promise<SrciInitiateIdentityValidationResponse> {\n try {\n const identityValidationResponse = await this.schemeSdk.initiateIdentityValidation();\n return identityValidationResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'initiateIdentityValidation', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Obtains the masked card and other account profile data associated with the userId.\n */\n public async getSrcProfile(idTokens: string[]): Promise<SrcProfile> {\n try {\n const getSrcProfileResponse = await this.schemeSdk.getSrcProfile({ idTokens });\n return getSrcProfileResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'getSrcProfile', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Obtains the user account associated with the consumer’s identity (an email address or phone\n * number).\n */\n public abstract identityLookup(params: SrcIdentityLookupParams): Promise<SrciIdentityLookupResponse>;\n\n /**\n * This method completes the identity validation by receiving the one-time password (OTP) sent to the\n * consumer to start validation.\n */\n public abstract completeIdentityValidation(otp: string): Promise<SrciCompleteIdentityValidationResponse>;\n}\n"],"names":["AbstractSrcInitiator","loadSdkScript","this","isSdkIsAvailableOnWindow","scriptElement","Script","src","sdkUrl","component","analytics","load","assignSdkReference","removeSdkScript","remove","checkout","params","schemeSdk","error","SrciError","schemeName","unbindAppInstance","isRecognized","initiateIdentityValidation","getSrcProfile","idTokens","constructor","customSdkConfiguration","_define_property","Error"],"mappings":"oMAiCe,MAAeA,EAkB1B,mBAAaC,GACJC,KAAKC,6BACND,KAAKE,cAAgB,IAAIC,EAAO,CAC5BC,IAAKJ,KAAKK,OACVC,UAAW,aACXC,UAAWP,KAAKO,kBAGdP,KAAKE,cAAcM,QAE7BR,KAAKS,oBACT,CAEOC,eAAAA,GACHV,KAAKE,cAAcS,QACvB,CAyBA,cAAaC,CAASC,GAClB,IAEI,aAD+Bb,KAAKc,UAAUF,SAASC,EAE3D,CAAE,MAAOE,GAEL,MADkB,IAAIC,EAAUD,EAAsC,WAAYf,KAAKiB,WAE3F,CACJ,CAKA,uBAAaC,GACT,UACUlB,KAAKc,UAAUI,mBACzB,CAAE,MAAOH,GAEL,MADkB,IAAIC,EAAUD,EAAsC,oBAAqBf,KAAKiB,WAEpG,CACJ,CAMA,kBAAaE,GACT,IAEI,aADmCnB,KAAKc,UAAUK,cAEtD,CAAE,MAAOJ,GAEL,MADkB,IAAIC,EAAUD,EAAsC,eAAgBf,KAAKiB,WAE/F,CACJ,CAMA,gCAAaG,GACT,IAEI,aADyCpB,KAAKc,UAAUM,4BAE5D,CAAE,MAAOL,GAEL,MADkB,IAAIC,EAAUD,EAAsC,6BAA8Bf,KAAKiB,WAE7G,CACJ,CAKA,mBAAaI,CAAcC,GACvB,IAEI,aADoCtB,KAAKc,UAAUO,cAAc,CAAEC,YAEvE,CAAE,MAAOP,GAEL,MADkB,IAAIC,EAAUD,EAAsC,gBAAiBf,KAAKiB,WAEhG,CACJ,CA7GA,WAAAM,CAAsBlB,EAAgBmB,EAAgDjB,GAClF,GAVJkB,EAAAzB,KAAOc,
|
|
1
|
+
{"version":3,"file":"AbstractSrcInitiator.js","sources":["../../../../../../../src/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.ts"],"sourcesContent":["import {\n CustomSdkConfiguration,\n SrcCheckoutParams,\n SrciCheckoutResponse,\n SrciCompleteIdentityValidationResponse,\n SrcIdentityLookupParams,\n SrciIdentityLookupResponse,\n SrciInitiateIdentityValidationResponse,\n SrciIsRecognizedResponse,\n SrcInitParams,\n SrcProfile\n} from './types';\nimport SrciError, { MastercardError, VisaError } from './SrciError';\nimport { ClickToPayScheme } from '../../types';\nimport Script from '../../../../../utils/Script';\nimport { IAnalytics } from '../../../../../core/Analytics/Analytics';\n\nexport interface ISrcInitiator {\n schemeName: ClickToPayScheme;\n // Loading 3rd party library\n loadSdkScript(): Promise<void>;\n removeSdkScript(): void;\n // SRCi specification methods\n init(params: SrcInitParams, srciTransactionId: string): Promise<void>;\n isRecognized(): Promise<SrciIsRecognizedResponse>;\n identityLookup(params: SrcIdentityLookupParams): Promise<SrciIdentityLookupResponse>;\n initiateIdentityValidation(): Promise<SrciInitiateIdentityValidationResponse>;\n completeIdentityValidation(validationData: string): Promise<SrciCompleteIdentityValidationResponse>;\n getSrcProfile(idTokens: string[]): Promise<SrcProfile>;\n checkout(params: SrcCheckoutParams): Promise<SrciCheckoutResponse>;\n unbindAppInstance(): Promise<void>;\n}\n\nexport default abstract class AbstractSrcInitiator implements ISrcInitiator {\n public schemeSdk: any;\n public abstract readonly schemeName: ClickToPayScheme;\n\n protected readonly customSdkConfiguration: CustomSdkConfiguration;\n\n private readonly analytics: IAnalytics;\n private readonly sdkUrl: string;\n private scriptElement: Script | null = null;\n\n protected constructor(sdkUrl: string, customSdkConfiguration: CustomSdkConfiguration, analytics: IAnalytics) {\n if (!sdkUrl) throw Error('AbstractSrcInitiator: Invalid SDK URL');\n\n this.sdkUrl = sdkUrl;\n this.customSdkConfiguration = customSdkConfiguration;\n this.analytics = analytics;\n }\n\n public async loadSdkScript(): Promise<void> {\n if (!this.isSdkIsAvailableOnWindow()) {\n this.scriptElement = new Script({\n src: this.sdkUrl,\n component: 'clicktopay',\n analytics: this.analytics\n });\n\n await this.scriptElement.load();\n }\n this.assignSdkReference();\n }\n\n public removeSdkScript(): void {\n this.scriptElement.remove();\n }\n\n /**\n * Verifies if SDK is already loaded on the window object.\n * Example: Merchant can preload the SDK to speed up the loading time\n */\n protected abstract isSdkIsAvailableOnWindow(): boolean;\n\n /**\n * Assign SchemeSDK object to 'schemeSdk' property.\n * Each scheme creates its own object reference on 'window' using different naming,\n * therefore this method should be implemented by the subclass to assign the property\n * accordingly\n */\n protected abstract assignSdkReference(): void;\n\n /**\n * Initializes the app with common state. The init method must be called before any other methods.\n */\n public abstract init(params: SrcInitParams, srciTransactionId: string): Promise<void>;\n\n /**\n * This method performs checkout using the specified card. If successful, the\n * response contains summary checkout information.\n */\n public async checkout(params: SrcCheckoutParams): Promise<SrciCheckoutResponse> {\n try {\n const checkoutResponse = await this.schemeSdk.checkout(params);\n return checkoutResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'checkout', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * This method disassociates the Consumer application / Consumer Device from the Consumer’s SRC Profile.\n */\n public async unbindAppInstance(): Promise<void> {\n try {\n await this.schemeSdk.unbindAppInstance();\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'unbindAppInstance', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Determines whether the consumer is recognized, e.g. by detecting the presence of a local cookie in\n * the browser environment.\n */\n public async isRecognized(): Promise<SrciIsRecognizedResponse> {\n try {\n const isRecognizedResponse = await this.schemeSdk.isRecognized();\n return isRecognizedResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'isRecognized', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Sends a validation code to the specified consumer.\n * This method sends a one-time password (OTP) to the consumer to start validation\n */\n public async initiateIdentityValidation(): Promise<SrciInitiateIdentityValidationResponse> {\n try {\n const identityValidationResponse = await this.schemeSdk.initiateIdentityValidation();\n return identityValidationResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'initiateIdentityValidation', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Obtains the masked card and other account profile data associated with the userId.\n */\n public async getSrcProfile(idTokens: string[]): Promise<SrcProfile> {\n try {\n const getSrcProfileResponse = await this.schemeSdk.getSrcProfile({ idTokens });\n return getSrcProfileResponse;\n } catch (error) {\n const srciError = new SrciError(error as VisaError | MastercardError, 'getSrcProfile', this.schemeName);\n throw srciError;\n }\n }\n\n /**\n * Obtains the user account associated with the consumer’s identity (an email address or phone\n * number).\n */\n public abstract identityLookup(params: SrcIdentityLookupParams): Promise<SrciIdentityLookupResponse>;\n\n /**\n * This method completes the identity validation by receiving the one-time password (OTP) sent to the\n * consumer to start validation.\n */\n public abstract completeIdentityValidation(otp: string): Promise<SrciCompleteIdentityValidationResponse>;\n}\n"],"names":["AbstractSrcInitiator","loadSdkScript","this","isSdkIsAvailableOnWindow","scriptElement","Script","src","sdkUrl","component","analytics","load","assignSdkReference","removeSdkScript","remove","checkout","params","schemeSdk","error","SrciError","schemeName","unbindAppInstance","isRecognized","initiateIdentityValidation","getSrcProfile","idTokens","constructor","customSdkConfiguration","_define_property","Error"],"mappings":"oMAiCe,MAAeA,EAkB1B,mBAAaC,GACJC,KAAKC,6BACND,KAAKE,cAAgB,IAAIC,EAAO,CAC5BC,IA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