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.71 kB
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as o}from"../internal/UIElement/UIElement.js";import e from"./components/UPIComponent/UPIComponent.js";import{Await as r}from"../internal/Await/Await.js";import{QRLoader as n}from"../internal/QRLoader/QRLoader.js";import"../../core/Context/CoreProvider.js";import"../../external/preact/hooks/dist/hooks.js";import"../../core/Errors/AdyenCheckoutError.js";import"../../core/Errors/SRPanelContext.js";import"../internal/Button/Button.js";import"../internal/QRLoader/QRLoaderDetailsProvider.js";import{TxVariants as i}from"../tx-variants.js";import s from"../../utils/isMobile.js";import{UPI_MODE as p}from"./constants.js";function a(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}class m extends o{formatProps(t){const{apps:o=[]}=t,e=o.length>0;return s()&&e?{...super.formatProps(t),apps:o}:(this.mode=p.QR_CODE,{...super.formatProps(t),apps:[]})}get isValid(){return this.state.isValid}formatData(){const{app:t}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===i.upi_intent&&t?.id&&{appId:t.id}}}}get paymentType(){return this.mode===p.QR_CODE?i.upi_qr:i.upi_intent}componentToRender(){const{type:o,url:s,paymentMethodType:p}=this.props,a=!!this.props.mandate;switch(o){case"qrCode":return t(n,{...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:i.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:this.props.countdownTime??5,onActionHandled:this.onActionHandled,showAmount:!a});case"await":return t(r,{url:s,type:p,showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!a,countdownTime:this.props.countdownTime??5,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(e,{ref:t=>{this.componentRef=t},payButton:this.payButton,onChange:this.setState,apps:this.props.apps,mode:this.mode,showPayButton:this.props.showPayButton,mandate:this.props.mandate})}}constructor(t,o){super(t,o),a(this,"mode",void 0);const{defaultMode:e}=o;e&&console.warn('[Adyen Checkout] UPI configuration property "defaultMode" is deprecated and will be removed in a future version.'),this.mode=s()?p.INTENT:p.QR_CODE}}a(m,"type",i.upi),a(m,"txVariants",[i.upi,i.upi_qr,i.upi_intent]);export{m as default}; //# sourceMappingURL=UPI.js.map