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) 3.94 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 r}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 i}from"../tx-variants.js";import s 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}function d(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),n.forEach(function(e){m(t,e,o[e])})}return t}function u(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 o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))}),t}class l extends e{formatProps(t){return d({showOtherInsteadOfNumber:!s()},t)}get isValid(){return this.state.isValid}formatData(){const{app:t}=this.state.data||{};return{paymentMethod:d({type:this.paymentType},this.paymentType===i.upi_intent&&(null==t?void 0: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?i.upi_qr:i.upi_intent}componentToRender(){const{type:e,url:s,paymentMethodType:a}=this.props,p=!!this.props.mandate;switch(e){case"qrCode":var m,l;return t(r,u(d({},this.props),{qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):void 0,type:i.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:null!==(m=null===(l=this.props.i18n)||void 0===l?void 0:l.get("upi.qrCodeWaitingMessage"))&&void 0!==m?m:"",countdownTime:this.props.countdownTime,onActionHandled:this.onActionHandled,showAmount:!p}));case"await":var c,h,y,f,v;return t(n,{url:s,type:null!=a?a:"",showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!p,countdownTime:this.props.countdownTime,clientKey:null!==(c=this.props.clientKey)&&void 0!==c?c:"",paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:null!==(h=null===(f=this.props.i18n)||void 0===f?void 0:f.get("upi.vpaWaitingMessage"))&&void 0!==h?h:"",awaitText:null!==(y=null===(v=this.props.i18n)||void 0===v?void 0:v.get("await.waitForConfirmation"))&&void 0!==y?y:"",onComplete:this.onComplete,brandLogo:this.icon});default:var w;return t(o,{setComponentRef:this.setComponentRef,payButton:this.payButton,onChange:this.setState,appsList:this.appsList,mode:this.mode,showPayButton:null===(w=this.props.showPayButton)||void 0===w||w,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=s()&&n?a.INTENT:a.QR_CODE,this.appsList=o.map(t=>{var e,o;const n=`upi/${t.id.toLowerCase()}`,r=null!==(e=null===(o=this.core.modules.resources)||void 0===o?void 0:o.getImage()(n))&&void 0!==e?e:"";return{id:t.id,name:t.name,icon:r}})}}m(l,"type",i.upi),m(l,"txVariants",[i.upi,i.upi_qr,i.upi_intent]),m(l,"defaultProps",{showPaymentMethodItemImages:!0,countdownTime:p});export{l as default}; //# sourceMappingURL=UPI.js.map