@adyen/adyen-web 6.40.2 → 6.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +35 -25
- package/dist/es/components/ANCV/ANCV.js +1 -1
- package/dist/es/components/ANCV/ANCV.js.map +1 -1
- package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
- package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
- package/dist/es/components/Card/Card.js +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js +1 -1
- package/dist/es/components/CustomCard/CustomCard.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/OrderPaymentMethods.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardPinField.js +1 -1
- package/dist/es/components/Giftcard/components/GiftcardPinField.js.map +1 -1
- package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
- package/dist/es/components/MealVoucherFR/components/MealVoucherExpiryField.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/components/DeviceFingerprint/DoFingerprint3DS2.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/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/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/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
- package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
- package/dist/es/core/config.js +1 -1
- package/dist/es/index.d.ts +35 -25
- package/dist/es/utils/commonUtils.js +1 -1
- package/dist/es/utils/commonUtils.js.map +1 -1
- package/dist/es/utils/promiseTimeout.js.map +1 -1
- package/dist/es/utils/validator-utils.js +1 -1
- package/dist/es/utils/validator-utils.js.map +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVInput.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/CustomCard/CustomCard.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.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/OrderPaymentMethods.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodsContainer.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardPinField.js.map +1 -1
- package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.js +1 -1
- package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherExpiryField.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/components/DeviceFingerprint/DoFingerprint3DS2.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/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/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/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js +1 -1
- package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
- package/dist/es-legacy/core/config.js +1 -1
- package/dist/es-legacy/utils/commonUtils.js +1 -1
- package/dist/es-legacy/utils/commonUtils.js.map +1 -1
- package/dist/es-legacy/utils/promiseTimeout.js.map +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{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 i from"../../../internal/Img/Img.js";import{hasOwnProperty as a}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 T,ErrorEventType as I}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 T({component:this.props.type,code:e,errorType:I.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:i,threeDSServerTransID:a}=this.state.challengeData.cReqData;if(!n||!i||!a){this.setError({errorInfo:`${_.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get("err.gen.9102")}`},!0);const e=new T({component:this.props.type,code:_.THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS,errorType:I.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 T({component:this.props.type,code:r,errorType:I.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:I.threeDS2};s=new T({component:this.props.type,message:n.message,...e}),this.props.onSubmitAnalytics(s)}let i;switch(e?.transStatus){case"Y":i="success";break;case"N":i="failed";break;case"U":i=r?"timeout":"cancelled"}e?.errorCode&&(i="noTransStatus"),s=new d({component:this.props.type,type:E.threeDS2,subType:D.challengeCompleted,message:`${m} challenge has completed`,result:i}),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(a(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 T({component:this.props.type,code:_.THREEDS2_CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,errorType:I.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(a(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}):"error"===this.state.status?r("div",{className:"adyen-checkout__threeds2-challenge-error"},r(i,{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 } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${ErrorEventCode.THREEDS2_TOKEN_IS_MISSING_ACSURL}: ${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_ACSURL,\n errorType: ErrorEventType.threeDS2,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n });\n this.props.onSubmitAnalytics(event);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\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 }) {\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","isValidHttpUrl","setError","errorInfo","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_ACSURL","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","errorCode","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","_","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,GAAWT,KAAKC,MAAMC,cAI9B,IAHuBQ,EAAeD,EAAQN,GAGzB,CAEjBH,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAeC,qCAAqCd,KAAKI,MAAMW,KAAKC,IAAI,oBAE1F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWnB,KAAKI,MAAMgB,KACtBC,KAAMR,EAAeC,iCACrBQ,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,wDAKhB,OAHA1B,KAAKI,MAAMuB,kBAAkBV,QAE7BW,QAAQC,MAAM,sDAElB,CAEA,MAAMC,WAAEA,EAAUC,eAAEA,EAAcC,qBAAEA,GAA0BhC,KAAKC,MAAMC,cAAgC+B,SAGzG,IAAKH,IAAeC,IAAmBC,EAAsB,CAEzDhC,KAAKW,SACD,CACIC,UAAW,GAAGC,EAAeqB,0CAA0ClC,KAAKI,MAAMW,KAAKC,IAAI,oBAE/F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWnB,KAAKI,MAAMgB,KACtBC,KAAMR,EAAeqB,sCACrBZ,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,6HAOhB,OALA1B,KAAKI,MAAMuB,kBAAkBV,QAE7BW,QAAQC,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AAEsG,SAAS,EAAOlE,MAAOE,IAEvDZ,QAAQC,MAAM,GAAGH,MAA6Bc,IAEtD,EAzBAyD,EADErG,EACqB6G,eAAe,CAClC3C,WAAY,OACZG,QAAS,OACTgB,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 />\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,IAAeC,IAAmBC,EAAsB,CAEzDtC,KAAKmB,SACD,CACIC,UAAW,GAAGL,EAAeyB,0CAA0CxC,KAAKI,MAAMiB,KAAKC,IAAI,oBAE/F,GAIJ,MAAMC,EAAQ,IAAIC,EAAoB,CAClCC,UAAWzB,KAAKI,MAAMsB,KACtBC,KAAMZ,EAAeyB,sCACrBZ,UAAWC,EAAeC,SAC1BC,QAAS,GAAGC,6HAOhB,OALAhC,KAAKI,MAAM6B,kBAAkBV,QAE7BW,QAAQC,MACJ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MAAQ,CAAEC,cAAe,CAAE4G,SAAS,EAAOlE,MAAOC,IAEvDX,QAAQC,MAAM,GAAGH,MAA6Ba,IAEtD,EAzBA0D,EADE3G,EACqBmH,eAAe,CAClC5C,WAAY,OACZG,QAAS,OACTiB,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise:
|
|
1
|
+
{"version":3,"file":"DoFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\nimport { ThreeDS2FlowObject } from '../../types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: { cancel: () => void; promise: Promise<ThreeDS2FlowObject> };\n public static readonly defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise(): 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, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then((resolveObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch((rejectObject: ThreeDS2FlowObject) => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAWA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,qBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,wBAEhD,CAEAM,iBAAAA,GAEIP,KAAKQ,mBAAqBC,EAAeC,EAAwBV,KAAKJ,uBAAwBe,GAC9FX,KAAKQ,mBAAmBI,QACnBC,KAAMC,IACHT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,sBAAsBF,KAEpCG,MAAOC,IACJb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,mBAAmBD,IAE1C,CAEAE,oBAAAA,GACQpB,KAAKQ,oBAAoBR,KAAKQ,mBAAmBa,SACrDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EAAOC,iBAAEA,EAAgBC,gBAAEA,EAAeC,aAAEA,IAAgBC,qBAAEA,IAC1D,OACIC,EAACC,MAAAA,CAAIC,UAAU,2CACV7B,KAAKG,MAAM2B,aAAeH,EAACI,QAC5BJ,EAACC,MAAAA,CAAII,MAAO,CAAEC,QAAS,SACnBN,EAACO,EAAAA,CACGC,KAAM1C,EACN2C,SAAU,KACNZ,IAAkB,CAAEa,cAAe,kBAAmBC,kBAAmB,GAAGC,mCAGpFZ,EAACa,EAAAA,CACGL,KAAM,oBACNM,OAAQlB,EACRmB,OAAQjD,EACRkD,UAAW,oBACXC,WAAYlB,EACZD,aAAcA,KAKlC,CApEA,WAAAoB,CAAY1C,GACR2C,MAAM3C,GAPV4C,EAAA/C,KAAQC,6BAAR,GACA8C,EAAA/C,KAAQQ,0BAAR,GAWI,MAAMwC,qBAAEA,EAAoBC,6BAAEA,GAAiCjD,KAAKG,MAE9D+C,EAAUC,KAAKC,UAAU,CAC3BJ,uBACAC,iCAEEvB,EAAuB2B,EAAgBH,GAC7ClD,KAAKsD,MAAQ,CAAE5B,uBACnB,EAlBAqB,EAHErD,EAGqB6D,eAAe,CAClCzB,aAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getFormattingRegEx as o,SPECIAL_CHARS as t
|
|
1
|
+
import{getFormattingRegEx as o,SPECIAL_CHARS as t}from"../../../utils/validator-utils.js";const a=t=>({formatterFn:a=>a.replace(o("^\\d","g"),"").substring(0,t),format:new Array(t).fill("9").join(""),maxlength:t}),e=o(t),r=o=>o.replace(e,""),l={postalCode:{formatterFn:(o,t)=>{const a=t.state.data.country,e=s[a]?.postalCode.formatterFn;return e?e(o):o}},street:{formatterFn:r},houseNumberOrName:{formatterFn:r},city:{formatterFn:r}},s={AT:{postalCode:a(4)},AU:{postalCode:a(4)},BE:{postalCode:a(4)},BG:{postalCode:a(4)},BR:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?9:8;return a.substring(0,e)},format:"12345678 or 12345-678",maxlength:9}},CA:{postalCode:{format:"A9A 9A9 or A9A9A9",maxlength:7}},CH:{postalCode:a(4)},CY:{postalCode:a(4)},CZ:{postalCode:{format:"999 99",maxlength:6}},DE:{postalCode:a(5)},DK:{postalCode:{format:"9999",maxlength:7}},EE:{postalCode:a(5)},ES:{postalCode:a(5)},FI:{postalCode:a(5)},FR:{postalCode:a(5)},GB:{postalCode:{formatterFn:a=>a.replace(o(t),"").substring(0,8),format:"AA99 9AA or A99 9AA or A9 9AA",maxlength:8}},GR:{postalCode:{format:"999 99",maxlength:6}},HR:{postalCode:{format:"[1-5]9999",maxlength:5}},HU:{postalCode:a(4)},IE:{postalCode:{format:"A99 A999",maxlength:8}},IS:{postalCode:a(3)},IT:{postalCode:a(5)},LI:{postalCode:a(4)},LT:{postalCode:{format:"9999 or 99999 or LT-99999",maxlength:8}},LU:{postalCode:a(4)},LV:{postalCode:{format:"9999 or LV-9999",maxlength:7}},MC:{postalCode:{format:"980NN",maxlength:5}},MT:{postalCode:{format:"AA99 or AAA99 or AA9999 or AAA9999",maxlength:8}},MY:{postalCode:a(5)},NL:{postalCode:{format:"9999AA",maxlength:7}},NZ:{postalCode:a(4)},NO:{postalCode:a(4)},PL:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?6:5;return a.substring(0,e)},format:"99999 or 99-999",maxlength:6}},PT:{postalCode:{formatterFn:t=>t.replace(o("^\\d-","g"),"").substring(0,8),format:"9999-999",maxlength:8}},RO:{postalCode:a(6)},SI:{postalCode:{format:"9999 or SI-9999",maxlength:7}},SE:{postalCode:a(5)},SG:{postalCode:a(6)},SK:{postalCode:{format:"99999 or SK-99999",maxlength:8}},JP:{postalCode:{format:"999-9999",maxlength:8}},US:{postalCode:{formatterFn:t=>{const a=t.replace(o("^\\d-","g"),""),e=a.includes("-")?10:5;return a.substring(0,e)},format:"99999 or 99999-9999"}}};export{l as addressFormatters,s as countrySpecificFormatters};
|
|
2
2
|
//# sourceMappingURL=validate.formats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS, trimValWithOneSpace } from '../../../utils/validator-utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = val => trimValWithOneSpace(val).replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","trimValWithOneSpace","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"mHAIA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAeX,GAAOY,EAAoBZ,GAAKC,QAAQQ,EAAmB,IAEnEI,EAAiC,CAC1CC,WAAY,CACRf,YAAa,CAACC,EAAKe,KACf,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWf,YACpE,OAAIoB,EACOA,EAAanB,GAIjBA,IAGfqB,OAAQ,CACJtB,YAAaY,GAEjBW,kBAAmB,CACfvB,YAAaY,GAEjBY,KAAM,C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
|
1
|
+
{"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS } from '../../../utils/validator-utils';\n\nconst asCountryFormatRules = <T extends CountryFormatRules>(rules: T): T & CountryFormatRules => rules;\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = (val: string) => val.replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters = asCountryFormatRules({\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.includes('-') ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n});\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","includes","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"0FAIA,MAEMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM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WAAY,CACRT,OAAQ,kBACRI,UAAW,IAGnBqD,GAAI,CACAhD,WAAYhB,EAAqB,IAErCiE,GAAI,CACAjD,WAAYhB,EAAqB,IAErCkE,GAAI,CACAlD,WAAY,CACRT,OAAQ,oBACRI,UAAW,IAGnBwD,GAAI,CACAnD,WAAY,CACRT,OAAQ,WACRI,UAAW,IAGnByD,GAAI,CACApD,WAAY,CACRd,YAAaC,IACT,MAAM4B,EAAQ5B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYoB,EAAMC,SAAS,KAAO,GAAK,EAC7C,OAAOD,EAAMzB,UAAU,EAAGK,IAE9BJ,OAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{CtpState as e}from"../services/ClickToPayService.js";import{ClickToPayContext as a}from"./ClickToPayContext.js";import{useState as o,useRef as s,useEffect as
|
|
1
|
+
import{createElement as t}from"../../../../external/preact/dist/preact.js";import{CtpState as e}from"../services/ClickToPayService.js";import{ClickToPayContext as a}from"./ClickToPayContext.js";import{useState as o,useRef as s,useEffect as i,useCallback as n}from"../../../../external/preact/hooks/dist/hooks.js";const r=({isStandaloneComponent:r=!1,clickToPayService:c,configuration:d,children:l,setClickToPayRef:p,onSubmit:u,onSetStatus:y,onError:S})=>{const[m]=o(c),[C,f]=o(c?.state||e.NotAvailable),[h,k]=o(!0),[I,P]=o("ready"),v=s(!1),w=s({setStatus:P});i(()=>{p(w.current)},[]),i(()=>{m?.subscribeOnStateChange(t=>f(t))},[m]);const b=n(()=>{v.current||(d.onReady?.(),v.current=!0)},[d?.onReady]),g=n(async t=>{await(m?.finishIdentityValidation(t))},[m]),E=n(async()=>await(m?.startIdentityValidation()),[m]),V=n(async t=>await(m?.checkout(t)),[m]),R=n(async t=>await(m?.verifyIfShopperIsEnrolled(t)),[m]),j=n(async()=>{await(m?.logout())},[m]),x=n(t=>{m.updateStoreCookiesConsent(t)},[m]);return t(a.Provider,{value:{status:I,onSubmit:u,onError:S,onSetStatus:y,configuration:d,isStoringCookies:m?.storeCookies,isStandaloneComponent:r,isCtpPrimaryPaymentMethod:h,setIsCtpPrimaryPaymentMethod:k,ctpState:C,verifyIfShopperIsEnrolled:R,cards:m?.shopperCards,schemes:m?.schemes,otpMaskedContact:m?.identityValidationData?.maskedShopperContact,otpNetwork:m?.identityValidationData?.selectedNetwork,checkout:V,logoutShopper:j,startIdentityValidation:E,finishIdentityValidation:g,updateStoreCookiesConsent:x,onReady:b}},l)};export{r as default};
|
|
2
2
|
//# sourceMappingURL=ClickToPayProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickToPayProvider.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayProvider.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayContext } from './ClickToPayContext';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { ClickToPayCheckoutPayload, IClickToPayService, IdentityLookupParams } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { UIElementStatus } from '../../UIElement/types';\n\ntype ClickToPayProviderRef = {\n setStatus?(status: UIElementStatus): void;\n};\n\nexport type ClickToPayProviderProps = {\n isStandaloneComponent: boolean;\n clickToPayService: IClickToPayService | null;\n configuration: ClickToPayProps;\n children: any;\n setClickToPayRef(ref): void;\n onSubmit(payload: ClickToPayCheckoutPayload): void;\n onSetStatus(status: UIElementStatus): void;\n onError(error: AdyenCheckoutError): void;\n};\n\nconst ClickToPayProvider = ({\n isStandaloneComponent = false,\n clickToPayService,\n configuration,\n children,\n setClickToPayRef,\n onSubmit,\n onSetStatus,\n onError\n}: Readonly<ClickToPayProviderProps>) => {\n const [ctpService] = useState<IClickToPayService | null>(clickToPayService);\n const [ctpState, setCtpState] = useState<CtpState>(clickToPayService?.state || CtpState.NotAvailable);\n const [isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod] = useState<boolean>(true);\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const
|
|
1
|
+
{"version":3,"file":"ClickToPayProvider.js","sources":["../../../../../../src/components/internal/ClickToPay/context/ClickToPayProvider.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { CtpState } from '../services/ClickToPayService';\nimport { ClickToPayContext } from './ClickToPayContext';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { ClickToPayCheckoutPayload, IClickToPayService, IdentityLookupParams } from '../services/types';\nimport ShopperCard from '../models/ShopperCard';\nimport { ClickToPayProps } from '../types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { ComponentMethodsRef, UIElementStatus } from '../../UIElement/types';\n\ntype ClickToPayProviderRef = {\n setStatus?(status: UIElementStatus): void;\n};\n\nexport type ClickToPayProviderProps = {\n isStandaloneComponent: boolean;\n clickToPayService: IClickToPayService | null;\n configuration: ClickToPayProps;\n children: any;\n setClickToPayRef(ref: ComponentMethodsRef): void;\n onSubmit(payload: ClickToPayCheckoutPayload): void;\n onSetStatus(status: UIElementStatus): void;\n onError(error: AdyenCheckoutError): void;\n};\n\nconst ClickToPayProvider = ({\n isStandaloneComponent = false,\n clickToPayService,\n configuration,\n children,\n setClickToPayRef,\n onSubmit,\n onSetStatus,\n onError\n}: Readonly<ClickToPayProviderProps>) => {\n const [ctpService] = useState<IClickToPayService | null>(clickToPayService);\n const [ctpState, setCtpState] = useState<CtpState>(clickToPayService?.state || CtpState.NotAvailable);\n const [isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod] = useState<boolean>(true);\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const isOnReadyInvoked = useRef<boolean>(false);\n\n const clickToPayRef = useRef<ClickToPayProviderRef>({\n setStatus\n });\n\n useEffect(() => {\n setClickToPayRef(clickToPayRef.current);\n }, []);\n\n useEffect(() => {\n ctpService?.subscribeOnStateChange(status => setCtpState(status));\n }, [ctpService]);\n\n const onReady = useCallback(() => {\n if (isOnReadyInvoked.current) {\n return;\n }\n configuration.onReady?.();\n isOnReadyInvoked.current = true;\n }, [configuration?.onReady]);\n\n const finishIdentityValidation = useCallback(\n async (otpValue: string) => {\n await ctpService?.finishIdentityValidation(otpValue);\n },\n [ctpService]\n );\n\n const startIdentityValidation = useCallback(async () => {\n const data = await ctpService?.startIdentityValidation();\n return data;\n }, [ctpService]);\n\n const checkout = useCallback(\n async (card: ShopperCard) => {\n return await ctpService?.checkout(card);\n },\n [ctpService]\n );\n\n const verifyIfShopperIsEnrolled = useCallback(\n async (shopperIdentity: IdentityLookupParams) => {\n return await ctpService?.verifyIfShopperIsEnrolled(shopperIdentity);\n },\n [ctpService]\n );\n\n const logoutShopper = useCallback(async () => {\n await ctpService?.logout();\n }, [ctpService]);\n\n const updateStoreCookiesConsent = useCallback(\n (shouldStore: boolean) => {\n ctpService.updateStoreCookiesConsent(shouldStore);\n },\n [ctpService]\n );\n\n return (\n <ClickToPayContext.Provider\n value={{\n status,\n onSubmit,\n onError,\n onSetStatus,\n configuration,\n isStoringCookies: ctpService?.storeCookies,\n isStandaloneComponent,\n isCtpPrimaryPaymentMethod,\n setIsCtpPrimaryPaymentMethod,\n ctpState,\n verifyIfShopperIsEnrolled,\n cards: ctpService?.shopperCards,\n schemes: ctpService?.schemes,\n otpMaskedContact: ctpService?.identityValidationData?.maskedShopperContact,\n otpNetwork: ctpService?.identityValidationData?.selectedNetwork,\n checkout,\n logoutShopper,\n startIdentityValidation,\n finishIdentityValidation,\n updateStoreCookiesConsent,\n onReady\n }}\n >\n {children}\n </ClickToPayContext.Provider>\n );\n};\n\nexport default ClickToPayProvider;\n"],"names":["ClickToPayProvider","isStandaloneComponent","clickToPayService","configuration","children","setClickToPayRef","onSubmit","onSetStatus","onError","ctpService","useState","ctpState","setCtpState","state","CtpState","NotAvailable","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","status","setStatus","isOnReadyInvoked","useRef","clickToPayRef","useEffect","current","subscribeOnStateChange","onReady","useCallback","finishIdentityValidation","async","otpValue","startIdentityValidation","checkout","card","verifyIfShopperIsEnrolled","shopperIdentity","logoutShopper","logout","updateStoreCookiesConsent","shouldStore","h","ClickToPayContext","Provider","value","isStoringCookies","storeCookies","cards","shopperCards","schemes","otpMaskedContact","identityValidationData","maskedShopperContact","otpNetwork","selectedNetwork"],"mappings":"yTAyBA,MAAMA,EAAqB,EACvBC,yBAAwB,EACxBC,oBACAC,gBACAC,WACAC,mBACAC,WACAC,cACAC,cAEA,MAAOC,GAAcC,EAAoCR,IAClDS,EAAUC,GAAeF,EAAmBR,GAAmBW,OAASC,EAASC,eACjFC,EAA2BC,GAAgCP,GAAkB,IAC7EQ,EAAQC,GAAaT,EAA0B,SAChDU,EAAmBC,GAAgB,GAEnCC,EAAgBD,EAA8B,CAChDF,cAGJI,EAAU,KACNlB,EAAiBiB,EAAcE,UAChC,IAEHD,EAAU,KACNd,GAAYgB,uBAAuBP,GAAUN,EAAYM,KAC1D,CAACT,IAEJ,MAAMiB,EAAUC,EAAY,KACpBP,EAAiBI,UAGrBrB,EAAcuB,YACdN,EAAiBI,SAAU,IAC5B,CAACrB,GAAeuB,UAEbE,EAA2BD,EAC7BE,MAAOC,UACGrB,GAAYmB,yBAAyBE,KAE/C,CAACrB,IAGCsB,EAA0BJ,EAAYE,eACrBpB,GAAYsB,2BAEhC,CAACtB,IAEEuB,EAAWL,EACbE,MAAOI,SACUxB,GAAYuB,SAASC,IAEtC,CAACxB,IAGCyB,EAA4BP,EAC9BE,MAAOM,SACU1B,GAAYyB,0BAA0BC,IAEvD,CAAC1B,IAGC2B,EAAgBT,EAAYE,gBACxBpB,GAAY4B,WACnB,CAAC5B,IAEE6B,EAA4BX,EAC7BY,IACG9B,EAAW6B,0BAA0BC,IAEzC,CAAC9B,IAGL,OACI+B,EAACC,EAAkBC,SAAQ,CACvBC,MAAO,CACHzB,SACAZ,WACAE,UACAD,cACAJ,gBACAyC,iBAAkBnC,GAAYoC,aAC9B5C,wBACAe,4BACAC,+BACAN,WACAuB,4BACAY,MAAOrC,GAAYsC,aACnBC,QAASvC,GAAYuC,QACrBC,iBAAkBxC,GAAYyC,wBAAwBC,qBACtDC,WAAY3C,GAAYyC,wBAAwBG,gBAChDrB,WACAI,gBACAL,0BACAH,2BACAU,4BACAZ,YAGHtB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as r,ARIA_CONTEXT_SUFFIX as a}from"../../../core/Errors/constants.js";function
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as r,ARIA_CONTEXT_SUFFIX as a}from"../../../core/Errors/constants.js";import{trimValWithOneSpace as t}from"../../../utils/validator-utils.js";function l({setRef:l,...s}){const{autoCorrect:i,classNameModifiers:u,isInvalid:d,isValid:c,readonly:p=null,spellcheck:y,type:m,uniqueId:f,disabled:h}=s,_=s.className;Object.prototype.hasOwnProperty.call(s,"onChange")&&console.error("Error: Form fields that rely on InputBase may not have an onChange property");const k=o(e=>{s.onInput?.(e)},[s.onInput]),v=o(e=>{s?.onKeyPress&&s.onKeyPress(e)},[s?.onKeyPress]),b=o(e=>{s?.onKeyUp&&s.onKeyUp(e)},[s?.onKeyUp]),B=o(e=>{if(s?.onBlurHandler?.(e),s.trimOnBlur){const o=e.target;o.value=t(o.value)}s?.onBlur?.(e)},[s.onBlur,s.onBlurHandler]),I=o(e=>{s?.onFocusHandler?.(e)},[s.onFocusHandler]),K=n("adyen-checkout__input",[`adyen-checkout__input--${m}`],_,{"adyen-checkout__input--invalid":d,"adyen-checkout__input--valid":c},(u??[]).map(e=>`adyen-checkout__input--${e}`)),{classNameModifiers:j,uniqueId:x,isInvalid:C,isValid:P,addContextualElement:N,"aria-describedby":g,autocomplete:q,...E}=s,F=["string"==typeof g&&g?g:null,f?`${f}${d?r:a}`:null].filter(Boolean).join(" ")||null;return e("input",{id:f,...E,autocomplete:q,"aria-required":E.required,type:m,className:K,readOnly:p,spellcheck:y,autoCorrect:i,"aria-describedby":F,"aria-invalid":d,onInput:k,onBlur:B,onFocus:I,onKeyUp:b,onKeyPress:v,disabled:h,ref:l})}l.defaultProps={type:"text",classNameModifiers:[]};export{l as default};
|
|
2
2
|
//# sourceMappingURL=InputBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import {\n h,\n RefCallback,\n InputHTMLAttributes,\n GenericEventHandler,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedFocusEvent,\n TargetedEvent\n} from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport { AutocompleteValue } from './types';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends InputHTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n /**\n * WCAG 2.2 autocomplete token for browser autofill.\n * Pass undefined to omit the attribute entirely.\n * @see https://www.w3.org/TR/WCAG22/#input-purposes\n */\n autocomplete: AutocompleteValue;\n}\n\nexport default function InputBase({ setRef, ...props }: Readonly<InputBaseProps>) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellcheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n
|
|
1
|
+
{"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import {\n h,\n RefCallback,\n InputHTMLAttributes,\n GenericEventHandler,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedFocusEvent,\n TargetedEvent\n} from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport { trimValWithOneSpace } from '../../../utils/validator-utils';\nimport Language from '../../../language';\nimport { AutocompleteValue } from './types';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends InputHTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n type?: string;\n /**\n * WCAG 2.2 autocomplete token for browser autofill.\n * Pass undefined to omit the attribute entirely.\n * @see https://www.w3.org/TR/WCAG22/#input-purposes\n */\n autocomplete: AutocompleteValue;\n}\n\nexport default function InputBase({ setRef, ...props }: Readonly<InputBaseProps>) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellcheck, type, uniqueId, disabled } = props;\n const className = props.className;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: TargetedInputEvent<HTMLInputElement>) => {\n props.onInput?.(event);\n },\n [props.onInput]\n );\n\n /**\n * Event is fired when a key that produces a character value is pressed down.\n * ENTER keypress also triggers this event.\n *\n * TODO: 'keypress' event is deprecated\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n */\n const handleKeyPress = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n /**\n * Event is fired when certain keys are pressed (keys that do not output characters):\n * Backspace, Arrow keys, Shift, Ctrl, Command, Option, Esc\n *\n * Exception: ENTER keypress triggers 'onKeyPress' AND 'onKeyUp'\n */\n const handleKeyUp = useCallback(\n (event: TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n const input = event.target as HTMLInputElement;\n input.value = trimValWithOneSpace(input.value);\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n (classNameModifiers ?? []).map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const {\n classNameModifiers: cnm,\n uniqueId: uid,\n isInvalid: iiv,\n isValid: iv,\n addContextualElement: ace,\n 'aria-describedby': ariaDescribedByProp,\n autocomplete,\n ...restProps\n } = props;\n\n const internalDescribedBy = uniqueId ? `${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}` : null;\n const extraDescribedBy = typeof ariaDescribedByProp === 'string' && ariaDescribedByProp ? ariaDescribedByProp : null;\n const mergedAriaDescribedBy = [extraDescribedBy, internalDescribedBy].filter(Boolean).join(' ') || null;\n\n return (\n <input\n id={uniqueId}\n {...restProps}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'autocomplete'\n autocomplete={autocomplete}\n aria-required={restProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n // eslint-disable-next-line react/no-unknown-property -- Preact uses lowercase 'spellcheck'\n spellcheck={spellcheck}\n autoCorrect={autoCorrect}\n aria-describedby={mergedAriaDescribedBy}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellcheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","input","target","value","trimValWithOneSpace","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","ariaDescribedByProp","autocomplete","restProps","mergedAriaDescribedBy","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","filter","Boolean","join","h","id","aria-required","required","readOnly","aria-describedby","aria-invalid","onFocus","ref","defaultProps"],"mappings":"oWA+Ce,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,EACfC,IACGnB,EAAMoB,UAAUD,IAEpB,CAACnB,EAAMoB,UAULC,EAAiBH,EAClBC,IACOnB,GAAOsB,YAAYtB,EAAMsB,WAAWH,IAE5C,CAACnB,GAAOsB,aASNC,EAAcL,EACfC,IACOnB,GAAOwB,SAASxB,EAAMwB,QAAQL,IAEtC,CAACnB,GAAOwB,UAGNC,EAAaP,EACdC,IAGG,GAFAnB,GAAO0B,gBAAgBP,GAEnBnB,EAAM2B,WAAY,CAClB,MAAMC,EAAQT,EAAMU,OACpBD,EAAME,MAAQC,EAAoBH,EAAME,MAC5C,CAEA9B,GAAOgC,SAASb,IAEpB,CAACnB,EAAMgC,OAAQhC,EAAM0B,gBAGnBO,EAAcf,EACfC,IACGnB,GAAOkC,iBAAiBf,IAE5B,CAACnB,EAAMkC,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B7B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,IAEnCF,GAAsB,IAAImC,IAAIC,GAAK,0BAA0BA,OAK9DpC,mBAAoBqC,EACpB/B,SAAUgC,EACVrC,UAAWsC,EACXrC,QAASsC,EACTC,qBAAsBC,EACtB,mBAAoBC,EAAmBC,aACvCA,KACGC,GACH/C,EAIEgD,EAAwB,CAD0B,iBAAxBH,GAAoCA,EAAsBA,EAAsB,KADpFrC,EAAW,GAAGA,IAAWL,EAAY8C,EAAoBC,IAAwB,MAEvCC,OAAOC,SAASC,KAAK,MAAQ,KAEnG,OACIC,EAAC1B,QAAAA,CACG2B,GAAI/C,KACAuC,EAEJD,aAAcA,EACdU,gBAAeT,EAAUU,SACzBlD,KAAMA,EACNG,UAAWyB,EACXuB,SAAUrD,EAEVC,WAAYA,EACZL,YAAaA,EACb0D,mBAAkBX,EAClBY,eAAczD,EACdiB,QAASH,EACTe,OAAQP,EACRoC,QAAS5B,EACTT,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACVqD,IAAK/D,GAGjB,CAEAD,EAAUiE,aAAe,CACrBxD,KAAM,OACNL,mBAAoB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as s,useState as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import n from"../CompanyDetails/CompanyDetails.js";import t from"../PersonalDetails/PersonalDetails.js";import a from"../Address/Address.js";import l from"../FormFields/Checkbox/Checkbox.js";import d from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as c,fieldsetsSchema as m,getActiveFieldsData as p}from"./utils.js";import
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as s,useState as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import n from"../CompanyDetails/CompanyDetails.js";import t from"../PersonalDetails/PersonalDetails.js";import a from"../Address/Address.js";import l from"../FormFields/Checkbox/Checkbox.js";import d from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as c,fieldsetsSchema as m,getActiveFieldsData as p}from"./utils.js";import u from"../IbanInput/IbanInput.js";import b from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import C from"./useSRPanelForOpenInvoiceErrors.js";import h from"../../../_virtual/index.js";const f={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function A(A){const{countryCode:v,visibility:k}=A,{i18n:g}=i(),x=s({});Object.keys(x.current).length||A.setComponentRef?.(x.current);const D=s(!1),j=s(null),F=c(k,A.data),[R,w]=r(F),{current:E}=s(m.reduce((e,s)=>(e[s]=e=>{E[s].current=e},e),{})),I=!!A.consentCheckboxLabel,S=!I&&Object.keys(R).every(e=>!R[e]),q="editable"===k.deliveryAddress&&"hidden"!==k.billingAddress,[P,V]=r({...A.data,...I&&{consentCheckbox:!1}}),[M,N]=r({}),[_,O]=r({}),[L,B]=r("ready");x.current.showValidation=()=>{D.current=!0,m.forEach(e=>{E[e].current&&E[e].current.showValidation()}),N({...I&&{consentCheckbox:P.consentCheckbox?null:f}})},x.current.setStatus=B,C({errors:M,data:P,props:A,isValidating:D,containerRef:j}),o(()=>{const e=Object.keys(R).every(e=>!R[e]||!!_[e]),s=!I||!!_.consentCheckbox,r=e&&s,o=p(R,P);A.onChange({data:o,errors:M,valid:_,isValid:r})},[P,R]);const z=e=>s=>{V(r=>({...r,[e]:s.data})),O(r=>({...r,[e]:s.isValid})),N(r=>({...r,[e]:s.errors}))};return e("div",{ref:j,className:h({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===L})},e(y,null),R.companyDetails&&e(n,{data:A.data.companyDetails,label:"companyDetails",onChange:z("companyDetails"),setComponentRef:E.companyDetails,visibility:k.companyDetails}),R.personalDetails&&e(t,{data:A.data.personalDetails,requiredFields:A.personalDetailsRequiredFields,label:"personalDetails",onChange:z("personalDetails"),setComponentRef:E.personalDetails,visibility:k.personalDetails}),R.bankAccount&&e(u,{holderName:!0,label:"ach.bankAccount",data:P.bankAccount,onChange:z("bankAccount"),ref:E.bankAccount}),R.billingAddress&&e(a,{allowedCountries:A?.billingAddressSpecification?.allowedCountries??A.allowedCountries,countryCode:v,requiredFields:A.billingAddressRequiredFields,specifications:A.billingAddressSpecification,data:P.billingAddress,label:"billingAddress",onChange:z("billingAddress"),setComponentRef:E.billingAddress,visibility:k.billingAddress}),q&&e(b,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(l,{label:g.get("separateDeliveryAddress"),checked:R.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{w(e=>({...e,deliveryAddress:!R.deliveryAddress}))}})),R.deliveryAddress&&e(a,{allowedCountries:A?.deliveryAddressSpecification?.allowedCountries??A.allowedCountries,countryCode:v,requiredFields:A.deliveryAddressRequiredFields,specifications:A.deliveryAddressSpecification,data:P.deliveryAddress,label:"deliveryAddress",onChange:z("deliveryAddress"),setComponentRef:E.deliveryAddress,visibility:k.deliveryAddress}),I&&e(d,{data:P,errorMessage:!!M.consentCheckbox,label:A.consentCheckboxLabel,onChange:e=>{const{checked:s}=e.target;V(e=>({...e,consentCheckbox:s})),O(e=>({...e,consentCheckbox:s})),N(e=>({...e,consentCheckbox:s?null:f}))},i18n:g}),A.showPayButton&&A.payButton({status:L,classNameModifiers:[...S?["standalone"]:[]],label:g.get("confirmPurchase")}))}export{A as default};
|
|
2
2
|
//# sourceMappingURL=OpenInvoice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\nimport classNames from 'classnames';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: Readonly<OpenInvoiceProps>) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\n <FormInstruction />\n\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"ach.bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"6zBA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,GAChC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,IAE9CC,OAAOC,KAAKH,EAAeI,SAASC,QACrCV,EAAMW,kBAAkBN,EAAeI,SAG3C,MAAMG,EAAeN,GAAO,GAEtBO,EAAqDC,EAA0BZ,EAAYF,EAAMe,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EJ,QAASU,GAAkBb,EAC/Bc,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUd,QAAUe,GAE/BF,GACR,CAAA,IAIDG,IAAuBzB,EAAM0B,qBAC7BC,GAAsBF,GAAsBlB,OAAOC,KAAKQ,GAAiBY,MAAMC,IAAQb,EAAgBa,IACvGC,EAAqE,aAA/B5B,EAAW6B,iBAAgE,WAA9B7B,EAAW8B,gBAE7FjB,EAAMkB,GAAWf,EAA+B,IAChDlB,EAAMe,QACLU,GAAsB,CAAES,iBAAiB,MAE1CC,EAAQC,GAAalB,EAAgC,CAAA,IACrDmB,EAAOC,GAAYpB,EAAgC,CAAA,IACnDqB,EAAQC,GAAatB,EAAS,SAGrCb,EAAeI,QAAQgC,eAAiB,KACpC7B,EAAaH,SAAU,EACvBW,EAAgBsB,QAAQnB,IAChBJ,EAAcI,GAAUd,SAASU,EAAcI,GAAUd,QAAQgC,mBAGzEL,EAAU,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AAK8E,IAAI,qBAIpC"}
|
|
1
|
+
{"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\nimport classNames from 'classnames';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: Readonly<OpenInvoiceProps>) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating, containerRef });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div\n ref={containerRef}\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\n <FormInstruction />\n\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"ach.bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","containerRef","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"6zBA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,GAChC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,IAE9CC,OAAOC,KAAKH,EAAeI,SAASC,QACrCV,EAAMW,kBAAkBN,EAAeI,SAG3C,MAAMG,EAAeN,GAAO,GACtBO,EAAeP,EAAuB,MAEtCQ,EAAqDC,EAA0Bb,EAAYF,EAAMgB,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EL,QAASW,GAAkBd,EAC/Be,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUf,QAAUgB,GAE/BF,GACR,CAAA,IAIDG,IAAuB1B,EAAM2B,qBAC7BC,GAAsBF,GAAsBnB,OAAOC,KAAKS,GAAiBY,MAAMC,IAAQb,EAAgBa,IACvGC,EAAqE,aAA/B7B,EAAW8B,iBAAgE,WAA9B9B,EAAW+B,gBAE7FjB,EAAMkB,GAAWf,EAA+B,IAChDnB,EAAMgB,QACLU,GAAsB,CAAES,iBAAiB,MAE1CC,EAAQC,GAAalB,EAAgC,CAAA,IACrDmB,EAAOC,GAAYpB,EAAgC,CAAA,IACnDqB,EAAQC,GAAatB,EAAS,SAGrCd,EAAeI,QAAQiC,eAAiB,KACpC9B,EAAaH,SAAU,EACvBY,EAAgBsB,QAAQnB,IAChBJ,EAAcI,GAAUf,SAASW,EAAcI,GAAUf,QAAQiC,mBAGzEL,EAAU,IACFX,GAAsB,CAAES,gBAAiBnB,EAAKmB,gBAAkB,KAAOxC,MAInFU,EAAeI,QAAQgC,UAAYA,EAEnCG,EAA+B,CAAER,SAAQpB,OAAMhB,Q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State as e,useMemo as s,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as o}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as t}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as i}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as l,ERROR_ACTION_FOCUS_FIELD as a}from"../../../core/Errors/constants.js";import c from"../../../core/Errors/useSRPanelContext.js";import n from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as u}from"../../../utils/hookUtils.js";import{getArrayDifferences as p}from"../../../utils/arrayUtils.js";import{mapFieldKey as f}from"./utils.js";const m=({errors:m,data:y,props:b,isValidating:j,containerRef:F})=>{const[g,A]=e(null),h=u(g),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:C,clearSRPanel:k,shouldMoveFocusSR:v}=c(),D=S?.({fieldTypeMappingFn:f}),R=s(()=>new n,[]),T=s(()=>new n(b.deliveryAddressSpecification),[]);r(()=>{try{const e="deliveryAddress:",s="billingAddress:",{companyDetails:r,personalDetails:c,bankAccount:n,billingAddress:u,deliveryAddress:f,...g}=m,S=o(u,s),E=o(f,e),M={..."object"==typeof r&&r,..."object"==typeof c&&c,..."object"==typeof n&&n,..."object"==typeof S&&S,..."object"==typeof E&&E,...g},$=t,x=b.personalDetailsRequiredFields??i,L=i.filter(e=>x?.includes(e)),P=["holder","iban"],w=R.getAddressSchemaForCountryFlat(y.billingAddress?.country).map(e=>`${s}${e}`),U=T.getAddressSchemaForCountryFlat(y.deliveryAddress?.country).map(s=>`${e}${s}`),V=$.concat(L,P,w,U,["consentCheckbox"]),_=R.getAddressLabelsForCountry(y.billingAddress?.country),q=T.getAddressLabelsForCountry(y.deliveryAddress?.country),B=D?.({errors:M,isValidating:j.current,layout:V,countrySpecificLabels:{..._,...q}}),O=B?.currentErrorsSortedByLayout;switch(A(O),B?.action){case a:{const e=B.fieldToFocus.includes(":")?B.fieldToFocus.split(":")[1]:B.fieldToFocus;let s="";const r=B.fieldToFocus.includes(":")?B.fieldToFocus.split(":")[0]:"";r.length&&(s=`.adyen-checkout__fieldset--${r} `),v&&F.current&&d(F.current,e,s),setTimeout(()=>{j.current=!1},300);break}case l:{const e=p(O,h,"field"),s=e?.[0];if(s){const e="shopperEmail"===s.field&&"field.error.invalid"===s.errorCode?s.errorMessage:null;C(e)}else k();break}}}catch(e){}},[m,y])};export{m as default};
|
|
2
2
|
//# sourceMappingURL=useSRPanelForOpenInvoiceErrors.js.map
|