@tiltbike/razorpay-checkout-js
Version:
Razorpay checkout.js loading utility
3 lines (2 loc) • 946 B
JavaScript
var e="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 n=document.querySelector('script[src="'+e+'"], script[src="'+e+'/"]')||function(){var n=document.createElement("script");n.src=e;var o=document.head||document.body;if(!o)throw new Error("Expected document.body not to be null. checkout.js requires a <body> element.");return o.appendChild(n),n}();return new Promise(function(e,o){n.addEventListener("load",function(){window.Razorpay?e(window.Razorpay):o(new Error("checkout.js not available"))}),n.addEventListener("error",function(){o(new Error("Failed to load checkout.js"))})})}),o=!1;n.catch(function(e){o||console.warn(e)}),exports.loadCheckout=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return o=!0,n.then(function(n){return n?n.apply(void 0,e):null})};
//# sourceMappingURL=checkout.js.map