@adyen/adyen-web 6.28.0 → 6.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adyen.css +15 -14
- 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 +2688 -2566
- package/dist/es/adyen.css +15 -14
- package/dist/es/adyen.css.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 +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es/components/Econtext/Econtext.js +1 -1
- package/dist/es/components/Econtext/Econtext.js.map +1 -1
- package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
- package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js +1 -1
- package/dist/es/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/Iris/Iris.js +2 -0
- package/dist/es/components/Iris/Iris.js.map +1 -0
- package/dist/es/components/Iris/components/IrisComponent.js +2 -0
- package/dist/es/components/Iris/components/IrisComponent.js.map +1 -0
- package/dist/es/components/Iris/components/IrisComponent.module.scss.js +2 -0
- package/dist/es/components/Iris/components/IrisComponent.module.scss.js.map +1 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.js +2 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.js.map +1 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.module.scss.js +2 -0
- package/dist/es/components/Iris/components/IrisGenerateQRCode.module.scss.js.map +1 -0
- package/dist/es/components/Iris/components/IrisQrCodeInstructions.js +2 -0
- package/dist/es/components/Iris/components/IrisQrCodeInstructions.js.map +1 -0
- package/dist/es/components/Iris/constants.js +2 -0
- package/dist/es/components/Iris/constants.js.map +1 -0
- package/dist/es/components/Iris/types.js +2 -0
- package/dist/es/components/Iris/types.js.map +1 -0
- package/dist/es/components/Iris/utils.js +2 -0
- package/dist/es/components/Iris/utils.js.map +1 -0
- package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
- package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es/components/Pix/components/PixQRDetails.js +1 -1
- package/dist/es/components/Pix/components/PixQRDetails.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/constants.js +1 -1
- package/dist/es/components/UPI/constants.js.map +1 -1
- package/dist/es/components/components-name-map.js +1 -1
- package/dist/es/components/components-name-map.js.map +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es/components/index.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Countdown/index.js +1 -1
- package/dist/es/components/internal/Countdown/index.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/QRLoader/QRLoaderDetailsProvider.js.map +1 -1
- package/dist/es/components/internal/QRLoader/components/QRDetails.js +1 -1
- package/dist/es/components/internal/QRLoader/components/QRDetails.js.map +1 -1
- package/dist/es/components/internal/QRLoader/components/QRImage.js +1 -1
- package/dist/es/components/internal/QRLoader/components/QRImage.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/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +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/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js +2 -0
- package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -0
- package/dist/es/components/internal/Voucher/Voucher.js +1 -1
- package/dist/es/components/internal/Voucher/Voucher.js.map +1 -1
- package/dist/es/components/internal/Voucher/utils.js.map +1 -1
- package/dist/es/components/tx-variants.js +1 -1
- package/dist/es/components/tx-variants.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/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/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/utils.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/index.d.ts +2688 -2566
- package/dist/es/index.js +1 -1
- package/dist/es/language/Language.js.map +1 -1
- package/dist/es/utils/createSdkData.js +2 -0
- package/dist/es/utils/createSdkData.js.map +1 -0
- package/dist/es-legacy/adyen.css +15 -14
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js +1 -1
- package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js +1 -1
- package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.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 +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/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/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +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/CustomCard/CustomCard.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es-legacy/components/Dragonpay/Dragonpay.js +1 -1
- package/dist/es-legacy/components/Dragonpay/Dragonpay.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/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
- package/dist/es-legacy/components/Econtext/Econtext.js.map +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/requests.js +1 -1
- package/dist/es-legacy/components/GooglePay/requests.js.map +1 -1
- package/dist/es-legacy/components/Iris/Iris.js +2 -0
- package/dist/es-legacy/components/Iris/Iris.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.module.scss.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisComponent.module.scss.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.module.scss.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.module.scss.js.map +1 -0
- package/dist/es-legacy/components/Iris/components/IrisQrCodeInstructions.js +2 -0
- package/dist/es-legacy/components/Iris/components/IrisQrCodeInstructions.js.map +1 -0
- package/dist/es-legacy/components/Iris/constants.js +2 -0
- package/dist/es-legacy/components/Iris/constants.js.map +1 -0
- package/dist/es-legacy/components/Iris/types.js +2 -0
- package/dist/es-legacy/components/Iris/types.js.map +1 -0
- package/dist/es-legacy/components/Iris/utils.js +2 -0
- package/dist/es-legacy/components/Iris/utils.js.map +1 -0
- package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
- package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
- package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
- package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
- package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
- package/dist/es-legacy/components/Pix/components/PixQRDetails.js +1 -1
- package/dist/es-legacy/components/Pix/components/PixQRDetails.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/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.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/constants.js +1 -1
- package/dist/es-legacy/components/UPI/constants.js.map +1 -1
- package/dist/es-legacy/components/components-name-map.js +1 -1
- package/dist/es-legacy/components/components-name-map.js.map +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es-legacy/components/index.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es-legacy/components/internal/Countdown/index.js +1 -1
- package/dist/es-legacy/components/internal/Countdown/index.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.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/Select/components/SelectButton.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
- package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.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/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +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/QRLoader/QRLoaderDetailsProvider.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoaderDetailsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRDetails.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRImage.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/components/QRImage.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/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +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/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js +2 -0
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -0
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js +1 -1
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Voucher/Voucher.js +1 -1
- package/dist/es-legacy/components/internal/Voucher/Voucher.js.map +1 -1
- package/dist/es-legacy/components/internal/Voucher/utils.js.map +1 -1
- package/dist/es-legacy/components/tx-variants.js +1 -1
- package/dist/es-legacy/components/tx-variants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/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/utils.js +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Context/Resources.js +1 -1
- package/dist/es-legacy/core/Context/Resources.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.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/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
- package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
- package/dist/es-legacy/index.js +1 -1
- package/dist/es-legacy/language/Language.js.map +1 -1
- package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
- package/dist/es-legacy/utils/commonUtils.js.map +1 -1
- package/dist/es-legacy/utils/createSdkData.js +2 -0
- package/dist/es-legacy/utils/createSdkData.js.map +1 -0
- package/dist/es-legacy/utils/useForm/reducer.js +1 -1
- package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
- package/package.json +12 -12
- package/styles/adyen.css +15 -14
- package/dist/es/components/UPI/components/VpaInput/VpaInput.js +0 -2
- package/dist/es/components/UPI/components/VpaInput/VpaInput.js.map +0 -1
- package/dist/es/components/UPI/components/VpaInput/validate.js +0 -2
- package/dist/es/components/UPI/components/VpaInput/validate.js.map +0 -1
- package/dist/es-legacy/components/UPI/components/VpaInput/VpaInput.js +0 -2
- package/dist/es-legacy/components/UPI/components/VpaInput/VpaInput.js.map +0 -1
- package/dist/es-legacy/components/UPI/components/VpaInput/validate.js +0 -2
- package/dist/es-legacy/components/UPI/components/VpaInput/validate.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import n from"../internal/PayButton/PayButton.js";import o from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as
|
|
1
|
+
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import n from"../internal/PayButton/PayButton.js";import o from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as i}from"../tx-variants.js";function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){s(e,t,r[t])})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}class p extends t{formatProps(e){return a({},null==e?void 0:e.configuration,e)}formatData(){var e,t;return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:null===(e=this.state.data)||void 0===e?void 0:e.encryptedCardNumber,encryptedSecurityCode:null===(t=this.state.data)||void 0===t?void 0:t.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){var e;return(null===(e=this.props.brandsConfiguration[this.props.brand])||void 0===e?void 0:e.icon)||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){var e;return(null===(e=this.props.brandsConfiguration[this.props.brand])||void 0===e?void 0:e.name)||this.props.name}setBalanceCheckError(e){var t,r;null===(r=this.componentRef)||void 0===r||null===(t=r.setBalanceCheckErrors)||void 0===t||t.call(r,e)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return e(r,c(a({ref:e=>{this.componentRef=e}},this.props),{handleKeyPress:this.handleKeyPress,showPayButton:this.props.showPayButton,onChange:this.setState,makeBalanceCheck:()=>this.onBalanceCheck(),makePayment:()=>this.makeSubmitCall(),payButton:this.payButton,onSubmitAnalytics:this.submitAnalytics}))}constructor(...t){super(...t),s(this,"componentRef",void 0),s(this,"handleBalanceCheck",e=>this.props.onBalanceCheck?new Promise((t,r)=>{this.props.onBalanceCheck(t,r,e)}):this.props.session?this.props.session.checkBalance(e):void 0),s(this,"onOrderRequest",e=>this.props.onOrderRequest?new Promise((t,r)=>{this.props.onOrderRequest(t,r,e)}):this.props.session?this.props.session.createOrder():void 0),s(this,"onBalanceCheck",()=>{if(!this.isValid)return void this.showValidation();if(!(this.props.session||this.props.onBalanceCheck))return super.submit();this.setStatus("loading"),this.handleBalanceCheck(this.formatData()).then(({balance:e,transactionLimit:t={}})=>{var r;if(this.setBalanceCheckError(null),!e)throw new Error("card-error");if((null==e?void 0:e.currency)!==(null===(r=this.props.amount)||void 0===r?void 0:r.currency))throw new Error("currency-error");if((null==e?void 0:e.value)<=0)throw new Error("no-balance");return this.props.amount.value>e.value||this.props.amount.value>t.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(e=>(this.setState({order:{orderData:e.orderData,pspReference:e.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(e,t)}).catch(e=>{this.setBalanceCheckError(null==e?void 0:e.message),e instanceof o?this.handleError(e):this.handleError(new o("ERROR",e))})}),s(this,"handleOnRequiringConfirmation",(e,t)=>{if(this.componentRef.setBalance({balance:e,transactionLimit:t}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new o("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((e,t)=>{this.props.onRequiringConfirmation(e,t)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),s(this,"payButton",t=>e(n,t))}}s(p,"type",i.giftcard),s(p,"defaultProps",{brandsConfiguration:{}});export{p as GiftcardElement,p as default};
|
|
2
2
|
//# sourceMappingURL=Giftcard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static type = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance, transactionLimit): Promise<any> => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n public payButton = props => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","_object_spread","configuration","formatData","_this_state_data","_this_state_data1","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","_this_props_brandsConfiguration_this_props_brand","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","_this_componentRef_setBalanceCheckErrors","_this_componentRef","componentRef","setBalanceCheckErrors","call","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","_this_props_amount","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"snCASO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,OAAOC,EAAA,CAAA,EACAD,aAAAA,EAAAA,EAAOE,cACPF,EAEX,CAEAG,UAAAA,OAKiCC,EACEC,EAL/B,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKR,MAAMU,MAClBC,oBAAoC,QAAfP,EAAAI,KAAKI,MAAMC,YAAX,IAAAT,OAAA,EAAAA,EAAiBO,oBACtCG,sBAAsC,QAAfT,EAAAG,KAAKI,MAAMC,YAAX,IAAAR,OAAA,EAAAA,EAAiBS,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,MAAMG,OACxB,CAEA,QAAIC,GACO,IAAAC,EAAP,eAAOA,EAAAT,KAAKR,MAAMkB,oBAAoBV,KAAKR,MAAMU,cAA1C,IAAAO,OAAA,EAAAA,EAAkDD,OAAQR,KAAKR,MAAMgB,MAAQR,KAAKW,UAAUC,UAAfZ,CAA0BA,KAAKR,MAAMU,MAC7H,CAEA,eAAIW,GACO,IAAAJ,EAAP,OAAuD,QAAhDA,EAAAT,KAAKR,MAAMkB,oBAAoBV,KAAKR,MAAMU,cAA1C,IAAAO,OAAA,EAAAA,EAAkDK,OAAQd,KA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AAOuE,EAAWC,UAIhChC,EALSlD,EAKQmF,eAAe,CAC5B9D,oBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"Giftcard.js","sources":["../../../../src/components/Giftcard/Giftcard.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GiftcardComponent from './components/GiftcardComponent';\nimport PayButton from '../internal/PayButton';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { PaymentAmount } from '../../types/global-types';\nimport { GiftCardElementData, GiftCardConfiguration, balanceCheckResponseType, GiftCardBalanceCheckErrorType } from './types';\nimport { TxVariants } from '../tx-variants';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static type = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static defaultProps = {\n brandsConfiguration: {}\n };\n\n formatProps(props) {\n return {\n ...props?.configuration,\n ...props\n };\n }\n\n formatData(): GiftCardElementData {\n return {\n paymentMethod: {\n type: this.constructor['type'],\n brand: this.props.brand,\n encryptedCardNumber: this.state.data?.encryptedCardNumber,\n encryptedSecurityCode: this.state.data?.encryptedSecurityCode\n }\n };\n }\n\n get isValid() {\n return !!this.state.isValid;\n }\n\n get icon() {\n return this.props.brandsConfiguration[this.props.brand]?.icon || this.props.icon || this.resources.getImage()(this.props.brand);\n }\n\n get displayName() {\n return this.props.brandsConfiguration[this.props.brand]?.name || this.props.name;\n }\n\n private setBalanceCheckError(errorMessage: GiftCardBalanceCheckErrorType | null): void {\n this.componentRef?.setBalanceCheckErrors?.(errorMessage);\n }\n\n private handleBalanceCheck = (data: GiftCardElementData): Promise<balanceCheckResponseType> => {\n if (this.props.onBalanceCheck) {\n return new Promise((resolve, reject) => {\n void this.props.onBalanceCheck(resolve, reject, data);\n });\n }\n\n if (this.props.session) {\n return this.props.session.checkBalance(data);\n }\n };\n\n private onOrderRequest = data => {\n if (this.props.onOrderRequest)\n return new Promise((resolve, reject) => {\n void this.props.onOrderRequest(resolve, reject, data);\n });\n if (this.props.session) {\n return this.props.session.createOrder();\n }\n };\n\n public balanceCheck() {\n return this.onBalanceCheck();\n }\n\n private onBalanceCheck = (): void => {\n if (!this.isValid) {\n this.showValidation();\n return;\n }\n\n // skip balance check if no onBalanceCheck event has been defined\n const hasBalanceCheck = this.props.session || this.props.onBalanceCheck;\n if (!hasBalanceCheck) return super.submit();\n\n this.setStatus('loading');\n\n this.handleBalanceCheck(this.formatData())\n .then(({ balance, transactionLimit = {} as PaymentAmount }) => {\n // Clear any previous balance check errors on success\n this.setBalanceCheckError(null);\n\n // We still need to throw these errors, otherwise it would be a breaking changing\n if (!balance) throw new Error('card-error'); // card doesn't exist\n if (balance?.currency !== this.props.amount?.currency) throw new Error('currency-error');\n if (balance?.value <= 0) throw new Error('no-balance');\n\n if (this.props.amount.value > balance.value || this.props.amount.value > transactionLimit.value) {\n if (this.props.order) {\n return this.makeSubmitCall();\n }\n\n return this.onOrderRequest(this.data).then((order: { orderData: string; pspReference: string }) => {\n this.setState({ order: { orderData: order.orderData, pspReference: order.pspReference } });\n return this.makeSubmitCall();\n });\n } else {\n return this.handleOnRequiringConfirmation(balance, transactionLimit);\n }\n })\n .catch(error => {\n // Simply pass the raw error message to setBalanceCheckError\n this.setBalanceCheckError(error?.message);\n\n // Still call handleError for other side effects (analytics, onError callback)\n if (error instanceof AdyenCheckoutError) {\n this.handleError(error);\n } else {\n this.handleError(new AdyenCheckoutError('ERROR', error));\n }\n });\n };\n\n /**\n * Check if it should call onRequiringConfirmation\n */\n private handleOnRequiringConfirmation = (balance, transactionLimit): Promise<any> => {\n this.componentRef.setBalance({ balance, transactionLimit });\n this.setStatus('ready');\n\n // 1. if we show pay button we don't need to ask for confirmation\n if (this.props.showPayButton) {\n return;\n }\n // 2. there's no callback, we throw error\n if (!this.props.onRequiringConfirmation) {\n throw new AdyenCheckoutError('IMPLEMENTATION_ERROR', 'onRequiringConfirmation must be provided');\n }\n // 3. success case if in case of custom pay button\n return (\n new Promise<void>((resolve, reject) => {\n void this.props.onRequiringConfirmation(resolve, reject);\n })\n //when this resolve passed to onRequiringConfirmation gets resolved make payments call\n .then(() => this.makeSubmitCall())\n //when it gets rejected handle cancellation\n .catch(() => {})\n );\n };\n\n public submit() {\n // for simplicity of the merchant we always only expose .submit()\n // however to make the actual payment call we call makeSubmitCall\n this.balanceCheck();\n }\n\n // this makes the payment, as .submit is used by the merchant to trigger the payButton action\n private makeSubmitCall() {\n super.submit();\n }\n\n // Giftcards override the regular payButton flow\n public payButton = props => {\n return <PayButton {...props} />;\n };\n\n protected override componentToRender(): h.JSX.Element {\n return (\n <GiftcardComponent\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n handleKeyPress={this.handleKeyPress}\n showPayButton={this.props.showPayButton}\n onChange={this.setState}\n makeBalanceCheck={() => this.onBalanceCheck()}\n makePayment={() => this.makeSubmitCall()}\n payButton={this.payButton}\n onSubmitAnalytics={this.submitAnalytics}\n />\n );\n }\n}\n\nexport default GiftcardElement;\n"],"names":["GiftcardElement","UIElement","formatProps","props","_object_spread","configuration","formatData","_this_state_data","_this_state_data1","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","_this_props_brandsConfiguration_this_props_brand","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","_this_componentRef_setBalanceCheckErrors","_this_componentRef","componentRef","setBalanceCheckErrors","call","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyPress","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","_this_props_amount","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"sn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MAClF3D,KAAKR,MAAMoE,MACJ5D,KAAKyB,iBAGTzB,KAAKgD,eAAehD,KAAKK,MAAM+C,KAAMQ,IACxC5D,KAAKkC,SAAS,CAAE0B,MAAO,CAAEC,UAAWD,EAAMC,UAAWC,aAAcF,EAAME,gBAClE9D,KAAKyB,mBAGTzB,KAAK+D,8BAA8BV,EAASC,KAG1DU,MAAMC,IAEHjE,KAAKe,qBAAqBkD,aAAAA,EAAAA,EAAOC,SAG7BD,aAAiBE,EACjBnE,KAAKoE,YAAYH,GAEjBjE,KAAKoE,YAAY,IAAID,EAAmB,QAASF,QAQjExB,EAAAzC,KAAQ+D,gCAAgC,CAACV,EAASC,KAK9C,GAJAtD,KAAKmB,aAAakD,WAAW,CAAEhB,UAASC,qBACxCtD,KAAKmD,UAAU,UAGXnD,KAAKR,MAAMwC,cAAf,CAIA,IAAKhC,KAAKR,MAAM8E,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIxB,QAAc,CAACC,EAASC,KACnB7C,KAAKR,MAAM8E,wBAAwB1B,EAASC,KAGhDO,KAAK,IAAMpD,KAAKyB,kBAEhBuC,MAAM,OAbf,IA6BJvB,EAAAzC,KAAOqC,YAAY7C,GACRoC,EAAC2C,EAAc/E,KA5J1BiD,EADSpD,EACKU,OAAOyE,EAAWC,UAIhChC,EALSpD,EAKQqF,eAAe,CAC5BhE,oBAAqB,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import s from"../../internal/Alert/Alert.js";import o from"./GiftcardResult.js";import{useCoreContext as a}from"../../../core/Context/CoreProvider.js";import{GIFT_CARD as n}from"../../internal/SecuredFields/lib/constants.js";import{GiftCardFields as i}from"./GiftcardFields.js";import{useSRPanelForGiftcardErrors as c}from"./useSRPanelForGiftcardErrors.js";function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},s=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),s.forEach(function(e){l(t,e,r[e])})}return t}function p(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}class d extends t{generateBalanceCheckErrors(t){const e={};return null===t||(e.encryptedCardNumber={isValid:!1,errorMessage:`error.giftcard.${t}`,error:t}),e}isBalanceCheckError(t){return["no-balance","card-error","currency-error"].includes(t)}render(t,{focusedElement:i,balance:l,transactionLimit:d,isValidating:h,transformedErrors:
|
|
1
|
+
import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import s from"../../internal/Alert/Alert.js";import o from"./GiftcardResult.js";import{useCoreContext as a}from"../../../core/Context/CoreProvider.js";import{GIFT_CARD as n}from"../../internal/SecuredFields/lib/constants.js";import{GiftCardFields as i}from"./GiftcardFields.js";import{useSRPanelForGiftcardErrors as c}from"./useSRPanelForGiftcardErrors.js";function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},s=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),s.forEach(function(e){l(t,e,r[e])})}return t}function p(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}class d extends t{generateBalanceCheckErrors(t){const e={};return null===t||(e.encryptedCardNumber={isValid:!1,errorMessage:`error.giftcard.${t}`,error:t}),e}isBalanceCheckError(t){return["no-balance","card-error","currency-error"].includes(t)}render(t,{focusedElement:i,balance:l,transactionLimit:d,isValidating:h,transformedErrors:m}){var f;const{i18n:y}=a();c({errors:m,isValidating:h,sfp:this.sfp});const b=(null==d?void 0:d.value)<(null==l?void 0:l.value)?d:l,g=(null==b?void 0:b.value)>=(null===(f=this.props.amount)||void 0===f?void 0:f.value);if(b&&g)return e(o,{amount:this.props.amount,balance:l,transactionLimit:d,makePayment:t.makePayment,status:this.state.status,makeBalanceCheck:t.makeBalanceCheck,showPayButton:this.props.showPayButton,payButton:this.props.payButton});const O=t=>t.errors.encryptedCardNumber?y.get(t.errors.encryptedCardNumber):m.encryptedCardNumber?y.get(m.encryptedCardNumber.errorMessage):null;return e("div",{className:"adyen-checkout__giftcard"},"error"===this.state.status&&e(s,{icon:"cross"},y.get("error.message.unknown")),e(r,p(u({},this.props),{ref:t=>{this.sfp=t},onChange:this.onChange,onFocus:this.handleFocus,onSubmitAnalytics:t.onSubmitAnalytics,type:n,componentType:t.type,render:({setRootNode:t,setFocusOn:e},r)=>this.props.fieldsLayoutComponent({i18n:y,pinRequired:this.props.pinRequired,focusedElement:i,getCardErrorMessage:O,setRootNode:t,setFocusOn:e,sfpState:r})})),this.props.showPayButton&&this.props.payButton({status:this.state.status,onClick:this.props.makeBalanceCheck,label:y.get("applyGiftcard")}))}constructor(...t){super(...t),l(this,"state",{status:"ready",data:{},balance:null,transactionLimit:null,focusedElement:!1,isValid:!1,sfpState:{},isValidating:!1,transformedErrors:{}}),l(this,"sfp",void 0),l(this,"mapErrorsToValidationObjects",()=>this.sfp?this.sfp.mapErrorsToValidationRuleResult():{}),l(this,"updateTransformedErrors",t=>{const e=u({},this.mapErrorsToValidationObjects(),t);this.setState({transformedErrors:e})}),l(this,"onChange",t=>{this.setState({sfpState:t},()=>this.updateTransformedErrors()),this.props.onChange({data:t.data,isValid:t.isSfpValid})}),l(this,"handleFocus",t=>{this.setState({focusedElement:t.currentFocusObject});!0===t.focus?this.props.onFocus(t):this.props.onBlur(t)}),l(this,"setBalance",({balance:t,transactionLimit:e})=>{this.setState({balance:t,transactionLimit:e})}),l(this,"setBalanceCheckErrors",t=>{if(this.isBalanceCheckError(t)){const e=this.generateBalanceCheckErrors(t);this.updateTransformedErrors(e)}}),l(this,"showValidation",()=>{var t;this.setState({isValidating:!0}),null===(t=this.sfp)||void 0===t||t.showValidation()})}}l(d,"defaultProps",{pinRequired:!0,expiryDateRequired:!1,onChange:()=>{},onFocus:()=>{},onBlur:()=>{},fieldsLayoutComponent:i});export{d as default};
|
|
2
2
|
//# sourceMappingURL=GiftcardComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PaymentAmount } from '../../../types/global-types';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType } from '../types';\n\ninterface GiftcardComponentProps {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n\n amount?: PaymentAmount;\n showPayButton: boolean;\n payButton: (config) => any;\n\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyPress?: (o: KeyboardEvent) => void;\n}\n\nclass Giftcard extends Component<GiftcardComponentProps> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, any>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, any> {\n const balanceCheckErrors: Record<string, any> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= this.props.amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n amount={this.props.amount}\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n type={GIFT_CARD}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","_this_props_amount","i18n","useCoreContext","useSRPanelForGiftcardErrors","errors","sfp","this","transactionAmount","value","hasEnoughBalance","amount","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","ref","onChange","onFocus","handleFocus","type","GIFT_CARD","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","_object_spread","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","_this_sfp","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"8yCA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA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BS,KAAK0C,SAAS,CAAEpD,UAASC,uBAsC7B4C,EAAAnC,KAAOiD,wBAAyBtE,IAE5B,GAAIqB,KAAKhB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBoB,KAAKtB,2BAA2BC,GAC3DqB,KAAKuC,wBAAwB3D,EACjC,IAGJuD,OAAOe,iBAAiB,SAIpBC,EAHAnD,KAAK0C,SAAS,CAAElD,cAAc,IAGtB,QAAR2D,EAAAnD,KAAKD,WAAL,IAAAoD,GAAAA,EAAUD,oBAtGdf,EAbE3D,EAaY4E,eAAe,CACzBtB,aAAa,EACbuB,oBAAoB,EACpB/B,SAAU,OACVC,QAAS,OACTwB,OAAQ,OACRlB,sBAAuByB"}
|
|
1
|
+
{"version":3,"file":"GiftcardComponent.js","sources":["../../../../../src/components/Giftcard/components/GiftcardComponent.tsx"],"sourcesContent":["import { Component, FunctionComponent, h } from 'preact';\nimport SecuredFieldsProvider from '../../internal/SecuredFields/SFP/SecuredFieldsProvider';\nimport Alert from '../../internal/Alert';\nimport GiftcardResult from './GiftcardResult';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PaymentAmount } from '../../../types/global-types';\nimport { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType } from '../types';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\n\ninterface GiftcardComponentProps {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n\n amount?: PaymentAmount;\n showPayButton: boolean;\n payButton: (config) => any;\n\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyPress?: (o: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<GiftcardComponentProps> {\n public state = {\n status: 'ready',\n data: {},\n balance: null,\n transactionLimit: null,\n focusedElement: false,\n isValid: false,\n sfpState: {},\n isValidating: false,\n transformedErrors: {}\n };\n\n public static defaultProps = {\n pinRequired: true,\n expiryDateRequired: false,\n onChange: () => {},\n onFocus: () => {},\n onBlur: () => {},\n fieldsLayoutComponent: GiftCardFields\n };\n\n public sfp: SecuredFieldsProvider;\n\n /**\n * Maps string error codes from SecuredFields to validation rule objects\n */\n public mapErrorsToValidationObjects = () => {\n // Use the sfp reference to call mapErrorsToValidationRuleResult\n if (!this.sfp) return {};\n return this.sfp.mapErrorsToValidationRuleResult();\n };\n\n private updateTransformedErrors = (balanceCheckErrors?: Record<string, any>) => {\n const transformedErrors = this.mapErrorsToValidationObjects();\n\n const mergedErrors = { ...transformedErrors, ...balanceCheckErrors };\n\n this.setState({ transformedErrors: mergedErrors });\n };\n\n public onChange = sfpState => {\n this.setState({ sfpState }, () => this.updateTransformedErrors());\n\n this.props.onChange({\n data: sfpState.data,\n isValid: sfpState.isSfpValid\n });\n };\n\n public handleFocus = e => {\n this.setState({ focusedElement: e.currentFocusObject });\n\n const isFocused = e.focus === true;\n if (isFocused) {\n this.props.onFocus(e);\n } else {\n this.props.onBlur(e);\n }\n };\n\n public setBalance = ({ balance, transactionLimit }) => {\n this.setState({ balance, transactionLimit });\n };\n\n /**\n * Generates balance check errors in the same format as SFP errors\n * Compatible with the transformedErrors structure\n */\n private generateBalanceCheckErrors(errorType?: GiftCardBalanceCheckErrorType | null): Record<string, any> {\n const balanceCheckErrors: Record<string, any> = {};\n\n // This is the field that the error is associated with, only used for SR logic\n const fieldToAnnounce = 'encryptedCardNumber';\n\n // If errorType is null, clear errors\n if (errorType === null) {\n return balanceCheckErrors;\n }\n\n // Create error in the same format as SFP errors for consistency\n balanceCheckErrors[fieldToAnnounce] = {\n isValid: false,\n errorMessage: `error.giftcard.${errorType}`,\n error: errorType\n };\n\n return balanceCheckErrors;\n }\n\n /**\n * Checks if a status represents a balance check error\n */\n private isBalanceCheckError(status: string): boolean {\n return ['no-balance', 'card-error', 'currency-error'].includes(status);\n }\n\n /**\n * Method called by GiftcardElement to set balance check errors only\n */\n public setBalanceCheckErrors = (errorType: GiftCardBalanceCheckErrorType | null): void => {\n // Check if the errors should be displayed\n if (this.isBalanceCheckError(errorType)) {\n // Generate balance check errors in the style of useForm\n // This is usefull because then we can use the same logic for SF and balance check errors\n // Also we can use the same logic for SRPanel errors\n const balanceCheckErrors = this.generateBalanceCheckErrors(errorType);\n this.updateTransformedErrors(balanceCheckErrors);\n }\n };\n\n public showValidation = () => {\n this.setState({ isValidating: true });\n\n // Validate SecuredFields\n this.sfp?.showValidation();\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= this.props.amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\n amount={this.props.amount}\n balance={balance}\n transactionLimit={transactionLimit}\n makePayment={props.makePayment}\n status={this.state.status}\n makeBalanceCheck={props.makeBalanceCheck}\n showPayButton={this.props.showPayButton}\n payButton={this.props.payButton}\n />\n );\n }\n\n const getCardErrorMessage = sfpState => {\n if (sfpState.errors.encryptedCardNumber) return i18n.get(sfpState.errors.encryptedCardNumber);\n\n // This logic is a bit of a hack, but it's the only way to get the error message for balance check errors\n // In the future we should move this logic to useForm\n if (transformedErrors.encryptedCardNumber) {\n return i18n.get(transformedErrors.encryptedCardNumber.errorMessage);\n }\n\n return null;\n };\n\n return (\n <div className=\"adyen-checkout__giftcard\">\n {this.state.status === 'error' && <Alert icon={'cross'}>{i18n.get('error.message.unknown')}</Alert>}\n\n <SecuredFieldsProvider\n {...this.props}\n ref={ref => {\n this.sfp = ref;\n }}\n onChange={this.onChange}\n onFocus={this.handleFocus}\n onSubmitAnalytics={props.onSubmitAnalytics}\n type={GIFT_CARD}\n componentType={props.type}\n render={({ setRootNode, setFocusOn }, sfpState) =>\n this.props.fieldsLayoutComponent({\n i18n: i18n,\n pinRequired: this.props.pinRequired,\n focusedElement: focusedElement,\n getCardErrorMessage: getCardErrorMessage,\n setRootNode: setRootNode,\n setFocusOn: setFocusOn,\n sfpState: sfpState\n })\n }\n />\n\n {this.props.showPayButton &&\n this.props.payButton({\n status: this.state.status,\n onClick: this.props.makeBalanceCheck,\n label: i18n.get('applyGiftcard')\n })}\n </div>\n );\n }\n}\n\nexport default Giftcard;\n"],"names":["Giftcard","Component","generateBalanceCheckErrors","errorType","balanceCheckErrors","isValid","errorMessage","error","isBalanceCheckError","status","includes","render","props","focusedElement","balance","transactionLimit","isValidating","transformedErrors","_this_props_amount","i18n","useCoreContext","useSRPanelForGiftcardErrors","errors","sfp","this","transactionAmount","value","hasEnoughBalance","amount","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","_object_spread","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","_this_sfp","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"8yCAiCA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA0C,CAAA,EAMhD,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAk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OmD,wBAAyBxE,IAE5B,GAAIqB,KAAKhB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBoB,KAAKtB,2BAA2BC,GAC3DqB,KAAKyC,wBAAwB7D,EACjC,IAGJyD,OAAOe,iBAAiB,SAIpBC,EAHArD,KAAK4C,SAAS,CAAEpD,cAAc,IAGtB,QAAR6D,EAAArD,KAAKD,WAAL,IAAAsD,GAAAA,EAAUD,oBAtGdf,EAbE7D,EAaY8E,eAAe,CACzBtB,aAAa,EACbuB,oBAAoB,EACpBjC,SAAU,OACVC,QAAS,OACT0B,OAAQ,OACRlB,sBAAuByB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./GooglePayService.js";import n from"./components/GooglePayButton.js";import r from"./defaultProps.js";import{getGooglePayLocale as s,formatGooglePayContactToAdyenAddressFormat as i}from"./utils.js";import a from"../../utils/browserInfo.js";import l from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as d}from"../tx-variants.js";import{sanitizeResponse as h,verifyPaymentDidNotFail as p}from"../internal/UIElement/utils.js";import{AnalyticsInfoEvent as c,InfoEventType as y,UiTarget as u}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{mapGooglePayBrands as g}from"./utils/map-adyen-brands-to-googlepay-brands.js";function m(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function P(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){m(e,t,o[t])})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}const f=["AMEX","DISCOVER","JCB","MASTERCARD","VISA"];class w extends t{getPaymentMethodFromPaymentMethodsResponse(e,t){return t?this.core.paymentMethodsResponse.findById(t):this.core.paymentMethodsResponse.find(e||this.constructor.type)||this.core.paymentMethodsResponse.find(d.paywithgoogle)}formatProps(e){var t,o;const
|
|
1
|
+
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./GooglePayService.js";import n from"./components/GooglePayButton.js";import r from"./defaultProps.js";import{getGooglePayLocale as s,formatGooglePayContactToAdyenAddressFormat as i}from"./utils.js";import a from"../../utils/browserInfo.js";import l from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as d}from"../tx-variants.js";import{sanitizeResponse as h,verifyPaymentDidNotFail as p}from"../internal/UIElement/utils.js";import{AnalyticsInfoEvent as c,InfoEventType as y,UiTarget as u}from"../../core/Analytics/events/AnalyticsInfoEvent.js";import{mapGooglePayBrands as g}from"./utils/map-adyen-brands-to-googlepay-brands.js";function m(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function P(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){m(e,t,o[t])})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}const f=["AMEX","DISCOVER","JCB","MASTERCARD","VISA"];class w extends t{getPaymentMethodFromPaymentMethodsResponse(e,t){return t?this.core.paymentMethodsResponse.findById(t):this.core.paymentMethodsResponse.find(e||this.constructor.type)||this.core.paymentMethodsResponse.find(d.paywithgoogle)}formatProps(e){var t,o,n;const r=null!==(t=e.buttonSizeMode)&&void 0!==t?t:e.isDropin?"fill":"static",i=s(null!==(o=e.buttonLocale)&&void 0!==o?o:null===(n=e.i18n)||void 0===n?void 0:n.locale),a=[...e.callbackIntents,"PAYMENT_AUTHORIZATION"],l=this.createAllowedCardNetworksValues({allowedCardNetworks:e.allowedCardNetworks,brands:e.brands});return b(P({},e),{allowedCardNetworks:l,configuration:e.configuration,buttonSizeMode:r,buttonLocale:i,callbackIntents:a})}formatData(){const{googlePayCardNetwork:e,googlePayToken:t,billingAddress:o,deliveryAddress:n}=this.state,{isExpress:r}=this.props;return P({paymentMethod:P({type:this.type,googlePayCardNetwork:e,googlePayToken:t},r&&{subtype:"express"}),browserInfo:this.browserInfo,origin:!!window&&window.location.origin},o&&{billingAddress:o},n&&{deliveryAddress:n})}createAllowedCardNetworksValues({allowedCardNetworks:e,brands:t}){return(null==e?void 0:e.length)>0?e:(null==t?void 0:t.length)>0?g(t):f}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new c(P({type:y.rendered,component:this.type,configData:b(P({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.isExpress)&&{isExpress:e.isExpress},(null==e?void 0:e.expressPage)&&{expressPage:e.expressPage}));this.analytics.sendAnalytics(t)}showGooglePayPaymentSheet(){this.googlePay.initiatePayment(this.props,this.core.options.countryCode).catch(e=>{this.handleError(new l("CANCELED"===e.statusCode?"CANCEL":"ERROR",e.toString(),{cause:e}))})}async handleAuthorization(){return new Promise((e,t)=>{this.props.onAuthorized||e();const{authorizedEvent:o,billingAddress:n,deliveryAddress:r}=this.state;this.props.onAuthorized(P({authorizedEvent:o},n&&{billingAddress:n},r&&{deliveryAddress:r}),{resolve:e,reject:t})}).catch(e=>{const t={error:{googlePayError:e}};return Promise.reject(t)})}get isValid(){return!0}async isAvailable(){return this.isReadyToPay().then(e=>{if(!e.result)throw new l("ERROR","GooglePay is not available");if(!1===e.paymentMethodPresent)throw new l("ERROR","GooglePay - No paymentMethodPresent");return Promise.resolve()}).catch(e=>Promise.reject(e))}get browserInfo(){return a()}get icon(){var e;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()("googlepay")}componentToRender(){return this.props.showPayButton?e(n,{buttonColor:this.props.buttonColor,buttonType:this.props.buttonType,buttonSizeMode:this.props.buttonSizeMode,buttonLocale:this.props.buttonLocale,buttonRootNode:this.props.buttonRootNode,buttonRadius:this.props.buttonRadius,paymentsClient:this.googlePay.paymentsClient,onClick:this.submit}):null}constructor(e,t){super(e,t),m(this,"googlePay",void 0),m(this,"submit",()=>{if(this.props.isInstantPayment){const e=new c({component:this.type,type:y.selected,target:u.instantPaymentButton});this.submitAnalytics(e)}new Promise((e,t)=>this.props.onClick(e,t)).then(this.showGooglePayPaymentSheet).catch(()=>{})}),m(this,"onPaymentAuthorized",async e=>{const t=i(e.paymentMethodData.info.billingAddress),o=i(e.shippingAddress,!0);return this.setState(P({authorizedEvent:e,googlePayToken:e.paymentMethodData.tokenizationData.token,googlePayCardNetwork:e.paymentMethodData.info.cardNetwork},t&&{billingAddress:t},o&&{deliveryAddress:o})),new Promise(e=>{this.handleAuthorization().then(this.makePaymentsCall).then(h).then(p).then(t=>(e({transactionState:"SUCCESS"}),t)).then(e=>{this.handleResponse(e)}).catch(t=>{var o;this.setElementStatus("ready");const n=null==t||null===(o=t.error)||void 0===o?void 0:o.googlePayError,r=this.props.i18n.get("error.subtitle.payment"),s="string"==typeof n?{intent:"PAYMENT_AUTHORIZATION",reason:"OTHER_ERROR",message:n||r}:{intent:(null==n?void 0:n.intent)||"PAYMENT_AUTHORIZATION",reason:(null==n?void 0:n.reason)||"OTHER_ERROR",message:(null==n?void 0:n.message)||r};e({transactionState:"ERROR",error:s});const i=b(P({},t),{error:{googlePayError:s}});this.handleFailedResult(i)})})}),m(this,"isReadyToPay",()=>this.googlePay.isReadyToPay(this.props)),m(this,"prefetch",()=>this.googlePay.prefetchPaymentData(this.props,this.core.options.countryCode)),this.handleAuthorization=this.handleAuthorization.bind(this),this.showGooglePayPaymentSheet=this.showGooglePayPaymentSheet.bind(this);const{isExpress:n,paymentDataCallbacks:r}=this.props;if(!1===n&&(null==r?void 0:r.onPaymentDataChanged))throw new l("IMPLEMENTATION_ERROR",'GooglePay - You must set "isExpress" flag to "true" in order to use "onPaymentDataChanged" callback');if(!this.props.configuration.merchantId)throw new l("IMPLEMENTATION_ERROR","GooglePay - Missing merchantId. Please ensure that it is correctly configured in your customer area.");this.googlePay=new o(this.props.environment,this.analytics,b(P({},n&&(null==r?void 0:r.onPaymentDataChanged)&&{onPaymentDataChanged:r.onPaymentDataChanged}),{onPaymentAuthorized:this.onPaymentAuthorized}))}}m(w,"type",d.googlepay),m(w,"txVariants",[d.googlepay,d.paywithgoogle]),m(w,"defaultProps",r);export{w as default};
|
|
2
2
|
//# sourceMappingURL=GooglePay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GooglePay.js","sources":["../../../../src/components/GooglePay/GooglePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GooglePayService from './GooglePayService';\nimport GooglePayButton from './components/GooglePayButton';\nimport defaultProps from './defaultProps';\nimport { formatGooglePayContactToAdyenAddressFormat, getGooglePayLocale } from './utils';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\n\nimport type { AddressData, BrowserInfo, RawPaymentMethod, PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport type { GooglePayConfiguration } from './types';\nimport type { ICore } from '../../core/types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { mapGooglePayBrands } from './utils/map-adyen-brands-to-googlepay-brands';\n\nconst DEFAULT_ALLOWED_CARD_NETWORKS: google.payments.api.CardNetwork[] = ['AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA'];\n\nclass GooglePay extends UIElement<GooglePayConfiguration> {\n public static type = TxVariants.googlepay;\n public static txVariants = [TxVariants.googlepay, TxVariants.paywithgoogle];\n public static defaultProps = defaultProps;\n\n protected readonly googlePay;\n\n constructor(checkout: ICore, props?: GooglePayConfiguration) {\n super(checkout, props);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n this.showGooglePayPaymentSheet = this.showGooglePayPaymentSheet.bind(this);\n\n const { isExpress, paymentDataCallbacks } = this.props;\n\n if (isExpress === false && paymentDataCallbacks?.onPaymentDataChanged) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - You must set \"isExpress\" flag to \"true\" in order to use \"onPaymentDataChanged\" callback'\n );\n }\n\n if (!this.props.configuration.merchantId) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - Missing merchantId. Please ensure that it is correctly configured in your customer area.'\n );\n }\n\n this.googlePay = new GooglePayService(this.props.environment, this.analytics, {\n ...(isExpress && paymentDataCallbacks?.onPaymentDataChanged && { onPaymentDataChanged: paymentDataCallbacks.onPaymentDataChanged }),\n onPaymentAuthorized: this.onPaymentAuthorized\n });\n }\n\n /**\n * Google Pay requires custom logic due to supporting two Tx variants that lead to the same payment method.\n * If the merchant creates a standalone Google Pay component, we need to verify if the payment method is available using both tx variants\n *\n * @param type\n * @param paymentMethodId - Unique internal payment method ID\n * @returns\n */\n protected override getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n\n return (\n this.core.paymentMethodsResponse.find(type || this.constructor['type']) || this.core.paymentMethodsResponse.find(TxVariants.paywithgoogle)\n );\n }\n\n protected override formatProps(props: GooglePayConfiguration): GooglePayConfiguration {\n const buttonSizeMode = props.buttonSizeMode ?? (props.isDropin ? 'fill' : 'static');\n const buttonLocale = getGooglePayLocale(props.buttonLocale ?? props.i18n?.locale);\n\n const callbackIntents: google.payments.api.CallbackIntent[] = [...props.callbackIntents, 'PAYMENT_AUTHORIZATION'];\n\n const allowedCardNetworks = this.createAllowedCardNetworksValues({\n allowedCardNetworks: props.allowedCardNetworks,\n brands: props.brands\n });\n\n return {\n ...props,\n allowedCardNetworks,\n configuration: props.configuration,\n buttonSizeMode,\n buttonLocale,\n callbackIntents\n };\n }\n\n /**\n * Formats the component data output\n */\n protected override formatData() {\n const { googlePayCardNetwork, googlePayToken, billingAddress, deliveryAddress } = this.state;\n const { isExpress } = this.props;\n\n return {\n paymentMethod: {\n type: this.type,\n googlePayCardNetwork,\n googlePayToken,\n ...(isExpress && { subtype: 'express' })\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n /**\n * Generate the 'allowedCardNetworks' value used by Google Pay\n *\n * If the 'allowedCardNetworks' is defined in the Component configuration, it will be used. Otherwise we fallback\n * to use the 'brands' returned by the backoffice. It can be that 'brands' is not returned, which in this case we\n * set default values\n *\n * @param {object} brandsConfig\n * @param brandsConfig.allowedCardNetworks - Brands set in the component config\n * @param brandsConfig.brands - Brands returned by backend\n * @private\n */\n private createAllowedCardNetworksValues({\n allowedCardNetworks,\n brands\n }: {\n allowedCardNetworks?: google.payments.api.CardNetwork[];\n brands?: string[];\n }): google.payments.api.CardNetwork[] {\n if (allowedCardNetworks?.length > 0) return allowedCardNetworks;\n if (brands?.length > 0) return mapGooglePayBrands(brands);\n\n return DEFAULT_ALLOWED_CARD_NETWORKS;\n }\n\n protected override beforeRender(configSetByMerchant?: GooglePayConfiguration) {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.isExpress && { isExpress: configSetByMerchant.isExpress }),\n ...(configSetByMerchant?.expressPage && { expressPage: configSetByMerchant.expressPage })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n /**\n * Displays the Google Pay payment sheet overlay\n */\n private showGooglePayPaymentSheet() {\n this.googlePay.initiatePayment(this.props, this.core.options.countryCode).catch((error: google.payments.api.PaymentsError) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n this.handleError(new AdyenCheckoutError(error.statusCode === 'CANCELED' ? 'CANCEL' : 'ERROR', error.toString(), { cause: error }));\n });\n }\n\n public override submit = () => {\n if (this.props.isInstantPayment) {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: InfoEventType.selected,\n target: UiTarget.instantPaymentButton\n });\n\n this.submitAnalytics(event);\n }\n\n new Promise<void>((resolve, reject) => this.props.onClick(resolve, reject)).then(this.showGooglePayPaymentSheet).catch(() => {\n // Swallow exception triggered by onClick reject\n });\n };\n\n /**\n * Method called when the payment is authorized in the payment sheet\n *\n * @see https://developers.google.com/pay/api/web/reference/client#onPaymentAuthorized\n **/\n private onPaymentAuthorized = async (paymentData: google.payments.api.PaymentData): Promise<google.payments.api.PaymentAuthorizationResult> => {\n const billingAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.paymentMethodData.info.billingAddress);\n const deliveryAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.shippingAddress, true);\n\n this.setState({\n authorizedEvent: paymentData,\n googlePayToken: paymentData.paymentMethodData.tokenizationData.token,\n googlePayCardNetwork: paymentData.paymentMethodData.info.cardNetwork,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<google.payments.api.PaymentAuthorizationResult>(resolve => {\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((paymentResponse: PaymentResponseData) => {\n resolve({ transactionState: 'SUCCESS' });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n this.setElementStatus('ready');\n\n const googlePayError = paymentResponse?.error?.googlePayError;\n const fallbackMessage = this.props.i18n.get('error.subtitle.payment');\n\n const error: google.payments.api.PaymentDataError =\n typeof googlePayError === 'string' || undefined\n ? {\n intent: 'PAYMENT_AUTHORIZATION',\n reason: 'OTHER_ERROR',\n message: (googlePayError as string) || fallbackMessage\n }\n : {\n intent: googlePayError?.intent || 'PAYMENT_AUTHORIZATION',\n reason: googlePayError?.reason || 'OTHER_ERROR',\n message: googlePayError?.message || fallbackMessage\n };\n\n resolve({\n transactionState: 'ERROR',\n error\n });\n\n const responseWithError = {\n ...paymentResponse,\n error: {\n googlePayError: error\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n });\n };\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: google.payments.api.PaymentDataError | string) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { googlePayError: error } };\n return Promise.reject(data);\n });\n }\n\n public get isValid(): boolean {\n return true;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public override async isAvailable(): Promise<void> {\n return this.isReadyToPay()\n .then(response => {\n if (!response.result) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay is not available');\n }\n\n if (response.paymentMethodPresent === false) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay - No paymentMethodPresent');\n }\n\n return Promise.resolve();\n })\n .catch(error => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public isReadyToPay = (): Promise<google.payments.api.IsReadyToPayResponse> => {\n return this.googlePay.isReadyToPay(this.props);\n };\n\n /**\n * Use this method to prefetch a PaymentDataRequest configuration to improve loadPaymentData execution time on later user interaction. No value is returned.\n */\n public prefetch = (): void => {\n return this.googlePay.prefetchPaymentData(this.props, this.core.options.countryCode);\n };\n\n get browserInfo(): BrowserInfo {\n return collectBrowserInfo();\n }\n\n get icon(): string {\n return this.props.icon ?? this.resources.getImage()('googlepay');\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.showPayButton) {\n return (\n <GooglePayButton\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonSizeMode={this.props.buttonSizeMode}\n buttonLocale={this.props.buttonLocale}\n buttonRootNode={this.props.buttonRootNode}\n buttonRadius={this.props.buttonRadius}\n paymentsClient={this.googlePay.paymentsClient}\n onClick={this.submit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default GooglePay;\n"],"names":["DEFAULT_ALLOWED_CARD_NETWORKS","GooglePay","UIElement","getPaymentMethodFromPaymentMethodsResponse","type","paymentMethodId","this","core","paymentMethodsResponse","findById","find","constructor","TxVariants","paywithgoogle","formatProps","props","buttonSizeMode","isDropin","buttonLocale","getGooglePayLocale","i18n","locale","callbackIntents","allowedCardNetworks","createAllowedCardNetworksValues","brands","_object_spread_props","_object_spread","configuration","formatData","googlePayCardNetwork","googlePayToken","billingAddress","deliveryAddress","state","isExpress","paymentMethod","subtype","browserInfo","origin","window","location","length","mapGooglePayBrands","beforeRender","configSetByMerchant","originalAction","event","AnalyticsInfoEvent","InfoEventType","rendered","component","configData","showPayButton","expressPage","analytics","sendAnalytics","showGooglePayPaymentSheet","googlePay","initiatePayment","options","countryCode","catch","error","handleError","AdyenCheckoutError","statusCode","toString","cause","handleAuthorization","Promise","resolve","reject","onAuthorized","authorizedEvent","data","googlePayError","isValid","isAvailable","isReadyToPay","then","response","result","paymentMethodPresent","collectBrowserInfo","icon","_this_props_icon","resources","getImage","componentToRender","h","GooglePayButton","buttonColor","buttonType","buttonRootNode","buttonRadius","paymentsClient","onClick","submit","checkout","super","_define_property","isInstantPayment","selected","target","UiTarget","instantPaymentButton","submitAnalytics","onPaymentAuthorized","async","paymentData","formatGooglePayContactToAdyenAddressFormat","paymentMethodData","info","shippingAddress","setState","tokenizationData","token","cardNetwork","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","paymentResponse","transactionState","handleResponse","setElementStatus","fallbackMessage","get","intent","reason","message","responseWithError","handleFailedResult","prefetch","prefetchPaymentData","bind","paymentDataCallbacks","onPaymentDataChanged","merchantId","GooglePayService","environment","googlepay","txVariants","defaultProps"],"mappings":"8jDAiBA,MAAMA,EAAmE,CAAC,OAAQ,WAAY,MAAO,aAAc,QAEnH,MAAMC,UAAkBC,EA0CpB,0CAAAC,CAA8DC,EAAeC,GACzE,OAAIA,EAAwBC,KAAKC,KAAKC,uBAAuBC,SAASJ,GAGlEC,KAAKC,KAAKC,uBAAuBE,KAAKN,GAAQE,KAAKK,YAAY,OAAYL,KAAKC,KAAKC,uBAAuBE,KAAKE,EAAWC,cAEpI,CAEmBC,WAAAA,CAAYC,GAEmCA,IAAAA,EADvCA,EAAvB,MAAMC,EAAqC,QAApBD,EAAAA,EAAMC,sBAAND,IAAAA,EAAAA,EAAyBA,EAAME,SAAW,OAAS,SAClCF,IAAAA,EAAxC,MAAMG,EAAeC,EAAqC,QAAlBJ,EAAAA,EAAMG,oBAANH,IAAAA,EAAAA,EAAgC,QAAVA,EAAAA,EAAMK,YAANL,IAAAA,OAAAA,EAAAA,EAAYM,QAEpEC,EAAwD,IAAIP,EAAMO,gBAAiB,y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SAAU,wBAClCC,QAAQrD,aAAAA,EAAAA,EAAgBqD,SAAU,cAClCC,SAAStD,aAAAA,EAAAA,EAAgBsD,UAAWJ,GAGlDvD,EAAQ,CACJoD,iBAAkB,QAClB5D,UAGJ,MAAMoE,EAAoBzG,EAAAC,EAAA,CAAA,EACnB+F,GAAAA,CACH3D,MAAO,CACHa,eAAgBb,KAIxBzD,KAAK8H,mBAAmBD,SA4DxC9B,OAAOtB,eAAe,IACXzE,KAAKoD,UAAUqB,aAAazE,KAAKS,QAM5CsF,OAAOgC,WAAW,IACP/H,KAAKoD,UAAU4E,oBAAoBhI,KAAKS,MAAOT,KAAKC,KAAKqD,QAAQC,cAvRxEvD,KAAK+D,oBAAsB/D,KAAK+D,oBAAoBkE,KAAKjI,MACzDA,KAAKmD,0BAA4BnD,KAAKmD,0BAA0B8E,KAAKjI,MAErE,MAAM6B,UAAEA,EAASqG,qBAAEA,GAAyBlI,KAAKS,MAEjD,IAAkB,IAAdoB,IAAuBqG,aAAAA,EAAAA,EAAsBC,sBAC7C,MAAM,IAAIxE,EACN,uBACA,uGAIR,IAAK3D,KAAKS,MAAMa,cAAc8G,WAC1B,MAAM,IAAIzE,EACN,uBACA,wGAIR3D,KAAKoD,UAAY,IAAIiF,EAAiBrI,KAAKS,MAAM6H,YAAatI,KAAKiD,UAAW7B,EAAAC,EAAA,GACtEQ,IAAaqG,aAAAA,EAAAA,EAAsBC,uBAAwB,CAAEA,qBAAsBD,EAAqBC,uBAAqB,CACjI7B,oBAAqBtG,KAAKsG,sBAElC,EA/BAP,EADEpG,EACYG,OAAOQ,EAAWiI,WAChCxC,EAFEpG,EAEY6I,aAAa,CAAClI,EAAWiI,UAAWjI,EAAWC,gBAC7DwF,EAHEpG,EAGY8I,eAAeA"}
|
|
1
|
+
{"version":3,"file":"GooglePay.js","sources":["../../../../src/components/GooglePay/GooglePay.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport GooglePayService from './GooglePayService';\nimport GooglePayButton from './components/GooglePayButton';\nimport defaultProps from './defaultProps';\nimport { formatGooglePayContactToAdyenAddressFormat, getGooglePayLocale } from './utils';\nimport collectBrowserInfo from '../../utils/browserInfo';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { TxVariants } from '../tx-variants';\nimport { sanitizeResponse, verifyPaymentDidNotFail } from '../internal/UIElement/utils';\n\nimport type { AddressData, BrowserInfo, RawPaymentMethod, PaymentResponseData, RawPaymentResponse } from '../../types/global-types';\nimport type { GooglePayConfiguration } from './types';\nimport type { ICore } from '../../core/types';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../core/Analytics/events/AnalyticsInfoEvent';\nimport { mapGooglePayBrands } from './utils/map-adyen-brands-to-googlepay-brands';\n\nconst DEFAULT_ALLOWED_CARD_NETWORKS: google.payments.api.CardNetwork[] = ['AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA'];\n\nclass GooglePay extends UIElement<GooglePayConfiguration> {\n public static type = TxVariants.googlepay;\n public static txVariants = [TxVariants.googlepay, TxVariants.paywithgoogle];\n public static defaultProps = defaultProps;\n\n protected readonly googlePay;\n\n constructor(checkout: ICore, props?: GooglePayConfiguration) {\n super(checkout, props);\n this.handleAuthorization = this.handleAuthorization.bind(this);\n this.showGooglePayPaymentSheet = this.showGooglePayPaymentSheet.bind(this);\n\n const { isExpress, paymentDataCallbacks } = this.props;\n\n if (isExpress === false && paymentDataCallbacks?.onPaymentDataChanged) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - You must set \"isExpress\" flag to \"true\" in order to use \"onPaymentDataChanged\" callback'\n );\n }\n\n if (!this.props.configuration.merchantId) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n 'GooglePay - Missing merchantId. Please ensure that it is correctly configured in your customer area.'\n );\n }\n\n this.googlePay = new GooglePayService(this.props.environment, this.analytics, {\n ...(isExpress && paymentDataCallbacks?.onPaymentDataChanged && { onPaymentDataChanged: paymentDataCallbacks.onPaymentDataChanged }),\n onPaymentAuthorized: this.onPaymentAuthorized\n });\n }\n\n /**\n * Google Pay requires custom logic due to supporting two Tx variants that lead to the same payment method.\n * If the merchant creates a standalone Google Pay component, we need to verify if the payment method is available using both tx variants\n *\n * @param type\n * @param paymentMethodId - Unique internal payment method ID\n * @returns\n */\n protected override getPaymentMethodFromPaymentMethodsResponse(type?: string, paymentMethodId?: string): RawPaymentMethod {\n if (paymentMethodId) return this.core.paymentMethodsResponse.findById(paymentMethodId);\n\n return (\n this.core.paymentMethodsResponse.find(type || this.constructor['type']) || this.core.paymentMethodsResponse.find(TxVariants.paywithgoogle)\n );\n }\n\n protected override formatProps(props: GooglePayConfiguration): GooglePayConfiguration {\n const buttonSizeMode = props.buttonSizeMode ?? (props.isDropin ? 'fill' : 'static');\n const buttonLocale = getGooglePayLocale(props.buttonLocale ?? props.i18n?.locale);\n\n const callbackIntents: google.payments.api.CallbackIntent[] = [...props.callbackIntents, 'PAYMENT_AUTHORIZATION'];\n\n const allowedCardNetworks = this.createAllowedCardNetworksValues({\n allowedCardNetworks: props.allowedCardNetworks,\n brands: props.brands\n });\n\n return {\n ...props,\n allowedCardNetworks,\n configuration: props.configuration,\n buttonSizeMode,\n buttonLocale,\n callbackIntents\n };\n }\n\n /**\n * Formats the component data output\n */\n protected override formatData() {\n const { googlePayCardNetwork, googlePayToken, billingAddress, deliveryAddress } = this.state;\n const { isExpress } = this.props;\n\n return {\n paymentMethod: {\n type: this.type,\n googlePayCardNetwork,\n googlePayToken,\n ...(isExpress && { subtype: 'express' })\n },\n browserInfo: this.browserInfo,\n origin: !!window && window.location.origin,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n };\n }\n\n /**\n * Generate the 'allowedCardNetworks' value used by Google Pay\n *\n * If the 'allowedCardNetworks' is defined in the Component configuration, it will be used. Otherwise we fallback\n * to use the 'brands' returned by the backoffice. It can be that 'brands' is not returned, which in this case we\n * set default values\n *\n * @param {object} brandsConfig\n * @param brandsConfig.allowedCardNetworks - Brands set in the component config\n * @param brandsConfig.brands - Brands returned by backend\n * @private\n */\n private createAllowedCardNetworksValues({\n allowedCardNetworks,\n brands\n }: {\n allowedCardNetworks?: google.payments.api.CardNetwork[];\n brands?: string[];\n }): google.payments.api.CardNetwork[] {\n if (allowedCardNetworks?.length > 0) return allowedCardNetworks;\n if (brands?.length > 0) return mapGooglePayBrands(brands);\n\n return DEFAULT_ALLOWED_CARD_NETWORKS;\n }\n\n protected override beforeRender(configSetByMerchant?: GooglePayConfiguration) {\n // We don't send 'rendered' events when rendering actions\n if (configSetByMerchant?.originalAction) {\n return;\n }\n\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.rendered,\n component: this.type,\n configData: { ...configSetByMerchant, showPayButton: this.props.showPayButton },\n ...(configSetByMerchant?.isExpress && { isExpress: configSetByMerchant.isExpress }),\n ...(configSetByMerchant?.expressPage && { expressPage: configSetByMerchant.expressPage })\n });\n\n this.analytics.sendAnalytics(event);\n }\n\n /**\n * Displays the Google Pay payment sheet overlay\n */\n private showGooglePayPaymentSheet() {\n this.googlePay.initiatePayment(this.props, this.core.options.countryCode).catch((error: google.payments.api.PaymentsError) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n this.handleError(new AdyenCheckoutError(error.statusCode === 'CANCELED' ? 'CANCEL' : 'ERROR', error.toString(), { cause: error }));\n });\n }\n\n public override submit = () => {\n if (this.props.isInstantPayment) {\n const event = new AnalyticsInfoEvent({\n component: this.type,\n type: InfoEventType.selected,\n target: UiTarget.instantPaymentButton\n });\n\n this.submitAnalytics(event);\n }\n\n new Promise<void>((resolve, reject) => this.props.onClick(resolve, reject)).then(this.showGooglePayPaymentSheet).catch(() => {\n // Swallow exception triggered by onClick reject\n });\n };\n\n /**\n * Method called when the payment is authorized in the payment sheet\n *\n * @see https://developers.google.com/pay/api/web/reference/client#onPaymentAuthorized\n **/\n private onPaymentAuthorized = async (paymentData: google.payments.api.PaymentData): Promise<google.payments.api.PaymentAuthorizationResult> => {\n const billingAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.paymentMethodData.info.billingAddress);\n const deliveryAddress: AddressData = formatGooglePayContactToAdyenAddressFormat(paymentData.shippingAddress, true);\n\n this.setState({\n authorizedEvent: paymentData,\n googlePayToken: paymentData.paymentMethodData.tokenizationData.token,\n googlePayCardNetwork: paymentData.paymentMethodData.info.cardNetwork,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n });\n\n return new Promise<google.payments.api.PaymentAuthorizationResult>(resolve => {\n this.handleAuthorization()\n .then(this.makePaymentsCall)\n .then(sanitizeResponse)\n .then(verifyPaymentDidNotFail)\n .then((paymentResponse: PaymentResponseData) => {\n resolve({ transactionState: 'SUCCESS' });\n return paymentResponse;\n })\n .then(paymentResponse => {\n this.handleResponse(paymentResponse);\n })\n .catch((paymentResponse?: RawPaymentResponse) => {\n this.setElementStatus('ready');\n\n const googlePayError = paymentResponse?.error?.googlePayError;\n const fallbackMessage = this.props.i18n.get('error.subtitle.payment');\n\n const error: google.payments.api.PaymentDataError =\n typeof googlePayError === 'string' || undefined\n ? {\n intent: 'PAYMENT_AUTHORIZATION',\n reason: 'OTHER_ERROR',\n message: (googlePayError as string) || fallbackMessage\n }\n : {\n intent: googlePayError?.intent || 'PAYMENT_AUTHORIZATION',\n reason: googlePayError?.reason || 'OTHER_ERROR',\n message: googlePayError?.message || fallbackMessage\n };\n\n resolve({\n transactionState: 'ERROR',\n error\n });\n\n const responseWithError = {\n ...paymentResponse,\n error: {\n googlePayError: error\n }\n };\n\n this.handleFailedResult(responseWithError);\n });\n });\n };\n\n /**\n * Call the 'onAuthorized' callback if available.\n * Must be resolved/reject for the payment flow to continue\n */\n private async handleAuthorization(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (!this.props.onAuthorized) {\n resolve();\n }\n\n const { authorizedEvent, billingAddress, deliveryAddress } = this.state;\n\n this.props.onAuthorized(\n {\n authorizedEvent,\n ...(billingAddress && { billingAddress }),\n ...(deliveryAddress && { deliveryAddress })\n },\n { resolve, reject }\n );\n }).catch((error?: google.payments.api.PaymentDataError | string) => {\n // Format error in a way that the 'catch' of the 'onPaymentAuthorize' block accepts it\n const data = { error: { googlePayError: error } };\n return Promise.reject(data);\n });\n }\n\n public get isValid(): boolean {\n return true;\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public override async isAvailable(): Promise<void> {\n return this.isReadyToPay()\n .then(response => {\n if (!response.result) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay is not available');\n }\n\n if (response.paymentMethodPresent === false) {\n throw new AdyenCheckoutError('ERROR', 'GooglePay - No paymentMethodPresent');\n }\n\n return Promise.resolve();\n })\n .catch(error => {\n return Promise.reject(error);\n });\n }\n\n /**\n * Determine a shopper's ability to return a form of payment from the Google Pay API.\n */\n public isReadyToPay = (): Promise<google.payments.api.IsReadyToPayResponse> => {\n return this.googlePay.isReadyToPay(this.props);\n };\n\n /**\n * Use this method to prefetch a PaymentDataRequest configuration to improve loadPaymentData execution time on later user interaction. No value is returned.\n */\n public prefetch = (): void => {\n return this.googlePay.prefetchPaymentData(this.props, this.core.options.countryCode);\n };\n\n get browserInfo(): BrowserInfo {\n return collectBrowserInfo();\n }\n\n get icon(): string {\n return this.props.icon ?? this.resources.getImage()('googlepay');\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.showPayButton) {\n return (\n <GooglePayButton\n buttonColor={this.props.buttonColor}\n buttonType={this.props.buttonType}\n buttonSizeMode={this.props.buttonSizeMode}\n buttonLocale={this.props.buttonLocale}\n buttonRootNode={this.props.buttonRootNode}\n buttonRadius={this.props.buttonRadius}\n paymentsClient={this.googlePay.paymentsClient}\n onClick={this.submit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default GooglePay;\n"],"names":["DEFAULT_ALLOWED_CARD_NETWORKS","GooglePay","UIElement","getPaymentMethodFromPaymentMethodsResponse","type","paymentMethodId","this","core","paymentMethodsResponse","findById","find","constructor","TxVariants","paywithgoogle","formatProps","props","buttonSizeMode","isDropin","buttonLocale","getGooglePayLocale","i18n","locale","callbackIntents","allowedCardNetworks","createAllowedCardNetworksValues","brands","_object_spread_props","_object_spread","configuration","formatData","googlePayCardNetwork","googlePayToken","billingAddress","deliveryAddress","state","isExpress","paymentMethod","subtype","browserInfo","origin","window","location","length","mapGooglePayBrands","beforeRender","configSetByMerchant","originalAction","event","AnalyticsInfoEvent","InfoEventType","rendered","component","configData","showPayButton","expressPage","analytics","sendAnalytics","showGooglePayPaymentSheet","googlePay","initiatePayment","options","countryCode","catch","error","handleError","AdyenCheckoutError","statusCode","toString","cause","handleAuthorization","Promise","resolve","reject","onAuthorized","authorizedEvent","data","googlePayError","isValid","isAvailable","isReadyToPay","then","response","result","paymentMethodPresent","collectBrowserInfo","icon","_this_props_icon","resources","getImage","componentToRender","h","GooglePayButton","buttonColor","buttonType","buttonRootNode","buttonRadius","paymentsClient","onClick","submit","checkout","super","_define_property","isInstantPayment","selected","target","UiTarget","instantPaymentButton","submitAnalytics","onPaymentAuthorized","async","paymentData","formatGooglePayContactToAdyenAddressFormat","paymentMethodData","info","shippingAddress","setState","tokenizationData","token","cardNetwork","makePaymentsCall","sanitizeResponse","verifyPaymentDidNotFail","paymentResponse","transactionState","handleResponse","setElementStatus","fallbackMessage","get","intent","reason","message","responseWithError","handleFailedResult","prefetch","prefetchPaymentData","bind","paymentDataCallbacks","onPaymentDataChanged","merchantId","GooglePayService","environment","googlepay","txVariants","defaultProps"],"mappings":"8jDAiBA,MAAMA,EAAmE,CAAC,OAAQ,WAAY,MAAO,aAAc,QAEnH,MAAMC,UAAkBC,EA0CpB,0CAAAC,CAA8DC,EAAeC,GACzE,OAAIA,EAAwBC,KAAKC,KAAKC,uBAAuBC,SAASJ,GAGlEC,KAAKC,KAAKC,uBAAuBE,KAAKN,GAAQE,KAAKK,YAAY,OAAYL,KAAKC,KAAKC,uBAAu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BC,uBAAqB,CACjI7B,oBAAqBtG,KAAKsG,sBAElC,EA/BAP,EADEpG,EACYG,OAAOQ,EAAWiI,WAChCxC,EAFEpG,EAEY6I,aAAa,CAAClI,EAAWiI,UAAWjI,EAAWC,gBAC7DwF,EAHEpG,EAGY8I,eAAeA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getDecimalAmount as e}from"../../utils/amount-util.js";import t from"./config.js";function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){r(e,t,n[t])})}return e}function a(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},i=Object.
|
|
1
|
+
import{getDecimalAmount as e}from"../../utils/amount-util.js";import t from"./config.js";function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){r(e,t,n[t])})}return e}function a(e,t){if(null==e)return{};var r,n,a,i={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(e),a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}if(i=function(e,t){if(null==e)return{};var r,n,a={},i=Object.getOwnPropertyNames(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}function i({allowedAuthMethods:e,allowedCardNetworks:r,existingPaymentMethodRequired:n=!1}){return{apiVersion:t.API_VERSION,apiVersionMinor:t.API_VERSION_MINOR,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:e,allowedCardNetworks:r},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{}}}],existingPaymentMethodRequired:n}}function o(t){let{amount:r,countryCode:i="US",totalPriceStatus:o="FINAL"}=t,l=a(t,["amount","countryCode","totalPriceStatus"]);const s=String(e(r.value,r.currency));return n({countryCode:i,currencyCode:r.currency,totalPrice:s,totalPriceStatus:o},l.transactionInfo)}function l(e,r){let i=[e,r],[l,...s]=i,{configuration:d}=l,c=a(l,["configuration"]),[u]=s;return{apiVersion:t.API_VERSION,apiVersionMinor:t.API_VERSION_MINOR,transactionInfo:o(n({countryCode:u},c)),merchantInfo:n({merchantId:d.merchantId,merchantName:d.merchantName},d.merchantOrigin?{merchantOrigin:d.merchantOrigin}:{},d.authJwt?{authJwt:d.authJwt}:{}),allowedPaymentMethods:[{type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:t.GATEWAY,gatewayMerchantId:d.gatewayMerchantId}},parameters:{allowedAuthMethods:c.allowedAuthMethods,allowedCardNetworks:c.allowedCardNetworks,assuranceDetailsRequired:c.assuranceDetailsRequired,allowPrepaidCards:c.allowPrepaidCards,allowCreditCards:c.allowCreditCards,billingAddressRequired:c.billingAddressRequired,billingAddressParameters:c.billingAddressParameters}}],emailRequired:c.emailRequired,shippingAddressRequired:c.shippingAddressRequired,shippingAddressParameters:c.shippingAddressParameters,shippingOptionRequired:c.shippingOptionRequired,shippingOptionParameters:c.shippingOptionParameters,callbackIntents:c.callbackIntents}}export{o as getTransactionInfo,l as initiatePaymentRequest,i as isReadyToPayRequest};
|
|
2
2
|
//# sourceMappingURL=requests.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.js","sources":["../../../../src/components/GooglePay/requests.ts"],"sourcesContent":["import { getDecimalAmount } from '../../utils/amount-util';\nimport config from './config';\nimport { GooglePaymentDataRequest, GooglePayConfiguration } from './types';\n\n/**\n * Configure your site's support for payment methods supported by the Google Pay API.\n *\n * @see {@link https://developers.google.com/pay/api/web/reference/object#IsReadyToPayRequest|isReadyToPayRequest}\n * @returns Google Pay API version, payment methods supported by the site\n */\nexport function isReadyToPayRequest({\n allowedAuthMethods,\n allowedCardNetworks,\n existingPaymentMethodRequired = false\n}: Pick<\n GooglePayConfiguration,\n 'allowedAuthMethods' | 'allowedCardNetworks' | 'existingPaymentMethodRequired'\n>): google.payments.api.IsReadyToPayRequest {\n return {\n apiVersion: config.API_VERSION,\n apiVersionMinor: config.API_VERSION_MINOR,\n allowedPaymentMethods: [\n {\n type: 'CARD',\n parameters: {\n allowedAuthMethods,\n allowedCardNetworks\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {}\n }\n }\n ],\n existingPaymentMethodRequired\n };\n}\n\n/**\n * Provide Google Pay API with a payment amount, currency, and amount status\n *\n * @see {@link https://developers.google.com/pay/api/web/reference/object#TransactionInfo|TransactionInfo}\n * @returns transaction info, suitable for use as transactionInfo property of PaymentDataRequest\n */\nexport function getTransactionInfo({\n amount,\n countryCode = 'US',\n totalPriceStatus = 'FINAL',\n ...props\n}: GooglePayConfiguration): google.payments.api.TransactionInfo {\n const formattedPrice = String(getDecimalAmount(amount.value, amount.currency));\n\n return {\n countryCode,\n currencyCode: amount.currency,\n totalPrice: formattedPrice,\n totalPriceStatus: totalPriceStatus,\n ...props.transactionInfo\n };\n}\n\nexport function initiatePaymentRequest({ configuration, ...props }: GooglePayConfiguration, countryCode: string): GooglePaymentDataRequest {\n return {\n apiVersion: config.API_VERSION,\n apiVersionMinor: config.API_VERSION_MINOR,\n transactionInfo: getTransactionInfo({ countryCode, ...props }),\n merchantInfo: {\n merchantId: configuration.merchantId,\n merchantName: configuration.merchantName,\n ...(configuration.merchantOrigin ? { merchantOrigin: configuration.merchantOrigin } : {}),\n ...(configuration.authJwt ? { authJwt: configuration.authJwt } : {})\n },\n allowedPaymentMethods: [\n {\n type: 'CARD',\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: config.GATEWAY,\n gatewayMerchantId: configuration.gatewayMerchantId\n }\n },\n parameters: {\n allowedAuthMethods: props.allowedAuthMethods,\n allowedCardNetworks: props.allowedCardNetworks,\n assuranceDetailsRequired: props.assuranceDetailsRequired,\n allowPrepaidCards: props.allowPrepaidCards,\n allowCreditCards: props.allowCreditCards,\n billingAddressRequired: props.billingAddressRequired,\n billingAddressParameters: props.billingAddressParameters\n }\n }\n ],\n emailRequired: props.emailRequired,\n shippingAddressRequired: props.shippingAddressRequired,\n shippingAddressParameters: props.shippingAddressParameters,\n shippingOptionRequired: props.shippingOptionRequired,\n shippingOptionParameters: props.shippingOptionParameters,\n callbackIntents: props.callbackIntents\n };\n}\n"],"names":["isReadyToPayRequest","allowedAuthMethods","allowedCardNetworks","existingPaymentMethodRequired","apiVersion","config","API_VERSION","apiVersionMinor","API_VERSION_MINOR","allowedPaymentMethods","type","parameters","tokenizationSpecification","getTransactionInfo","
|
|
1
|
+
{"version":3,"file":"requests.js","sources":["../../../../src/components/GooglePay/requests.ts"],"sourcesContent":["import { getDecimalAmount } from '../../utils/amount-util';\nimport config from './config';\nimport { GooglePaymentDataRequest, GooglePayConfiguration } from './types';\n\n/**\n * Configure your site's support for payment methods supported by the Google Pay API.\n *\n * @see {@link https://developers.google.com/pay/api/web/reference/object#IsReadyToPayRequest|isReadyToPayRequest}\n * @returns Google Pay API version, payment methods supported by the site\n */\nexport function isReadyToPayRequest({\n allowedAuthMethods,\n allowedCardNetworks,\n existingPaymentMethodRequired = false\n}: Pick<\n GooglePayConfiguration,\n 'allowedAuthMethods' | 'allowedCardNetworks' | 'existingPaymentMethodRequired'\n>): google.payments.api.IsReadyToPayRequest {\n return {\n apiVersion: config.API_VERSION,\n apiVersionMinor: config.API_VERSION_MINOR,\n allowedPaymentMethods: [\n {\n type: 'CARD',\n parameters: {\n allowedAuthMethods,\n allowedCardNetworks\n },\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {}\n }\n }\n ],\n existingPaymentMethodRequired\n };\n}\n\n/**\n * Provide Google Pay API with a payment amount, currency, and amount status\n *\n * @see {@link https://developers.google.com/pay/api/web/reference/object#TransactionInfo|TransactionInfo}\n * @returns transaction info, suitable for use as transactionInfo property of PaymentDataRequest\n */\nexport function getTransactionInfo({\n amount,\n countryCode = 'US',\n totalPriceStatus = 'FINAL',\n ...props\n}: GooglePayConfiguration): google.payments.api.TransactionInfo {\n const formattedPrice = String(getDecimalAmount(amount.value, amount.currency));\n\n return {\n countryCode,\n currencyCode: amount.currency,\n totalPrice: formattedPrice,\n totalPriceStatus: totalPriceStatus,\n ...props.transactionInfo\n };\n}\n\nexport function initiatePaymentRequest({ configuration, ...props }: GooglePayConfiguration, countryCode: string): GooglePaymentDataRequest {\n return {\n apiVersion: config.API_VERSION,\n apiVersionMinor: config.API_VERSION_MINOR,\n transactionInfo: getTransactionInfo({ countryCode, ...props }),\n merchantInfo: {\n merchantId: configuration.merchantId,\n merchantName: configuration.merchantName,\n ...(configuration.merchantOrigin ? { merchantOrigin: configuration.merchantOrigin } : {}),\n ...(configuration.authJwt ? { authJwt: configuration.authJwt } : {})\n },\n allowedPaymentMethods: [\n {\n type: 'CARD',\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n gateway: config.GATEWAY,\n gatewayMerchantId: configuration.gatewayMerchantId\n }\n },\n parameters: {\n allowedAuthMethods: props.allowedAuthMethods,\n allowedCardNetworks: props.allowedCardNetworks,\n assuranceDetailsRequired: props.assuranceDetailsRequired,\n allowPrepaidCards: props.allowPrepaidCards,\n allowCreditCards: props.allowCreditCards,\n billingAddressRequired: props.billingAddressRequired,\n billingAddressParameters: props.billingAddressParameters\n }\n }\n ],\n emailRequired: props.emailRequired,\n shippingAddressRequired: props.shippingAddressRequired,\n shippingAddressParameters: props.shippingAddressParameters,\n shippingOptionRequired: props.shippingOptionRequired,\n shippingOptionParameters: props.shippingOptionParameters,\n callbackIntents: props.callbackIntents\n };\n}\n"],"names":["isReadyToPayRequest","allowedAuthMethods","allowedCardNetworks","existingPaymentMethodRequired","apiVersion","config","API_VERSION","apiVersionMinor","API_VERSION_MINOR","allowedPaymentMethods","type","parameters","tokenizationSpecification","getTransactionInfo","_0","amount","countryCode","totalPriceStatus","props","formattedPrice","String","getDecimalAmount","value","currency","_object_spread","currencyCode","totalPrice","transactionInfo","initiatePaymentRequest","configuration","_ref1","merchantInfo","merchantId","merchantName","merchantOrigin","authJwt","gateway","GATEWAY","gatewayMerchantId","assuranceDetailsRequired","allowPrepaidCards","allowCreditCards","billingAddressRequired","billingAddressParameters","emailRequired","shippingAddressRequired","shippingAddressParameters","shippingOptionRequired","shippingOptionParameters","callbackIntents"],"mappings":"soCAUO,SAASA,GAAoBC,mBAChCA,EAAkBC,oBAClBA,EAAmBC,8BACnBA,GAAgC,IAKhC,MAAO,CACHC,WAAYC,EAAOC,YACnBC,gBAAiBF,EAAOG,kBACxBC,sBAAuB,CACnB,CACIC,KAAM,OACNC,WAAY,CACRV,qBACAC,uBAEJU,0BAA2B,CACvBF,KAAM,kBACNC,WAAY,CAAA,KAIxBR,gCAER,CAQO,SAASU,EAAmBC,OAAAC,OAC/BA,EAAMC,YACNA,EAAc,KAAIC,iBAClBA,EAAmB,SAEEH,EADlBI,EAAAA,EAAAA,EAAAA,6CAEH,MAAMC,EAAiBC,OAAOC,EAAiBN,EAAOO,MAAOP,EAAOQ,WAEpE,OAAOC,EAAA,CACHR,cACAS,aAAcV,EAAOQ,SACrBG,WAAYP,EACZF,iBAAkBA,GACfC,EAAMS,gBAEjB,CAEO,SAASC,EAAuBd,EAAqDE,2BAArDa,cAAEA,GAAiDC,EAA/BZ,EAAAA,EAAAA,EAAAA,oBAAiCF,GAAAA,EACxF,MAAO,CACHZ,WAAYC,EAAOC,YACnBC,gBAAiBF,EAAOG,kBACxBmB,gBAAiBd,EAAmBW,EAAA,CAAER,eAAgBE,IACtDa,aAAcP,EAAA,CACVQ,WAAYH,EAAcG,WAC1BC,aAAcJ,EAAcI,cACxBJ,EAAcK,eAAiB,CAAEA,eAAgBL,EAAcK,gBAAmB,CAAA,EAClFL,EAAcM,QAAU,CAAEA,QAASN,EAAcM,SAAY,IAErE1B,sBAAuB,CACnB,CACIC,KAAM,OACNE,0BAA2B,CACvBF,KAAM,kBACNC,WAAY,CACRyB,QAAS/B,EAAOgC,QAChBC,kBAAmBT,EAAcS,oBAGzC3B,WAAY,CACRV,mBAAoBiB,EAAMjB,mBAC1BC,oBAAqBgB,EAAMhB,oBAC3BqC,yBAA0BrB,EAAMqB,yBAChCC,kBAAmBtB,EAAMsB,kBACzBC,iBAAkBvB,EAAMuB,iBACxBC,uBAAwBxB,EAAMwB,uBAC9BC,yBAA0BzB,EAAMyB,4BAI5CC,cAAe1B,EAAM0B,cACrBC,wBAAyB3B,EAAM2B,wBAC/BC,0BAA2B5B,EAAM4B,0BACjCC,uBAAwB7B,EAAM6B,uBAC9BC,yBAA0B9B,EAAM8B,yBAChCC,gBAAiB/B,EAAM+B,gBAE/B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as t}from"../../external/preact/dist/preact.js";import e from"../../utils/isMobile.js";import o from"../helpers/IssuerListContainer/IssuerListContainer.js";import{QRLoader as r}from"../internal/QRLoader/QRLoader.js";import"../../core/Context/CoreProvider.js";import"../../external/preact/hooks/dist/hooks.js";import"../../core/Errors/AdyenCheckoutError.js";import"../../core/Errors/SRPanelContext.js";import"../internal/Button/Button.js";import"../internal/QRLoader/QRLoaderDetailsProvider.js";import{TxVariants as n}from"../tx-variants.js";import s from"./components/IrisComponent.js";import{IrisQrCodeInstructions as i}from"./components/IrisQrCodeInstructions.js";import{IrisMode as p}from"./types.js";import{DEFAULT_IRIS_COUNTDOWN_TIME as a}from"./constants.js";function u(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function m(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}class c extends o{renderIssuerList(){return super.componentToRender()}formatData(){var t,e;return this.mode===p.BANK_LIST?{paymentMethod:{type:this.type,issuer:null===(e=this.state)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.issuer}}:{paymentMethod:{type:this.type}}}formatProps(t){var e;return m(function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){u(t,e,o[e])})}return t}({},super.formatProps(t)),{countdownTime:null!==(e=t.countdownTime)&&void 0!==e?e:a})}get isValid(){return this.mode!==p.BANK_LIST||super.isValid}componentToRender(){return"qrCode"===this.props.type?t(r,{type:n.iris,brandLogo:this.icon,clientKey:this.props.clientKey,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,countdownTime:this.props.countdownTime,paymentData:this.props.paymentData,amount:this.props.amount,delay:this.props.delay,onActionHandled:this.onActionHandled,onError:this.props.onError,onComplete:this.onComplete,introduction:i,showAmount:!0,copyBtn:!1}):t(s,{setComponentRef:this.setComponentRef,defaultMode:this.mode,onUpdateMode:this.onUpdateMode,issuerListUI:this.renderIssuerList(),showPayButton:this.props.showPayButton,payButton:this.payButton,issuers:this.props.issuers})}constructor(t,o){super(t,o),u(this,"mode",void 0),u(this,"onUpdateMode",t=>{this.mode=t}),this.mode=e()?p.BANK_LIST:p.QR_CODE}}u(c,"type",n.iris);export{c as Iris,c as default};
|
|
2
|
+
//# sourceMappingURL=Iris.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Iris.js","sources":["../../../../src/components/Iris/Iris.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { ICore } from '../../types';\nimport isMobile from '../../utils/isMobile';\nimport IssuerListContainer from '../helpers/IssuerListContainer/IssuerListContainer';\nimport { QRLoader } from '../internal/QRLoader';\nimport { TxVariants } from '../tx-variants';\nimport IrisComponent from './components/IrisComponent';\nimport { IrisQrCodeInstructions } from './components/IrisQrCodeInstructions';\nimport { IrisConfiguration, IrisData, IrisMode } from './types';\nimport { DEFAULT_IRIS_COUNTDOWN_TIME } from './constants';\n\nexport class Iris extends IssuerListContainer<IrisConfiguration, IrisData> {\n public static readonly type = TxVariants.iris;\n\n private mode: IrisMode;\n\n constructor(checkout: ICore, props: IrisConfiguration) {\n super(checkout, props);\n this.mode = isMobile() ? IrisMode.BANK_LIST : IrisMode.QR_CODE;\n }\n\n private readonly onUpdateMode = (mode: IrisMode): void => {\n this.mode = mode;\n };\n\n private renderIssuerList(): h.JSX.Element {\n return super.componentToRender();\n }\n\n formatData(): IrisData {\n if (this.mode === IrisMode.BANK_LIST) {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n };\n }\n\n return {\n paymentMethod: {\n type: this.type\n }\n };\n }\n\n formatProps(props: IrisConfiguration): IrisConfiguration {\n return {\n ...super.formatProps(props),\n countdownTime: props.countdownTime ?? DEFAULT_IRIS_COUNTDOWN_TIME\n };\n }\n\n get isValid() {\n if (this.mode === IrisMode.BANK_LIST) {\n return super.isValid;\n }\n\n return true;\n }\n\n protected override componentToRender(): h.JSX.Element {\n if (this.props.type === 'qrCode') {\n return (\n <QRLoader\n type={TxVariants.iris}\n brandLogo={this.icon}\n clientKey={this.props.clientKey}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n countdownTime={this.props.countdownTime}\n paymentData={this.props.paymentData}\n amount={this.props.amount}\n delay={this.props.delay}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n onComplete={this.onComplete}\n introduction={IrisQrCodeInstructions}\n showAmount\n copyBtn={false}\n />\n );\n }\n\n return (\n <IrisComponent\n setComponentRef={this.setComponentRef}\n defaultMode={this.mode}\n onUpdateMode={this.onUpdateMode}\n issuerListUI={this.renderIssuerList()}\n showPayButton={this.props.showPayButton}\n payButton={this.payButton}\n issuers={this.props.issuers}\n />\n );\n }\n}\n\nexport default Iris;\n"],"names":["Iris","IssuerListContainer","renderIssuerList","super","componentToRender","formatData","_this_state_data","_this_state","this","mode","IrisMode","BANK_LIST","paymentMethod","type","issuer","state","data","formatProps","props","_object_spread_props","_object_spread","countdownTime","DEFAULT_IRIS_COUNTDOWN_TIME","isValid","h","QRLoader","TxVariants","iris","brandLogo","icon","clientKey","qrCodeData","encodeURIComponent","paymentData","amount","delay","onActionHandled","onError","onComplete","introduction","IrisQrCodeInstructions","showAmount","copyBtn","IrisComponent","setComponentRef","defaultMode","onUpdateMode","issuerListUI","showPayButton","payButton","issuers","constructor","checkout","_define_property","isMobile","QR_CODE"],"mappings":"uvCAWO,MAAMA,UAAaC,EAcdC,gBAAAA,GACJ,OAAOC,MAAMC,mBACjB,CAEAC,UAAAA,OAKwBC,EAAAC,EAJpB,OAAIC,KAAKC,OAASC,EAASC,UAChB,CACHC,cAAe,CACXC,KAAML,KAAKK,KACXC,OAAkB,QAAVP,EAAAC,KAAKO,aAAL,IAAAR,GAAgB,QAAhBD,EAAAC,EAAYS,YAAZ,IAAAV,OAAA,EAAAA,EAAkBQ,SAK/B,CACHF,cAAe,CACXC,KAAML,KAAKK,MAGvB,CAEA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types.js";import{useState as o,useMemo as s,useRef as n,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import{IRIS_ALLY_LABELS as a}from"../constants.js";import{getIrisSegmentedControlOptions as i}from"../utils.js";import{useCoreContext as d}from"../../../core/Context/CoreProvider.js";import{SegmentedControl as l}from"../../internal/SegmentedControl/SegmentedControl.js";import{SegmentedControlRegion as m}from"../../internal/SegmentedControl/SegmentedControlRegion.js";import u from"./IrisGenerateQRCode.js";import p from"./IrisComponent.module.scss.js";import{AnalyticsInfoEvent as c,UiTarget as f,InfoEventType as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{TxVariants as C}from"../../tx-variants.js";import B from"../../../core/Analytics/useAnalytics.js";function j(j){const{i18n:g}=d(),{analytics:A}=B(),[I,R]=o(j.defaultMode),[S,h]=o("ready"),E=s(()=>i(g,j.defaultMode),[g,j.defaultMode]),L=j.issuers.length>0,_=(t,e=!1)=>{if(R(t),j.onUpdateMode(t),e){const e=new c({type:y.selected,target:f.segmentedControl,component:C.iris,selectedValue:t});A.sendAnalytics(e)}},w=n({setStatus:h});return r(()=>{j.setComponentRef(w.current)},[j.setComponentRef]),r(()=>{if(L){const t=new c({type:y.displayed,target:f.segmentedControl,component:C.iris,selectedValue:j.defaultMode});A.sendAnalytics(t)}},[]),r(()=>{L||_(e.QR_CODE)},[L]),L?t("div",null,t(l,{onChange:t=>_(t,!0),selectedValue:I,disabled:"loading"===S,options:E}),I===e.BANK_LIST&&t(m,{id:a.AreaId.BANK_LIST,ariaLabelledBy:a.ButtonId.BANK_LIST,className:p.bankList},j.issuerListUI),I===e.QR_CODE&&t(m,{id:a.AreaId.QR_CODE,ariaLabelledBy:a.ButtonId.QR_CODE},t(u,{showPayButton:j.showPayButton,payButton:j.payButton,status:S}))):t(u,{showPayButton:j.showPayButton,payButton:j.payButton,status:S})}export{j as default};
|
|
2
|
+
//# sourceMappingURL=IrisComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrisComponent.js","sources":["../../../../../src/components/Iris/components/IrisComponent.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { IrisMode } from '../types';\nimport { useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport { IRIS_ALLY_LABELS } from '../constants';\nimport { getIrisSegmentedControlOptions } from '../utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { SegmentedControl, SegmentedControlRegion } from '../../internal/SegmentedControl';\nimport { ComponentMethodsRef, UIElementStatus } from '../../types';\nimport { IssuerItem } from '../../internal/IssuerList/types';\nimport IrisGenerateQRCode from './IrisGenerateQRCode';\nimport styles from './IrisComponent.module.scss';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { TxVariants } from '../../tx-variants';\nimport useAnalytics from '../../../core/Analytics/useAnalytics';\n\ninterface IrisComponentProps {\n defaultMode: IrisMode;\n showPayButton?: boolean;\n issuers: IssuerItem[];\n issuerListUI: h.JSX.Element;\n onUpdateMode: (mode: IrisMode) => void;\n payButton: (props: Partial<PayButtonProps>) => h.JSX.Element;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n}\n\nexport default function IrisComponent(props: Readonly<IrisComponentProps>) {\n const { i18n } = useCoreContext();\n const { analytics } = useAnalytics();\n\n const [mode, setMode] = useState<IrisMode>(props.defaultMode);\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const segmentedControlOptions = useMemo(() => getIrisSegmentedControlOptions(i18n, props.defaultMode), [i18n, props.defaultMode]);\n\n const issuersAvailable = props.issuers.length > 0;\n\n const handleModeChange = (mode: IrisMode, sendAnalytics = false) => {\n setMode(mode);\n props.onUpdateMode(mode);\n if (sendAnalytics) {\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.selected,\n target: UiTarget.segmentedControl,\n component: TxVariants.iris,\n selectedValue: mode\n });\n analytics.sendAnalytics(event);\n }\n };\n\n const irisRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus\n });\n\n useEffect(() => {\n props.setComponentRef(irisRef.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n if (issuersAvailable) {\n const event = new AnalyticsInfoEvent({\n type: InfoEventType.displayed,\n target: UiTarget.segmentedControl,\n component: TxVariants.iris,\n selectedValue: props.defaultMode\n });\n analytics.sendAnalytics(event);\n }\n }, []);\n\n useEffect(() => {\n if (!issuersAvailable) {\n handleModeChange(IrisMode.QR_CODE);\n }\n }, [issuersAvailable]);\n\n if (!issuersAvailable) {\n return <IrisGenerateQRCode showPayButton={props.showPayButton} payButton={props.payButton} status={status} />;\n }\n\n return (\n <div>\n <SegmentedControl\n onChange={mode => handleModeChange(mode, true)}\n selectedValue={mode}\n disabled={status === 'loading'}\n options={segmentedControlOptions}\n />\n {mode === IrisMode.BANK_LIST && (\n <SegmentedControlRegion\n id={IRIS_ALLY_LABELS.AreaId.BANK_LIST}\n ariaLabelledBy={IRIS_ALLY_LABELS.ButtonId.BANK_LIST}\n className={styles.bankList}\n >\n {props.issuerListUI}\n </SegmentedControlRegion>\n )}\n {mode === IrisMode.QR_CODE && (\n <SegmentedControlRegion id={IRIS_ALLY_LABELS.AreaId.QR_CODE} ariaLabelledBy={IRIS_ALLY_LABELS.ButtonId.QR_CODE}>\n <IrisGenerateQRCode showPayButton={props.showPayButton} payButton={props.payButton} status={status} />\n </SegmentedControlRegion>\n )}\n </div>\n );\n}\n"],"names":["IrisComponent","props","i18n","useCoreContext","analytics","useAnalytics","mode","setMode","useState","defaultMode","status","setStatus","segmentedControlOptions","useMemo","getIrisSegmentedControlOptions","issuersAvailable","issuers","length","handleModeChange","sendAnalytics","onUpdateMode","event","AnalyticsInfoEvent","type","InfoEventType","selected","target","UiTarget","segmentedControl","component","TxVariants","iris","selectedValue","irisRef","useRef","useEffect","setComponentRef","current","displayed","IrisMode","QR_CODE","h","div","SegmentedControl","onChange","disabled","options","BANK_LIST","SegmentedControlRegion","id","IRIS_ALLY_LABELS","AreaId","ariaLabelledBy","ButtonId","className","styles","bankList","issuerListUI","IrisGenerateQRCode","showPayButton","payButton"],"mappings":"y4BA0Be,SAASA,EAAcC,GAClC,MAAMC,KAAEA,GAASC,KACXC,UAAEA,GAAcC,KAEfC,EAAMC,GAAWC,EAAmBP,EAAMQ,cAC1CC,EAAQC,GAAaH,EAA0B,SAChDI,EAA0BC,EAAQ,IAAMC,EAA+BZ,EAAMD,EAAMQ,aAAc,CAACP,EAAMD,EAAMQ,cAE9GM,EAAmBd,EAAMe,QAAQC,OAAS,EAE1CC,EAAmB,CAACZ,EAAgBa,GAAgB,KAGtD,GAFAZ,EAAQD,GACRL,EAAMmB,aAAad,GACfa,EAAe,CACf,MAAME,EAAQ,IAAIC,EAAmB,CACjCC,KAAMC,EAAcC,SACpBC,OAAQC,EAASC,iBACjBC,UAAWC,EAAWC,KACtBC,cAAe1B,IAEnBF,EAAUe,cAAcE,EAC5B,GAGEY,EAAUC,EAA4B,CACxCvB,UAAWA,IAyBf,OAtBAwB,EAAU,KACNlC,EAAMmC,gBAAgBH,EAAQI,UAC/B,CAACpC,EAAMmC,kBAEVD,EAAU,KACN,GAAIpB,EAAkB,CAClB,MAAMM,EAAQ,IAAIC,EAAmB,CACjCC,KAAMC,EAAcc,UACpBZ,OAAQC,EAASC,iBACjBC,UAAWC,EAAWC,KACtBC,cAAe/B,EAAMQ,cAEzBL,EAAUe,cAAcE,EAC5B,GACD,IAEHc,EAAU,KACDpB,GACDG,EAAiBqB,EAASC,UAE/B,CAACzB,IAECA,EAKD0B,EAACC,WACGD,EAACE,EAAAA,CACGC,SAAUtC,GAAQY,EAAiBZ,GAAM,GACzC0B,cAAe1B,EACfuC,SAAqB,YAAXnC,EACVoC,QAASlC,IAEZN,IAASiC,EAASQ,WACfN,EAACO,EAAAA,CACGC,GAAIC,EAAiBC,OAAOJ,UAC5BK,eAAgBF,EAAiBG,SAASN,UAC1CO,UAAWC,EAAOC,UAEjBvD,EAAMwD,cAGdnD,IAASiC,EAASC,SACfC,EAACO,EAAAA,CAAuBC,GAAIC,EAAiBC,OAAOX,QAASY,eAAgBF,EAAiBG,SAASb,SACnGC,EAACiB,EAAAA,CAAmBC,cAAe1D,EAAM0D,cAAeC,UAAW3D,EAAM2D,UAAWlD,OAAQA,MAtBjG+B,EAACiB,EAAAA,CAAmBC,cAAe1D,EAAM0D,cAAeC,UAAW3D,EAAM2D,UAAWlD,OAAQA,GA2B3G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrisComponent.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import r from"../../../core/Context/useImage.js";import o from"./IrisGenerateQRCode.module.scss.js";function s(s){const{i18n:a}=t(),n=r();return e("div",{"data-testid":"iris-generate-qr-code"},e("p",{className:o.instruction},a.get("iris.instructions.generateQrCode")),s.showPayButton&&s.payButton({label:a.get("generateQRCode"),icon:n({imageFolder:"components/"})("qr"),status:s.status}))}export{s as default};
|
|
2
|
+
//# sourceMappingURL=IrisGenerateQRCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrisGenerateQRCode.js","sources":["../../../../../src/components/Iris/components/IrisGenerateQRCode.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport useImage from '../../../core/Context/useImage';\nimport { UIElementStatus } from '../../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport styles from './IrisGenerateQRCode.module.scss';\n\ninterface IrisGenerateQRCodeProps {\n showPayButton?: boolean;\n payButton: (props: Partial<PayButtonProps>) => h.JSX.Element;\n status: UIElementStatus;\n}\n\nexport default function IrisGenerateQRCode(props: Readonly<IrisGenerateQRCodeProps>) {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n <div data-testid=\"iris-generate-qr-code\">\n <p className={styles.instruction}>{i18n.get('iris.instructions.generateQrCode')}</p>\n {props.showPayButton &&\n props.payButton({\n label: i18n.get('generateQRCode'),\n icon: getImage({ imageFolder: 'components/' })('qr'),\n status: props.status\n })}\n </div>\n );\n}\n"],"names":["IrisGenerateQRCode","props","i18n","useCoreContext","getImage","useImage","h","div","data-testid","p","className","styles","instruction","get","showPayButton","payButton","label","icon","imageFolder","status"],"mappings":"mPAae,SAASA,EAAmBC,GACvC,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OACIC,EAACC,MAAAA,CAAIC,cAAY,yBACbF,EAACG,IAAAA,CAAEC,UAAWC,EAAOC,aAAcV,EAAKW,IAAI,qCAC3CZ,EAAMa,eACHb,EAAMc,UAAU,CACZC,MAAOd,EAAKW,IAAI,kBAChBI,KAAMb,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,MAC/Ce,OAAQlB,EAAMkB,SAIlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrisGenerateQRCode.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as t}from"../../../external/preact/dist/preact.js";import{TimelineWrapper as e}from"../../internal/Timeline/TimelineWrapper.js";import{Timeline as i}from"../../internal/Timeline/Timeline.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";const n=()=>{const{i18n:n}=r();return t(e,null,t(i,{instructions:[n.get("iris.instructions.payment.step1"),n.get("iris.instructions.payment.step2"),n.get("iris.instructions.payment.step3")]}))};export{n as IrisQrCodeInstructions};
|
|
2
|
+
//# sourceMappingURL=IrisQrCodeInstructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IrisQrCodeInstructions.js","sources":["../../../../../src/components/Iris/components/IrisQrCodeInstructions.tsx"],"sourcesContent":["import { h } from 'preact';\n\nimport { Timeline, TimelineWrapper } from '../../internal/Timeline';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\n\nexport const IrisQrCodeInstructions = () => {\n const { i18n } = useCoreContext();\n return (\n <TimelineWrapper>\n <Timeline\n instructions={[\n i18n.get('iris.instructions.payment.step1'),\n i18n.get('iris.instructions.payment.step2'),\n i18n.get('iris.instructions.payment.step3')\n ]}\n />\n </TimelineWrapper>\n );\n};\n"],"names":["IrisQrCodeInstructions","i18n","useCoreContext","h","TimelineWrapper","Timeline","instructions","get"],"mappings":"iSAKaA,EAAyB,KAClC,MAAMC,KAAEA,GAASC,IACjB,OACIC,EAACC,OACGD,EAACE,EAAAA,CACGC,aAAc,CACVL,EAAKM,IAAI,mCACTN,EAAKM,IAAI,mCACTN,EAAKM,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/Iris/constants.ts"],"sourcesContent":["export const IRIS_ALLY_LABELS = {\n ButtonId: {\n BANK_LIST: 'iris-button-bank-list',\n QR_CODE: 'iris-button-qrCode'\n },\n AreaId: {\n BANK_LIST: 'iris-area-bank-list',\n QR_CODE: 'iris-area-qrCode'\n }\n};\n\nexport const DEFAULT_IRIS_COUNTDOWN_TIME = 10;\n"],"names":["IRIS_ALLY_LABELS","ButtonId","BANK_LIST","QR_CODE","AreaId","DEFAULT_IRIS_COUNTDOWN_TIME"],"mappings":"MAAaA,EAAmB,CAC5BC,SAAU,CACNC,UAAW,wBACXC,QAAS,sBAEbC,OAAQ,CACJF,UAAW,sBACXC,QAAS,qBAIJE,EAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/components/Iris/types.ts"],"sourcesContent":["import { IssuerListConfiguration, QRLoaderConfiguration } from '../types';\n\nexport type IrisConfiguration = IssuerListConfiguration & Pick<QRLoaderConfiguration, 'countdownTime' | 'qrCodeData' | 'paymentData' | 'delay'>;\n\n/**\n * Iris data format for /payment request\n * @internal\n */\nexport interface IrisData {\n paymentMethod: {\n type: string;\n issuer?: string;\n };\n}\n\n/**\n * Iris component display modes\n * @internal\n */\nexport enum IrisMode {\n QR_CODE = 'qrCode',\n BANK_LIST = 'bankList'\n}\n"],"names":["IrisMode"],"mappings":"AAmBO,IAAKA,EAAAA,SAAAA,GAAAA,iDAAAA,CAGX,CAHWA,CAGX,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{IRIS_ALLY_LABELS as t}from"./constants.js";import{IrisMode as o}from"./types.js";const e=(e,r)=>[{label:e.get("qrCode"),value:o.QR_CODE,id:t.ButtonId.QR_CODE,controls:t.AreaId.QR_CODE},{label:e.get("bankList"),value:o.BANK_LIST,id:t.ButtonId.BANK_LIST,controls:t.AreaId.BANK_LIST}].sort((t,o)=>t.value===r?-1:o.value===r?1:0);export{e as getIrisSegmentedControlOptions};
|
|
2
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/Iris/utils.ts"],"sourcesContent":["import Language from '../../language';\nimport { SegmentedControlOption } from '../internal/SegmentedControl/SegmentedControl';\nimport { IRIS_ALLY_LABELS } from './constants';\nimport { IrisMode } from './types';\n\nexport const getIrisSegmentedControlOptions = (i18n: Language, defaultMode: IrisMode): SegmentedControlOption<IrisMode>[] => {\n const options = [\n {\n label: i18n.get('qrCode'),\n value: IrisMode.QR_CODE,\n id: IRIS_ALLY_LABELS.ButtonId.QR_CODE,\n controls: IRIS_ALLY_LABELS.AreaId.QR_CODE\n },\n {\n label: i18n.get('bankList'),\n value: IrisMode.BANK_LIST,\n id: IRIS_ALLY_LABELS.ButtonId.BANK_LIST,\n controls: IRIS_ALLY_LABELS.AreaId.BANK_LIST\n }\n ];\n\n return options.sort((a, b) => {\n if (a.value === defaultMode) return -1;\n if (b.value === defaultMode) return 1;\n return 0;\n });\n};\n"],"names":["getIrisSegmentedControlOptions","i18n","defaultMode","label","get","value","IrisMode","QR_CODE","id","IRIS_ALLY_LABELS","ButtonId","controls","AreaId","BANK_LIST","sort","a","b"],"mappings":"wFAKO,MAAMA,EAAiC,CAACC,EAAgBC,IAC3C,CACZ,CACIC,MAAOF,EAAKG,IAAI,UAChBC,MAAOC,EAASC,QAChBC,GAAIC,EAAiBC,SAASH,QAC9BI,SAAUF,EAAiBG,OAAOL,SAEtC,CACIJ,MAAOF,EAAKG,IAAI,YAChBC,MAAOC,EAASO,UAChBL,GAAIC,EAAiBC,SAASG,UAC9BF,SAAUF,EAAiBG,OAAOC,YAI3BC,KAAK,CAACC,EAAGC,IAChBD,EAAEV,QAAUH,GAAoB,EAChCc,EAAEX,QAAUH,EAAoB,EAC7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useRef as n,useEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import{KlarnaWidget as o}from"../KlarnaWidget/KlarnaWidget.js";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useRef as n,useEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import{KlarnaWidget as o}from"../KlarnaWidget/KlarnaWidget.js";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(e,t){if(null==e)return{};var n,r,o,a={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(n=Reflect.ownKeys(e),o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}if(a=function(e,t){if(null==e)return{};var n,r,o={},a=Object.getOwnPropertyNames(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(n=Object.getOwnPropertySymbols(e),o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r]);return a}function c(c){let{setComponentRef:p}=c,s=l(c,["setComponentRef"]);const[u,y]=t(null),[f,d]=t(),[b,O]=t("ready"),m=n({setAction:e=>{d(e),y((new Date).getTime())},setStatus:e=>O(e),reinitializeWidget:()=>{y((new Date).getTime())}});return r(()=>{p(m.current)},[p]),(null==f?void 0:f.sdkData)?e(o,{widgetInitializationTime:u,sdkData:f.sdkData,paymentMethodType:f.paymentMethodType,paymentData:f.paymentData,payButton:s.payButton,onComplete:s.onComplete,onError:s.onError,onLoaded:()=>{var e;null===(e=s.onActionHandled)||void 0===e||e.call(s,{componentType:s.type,actionDescription:"sdk-loaded",originalAction:f}),s.onLoaded()}}):s.showPayButton?s.payButton(i(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){a(e,t,n[t])})}return e}({},s),{status:b,disabled:"loading"===b,classNameModifiers:["standalone"],label:`${this.props.i18n.get("continueTo")} ${s.displayName}`})):null}export{c as KlarnaContainer};
|
|
2
2
|
//# sourceMappingURL=KlarnaContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlarnaContainer.js","sources":["../../../../../../src/components/Klarna/components/KlarnaContainer/KlarnaContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { KlarnaWidget } from '../KlarnaWidget/KlarnaWidget';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementStatus } from '../../../internal/UIElement/types';\nimport type { ActionHandledReturnObject } from '../../../../types/global-types';\nimport type { AdyenCheckoutError, KlarnaAction, KlarnaAdditionalDetailsData, KlarnaComponentRef } from '../../../../types';\n\ninterface KlarnaContainerProps {\n setComponentRef: (ref: ComponentMethodsRef) => void;\n displayName: string;\n showPayButton: boolean;\n type: string;\n onComplete(state: KlarnaAdditionalDetailsData): void;\n onError(error: AdyenCheckoutError): void;\n payButton(props?: PayButtonFunctionProps): h.JSX.Element;\n onLoaded(): void;\n onActionHandled(actionHandled: ActionHandledReturnObject): void;\n}\n\nexport function KlarnaContainer({ setComponentRef, ...props }: KlarnaContainerProps) {\n const [widgetInitializationTime, setWidgetInitializationTime] = useState<number>(null);\n const [action, setAction] = useState<KlarnaAction>();\n const [status, setStatus] = useState('ready');\n const klarnaRef = useRef<KlarnaComponentRef>({\n setAction: (action: KlarnaAction) => {\n setAction(action);\n setWidgetInitializationTime(new Date().getTime());\n },\n setStatus: (status: UIElementStatus) => setStatus(status),\n reinitializeWidget: () => {\n setWidgetInitializationTime(new Date().getTime());\n }\n });\n\n useEffect(() => {\n setComponentRef(klarnaRef.current);\n }, [setComponentRef]);\n\n if (action?.sdkData) {\n return (\n <KlarnaWidget\n widgetInitializationTime={widgetInitializationTime}\n sdkData={action.sdkData}\n paymentMethodType={action.paymentMethodType}\n paymentData={action.paymentData}\n payButton={props.payButton}\n onComplete={props.onComplete}\n onError={props.onError}\n onLoaded={() => {\n props.onActionHandled?.({ componentType: props.type, actionDescription: 'sdk-loaded', originalAction: action });\n props.onLoaded();\n }}\n />\n );\n }\n\n if (props.showPayButton) {\n return props.payButton({\n ...props,\n status,\n disabled: status === 'loading',\n classNameModifiers: ['standalone'],\n label: `${this.props.i18n.get('continueTo')} ${props.displayName}`\n });\n }\n\n return null;\n}\n"],"names":["KlarnaContainer","
|
|
1
|
+
{"version":3,"file":"KlarnaContainer.js","sources":["../../../../../../src/components/Klarna/components/KlarnaContainer/KlarnaContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { KlarnaWidget } from '../KlarnaWidget/KlarnaWidget';\nimport type { ComponentMethodsRef, PayButtonFunctionProps, UIElementStatus } from '../../../internal/UIElement/types';\nimport type { ActionHandledReturnObject } from '../../../../types/global-types';\nimport type { AdyenCheckoutError, KlarnaAction, KlarnaAdditionalDetailsData, KlarnaComponentRef } from '../../../../types';\n\ninterface KlarnaContainerProps {\n setComponentRef: (ref: ComponentMethodsRef) => void;\n displayName: string;\n showPayButton: boolean;\n type: string;\n onComplete(state: KlarnaAdditionalDetailsData): void;\n onError(error: AdyenCheckoutError): void;\n payButton(props?: PayButtonFunctionProps): h.JSX.Element;\n onLoaded(): void;\n onActionHandled(actionHandled: ActionHandledReturnObject): void;\n}\n\nexport function KlarnaContainer({ setComponentRef, ...props }: KlarnaContainerProps) {\n const [widgetInitializationTime, setWidgetInitializationTime] = useState<number>(null);\n const [action, setAction] = useState<KlarnaAction>();\n const [status, setStatus] = useState('ready');\n const klarnaRef = useRef<KlarnaComponentRef>({\n setAction: (action: KlarnaAction) => {\n setAction(action);\n setWidgetInitializationTime(new Date().getTime());\n },\n setStatus: (status: UIElementStatus) => setStatus(status),\n reinitializeWidget: () => {\n setWidgetInitializationTime(new Date().getTime());\n }\n });\n\n useEffect(() => {\n setComponentRef(klarnaRef.current);\n }, [setComponentRef]);\n\n if (action?.sdkData) {\n return (\n <KlarnaWidget\n widgetInitializationTime={widgetInitializationTime}\n sdkData={action.sdkData}\n paymentMethodType={action.paymentMethodType}\n paymentData={action.paymentData}\n payButton={props.payButton}\n onComplete={props.onComplete}\n onError={props.onError}\n onLoaded={() => {\n props.onActionHandled?.({ componentType: props.type, actionDescription: 'sdk-loaded', originalAction: action });\n props.onLoaded();\n }}\n />\n );\n }\n\n if (props.showPayButton) {\n return props.payButton({\n ...props,\n status,\n disabled: status === 'loading',\n classNameModifiers: ['standalone'],\n label: `${this.props.i18n.get('continueTo')} ${props.displayName}`\n });\n }\n\n return null;\n}\n"],"names":["KlarnaContainer","_0","setComponentRef","props","widgetInitializationTime","setWidgetInitializationTime","useState","action","setAction","status","setStatus","klarnaRef","useRef","Date","getTime","reinitializeWidget","useEffect","current","sdkData","h","KlarnaWidget","paymentMethodType","paymentData","payButton","onComplete","onError","onLoaded","onActionHandled","componentType","type","actionDescription","originalAction","showPayButton","_object_spread_props","_object_spread","disabled","classNameModifiers","label","this","i18n","get","displayName"],"mappings":"s0CAmBO,SAASA,EAAgBC,OAAAC,gBAAEA,GAAiDD,EAA7BE,EAAAA,EAAAA,EAAAA,qBAClD,MAAOC,EAA0BC,GAA+BC,EAAiB,OAC1EC,EAAQC,GAAaF,KACrBG,EAAQC,GAAaJ,EAAS,SAC/BK,EAAYC,EAA2B,CACzCJ,UAAYD,IACRC,EAAUD,GACVF,GAA4B,IAAIQ,MAAOC,YAE3CJ,UAAYD,GAA4BC,EAAUD,GAClDM,mBAAoB,KAChBV,GAA4B,IAAIQ,MAAOC,cAQ/C,OAJAE,EAAU,KACNd,EAAgBS,EAAUM,UAC3B,CAACf,KAEAK,aAAAA,EAAAA,EAAQW,SAEJC,EAACC,EAAAA,CACGhB,yBAA0BA,EAC1Bc,QAASX,EAAOW,QAChBG,kBAAmBd,EAAOc,kBAC1BC,YAAaf,EAAOe,YACpBC,UAAWpB,EAAMoB,UACjBC,WAAYrB,EAAMqB,WAClBC,QAAStB,EAAMsB,QACfC,SAAU,KACNvB,IAAAA,EAAqB,QAArBA,EAAAA,EAAMwB,uBAANxB,IAAAA,GAAAA,OAAAA,EAAwB,CAAEyB,cAAezB,EAAM0B,KAAMC,kBAAmB,aAAcC,eAAgBxB,IACtGJ,EAAMuB,cAMlBvB,EAAM6B,cACC7B,EAAMoB,UAAUU,oUAAAC,CAAA,CAAA,EAChB/B,GAAAA,CACHM,SACA0B,SAAqB,YAAX1B,EACV2B,mBAAoB,CAAC,cACrBC,MAAO,GAAGC,KAAKnC,MAAMoC,KAAKC,IAAI,iBAAiBrC,EAAMsC,iBAItD,IACX"}
|