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.92 kB
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{Await as n}from"../internal/Await/Await.js";import{QRLoader as i}from"../internal/QRLoader/QRLoader.js";import"../../core/Context/CoreProvider.js";import"../../external/preact/hooks/dist/hooks.js";import"../../core/Errors/SRPanelContext.js";import"../internal/Button/Button.js";import"../internal/QRLoader/QRLoaderDetailsProvider.js";import{TxVariants as s}from"../tx-variants.js";import r from"../../utils/isMobile.js";import{UPI_MODE as a,UPI_COUNTDOWN_TIME as p}from"./constants.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d extends e{formatProps(t){return{showOtherInsteadOfNumber:!r(),...t}}get isValid(){return this.state.isValid}formatData(){const{app:t}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===s.upi_intent&&t?.id&&{appId:t.id}}}}get brands(){const{showPaymentMethodItemImages:t}=this.props;return t?this.appsList.map(t=>({icon:t.icon,name:t.name})):[]}get paymentType(){return this.mode===a.QR_CODE?s.upi_qr:s.upi_intent}componentToRender(){const{type:e,url:r,paymentMethodType:a}=this.props,p=!!this.props.mandate;switch(e){case"qrCode":return t(i,{...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):void 0,type:s.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n?.get("upi.qrCodeWaitingMessage")??"",countdownTime:this.props.countdownTime,onActionHandled:this.onActionHandled,showAmount:!p});case"await":return t(n,{url:r,type:a??"",showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!p,countdownTime:this.props.countdownTime,clientKey:this.props.clientKey??"",paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n?.get("upi.vpaWaitingMessage")??"",awaitText:this.props.i18n?.get("await.waitForConfirmation")??"",onComplete:this.onComplete,brandLogo:this.icon});default:return t(o,{setComponentRef:this.setComponentRef,payButton:this.payButton,onChange:this.setState,appsList:this.appsList,mode:this.mode,showPayButton:this.props.showPayButton??!0,mandate:this.props.mandate,onSubmitAnalytics:this.submitAnalytics})}}constructor(t,e){super(t,e),m(this,"mode",void 0),m(this,"appsList",void 0);const{apps:o=[]}=this.props,n=o.length>0;this.mode=r()&&n?a.INTENT:a.QR_CODE,this.appsList=o.map(t=>{const e=`upi/${t.id.toLowerCase()}`,o=this.core.modules.resources?.getImage()(e)??"";return{id:t.id,name:t.name,icon:o}})}}m(d,"type",s.upi),m(d,"txVariants",[s.upi,s.upi_qr,s.upi_intent]),m(d,"defaultProps",{showPaymentMethodItemImages:!0,countdownTime:p});export{d as default}; //# sourceMappingURL=UPI.js.map