@tiltbike/razorpay-checkout-js
Version:
Razorpay checkout.js loading utility
3 lines (2 loc) • 1.13 kB
JavaScript
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o(e.razorpayCheckoutJs={})}(this,function(e){var o="https://checkout.razorpay.com/v1/checkout.js",n=Promise.resolve().then(function(){if("undefined"==typeof window)return null;if(window.Razorpay)return window.Razorpay;var e=document.querySelector('script[src="'+o+'"], script[src="'+o+'/"]')||function(){var e=document.createElement("script");e.src=o;var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. checkout.js requires a <body> element.");return n.appendChild(e),e}();return new Promise(function(o,n){e.addEventListener("load",function(){window.Razorpay?o(window.Razorpay):n(new Error("checkout.js not available"))}),e.addEventListener("error",function(){n(new Error("Failed to load checkout.js"))})})}),t=!1;n.catch(function(e){t||console.warn(e)}),e.loadCheckout=function(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];return t=!0,n.then(function(o){return o?o.apply(void 0,e):null})}});
//# sourceMappingURL=checkout.umd.js.map