@adyen/adyen-web 6.41.0 → 6.42.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/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +48 -33
- 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/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/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/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/Dropin/utils/paymentMethodsAnalytics.js +2 -0
- package/dist/es/components/Dropin/utils/paymentMethodsAnalytics.js.map +1 -0
- 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.map +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/constants.js +1 -1
- package/dist/es/components/ThreeDS2/constants.js.map +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/Address/validate.formats.js +1 -1
- package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es/components/internal/Address/validate.js +1 -1
- package/dist/es/components/internal/Address/validate.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/Button/CopyButton.js +1 -1
- package/dist/es/components/internal/Button/CopyButton.js.map +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js +1 -1
- package/dist/es/components/internal/Button/CopyIconButton.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es/components/internal/IFrame/Iframe.js +1 -1
- package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Modal/Modal.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
- package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.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/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.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/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.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/PaymentAction/actionTypes.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/index.d.ts +48 -33
- package/dist/es/utils/validator-utils.js +1 -1
- package/dist/es/utils/validator-utils.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/types.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/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/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/DisableOneClickConfirmation.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.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/utils/paymentMethodsAnalytics.js +2 -0
- package/dist/es-legacy/components/Dropin/utils/paymentMethodsAnalytics.js.map +1 -0
- 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.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/constants.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/constants.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js +1 -1
- package/dist/es-legacy/components/internal/Button/Button.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/ClickToPay/ClickToPayComponent.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPSection.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.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/IFrame/Iframe.js +1 -1
- package/dist/es-legacy/components/internal/IFrame/Iframe.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/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/SFP/defaultProps.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/configureCallbacks.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/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/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/utils/validator-utils.js +1 -1
- package/dist/es-legacy/utils/validator-utils.js.map +1 -1
- package/package.json +19 -19
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import
|
|
1
|
+
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/GiftcardComponent.js";import s from"../internal/PayButton/PayButton.js";import n from"../../core/Errors/AdyenCheckoutError.js";import{TxVariants as a}from"../tx-variants.js";function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class o extends e{formatProps(t){return{...t?.configuration,...t}}formatData(){return{paymentMethod:{type:this.constructor.type,brand:this.props.brand,encryptedCardNumber:this.state.data?.encryptedCardNumber,encryptedSecurityCode:this.state.data?.encryptedSecurityCode}}}get isValid(){return!!this.state.isValid}get icon(){return this.props.brandsConfiguration[this.props.brand]?.icon||this.props.icon||this.resources.getImage()(this.props.brand)}get displayName(){return this.props.brandsConfiguration[this.props.brand]?.name||this.props.name}setBalanceCheckError(t){this.componentRef?.setBalanceCheckErrors?.(t)}balanceCheck(){return this.onBalanceCheck()}submit(){this.balanceCheck()}makeSubmitCall(){super.submit()}componentToRender(){return t(r,{ref:t=>{this.componentRef=t},...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(...e){super(...e),i(this,"componentRef",void 0),i(this,"handleBalanceCheck",t=>this.props.onBalanceCheck?new Promise((e,r)=>{this.props.onBalanceCheck(e,r,t)}):this.props.session?this.props.session.checkBalance(t):void 0),i(this,"onOrderRequest",t=>this.props.onOrderRequest?new Promise((e,r)=>{this.props.onOrderRequest(e,r,t)}):this.props.session?this.props.session.createOrder():void 0),i(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:t,transactionLimit:e={}})=>{if(this.setBalanceCheckError(null),!t)throw new Error("card-error");if(t?.currency!==this.props.amount?.currency)throw new Error("currency-error");if(t?.value<=0)throw new Error("no-balance");return this.props.amount.value>t.value||this.props.amount.value>e.value?this.props.order?this.makeSubmitCall():this.onOrderRequest(this.data).then(t=>(this.setState({order:{orderData:t.orderData,pspReference:t.pspReference}}),this.makeSubmitCall())):this.handleOnRequiringConfirmation(t,e)}).catch(t=>{this.setBalanceCheckError(t?.message),t instanceof n?this.handleError(t):this.handleError(new n("ERROR",t))})}),i(this,"handleOnRequiringConfirmation",(t,e)=>{if(this.componentRef.setBalance({balance:t,transactionLimit:e}),this.setStatus("ready"),!this.props.showPayButton){if(!this.props.onRequiringConfirmation)throw new n("IMPLEMENTATION_ERROR","onRequiringConfirmation must be provided");return new Promise((t,e)=>{this.props.onRequiringConfirmation(t,e)}).then(()=>this.makeSubmitCall()).catch(()=>{})}}),i(this,"payButton",e=>t(s,e))}}i(o,"type",a.giftcard),i(o,"defaultProps",{brandsConfiguration:{}});export{o as GiftcardElement,o 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';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly 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: PaymentAmount, transactionLimit: PaymentAmount): Promise<void> | void => {\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 protected override payButton = (props: PayButtonProps) => {\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 handleKeyDown={this.handleKeyDown}\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","configuration","formatData","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","componentRef","setBalanceCheckErrors","balanceCheck","onBalanceCheck","submit","makeSubmitCall","super","componentToRender","h","GiftcardComponent","ref","handleKeyDown","showPayButton","onChange","setState","makeBalanceCheck","makePayment","payButton","onSubmitAnalytics","submitAnalytics","args","_define_property","handleBalanceCheck","Promise","resolve","reject","session","checkBalance","onOrderRequest","createOrder","showValidation","setStatus","then","balance","transactionLimit","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"qcAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,MAAO,IACAA,GAAOC,iBACPD,EAEX,CAEAE,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKL,MAAMO,MAClBC,oB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,MAAMsE,wBAAwBzB,EAASC,KAGhDO,KAAK,IAAMhD,KAAKqB,kBAEhBsC,MAAM,OAbf,IA6BJtB,EAAArC,KAAmBiC,YAAatC,GACrB6B,EAAC0C,EAAcvE,KA5J1B0C,EADS7C,EACcO,OAAmBoE,EAAWC,UAIrD/B,EALS7C,EAKiB6E,eAAe,CACrC5D,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';\nimport { PayButtonProps } from '../internal/PayButton/PayButton';\n\nexport class GiftcardElement extends UIElement<GiftCardConfiguration> {\n public static readonly type: TxVariants = TxVariants.giftcard;\n\n protected componentRef: GiftcardComponent | undefined;\n\n protected static readonly 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: PaymentAmount, transactionLimit: PaymentAmount): Promise<void> | void => {\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 protected override payButton = (props: PayButtonProps) => {\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","configuration","formatData","paymentMethod","type","this","constructor","brand","encryptedCardNumber","state","data","encryptedSecurityCode","isValid","icon","brandsConfiguration","resources","getImage","displayName","name","setBalanceCheckError","errorMessage","componentRef","setBalanceCheckErrors","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","Error","currency","amount","value","order","orderData","pspReference","handleOnRequiringConfirmation","catch","error","message","AdyenCheckoutError","handleError","setBalance","onRequiringConfirmation","PayButton","TxVariants","giftcard","defaultProps"],"mappings":"qcAUO,MAAMA,UAAwBC,EASjCC,WAAAA,CAAYC,GACR,MAAO,IACAA,GAAOC,iBACPD,EAEX,CAEAE,UAAAA,GACI,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKC,YAAY,KACvBC,MAAOF,KAAKL,MAAMO,MAClBC,oBAAqBH,KAAKI,MAAMC,MAAMF,oBACtCG,sBAAuBN,KAAKI,MAAMC,MAAMC,uBAGpD,CAEA,WAAIC,GACA,QAASP,KAAKI,MAAMG,OACxB,CAEA,QAAIC,GACA,OAAOR,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQM,MAAQR,KAAKL,MAAMa,MAAQR,KAAKU,UAAUC,UAAfX,CAA0BA,KAAKL,MAAMO,MAC7H,CAEA,eAAIU,GACA,OAAOZ,KAAKL,MAAMc,oBAAoBT,KAAKL,MAAMO,QAAQW,MAAQb,KAAKL,MAAMkB,IAChF,CAEQC,oBAAAA,CAAqBC,GACzBf,KAAKgB,cAAcC,wBAAwBF,EAC/C,CAwBOG,YAAAA,GACH,OAAOlB,KAAKmB,gBAChB,CA6EOC,MAAAA,GAGHpB,KAAKkB,cACT,CAGQG,cAAAA,GACJC,MAAMF,QACV,CAOmBG,iBAAAA,GACf,OACIC,EAACC,EAAAA,CACGC,IAAKA,IACD1B,KAAKgB,aAAeU,MAEpB1B,KAAKL,MACTgC,eAAgB3B,KAAK2B,eACrBC,cAAe5B,KAAKL,MAAMiC,cAC1BC,SAAU7B,KAAK8B,SACfC,iBAAkB,IAAM/B,KAAKmB,iBAC7Ba,YAAa,IAAMhC,KAAKqB,iBACxBY,UAAWjC,KAAKiC,UAChBC,kBAAmBlC,KAAKmC,iBAGpC,mBAhLGb,SAAAc,GAGHC,OAAUrB,oBAAV,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EACjB9D,KAAK+D,YAAYH,GAEjB5D,KAAK+D,YAAY,IAAID,EAAmB,QAASF,QAQjEvB,EAAArC,KAAQ0D,gCAAgC,CAACT,EAAwBC,KAK7D,GAJAlD,KAAKgB,aAAagD,WAAW,CAAEf,UAASC,qBACxClD,KAAK+C,UAAU,UAGX/C,KAAKL,MAAMiC,cAAf,CAIA,IAAK5B,KAAKL,MAAMsE,wBACZ,MAAM,IAAIH,EAAmB,uBAAwB,4CAGzD,OACI,IAAIvB,QAAc,CAACC,EAASC,KACnBzC,KAAKL,MAAMsE,wBAAwBzB,EAASC,KAGhDO,KAAK,IAAMhD,KAAKqB,kBAEhBsC,MAAM,OAbf,IA6BJtB,EAAArC,KAAmBiC,YAAatC,GACrB6B,EAAC0C,EAAcvE,KA5J1B0C,EADS7C,EACcO,OAAmBoE,EAAWC,UAIrD/B,EALS7C,EAKiB6E,eAAe,CACrC5D,oBAAqB,CAAA"}
|
|
@@ -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 { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType, GiftCardValidationError } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\n pinRequired: boolean;\n expiryDateRequired?: boolean;\n fieldsLayoutComponent: FunctionComponent<GiftcardFieldsProps>;\n placeholders?: Placeholders;\n handleKeyDown?: (event: KeyboardEvent) => void;\n onSubmitAnalytics?: (event: AbstractAnalyticsEvent) => void;\n}\n\nclass Giftcard extends Component<Readonly<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 readonly 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, GiftCardValidationError>) => {\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, GiftCardValidationError> {\n const balanceCheckErrors: Record<string, GiftCardValidationError> = {};\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 public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\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 clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\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","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"isBA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA8D,CAAA,EAMpE,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAkBH,IAChCI,MAAOJ,IAPAC,CAWf,CAKQI,mBAAAA,CAAoBC,GACxB,MAAO,CAAC,aAAc,aAAc,kBAAkBC,SAASD,EACnE,CA2BAE,MAAAA,CAAOC,GAAOC,eAAEA,EAAcC,QAAEA,EAAOC,iBAAEA,EAAgBC,aAAEA,EAAYC,kBAAEA,IACrE,MAAMC,KAAEA,GAASC,KACXC,OAAEA,GAAWC,IAGnBC,EAA4B,CACxBC,OAAQN,EACRD,eACAQ,gBAAiBC,KAAKD,gBACtBE,IAAKD,KAAKC,MAGd,MAAMC,EAAoBZ,GAAkBa,MAAQd,GAASc,MAAQb,EAAmBD,EAGxF,GAAIa,GAFqBA,GAAmBC,OAASR,GAAQQ,MAGzD,OACIC,EAACC,EAAAA,CACGhB,QAASA,EACTC,iBAAkBA,EAClBgB,YAAanB,EAAMmB,YACnBtB,OAAQgB,KAAKO,MAAMvB,OACnBwB,iBAAkBrB,EAAMqB,iBACxBC,cAAeT,KAAKb,MAAMsB,cAC1BC,UAAWV,KAAKb,MAAMuB,YAKlC,MAAMC,EAAsBC,GACpBA,EAASd,OAAOe,oBAA4BpB,EAAKqB,IAAIF,EAASd,OAAOe,qBAIrErB,EAAkBqB,oBACXpB,EAAKqB,IAAItB,EAAkBqB,oBAAoBhC,cAGnD,KAGX,OACIu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C1C,KAAKb,MAAMoC,SAAS,CAChBgB,KAAM3B,EAAS2B,KACf3D,QAASgC,EAASiC,eAI1BP,EAAAtC,KAAOyB,cAAcqB,IACjB9C,KAAK4C,SAAS,CAAExD,eAAgB0D,EAAEC,sBAEJ,IAAZD,EAAEE,MAEhBhD,KAAKb,MAAMqC,QAAQsB,GAEnB9C,KAAKb,MAAM8D,OAAOH,KAI1BR,OAAOY,aAAa,EAAG7D,UAASC,uBAC5BU,KAAK4C,SAAS,CAAEvD,UAASC,uBAsC7BgD,EAAAtC,KAAOmD,wBAAyBzE,IAE5B,GAAIsB,KAAKjB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK0C,wBAAwB/D,EACjC,IAGJ2D,OAAOc,iBAAiB,KACpBpD,KAAK4C,SAAS,CAAErD,cAAc,IAG9BS,KAAKC,KAAKmD,mBAGdd,EAAAtC,KAAOD,kBAAmBsD,IACtBrD,KAAK4C,SAAS,CAAErD,aAAc8D,OA1GlCf,EAbE/D,EAaqB+E,eAAe,CAClCrB,aAAa,EACbsB,oBAAoB,EACpBhC,SAAU,OACVC,QAAS,OACTyB,OAAQ,OACRjB,sBAAuBwB"}
|
|
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 { GIFT_CARD } from '../../internal/SecuredFields/lib/constants';\nimport { GiftCardFields } from './GiftcardFields';\nimport { GiftcardFieldsProps, Placeholders } from './types';\nimport { useSRPanelForGiftcardErrors } from './useSRPanelForGiftcardErrors';\nimport { GiftCardBalanceCheckErrorType, GiftCardValidationError } from '../types';\nimport { PayButtonProps } from '../../internal/PayButton/PayButton';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport type { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport type { SFPProps } from '../../internal/SecuredFields/SFP/types';\n\ninterface GiftcardComponentProps extends Partial<Pick<SFPProps, 'clientKey' | 'loadingContext'>> {\n onChange: (state) => void;\n onFocus: (event) => void;\n onBlur: (event) => void;\n makeBalanceCheck: (event) => void;\n makePayment: (event) => void;\n showPayButton: boolean;\n payButton: (props: PayButtonProps) => h.JSX.Element;\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<Readonly<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 readonly 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, GiftCardValidationError>) => {\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, GiftCardValidationError> {\n const balanceCheckErrors: Record<string, GiftCardValidationError> = {};\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 public setIsValidating = (val: boolean) => {\n this.setState({ isValidating: val });\n };\n\n render(props, { focusedElement, balance, transactionLimit, isValidating, transformedErrors }) {\n const { i18n } = useCoreContext();\n const { amount } = useAmount();\n\n // Handle SRPanel errors in render with transformed error objects\n useSRPanelForGiftcardErrors({\n errors: transformedErrors,\n isValidating,\n setIsValidating: this.setIsValidating,\n sfp: this.sfp\n });\n\n const transactionAmount = transactionLimit?.value < balance?.value ? transactionLimit : balance;\n const hasEnoughBalance = transactionAmount?.value >= amount?.value;\n\n if (transactionAmount && hasEnoughBalance) {\n return (\n <GiftcardResult\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 clientKey={this.props.clientKey}\n loadingContext={this.props.loadingContext}\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","i18n","useCoreContext","amount","useAmount","useSRPanelForGiftcardErrors","errors","setIsValidating","this","sfp","transactionAmount","value","h","GiftcardResult","makePayment","state","makeBalanceCheck","showPayButton","payButton","getCardErrorMessage","sfpState","encryptedCardNumber","get","div","className","Alert","icon","SecuredFieldsProvider","clientKey","loadingContext","ref","onChange","onFocus","handleFocus","onSubmitAnalytics","type","GIFT_CARD","componentType","setRootNode","setFocusOn","fieldsLayoutComponent","pinRequired","onClick","label","super","args","_define_property","data","mapErrorsToValidationObjects","mapErrorsToValidationRuleResult","updateTransformedErrors","mergedErrors","setState","isSfpValid","e","currentFocusObject","focus","onBlur","setBalance","setBalanceCheckErrors","showValidation","val","defaultProps","expiryDateRequired","GiftCardFields"],"mappings":"isBA+BA,MAAMA,UAAiBC,EAqEXC,0BAAAA,CAA2BC,GAC/B,MAAMC,EAA8D,CAAA,EAMpE,OAAkB,OAAdD,IAKJC,sBAAsC,CAClCC,SAAS,EACTC,aAAc,kBAAkBH,IAChCI,MAAOJ,IAPAC,CAWf,CAKQI,mBAAAA,CAAoBC,GACxB,MAAO,CAAC,aAAc,aAAc,kBAAkBC,SAASD,EACnE,CA2BAE,MAAAA,CAAOC,GAAOC,eAAEA,EAAcC,QAAEA,EAAOC,iBAAEA,EAAgBC,aAAEA,EAAYC,kBAAEA,IACrE,MAAMC,KAAEA,GAASC,KACXC,OAAEA,GAAWC,IAGnBC,EAA4B,CACxBC,OAAQN,EACRD,eACAQ,gBAAiBC,KAAKD,gBACtBE,IAAKD,KAAKC,MAGd,MAAMC,EAAoBZ,GAAkBa,MAAQd,GAASc,MAAQb,EAAmBD,EAGxF,GAAIa,GAFqBA,GAAmBC,OAASR,GAAQQ,MAGzD,OACIC,EAACC,EAAAA,CACGhB,QAASA,EACTC,iBAAkBA,EAClBgB,YAAanB,EAAMmB,YACnBtB,OAAQgB,KAAKO,MAAMvB,OACnBwB,iBAAkBrB,EAAMqB,iBACxBC,cAAeT,KAAKb,MAAMsB,cAC1BC,UAAWV,KAAKb,MAAMuB,YAKlC,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3C,KAAKwC,kCAEiB7D,GAEhDqB,KAAK4C,SAAS,CAAEpD,kBAAmBmD,MAGvCL,EAAAtC,KAAOuB,WAAWX,IACdZ,KAAK4C,SAAS,CAAEhC,YAAY,IAAMZ,KAAK0C,2BAEvC1C,KAAKb,MAAMoC,SAAS,CAChBgB,KAAM3B,EAAS2B,KACf3D,QAASgC,EAASiC,eAI1BP,EAAAtC,KAAOyB,cAAcqB,IACjB9C,KAAK4C,SAAS,CAAExD,eAAgB0D,EAAEC,sBAEJ,IAAZD,EAAEE,MAEhBhD,KAAKb,MAAMqC,QAAQsB,GAEnB9C,KAAKb,MAAM8D,OAAOH,KAI1BR,OAAOY,aAAa,EAAG7D,UAASC,uBAC5BU,KAAK4C,SAAS,CAAEvD,UAASC,uBAsC7BgD,EAAAtC,KAAOmD,wBAAyBzE,IAE5B,GAAIsB,KAAKjB,oBAAoBL,GAAY,CAIrC,MAAMC,EAAqBqB,KAAKvB,2BAA2BC,GAC3DsB,KAAK0C,wBAAwB/D,EACjC,IAGJ2D,OAAOc,iBAAiB,KACpBpD,KAAK4C,SAAS,CAAErD,cAAc,IAG9BS,KAAKC,KAAKmD,mBAGdd,EAAAtC,KAAOD,kBAAmBsD,IACtBrD,KAAK4C,SAAS,CAAErD,aAAc8D,OA1GlCf,EAbE/D,EAaqB+E,eAAe,CAClCrB,aAAa,EACbsB,oBAAoB,EACpBhC,SAAU,OACVC,QAAS,OACTyB,OAAQ,OACRjB,sBAAuBwB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{httpPost as e}from"../../core/Services/http.js";import{pick as t}from"../../utils/commonUtils.js";import{THREEDS2_FINGERPRINT_SUBMIT as n}from"./constants.js";import{API_ERROR_CODE as o}from"../../core/Services/sessions/constants.js";import{AnalyticsErrorEvent as r,ErrorEventType as i,ErrorEventCode as s}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function a({data:a}){e({path:`v1/submitThreeDS2Fingerprint?token=${this.props.clientKey}`,loadingContext:this.props.loadingContext,errorLevel:"fatal",errorCode:o.submitThreeDS2Fingerprint},{...a}).then(e=>{let o;if("completed"===e.type){const{details:t}=e;return e.details?this.onComplete({data:{details:t}}):(console.debug('Handled Error::callSubmit3DS2Fingerprint::FAILED:: no details object in a response indicating either a "frictionless" flow, or a "refused" response. resData=',e),o=new r({component:"threeDS2Fingerprint",code:s.THREEDS2_NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED,errorType:i.threeDS2,message:`${n}: no details object in a response indicating either a "frictionless" flow, or a "refused" response`}),void this.submitAnalytics(o))}if(!e.action)return console.debug('Handled Error::callSubmit3DS2Fingerprint::FAILED:: no action object in a response indicating a "challenge". resData=',e),o=new r({component:"threeDS2Fingerprint",code:s.THREEDS2_NO_ACTION_FOR_CHALLENGE,errorType:i.threeDS2,message:`${n}: no action object in a response indicating a "challenge" flow`}),void this.submitAnalytics(o);const a=this.props.elementRef??this;return a?"threeDS2"===e.action?.type?a.handleAction(e.action,t("challengeWindowSize").from(this.props)):"redirect"===e.action?.type?a.handleAction(e.action):void 0:(console.debug("Handled Error::callSubmit3DS2Fingerprint::FAILED:: no actionHandler"),o=new r({component:"threeDS2Fingerprint",code:s.THREEDS2_NO_COMPONENT_FOR_ACTION,errorType:i.threeDS2,message:`${n}: no component defined to handle the action response`}),void this.submitAnalytics(o))}).catch(e=>{this.handleError(e)})}export{a as default};
|
|
1
|
+
import{httpPost as e}from"../../core/Services/http.js";import{pick as t}from"../../utils/commonUtils.js";import{THREEDS2_FINGERPRINT_SUBMIT as n}from"./constants.js";import{API_ERROR_CODE as o}from"../../core/Services/sessions/constants.js";import{AnalyticsErrorEvent as r,ErrorEventType as i,ErrorEventCode as s}from"../../core/Analytics/events/AnalyticsErrorEvent.js";function a({data:a}){e({path:`v1/submitThreeDS2Fingerprint?token=${this.props.clientKey}`,loadingContext:this.props.loadingContext,errorLevel:"fatal",errorCode:o.submitThreeDS2Fingerprint},{...a}).then(e=>{let o;if("completed"===e.type){const{details:t}=e;return e.details?this.onComplete({data:{details:t}}):(console.debug('Handled Error::callSubmit3DS2Fingerprint::FAILED:: no details object in a response indicating either a "frictionless" flow, or a "refused" response. resData=',e),o=new r({component:"threeDS2Fingerprint",code:s.THREEDS2_NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED,errorType:i.threeDS2,message:`${n}: no details object in a response indicating either a "frictionless" flow, or a "refused" response`}),void this.submitAnalytics(o))}if(!e.action)return console.debug('Handled Error::callSubmit3DS2Fingerprint::FAILED:: no action object in a response indicating a "challenge". resData=',e),o=new r({component:"threeDS2Fingerprint",code:s.THREEDS2_NO_ACTION_FOR_CHALLENGE,errorType:i.threeDS2,message:`${n}: no action object in a response indicating a "challenge" flow`}),void this.submitAnalytics(o);const a=this.props.elementRef??this;return a?"threeDS2"===e.action?.type?a.handleAction(e.action,t("challengeWindowSize","usePasskeyIFrameAttributes").from(this.props)):"redirect"===e.action?.type?a.handleAction(e.action):void 0:(console.debug("Handled Error::callSubmit3DS2Fingerprint::FAILED:: no actionHandler"),o=new r({component:"threeDS2Fingerprint",code:s.THREEDS2_NO_COMPONENT_FOR_ACTION,errorType:i.threeDS2,message:`${n}: no component defined to handle the action response`}),void this.submitAnalytics(o))}).catch(e=>{this.handleError(e)})}export{a as default};
|
|
2
2
|
//# sourceMappingURL=callSubmit3DS2Fingerprint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callSubmit3DS2Fingerprint.js","sources":["../../../../src/components/ThreeDS2/callSubmit3DS2Fingerprint.ts"],"sourcesContent":["import { httpPost } from '../../core/Services/http';\nimport { pick } from '../../utils/commonUtils';\nimport { ThreeDS2FingerprintResponse } from './types';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_FINGERPRINT_SUBMIT } from './constants';\nimport { API_ERROR_CODE } from '../../core/Services/sessions/constants';\nimport { AbstractAnalyticsEvent } from '../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\n/**\n * ThreeDS2DeviceFingerprint, onComplete, calls a new, internal, endpoint which\n * behaves like the /details endpoint but doesn't require the same credentials\n */\nexport default function callSubmit3DS2Fingerprint({ data }): void {\n httpPost<ThreeDS2FingerprintResponse>(\n {\n path: `v1/submitThreeDS2Fingerprint?token=${this.props.clientKey}`,\n loadingContext: this.props.loadingContext,\n errorLevel: 'fatal',\n errorCode: API_ERROR_CODE.submitThreeDS2Fingerprint\n },\n {\n ...data\n }\n )\n .then(resData => {\n let event: AbstractAnalyticsEvent;\n\n /**\n * Frictionless (no challenge) flow OR \"refused\" flow\n */\n if (resData.type === 'completed') {\n const { details } = resData;\n\n if (!resData.details) {\n console.debug(\n 'Handled Error::callSubmit3DS2Fingerprint::FAILED:: no details object in a response indicating either a \"frictionless\" flow, or a \"refused\" response. resData=',\n resData\n );\n\n event = new AnalyticsErrorEvent({\n component: 'threeDS2Fingerprint',\n code: ErrorEventCode.THREEDS2_NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_SUBMIT}: no details object in a response indicating either a \"frictionless\" flow, or a \"refused\" response`\n });\n\n this.submitAnalytics(event);\n\n return;\n }\n\n return this.onComplete({ data: { details } });\n }\n\n /**\n * If we don't have a type: \"completed\", then we expect an action, because we must be in a Challenge or Redirect flow\n */\n if (!resData.action) {\n console.debug(\n 'Handled Error::callSubmit3DS2Fingerprint::FAILED:: no action object in a response indicating a \"challenge\". resData=',\n resData\n );\n\n event = new AnalyticsErrorEvent({\n component: 'threeDS2Fingerprint',\n code: ErrorEventCode.THREEDS2_NO_ACTION_FOR_CHALLENGE,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_SUBMIT}: no action object in a response indicating a \"challenge\" flow`\n });\n this.submitAnalytics(event);\n\n return;\n }\n\n // elementRef exists when the fingerprint component is created from the Dropin\n const actionHandler = this.props.elementRef ?? this;\n\n /**\n * We have an action but do we have a way to handle it?\n * TODO - check logs: do we ever *not* have an actionHandler?\n */\n if (!actionHandler) {\n console.debug('Handled Error::callSubmit3DS2Fingerprint::FAILED:: no actionHandler');\n\n event = new AnalyticsErrorEvent({\n component: 'threeDS2Fingerprint',\n code: ErrorEventCode.THREEDS2_NO_COMPONENT_FOR_ACTION,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_SUBMIT}: no component defined to handle the action response`\n });\n\n this.submitAnalytics(event);\n\n return;\n }\n\n /**\n * Challenge flow\n */\n if (resData.action?.type === 'threeDS2') {\n // Ensure challengeWindowSize is propagated if there was a (merchant defined) handleAction call proceeding this one that had it set as an option\n return actionHandler.handleAction(resData.action, pick('challengeWindowSize').from(this.props));\n }\n\n /**\n * Redirect flow (usecase: we thought we could do 3DS2 but it turns out we can't)\n * TODO - check logs: does this ever happen, anymore?\n */\n if (resData.action?.type === 'redirect') {\n return actionHandler.handleAction(resData.action);\n }\n })\n .catch((error: AdyenCheckoutError) => {\n this.handleError(error);\n });\n}\n"],"names":["callSubmit3DS2Fingerprint","data","httpPost","path","this","props","clientKey","loadingContext","errorLevel","errorCode","API_ERROR_CODE","submitThreeDS2Fingerprint","then","resData","event","type","details","onComplete","console","debug","AnalyticsErrorEvent","component","code","ErrorEventCode","THREEDS2_NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED","errorType","ErrorEventType","threeDS2","message","THREEDS2_FINGERPRINT_SUBMIT","submitAnalytics","action","THREEDS2_NO_ACTION_FOR_CHALLENGE","actionHandler","elementRef","handleAction","pick","from","THREEDS2_NO_COMPONENT_FOR_ACTION","catch","error","handleError"],"mappings":"kXAae,SAASA,GAA0BC,KAAEA,IAChDC,EACI,CACIC,KAAM,sCAAsCC,KAAKC,MAAMC,YACvDC,eAAgBH,KAAKC,MAAME,eAC3BC,WAAY,QACZC,UAAWC,EAAeC,2BAE9B,IACOV,IAGNW,KAAKC,IACF,IAAIC,EAKJ,GAAqB,cAAjBD,EAAQE,KAAsB,CAC9B,MAAMC,QAAEA,GAAYH,EAEpB,OAAKA,EAAQG,QAkBNZ,KAAKa,WAAW,CAAEhB,KAAM,CAAEe,cAjB7BE,QAAQC,MACJ,gKACAN,GAGJC,EAAQ,IAAIM,EAAoB,CAC5BC,UAAW,sBACXC,KAAMC,EAAeC,gDACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,6GAGhBzB,KAAK0B,gBAAgBhB,GAM7B,CAKA,IAAKD,EAAQkB,OAcT,OAbAb,QAAQC,MACJ,uHACAN,GAGJC,EAAQ,IAAIM,EAAoB,CAC5BC,UAAW,sBACXC,KAAMC,EAAeS,iCACrBP,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,yEAEhBzB,KAAK0B,gBAAgBhB,GAMzB,MAAMmB,EAAgB7B,KAAKC,MAAM6B,YAAc9B,KAM/C,OAAK6B,EAkBwB,aAAzBpB,EAAQkB,QAAQhB,KAETkB,EAAcE,aAAatB,EAAQkB,OAAQK,EAAK,
|
|
1
|
+
{"version":3,"file":"callSubmit3DS2Fingerprint.js","sources":["../../../../src/components/ThreeDS2/callSubmit3DS2Fingerprint.ts"],"sourcesContent":["import { httpPost } from '../../core/Services/http';\nimport { pick } from '../../utils/commonUtils';\nimport { ThreeDS2FingerprintResponse } from './types';\nimport AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_FINGERPRINT_SUBMIT } from './constants';\nimport { API_ERROR_CODE } from '../../core/Services/sessions/constants';\nimport { AbstractAnalyticsEvent } from '../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../core/Analytics/events/AnalyticsErrorEvent';\n\n/**\n * ThreeDS2DeviceFingerprint, onComplete, calls a new, internal, endpoint which\n * behaves like the /details endpoint but doesn't require the same credentials\n */\nexport default function callSubmit3DS2Fingerprint({ data }): void {\n httpPost<ThreeDS2FingerprintResponse>(\n {\n path: `v1/submitThreeDS2Fingerprint?token=${this.props.clientKey}`,\n loadingContext: this.props.loadingContext,\n errorLevel: 'fatal',\n errorCode: API_ERROR_CODE.submitThreeDS2Fingerprint\n },\n {\n ...data\n }\n )\n .then(resData => {\n let event: AbstractAnalyticsEvent;\n\n /**\n * Frictionless (no challenge) flow OR \"refused\" flow\n */\n if (resData.type === 'completed') {\n const { details } = resData;\n\n if (!resData.details) {\n console.debug(\n 'Handled Error::callSubmit3DS2Fingerprint::FAILED:: no details object in a response indicating either a \"frictionless\" flow, or a \"refused\" response. resData=',\n resData\n );\n\n event = new AnalyticsErrorEvent({\n component: 'threeDS2Fingerprint',\n code: ErrorEventCode.THREEDS2_NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_SUBMIT}: no details object in a response indicating either a \"frictionless\" flow, or a \"refused\" response`\n });\n\n this.submitAnalytics(event);\n\n return;\n }\n\n return this.onComplete({ data: { details } });\n }\n\n /**\n * If we don't have a type: \"completed\", then we expect an action, because we must be in a Challenge or Redirect flow\n */\n if (!resData.action) {\n console.debug(\n 'Handled Error::callSubmit3DS2Fingerprint::FAILED:: no action object in a response indicating a \"challenge\". resData=',\n resData\n );\n\n event = new AnalyticsErrorEvent({\n component: 'threeDS2Fingerprint',\n code: ErrorEventCode.THREEDS2_NO_ACTION_FOR_CHALLENGE,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_SUBMIT}: no action object in a response indicating a \"challenge\" flow`\n });\n this.submitAnalytics(event);\n\n return;\n }\n\n // elementRef exists when the fingerprint component is created from the Dropin\n const actionHandler = this.props.elementRef ?? this;\n\n /**\n * We have an action but do we have a way to handle it?\n * TODO - check logs: do we ever *not* have an actionHandler?\n */\n if (!actionHandler) {\n console.debug('Handled Error::callSubmit3DS2Fingerprint::FAILED:: no actionHandler');\n\n event = new AnalyticsErrorEvent({\n component: 'threeDS2Fingerprint',\n code: ErrorEventCode.THREEDS2_NO_COMPONENT_FOR_ACTION,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_FINGERPRINT_SUBMIT}: no component defined to handle the action response`\n });\n\n this.submitAnalytics(event);\n\n return;\n }\n\n /**\n * Challenge flow\n */\n if (resData.action?.type === 'threeDS2') {\n // Ensure challengeWindowSize is propagated if there was a (merchant defined) handleAction call proceeding this one that had it set as an option\n return actionHandler.handleAction(resData.action, pick('challengeWindowSize', 'usePasskeyIFrameAttributes').from(this.props));\n }\n\n /**\n * Redirect flow (usecase: we thought we could do 3DS2 but it turns out we can't)\n * TODO - check logs: does this ever happen, anymore?\n */\n if (resData.action?.type === 'redirect') {\n return actionHandler.handleAction(resData.action);\n }\n })\n .catch((error: AdyenCheckoutError) => {\n this.handleError(error);\n });\n}\n"],"names":["callSubmit3DS2Fingerprint","data","httpPost","path","this","props","clientKey","loadingContext","errorLevel","errorCode","API_ERROR_CODE","submitThreeDS2Fingerprint","then","resData","event","type","details","onComplete","console","debug","AnalyticsErrorEvent","component","code","ErrorEventCode","THREEDS2_NO_DETAILS_FOR_FRICTIONLESS_OR_REFUSED","errorType","ErrorEventType","threeDS2","message","THREEDS2_FINGERPRINT_SUBMIT","submitAnalytics","action","THREEDS2_NO_ACTION_FOR_CHALLENGE","actionHandler","elementRef","handleAction","pick","from","THREEDS2_NO_COMPONENT_FOR_ACTION","catch","error","handleError"],"mappings":"kXAae,SAASA,GAA0BC,KAAEA,IAChDC,EACI,CACIC,KAAM,sCAAsCC,KAAKC,MAAMC,YACvDC,eAAgBH,KAAKC,MAAME,eAC3BC,WAAY,QACZC,UAAWC,EAAeC,2BAE9B,IACOV,IAGNW,KAAKC,IACF,IAAIC,EAKJ,GAAqB,cAAjBD,EAAQE,KAAsB,CAC9B,MAAMC,QAAEA,GAAYH,EAEpB,OAAKA,EAAQG,QAkBNZ,KAAKa,WAAW,CAAEhB,KAAM,CAAEe,cAjB7BE,QAAQC,MACJ,gKACAN,GAGJC,EAAQ,IAAIM,EAAoB,CAC5BC,UAAW,sBACXC,KAAMC,EAAeC,gDACrBC,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,6GAGhBzB,KAAK0B,gBAAgBhB,GAM7B,CAKA,IAAKD,EAAQkB,OAcT,OAbAb,QAAQC,MACJ,uHACAN,GAGJC,EAAQ,IAAIM,EAAoB,CAC5BC,UAAW,sBACXC,KAAMC,EAAeS,iCACrBP,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,yEAEhBzB,KAAK0B,gBAAgBhB,GAMzB,MAAMmB,EAAgB7B,KAAKC,MAAM6B,YAAc9B,KAM/C,OAAK6B,EAkBwB,aAAzBpB,EAAQkB,QAAQhB,KAETkB,EAAcE,aAAatB,EAAQkB,OAAQK,EAAK,sBAAuB,8BAA8BC,KAAKjC,KAAKC,QAO7F,aAAzBQ,EAAQkB,QAAQhB,KACTkB,EAAcE,aAAatB,EAAQkB,aAD9C,GA1BIb,QAAQC,MAAM,uEAEdL,EAAQ,IAAIM,EAAoB,CAC5BC,UAAW,sBACXC,KAAMC,EAAee,iCACrBb,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,+DAGhBzB,KAAK0B,gBAAgBhB,MAqB5ByB,MAAOC,IACJpC,KAAKqC,YAAYD,IAE7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as s}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import r from"../../../internal/IFrame/Iframe.js";import a from"../../../internal/Spinner/Spinner.js";import n from"../Form/ThreeDS2Form.js";import i from"../../../../utils/get-process-message-handler.js";import{encodeBase64URL as o}from"../utils.js";import l from"../../../../utils/promiseTimeout.js";import{CHALLENGE_TIMEOUT as m,
|
|
1
|
+
import{Component as e,createElement as s}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import r from"../../../internal/IFrame/Iframe.js";import a from"../../../internal/Spinner/Spinner.js";import n from"../Form/ThreeDS2Form.js";import i from"../../../../utils/get-process-message-handler.js";import{encodeBase64URL as o}from"../utils.js";import l from"../../../../utils/promiseTimeout.js";import{CHALLENGE_TIMEOUT as m,PASSKEY_VISA_IFRAME_SANDBOX as c,PASSKEY_VISA_IFRAME_ALLOW as h,PASSKEY_3DS2_IFRAME_ALLOW as p,CHALLENGE_TIMEOUT_REJECT_OBJECT as d,THREEDS2_NUM as g}from"../../constants.js";function u(e,s,t){return s in e?Object.defineProperty(e,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[s]=t,e}const f="threeDSIframe";class b extends e{get3DS2ChallengePromise(){return new Promise((e,s)=>{this.processMessageHandler=i(this.props.postMessageDomain,e,s,"challengeResult"),window.addEventListener("message",this.processMessageHandler)})}componentDidMount(){this.challengePromise=l(m,this.get3DS2ChallengePromise(),d),this.challengePromise.promise.then(e=>{window.removeEventListener("message",this.processMessageHandler),this.props.onCompleteChallenge(e)}).catch(e=>{window.removeEventListener("message",this.processMessageHandler),this.props.onErrorChallenge(e)})}componentWillUnmount(){this.challengePromise&&this.challengePromise.cancel(),window.removeEventListener("message",this.processMessageHandler)}render({acsURL:e,cReqData:i,iframeSizeArr:o,onFormSubmit:l,usePasskeyIFrameAttributes:m},{base64URLencodedData:d,status:g}){const[u,b]=o;return s("div",{className:t(["adyen-checkout__threeds2__challenge",`adyen-checkout__threeds2__challenge--${i.challengeWindowSize}`])},"iframeLoaded"!==g&&s(a,null),s(r,{name:f,width:u,height:b,callback:this.iframeCallback,allow:m?h:p,sandbox:m?c:void 0}),s(n,{name:"cReqForm",action:e,target:f,inputName:"creq",inputValue:d??"",onFormSubmit:l}))}constructor(e){super(e),u(this,"processMessageHandler",void 0),u(this,"challengePromise",void 0),u(this,"iframeCallback",()=>{this.setState({status:"iframeLoaded"}),"init"===this.state.status&&this.props.onActionHandled?.({componentType:"3DS2Challenge",actionDescription:`${g} challenge iframe loaded`})});const s=JSON.stringify(this.props.cReqData),t=o(s);this.state={base64URLencodedData:t,status:"init"}}}export{b as default};
|
|
2
2
|
//# sourceMappingURL=DoChallenge3DS2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport { CHALLENGE_TIMEOUT, CHALLENGE_TIMEOUT_REJECT_OBJECT, THREEDS2_NUM } from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler: (event: Pick<MessageEvent, 'origin' | 'data'>) => string | boolean;\n private challengePromise: { promise: Promise<ThreeDS2FlowObject>; cancel: () => void };\n\n constructor(props: DoChallenge3DS2Props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<ThreeDS2FlowObject> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ acsURL, cReqData, iframeSizeArr, onFormSubmit }, { base64URLencodedData, status }) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe
|
|
1
|
+
{"version":3,"file":"DoChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/DoChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { encodeBase64URL } from '../utils';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport { CHALLENGE_TIMEOUT, CHALLENGE_TIMEOUT_REJECT_OBJECT, THREEDS2_NUM, PASSKEY_VISA_IFRAME_ALLOW, PASSKEY_3DS2_IFRAME_ALLOW, PASSKEY_VISA_IFRAME_SANDBOX } from '../../constants';\nimport { DoChallenge3DS2Props, DoChallenge3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSIframe';\n\nclass DoChallenge3DS2 extends Component<DoChallenge3DS2Props, DoChallenge3DS2State> {\n private processMessageHandler: (event: Pick<MessageEvent, 'origin' | 'data'>) => string | boolean;\n private challengePromise: { promise: Promise<ThreeDS2FlowObject>; cancel: () => void };\n\n constructor(props: DoChallenge3DS2Props) {\n super(props);\n\n /**\n * Create and Base64Url encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL\n */\n const jsonStr = JSON.stringify(this.props.cReqData);\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData, status: 'init' };\n }\n\n private iframeCallback = () => {\n this.setState({ status: 'iframeLoaded' });\n // On Test - actually calls-back 3 times: once for challenge screen, once again as challenge.html reloads after the challenge is submitted, and once for redirect to threeDSNotificationURL.\n // But for the purposes of calling the merchant defined onActionHandled callback - we only want to do it once\n if (this.state.status === 'init') {\n this.props.onActionHandled?.({ componentType: '3DS2Challenge', actionDescription: `${THREEDS2_NUM} challenge iframe loaded` });\n }\n };\n\n private get3DS2ChallengePromise(): Promise<ThreeDS2FlowObject> {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'challengeResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Render challenge\n this.challengePromise = promiseTimeout(CHALLENGE_TIMEOUT, this.get3DS2ChallengePromise(), CHALLENGE_TIMEOUT_REJECT_OBJECT);\n this.challengePromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteChallenge(resolveObject);\n })\n /** Catch, for when Challenge times-out */\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorChallenge(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.challengePromise) this.challengePromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ acsURL, cReqData, iframeSizeArr, onFormSubmit, usePasskeyIFrameAttributes }: DoChallenge3DS2Props, { base64URLencodedData, status }: DoChallenge3DS2State) {\n const [width, height] = iframeSizeArr;\n\n return (\n <div\n className={classNames([\n 'adyen-checkout__threeds2__challenge',\n `adyen-checkout__threeds2__challenge--${cReqData.challengeWindowSize}`\n ])}\n >\n {status !== 'iframeLoaded' && <Spinner />}\n\n <Iframe\n name={iframeName}\n width={width}\n height={height}\n callback={this.iframeCallback}\n allow={usePasskeyIFrameAttributes ? PASSKEY_VISA_IFRAME_ALLOW : PASSKEY_3DS2_IFRAME_ALLOW}\n sandbox={usePasskeyIFrameAttributes ? PASSKEY_VISA_IFRAME_SANDBOX : undefined}\n />\n <ThreeDS2Form\n name={'cReqForm'}\n action={acsURL}\n target={iframeName}\n inputName={'creq'}\n inputValue={base64URLencodedData ?? ''}\n onFormSubmit={onFormSubmit}\n />\n </div>\n );\n }\n}\n\nexport default DoChallenge3DS2;\n"],"names":["iframeName","DoChallenge3DS2","Component","get3DS2ChallengePromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","challengePromise","promiseTimeout","CHALLENGE_TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","promise","then","resolveObject","removeEventListener","onCompleteChallenge","catch","rejectObject","onErrorChallenge","componentWillUnmount","cancel","render","acsURL","cReqData","iframeSizeArr","onFormSubmit","usePasskeyIFrameAttributes","base64URLencodedData","status","width","height","h","div","className","classNames","challengeWindowSize","Spinner","Iframe","name","callback","iframeCallback","allow","PASSKEY_VISA_IFRAME_ALLOW","PASSKEY_3DS2_IFRAME_ALLOW","sandbox","PASSKEY_VISA_IFRAME_SANDBOX","undefined","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","setState","state","onActionHandled","componentType","actionDescription","THREEDS2_NUM","jsonStr","JSON","stringify","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,EAAAvD,KAAQQ,wBAAR,GAaA+C,EAAAvD,KAAQyC,iBAAiB,KACrBzC,KAAKwD,SAAS,CAAE3B,OAAQ,iBAGE,SAAtB7B,KAAKyD,MAAM5B,QACX7B,KAAKG,MAAMuD,kBAAkB,CAAEC,cAAe,gBAAiBC,kBAAmB,GAAGC,gCAVzF,MAAMC,EAAUC,KAAKC,UAAUhE,KAAKG,MAAMqB,UACpCI,EAAuBqC,EAAgBH,GAC7C9D,KAAKyD,MAAQ,CAAE7B,uBAAsBC,OAAQ,OACjD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as s,createChallengeResolveData as o,prepareChallengeData as n}from"../utils.js";import
|
|
1
|
+
import{Component as e,createElement as r}from"../../../../external/preact/dist/preact.js";import t from"./DoChallenge3DS2.js";import{isErrorObject as s,createChallengeResolveData as o,prepareChallengeData as n}from"../utils.js";import a from"../../../internal/Img/Img.js";import{hasOwnProperty as i}from"../../../../utils/hasOwnProperty.js";import l from"../../../../core/Context/useImage.js";import p,{ERROR as c}from"../../../../core/Errors/AdyenCheckoutError.js";import{THREEDS2_CHALLENGE_ERROR as h,MISSING_TOKEN_IN_ACTION_MSG as u,THREEDS2_NUM as m,THREEDS2_CHALLENGE as S}from"../../constants.js";import{isValidHttpUrl as g}from"../../../../utils/isValidURL.js";import{AnalyticsLogEvent as d,LogEventSubtype as D,LogEventType as E}from"../../../../core/Analytics/events/AnalyticsLogEvent.js";import{ErrorEventCode as _,AnalyticsErrorEvent as I,ErrorEventType as T}from"../../../../core/Analytics/events/AnalyticsErrorEvent.js";function f(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}class C extends e{componentDidMount(){if(!s(this.state.challengeData)){const e="test"===this.props.environment&&this.props._environmentUrls?.api?.includes("http://localhost:8080"),{acsURL:r,postMessageDomain:t}=this.state.challengeData,s=g(r,e),o=g(t,e);if(!s||!o){const e=s?_.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL:_.THREEDS2_TOKEN_IS_MISSING_ACSURL,r=s?"threeDSNotificationURL":"acsURL";this.setError({errorInfo:`${e}: ${this.props.i18n.get("err.gen.9102")}`},!0);const n=new I({component:this.props.type,code:e,errorType:T.threeDS2,message:`${h}: Decoded token is missing a valid ${r} property`});return this.props.onSubmitAnalytics(n),void console.debug(`### PrepareChallenge3DS2::exiting:: no valid ${r}.${o?"":` postMessageDomain=${t}`}`)}const{acsTransID:n,messageVersion:a,threeDSServerTransID:i}=this.state.challengeData.cReqData;if(!n||!a||!i){this.setError({errorInfo:`${_.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new I({component:this.props.type,code:_.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:T.threeDS2,message:`${h}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`});return this.props.onSubmitAnalytics(e),void console.debug("### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)")}this.setState({status:"performingChallenge"})}else{const e=this.state.challengeData.error,r=e.includes(u)?_.THREEDS2_ACTION_IS_MISSING_TOKEN:_.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;this.setError({errorInfo:`${r}: ${this.props.i18n.get("err.gen.9102")}`},!0);const t=new I({component:this.props.type,code:r,errorType:T.threeDS2,message:`${h}: ${e}`});this.props.onSubmitAnalytics(t),console.debug("### PrepareChallenge3DS2::exiting:: no challengeData")}}setStatusComplete(e,r=null){this.setState({status:"complete"},()=>{const t=o(this.props.dataKey,e.transStatus,this.props.paymentData);let s;r&&console.debug("### PrepareChallenge3DS2::errorCodeObject::",r);const n=r||e;if(n.errorCode){const e={code:"timeout"===n.errorCode?_.THREEDS2_TIMEOUT:_.THREEDS2_NO_TRANSSTATUS,errorType:T.threeDS2};s=new I({component:this.props.type,message:n.message,...e}),this.props.onSubmitAnalytics(s)}let a;switch(e?.transStatus){case"Y":a="success";break;case"N":a="failed";break;case"U":a=r?"timeout":"cancelled"}e?.errorCode&&(a="noTransStatus"),s=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:a}),this.props.onSubmitAnalytics(s),this.props.onComplete(t)})}setError(e,r){this.setState({status:"error",errorInfo:e.errorInfo}),r&&this.props.onError(new p(c,e.errorInfo,{cause:e.errorObj}))}render(e,{challengeData:s}){const o=s,n=l();return"performingChallenge"===this.state.status?r(t,{onCompleteChallenge:e=>{let r=null;if(i(e.result,"errorCode")&&e.result.errorCode.length&&(r={errorCode:e.result.errorCode,message:`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`},this.props.isMDFlow&&this.props.onError(new p(c,`${h}: ${e.result.errorDescription?e.result.errorDescription:"no transStatus could be retrieved"}`,{cause:e.result.errorCode}))),!e.result){this.setError({errorInfo:`${h}: ${this.props.i18n.get("3ds.chal.805",{values:{result:'"result"'}})}`,errorObj:e},!0);const r=new I({component:this.props.type,code:_.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:T.threeDS2,message:`${h}: challenge resolved without a "result" object`});return this.props.onSubmitAnalytics(r),void console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a "result" object')}this.setStatusComplete(e.result,r)},onErrorChallenge:e=>{if(i(e,"errorCode")){const r={errorCode:e.errorCode,message:`${S}: ${e.errorCode}`};return this.props.isMDFlow&&this.props.onError(new p(c,`${h}: '3DS2 challenge timed out'`,{cause:e.errorCode})),void this.setStatusComplete(e.result,r)}},...o,onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit,usePasskeyIFrameAttributes:this.props.usePasskeyIFrameAttributes}):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(a,{className:"adyen-checkout__status__icon adyen-checkout__status__icon--error",src:n({imageFolder:"components/"})("error"),alt:""}),r("div",{className:"adyen-checkout__status__text"},this.state.errorInfo?this.state.errorInfo:this.props.i18n.get("error.message.unknown"))):null}constructor(e){if(super(e),f(this,"onFormSubmit",e=>{const r=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeDataSentWeb,message:e});this.props.onSubmitAnalytics(r)}),this.props.token){const e=n({token:this.props.token,size:this.props.challengeWindowSize||this.props.size});this.state={status:"init",challengeData:e}}else this.state={challengeData:{success:!1,error:u}},console.debug(`${h}: ${u}`)}}f(C,"defaultProps",{onComplete:()=>{},onError:()=>{},isMDFlow:!1});export{C as default};
|
|
2
2
|
//# sourceMappingURL=PrepareChallenge3DS2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL, postMessageDomain } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n\n // Only render component if we have a valid acsURL & postMessageDomain.\n // i.e. a url to load into the iframe, and the domain that we expect the iframe to be sending messages back from\n if (!hasValidAcsURL || !hasValidPostMessageDomain) {\n const errorCode = !hasValidAcsURL\n ? ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL\n : ErrorEventCode.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL;\n const missingProperty = !hasValidAcsURL ? 'acsURL' : 'threeDSNotificationURL';\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid ${missingProperty} property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n `### PrepareChallenge3DS2::exiting:: no valid ${missingProperty}.${!hasValidPostMessageDomain ? ` postMessageDomain=${postMessageDomain}` : ''}`\n );\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData: stateChallengeData }: PrepareChallenge3DS2State) {\n const challengeData = stateChallengeData as ChallengeData;\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","postMessageDomain","hasValidAcsURL","isValidHttpUrl","hasValidPostMessageDomain","errorCode","ErrorEventCode","THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL","THREEDS2_TOKEN_IS_MISSING_ACSURL","missingProperty","setError","errorInfo","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","stateChallengeData","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"6hCAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,OAAEA,EAAMC,kBAAEA,GAAsBV,KAAKC,MAAMC,cAC3CS,EAAiBC,EAAeH,EAAQN,GACxCU,EAA4BD,EAAeF,EAAmBP,GAIpE,IAAKQ,IAAmBE,EAA2B,CAC/C,MAAMC,EAAaH,EAEbI,EAAeC,2DADfD,EAAeE,iCAEfC,EAAmBP,EAA4B,yBAAX,SAG1CX,KAAKmB,SACD,CACIC,UAAW,GAAGN,MAAcd,KAAKI,MAAMiB,KAAKC,IAAI,oBAEpD,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWzB,KAAKI,MAAMsB,KACtBC,KAAMb,EACNc,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,uCAA8Dd,eAO9E,OALAlB,KAAKI,MAAM6B,kBAAkBV,QAE7BW,QAAQC,MACJ,gDAAgDjB,KAAoBL,EAAwE,GAA5C,sBAAsBH,MAG9H,CAEA,MAAM0B,WAAEA,EAAUC,eAAEA,EAAcC,qBAAEA,GAA0BtC,KAAKC,MAAMC,cAAgCqC,SAGzG,IAAKH,IA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sB,KACtBA,KAAMoC,EAAahC,SACnBiC,QAASC,EAAgByC,qBACzB1E,QAASyE,IAGbxG,KAAKI,MAAM6B,kBAAkBV,KA1BzBvB,KAAKI,MAAMsG,MAAO,CAClB,MAAMxG,EAA6CyG,EAAqB,CACpED,MAAO1G,KAAKI,MAAMsG,MAClBE,KAAM5G,KAAKI,MAAMyG,qBAAuB7G,KAAKI,MAAMwG,OAGvD5G,KAAKC,MAAQ,CACTyC,OAAQ,OACRxC,gBAER,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAE4G,SAAS,EAAOlE,MAAOC,IAEvDX,QAAQC,MAAM,GAAGH,MAA6Ba,IAEtD,EAzBA0D,EADE3G,EACqBmH,eAAe,CAClC5C,WAAY,OACZG,QAAS,OACTiB,UAAU"}
|
|
1
|
+
{"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject, ChallengeResolveData } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { THREEDS2_CHALLENGE, THREEDS2_CHALLENGE_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG } from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeDataSentWeb,\n message: msg\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.includes('localhost:8080')) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL, postMessageDomain } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n\n // Only render component if we have a valid acsURL & postMessageDomain.\n // i.e. a url to load into the iframe, and the domain that we expect the iframe to be sending messages back from\n if (!hasValidAcsURL || !hasValidPostMessageDomain) {\n const errorCode = !hasValidAcsURL\n ? ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL\n : ErrorEventCode.THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL;\n const missingProperty = !hasValidAcsURL ? 'acsURL' : 'threeDSNotificationURL';\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid ${missingProperty} property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n `### PrepareChallenge3DS2::exiting:: no valid ${missingProperty}.${!hasValidPostMessageDomain ? ` postMessageDomain=${postMessageDomain}` : ''}`\n );\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${errorCode}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: errorCode,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n const data: ChallengeResolveData = createChallengeResolveData(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let event: AbstractAnalyticsEvent;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? ErrorEventCode.THREEDS2_TIMEOUT : ErrorEventCode.THREEDS2_NO_TRANSSTATUS,\n errorType: ErrorEventType.threeDS2\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n\n event = new AnalyticsErrorEvent({\n component: this.props.type,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n\n event = new AnalyticsLogEvent({\n component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.challengeCompleted,\n message: `${THREEDS2_NUM} challenge has completed`,\n result\n });\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData: stateChallengeData }: PrepareChallenge3DS2State) {\n const challengeData = stateChallengeData as ChallengeData;\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\n }`\n };\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n const event = new AnalyticsErrorEvent({\n component: this.props.type,\n code: ErrorEventCode.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n usePasskeyIFrameAttributes={this.props.usePasskeyIFrameAttributes}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","postMessageDomain","hasValidAcsURL","isValidHttpUrl","hasValidPostMessageDomain","errorCode","ErrorEventCode","THREEDS2_CHALLENGE_TOKEN_IS_MISSING_THREEDSNOTIFICATIONURL","THREEDS2_TOKEN_IS_MISSING_ACSURL","missingProperty","setError","errorInfo","i18n","get","event","AnalyticsErrorEvent","component","type","code","errorType","ErrorEventType","threeDS2","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","errorCodeObject","data","createChallengeResolveData","dataKey","transStatus","paymentData","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","THREEDS2_NO_TRANSSTATUS","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","challengeCompleted","THREEDS2_NUM","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","stateChallengeData","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","isMDFlow","values","THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","usePasskeyIFrameAttributes","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","challengeDataSentWeb","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"6hCAkBA,MAAMA,UAA6BC,EAuC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAClB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,OAAEA,EAAMC,kBAAEA,GAAsBV,KAAKC,MAAMC,cAC3CS,EAAiBC,EAAeH,EAAQN,GACxCU,EAA4BD,EAAeF,EAAmBP,GAIpE,IAAKQ,IAAmBE,EAA2B,CAC/C,MAAMC,EAAaH,EAEbI,EAAeC,2DADfD,EAAeE,iCAEfC,EAAmBP,EAA4B,yBAAX,SAG1CX,KAAKmB,SACD,CACIC,UAAW,GAAGN,MAAcd,KAAKI,MAAMiB,KAAKC,IAAI,oBAEpD,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWzB,KAAKI,MAAMsB,KACtBC,KAAMb,EACNc,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,uCAA8Dd,eAO9E,OALAlB,KAAKI,MAAM6B,kBAAkBV,QAE7BW,QAAQC,MACJ,gDAAgDjB,KAAoBL,EAAwE,GAA5C,sBAAsBH,MAG9H,CAEA,MAAM0B,WAAE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GR,GAFAmG,MAAMnG,GAoBVoG,EAAAxG,KAAO8F,eAAgBW,IACnB,MAAMlF,EAAQ,IAAIsC,EAAkB,CAChCpC,UAAWzB,KAAKI,MAAMsB,KACtBA,KAAMoC,EAAahC,SACnBiC,QAASC,EAAgB0C,qBACzB3E,QAAS0E,IAGbzG,KAAKI,MAAM6B,kBAAkBV,KA1BzBvB,KAAKI,MAAMuG,MAAO,CAClB,MAAMzG,EAA6C0G,EAAqB,CACpED,MAAO3G,KAAKI,MAAMuG,MAClBE,KAAM7G,KAAKI,MAAM0G,qBAAuB9G,KAAKI,MAAMyG,OAGvD7G,KAAKC,MAAQ,CACTyC,OAAQ,OACRxC,gBAER,MAEIF,KAAKC,MAAQ,CAAEC,cAAe,CAAE6G,SAAS,EAAOnE,MAAOC,IAEvDX,QAAQC,MAAM,GAAGH,MAA6Ba,IAEtD,EAzBA2D,EADE5G,EACqBoH,eAAe,CAClC7C,WAAY,OACZG,QAAS,OACTiB,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="threeDS2Fingerprint",r="3DS2Fingerprint_Error",t="callSubmit3DS2Fingerprint_Response",
|
|
1
|
+
const e="threeDS2Fingerprint",r="3DS2Fingerprint_Error",t="callSubmit3DS2Fingerprint_Response",l="threeDS2Challenge",p="3DS2Challenge_Error",n="threeDS2",o="3DS2",i='Missing "token" property from threeDS2 action',a="02",s=1e4,c=6e5,g="timeout",u={result:{transStatus:"U"},type:"challengeResult",errorCode:g},S={result:{threeDSCompInd:"N"},type:"fingerPrintResult",errorCode:g},x="payment *; publickey-credentials-get *",D="payment *; publickey-credentials-get *; publickey-credentials-create *",h="allow-forms allow-same-origin allow-scripts allow-pointer-lock allow-popups",m={"01":["250px","400px"],"02":["390px","400px"],"03":["500px","600px"],"04":["600px","400px"],"05":["100%","100%"]};export{c as CHALLENGE_TIMEOUT,u as CHALLENGE_TIMEOUT_REJECT_OBJECT,m as CHALLENGE_WINDOW_SIZES,a as DEFAULT_CHALLENGE_WINDOW_SIZE,S as FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT,i as MISSING_TOKEN_IN_ACTION_MSG,x as PASSKEY_3DS2_IFRAME_ALLOW,D as PASSKEY_VISA_IFRAME_ALLOW,h as PASSKEY_VISA_IFRAME_SANDBOX,l as THREEDS2_CHALLENGE,p as THREEDS2_CHALLENGE_ERROR,e as THREEDS2_FINGERPRINT,r as THREEDS2_FINGERPRINT_ERROR,t as THREEDS2_FINGERPRINT_SUBMIT,n as THREEDS2_FULL,o as THREEDS2_NUM,s as THREEDS_METHOD_TIMEOUT,g as TIMEOUT};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/ThreeDS2/constants.ts"],"sourcesContent":["import { ThreeDS2FlowObject } from './types';\n\nexport const THREEDS2_FINGERPRINT = 'threeDS2Fingerprint';\nexport const THREEDS2_FINGERPRINT_ERROR = '3DS2Fingerprint_Error';\nexport const THREEDS2_FINGERPRINT_SUBMIT = 'callSubmit3DS2Fingerprint_Response';\nexport const THREEDS2_CHALLENGE = 'threeDS2Challenge';\nexport const THREEDS2_CHALLENGE_ERROR = '3DS2Challenge_Error';\n\nexport const THREEDS2_ERROR = 'threeDS2Error';\nexport const THREEDS2_FULL = 'threeDS2';\nexport const THREEDS2_NUM = '3DS2';\n\nexport const MISSING_TOKEN_IN_ACTION_MSG = 'Missing \"token\" property from threeDS2 action';\n\nexport const DEFAULT_CHALLENGE_WINDOW_SIZE = '02';\n\nexport const THREEDS_METHOD_TIMEOUT = 10000;\nexport const CHALLENGE_TIMEOUT = 600000;\n\nexport const TIMEOUT = 'timeout';\n\nexport const CHALLENGE_TIMEOUT_REJECT_OBJECT: ThreeDS2FlowObject = {\n result: {\n transStatus: 'U'\n },\n type: 'challengeResult',\n errorCode: TIMEOUT\n};\n\nexport const FAILED_METHOD_STATUS_RESOLVE_OBJECT: ThreeDS2FlowObject = {\n result: {\n threeDSCompInd: 'N'\n },\n type: 'fingerPrintResult'\n};\n\nexport const FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT: ThreeDS2FlowObject = {\n result: {\n threeDSCompInd: 'N'\n },\n type: 'fingerPrintResult',\n errorCode: TIMEOUT\n};\n\n// Re. EMV 3-D Specification: EMVCo_3DS_Spec_210_1017.pdf\nexport const CHALLENGE_WINDOW_SIZES = {\n '01': ['250px', '400px'],\n '02': ['390px', '400px'],\n '03': ['500px', '600px'],\n '04': ['600px', '400px'],\n '05': ['100%', '100%']\n};\n"],"names":["THREEDS2_FINGERPRINT","THREEDS2_FINGERPRINT_ERROR","THREEDS2_FINGERPRINT_SUBMIT","THREEDS2_CHALLENGE","THREEDS2_CHALLENGE_ERROR","THREEDS2_FULL","THREEDS2_NUM","MISSING_TOKEN_IN_ACTION_MSG","DEFAULT_CHALLENGE_WINDOW_SIZE","THREEDS_METHOD_TIMEOUT","CHALLENGE_TIMEOUT","TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","result","transStatus","type","errorCode","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","threeDSCompInd","CHALLENGE_WINDOW_SIZES"],"mappings":"AAEO,MAAMA,EAAuB,sBACvBC,EAA6B,wBAC7BC,EAA8B,qCAC9BC,EAAqB,oBACrBC,EAA2B,sBAG3BC,EAAgB,WAChBC,EAAe,OAEfC,EAA8B,gDAE9BC,EAAgC,KAEhCC,EAAyB,IACzBC,EAAoB,IAEpBC,EAAU,UAEVC,EAAsD,CAC/DC,OAAQ,CACJC,YAAa,KAEjBC,KAAM,kBACNC,UAAWL,GAUFM,EAAkE,CAC3EJ,OAAQ,CACJK,eAAgB,KAEpBH,KAAM,oBACNC,UAAWL,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/ThreeDS2/constants.ts"],"sourcesContent":["import { ThreeDS2FlowObject } from './types';\n\nexport const THREEDS2_FINGERPRINT = 'threeDS2Fingerprint';\nexport const THREEDS2_FINGERPRINT_ERROR = '3DS2Fingerprint_Error';\nexport const THREEDS2_FINGERPRINT_SUBMIT = 'callSubmit3DS2Fingerprint_Response';\nexport const THREEDS2_CHALLENGE = 'threeDS2Challenge';\nexport const THREEDS2_CHALLENGE_ERROR = '3DS2Challenge_Error';\n\nexport const THREEDS2_ERROR = 'threeDS2Error';\nexport const THREEDS2_FULL = 'threeDS2';\nexport const THREEDS2_NUM = '3DS2';\n\nexport const MISSING_TOKEN_IN_ACTION_MSG = 'Missing \"token\" property from threeDS2 action';\n\nexport const DEFAULT_CHALLENGE_WINDOW_SIZE = '02';\n\nexport const THREEDS_METHOD_TIMEOUT = 10000;\nexport const CHALLENGE_TIMEOUT = 600000;\n\nexport const TIMEOUT = 'timeout';\n\nexport const CHALLENGE_TIMEOUT_REJECT_OBJECT: ThreeDS2FlowObject = {\n result: {\n transStatus: 'U'\n },\n type: 'challengeResult',\n errorCode: TIMEOUT\n};\n\nexport const FAILED_METHOD_STATUS_RESOLVE_OBJECT: ThreeDS2FlowObject = {\n result: {\n threeDSCompInd: 'N'\n },\n type: 'fingerPrintResult'\n};\n\nexport const FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT: ThreeDS2FlowObject = {\n result: {\n threeDSCompInd: 'N'\n },\n type: 'fingerPrintResult',\n errorCode: TIMEOUT\n};\n\nexport const PASSKEY_3DS2_IFRAME_ALLOW = 'payment *; publickey-credentials-get *';\nexport const PASSKEY_VISA_IFRAME_ALLOW = 'payment *; publickey-credentials-get *; publickey-credentials-create *';\nexport const PASSKEY_VISA_IFRAME_SANDBOX = 'allow-forms allow-same-origin allow-scripts allow-pointer-lock allow-popups';\n\n// Re. EMV 3-D Specification: EMVCo_3DS_Spec_210_1017.pdf\nexport const CHALLENGE_WINDOW_SIZES = {\n '01': ['250px', '400px'],\n '02': ['390px', '400px'],\n '03': ['500px', '600px'],\n '04': ['600px', '400px'],\n '05': ['100%', '100%']\n};\n"],"names":["THREEDS2_FINGERPRINT","THREEDS2_FINGERPRINT_ERROR","THREEDS2_FINGERPRINT_SUBMIT","THREEDS2_CHALLENGE","THREEDS2_CHALLENGE_ERROR","THREEDS2_FULL","THREEDS2_NUM","MISSING_TOKEN_IN_ACTION_MSG","DEFAULT_CHALLENGE_WINDOW_SIZE","THREEDS_METHOD_TIMEOUT","CHALLENGE_TIMEOUT","TIMEOUT","CHALLENGE_TIMEOUT_REJECT_OBJECT","result","transStatus","type","errorCode","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","threeDSCompInd","PASSKEY_3DS2_IFRAME_ALLOW","PASSKEY_VISA_IFRAME_ALLOW","PASSKEY_VISA_IFRAME_SANDBOX","CHALLENGE_WINDOW_SIZES"],"mappings":"AAEO,MAAMA,EAAuB,sBACvBC,EAA6B,wBAC7BC,EAA8B,qCAC9BC,EAAqB,oBACrBC,EAA2B,sBAG3BC,EAAgB,WAChBC,EAAe,OAEfC,EAA8B,gDAE9BC,EAAgC,KAEhCC,EAAyB,IACzBC,EAAoB,IAEpBC,EAAU,UAEVC,EAAsD,CAC/DC,OAAQ,CACJC,YAAa,KAEjBC,KAAM,kBACNC,UAAWL,GAUFM,EAAkE,CAC3EJ,OAAQ,CACJK,eAAgB,KAEpBH,KAAM,oBACNC,UAAWL,GAGFQ,EAA4B,yCAC5BC,EAA4B,yEAC5BC,EAA8B,8EAG9BC,EAAyB,CAClC,KAAM,CAAC,QAAS,SAChB,KAAM,CAAC,QAAS,SAChB,KAAM,CAAC,QAAS,SAChB,KAAM,CAAC,QAAS,SAChB,KAAM,CAAC,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as s,useMemo as o,useState as r,useCallback as a,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as d}from"./validate.js";import{countrySpecificFormatters as c,addressFormatters as u}from"./validate.formats.js";import m from"./components/FieldContainer.js";import p from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import f from"./Specifications.js";import{COUNTRY as y,ADDRESS_SCHEMA as F,FALLBACK_VALUE as h}from"./constants.js";import{getMaxLengthByFieldAndCountry as C}from"../../../utils/validator-utils.js";import{useCoreContext as g}from"../../../core/Context/CoreProvider.js";import A from"./components/AddressSearch.js";import{getAddressTypeFromLabel as v}from"./utils.js";function b(b){const{i18n:j}=g(),{label:S="",requiredFields:x,visibility:k,iOSFocusedField:M=null,showContextualElement:O}=b,D=v(b.addressType,S),w=s({});Object.keys(w.current).length||b.setComponentRef?.(w.current);const B=o(()=>new f(b.specifications),[b.specifications]),E=B.getAddressSchemaForCountryFlat(b.countryCode).filter(e=>x.includes(e)),[L,N]=r(!1),[P,R]=r(!1),[T,V]=r(""),H=!!b.onAddressLookup,[q,_]=r(!1),I=!b.onAddressLookup||(L||P),U=b.data?.country,$=U&&!E.includes(y)?[...E,y]:E,z=o(()=>U?{...b.data,country:U.toUpperCase()}:b.data,[b.data,U]),{data:G,errors:J,valid:K,isValid:Q,handleChangeFor:W,triggerValidation:X,setData:Y,mergeData:Z}=p({schema:$,defaultData:z,rules:{...d(B),...b.validationRules},formatters:u}),ee=a(e=>{const t=F.reduce((t,s)=>{const o=e[s];return null!=o&&(t[s]=String(o)),t},{});Z(t),_(!0),X(),N(!0)},[N,X,Y]),te=a(()=>{R(!0)},[]);w.current.showValidation=()=>{X(),V(!H||I||Q?"":j.get("address.errors.incomplete"))};const se=E.filter(e=>!M||e===M);if(n(()=>{if(q)return void _(!1);const e=B.countryHasDataset(G.country)?"":h,t={...G,stateOrProvince:e};x.forEach(e=>{W(e,"input")(t[e]??"")}),t.postalCode&&W("postalCode","blur")(G.postalCode)},[G.country]),n(()=>{const e=x.includes("stateOrProvince"),t=G.country&&B.countryHasDataset(G.country),s=e&&t,o=G.stateOrProvince||(s?"":h);W("stateOrProvince","input")(o)},[]),n(()=>{const e=B.getOptionalFieldsForCountry(G.country),t=F.reduce((t,s)=>{const o=e.includes(s),r=x.includes(s),a=G[s],n=z[s],i=o&&!a||!r?!r&&n?n:h:a;return i?.length&&(t[s]=i),t},{});b.onChange({data:t,valid:K,errors:J,isValid:Q})},[G,K,J,Q]),"hidden"===k)return null;if("readOnly"===k)return e(l,{data:G,label:S});const oe=(t,{classNameModifiers:s=[]})=>x.includes(t)?e(m,{key:t,allowedCountries:b.allowedCountries,classNameModifiers:[...s,t],data:G,errors:J,valid:K,fieldName:t,onInput:W(t,"input"),onBlur:W(t,"blur"),onDropdownChange:W(t,"blur"),specifications:B,maxLength:C(c,t,G.country),trimOnBlur:!0,disabled:!se.includes(t),addressType:D,onFieldFocusAnalytics:b.onFieldFocusAnalytics,onFieldBlurAnalytics:b.onFieldBlurAnalytics}):null,re=B.getAddressSchemaForCountry(G.country);return e(t,null,e(i,{classNameModifiers:[S,"address"],label:S,renderLabelAsSectionHeading:!0},H&&e(A,{onAddressLookup:b.onAddressLookup,onAddressSelected:b.onAddressSelected,onSelect:ee,onManualAddress:te,externalErrorMessage:T,hideManualButton:I,showContextualElement:O,contextualText:j.get("address.search.contextualText"),addressSearchDebounceMs:b.addressSearchDebounceMs}),I&&e(t,null,re.map(t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map(([e,t])=>oe(e,{classNameModifiers:[`col-${t}`]}))):oe(t,{})))))}b.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:F,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{b as default};
|
|
2
2
|
//# sourceMappingURL=Address.js.map
|