@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 3.5 kB
JavaScript
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 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,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function c(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),r.forEach(function(e){a(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 m extends e{formatProps(t){const{apps:e=[]}=t,o=e.length>0;return s()&&o?u(c({},super.formatProps(t)),{apps:e}):(this.mode=p.QR_CODE,u(c({},super.formatProps(t)),{apps:[]}))}get isValid(){return this.state.isValid}formatData(){const{app:t}=this.state.data||{};return{paymentMethod:c({type:this.paymentType},this.paymentType===i.upi_intent&&(null==t?void 0:t.id)&&{appId:t.id})}}get paymentType(){return this.mode===p.QR_CODE?i.upi_qr:i.upi_intent}componentToRender(){const{type:e,url:s,paymentMethodType:p}=this.props,a=!!this.props.mandate;switch(e){case"qrCode":var m;return t(n,u(c({},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:null!==(m=this.props.countdownTime)&&void 0!==m?m:5,onActionHandled:this.onActionHandled,showAmount:!a}));case"await":var d;return t(r,{url:s,type:p,showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!a,countdownTime:null!==(d=this.props.countdownTime)&&void 0!==d?d: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(o,{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,e){super(t,e),a(this,"mode",void 0);const{defaultMode:o}=e;o&&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