@tiltbike/razorpay-checkout-js
Version:
Razorpay checkout.js loading utility
3 lines (2 loc) • 959 B
JavaScript
var e="https://checkout.razorpay.com/v1/checkout.js",r=Promise.resolve().then(function(){if("undefined"==typeof window)return null;if(window.Razorpay)return window.Razorpay;var r=document.querySelector('script[src="'+e+'"], script[src="'+e+'/"]')||function(){var r=document.createElement("script");r.src=e;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(r),r}();return new Promise(function(e,n){r.addEventListener("load",function(){window.Razorpay?e(window.Razorpay):n(new Error("checkout.js not available"))}),r.addEventListener("error",function(){n(new Error("Failed to load checkout.js"))})})}),n=!1;r.catch(function(e){n||console.warn(e)});var o=function(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];return n=!0,r.then(function(r){return r?r.apply(void 0,e):null})};export{o as loadCheckout};
//# sourceMappingURL=checkout.m.js.map