UNPKG

@atlas-kitchen/adyen-web

Version:
3 lines (2 loc) 2.99 kB
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/Challenge/PrepareChallenge3DS2.js";import{THREEDS2_CHALLENGE_ERROR as o,THREEDS2_FULL as n,THREEDS2_CHALLENGE as s,DEFAULT_CHALLENGE_WINDOW_SIZE as i}from"./constants.js";import{existy as c}from"../../utils/commonUtils.js";import{hasOwnProperty as p}from"../../utils/hasOwnProperty.js";import{TxVariants as a}from"../tx-variants.js";import l,{API_ERROR as m}from"../../core/Errors/AdyenCheckoutError.js";import{ANALYTICS_ERROR_TYPE as u,Analytics3DS2Errors as y,ANALYTICS_RENDERED_STR as f,Analytics3DS2Events as h}from"../../core/Analytics/constants.js";import{CoreProvider as b}from"../../core/Context/CoreProvider.js";import{AnalyticsLogEvent as j}from"../../core/Analytics/AnalyticsLogEvent.js";import{AnalyticsInfoEvent as A}from"../../core/Analytics/AnalyticsInfoEvent.js";import{AnalyticsErrorEvent as O}from"../../core/Analytics/AnalyticsErrorEvent.js";function d(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function g(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}class D extends e{onComplete(t){t&&super.onComplete(t),this.unmount()}render(){if(!c(this.props.paymentData)){const t=p(this.props,"isMDFlow")?"paymentData":"authorisationToken";this.props.onError(new l(m,`No ${t} received. 3DS2 Challenge cannot proceed`));const e=new O({code:y.ACTION_IS_MISSING_PAYMENT_DATA,errorType:u.apiError,message:`${o}: Missing 'paymentData' property from threeDS2 action`});return this.submitAnalytics(e),null}return t(b,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(r,g(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){d(t,e,r[e])}))}return t}({},this.props),{onComplete:this.onComplete,onSubmitAnalytics:this.submitAnalytics,isMDFlow:this.props.paymentData.length<15,onActionHandled:this.onActionHandled})))}constructor(...t){super(...t),d(this,"submitAnalytics",(t=>{t instanceof A&&t.type===f||super.submitAnalytics(t)})),d(this,"onActionHandled",(t=>{const e=new j({type:n,message:t.actionDescription,subType:h.CHALLENGE_IFRAME_LOADED});this.submitAnalytics(e),super.onActionHandled(t)}))}}d(D,"type",a.threeDS2Challenge),d(D,"defaultProps",{dataKey:"threeDSResult",size:i,type:s});export{D as default}; //# sourceMappingURL=ThreeDS2Challenge.js.map