UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 2.67 kB
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import r from"./components/ANCVInput.js";import{CoreProvider as s}from"../../core/Context/CoreProvider.js";import o from"./components/ANCVAwait/config.js";import n from"../internal/Await/Await.js";import i from"../../core/Errors/SRPanelProvider.js";import a from"../../core/Errors/AdyenCheckoutError.js";import p from"../internal/PayButton/PayButton.js";import{sanitizeResponse as h,verifyPaymentDidNotFail as m}from"../internal/UIElement/utils.js";function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class d extends e{formatData(){return{paymentMethod:{type:d.type,beneficiaryId:this.state.data?.beneficiaryId}}}submit(){if(!this.isValid)return this.showValidation(),!1;this.createOrder().then(this.makePaymentsCall).then(h).then(m).then(this.handleResponse).catch(this.handleFailedResult)}get isValid(){return!!this.state.isValid}get displayName(){return this.props.name}render(){return this.props.paymentData?t(s,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{srPanel:this.props.modules.srPanel},t(n,{ref:t=>{this.componentRef=t},clientKey:this.props.clientKey,paymentData:this.props.paymentData,onError:this.props.onError,onComplete:this.onComplete,brandLogo:this.icon,type:this.constructor.type,messageText:this.props.i18n.get("ancv.confirmPayment"),awaitText:this.props.i18n.get("await.waitForConfirmation"),showCountdownTimer:o.showCountdownTimer,throttleTime:o.THROTTLE_TIME,throttleInterval:o.THROTTLE_INTERVAL,onActionHandled:this.onActionHandled}))):t(s,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(r,{ref:t=>{this.componentRef=t},...this.props,onSubmit:this.submit,onChange:this.setState,payButton:this.payButton,showPayButton:this.props.showPayButton}))}constructor(...e){super(...e),l(this,"onOrderRequest",(t=>this.props.onOrderRequest?new Promise(((e,r)=>{this.props.onOrderRequest(e,r,t)})):this.props.session?this.props.session.createOrder():void 0)),l(this,"createOrder",(()=>(this.setStatus("loading"),this.props.order?Promise.resolve():this.onOrderRequest(this.data).then((t=>{const e={order:{orderData:t.orderData,pspReference:t.pspReference}};return this.setState(e),Promise.resolve()})).catch((t=>{this.setStatus(t?.message||"error"),this.props.onError&&(t instanceof a?this.handleError(t):this.handleError(new a("ERROR",t)))}))))),l(this,"payButton",(e=>t(p,e)))}}l(d,"type","ancv");export{d as ANCVElement,d as default}; //# sourceMappingURL=ANCV.js.map