UNPKG

@juspay/blaze-sdk-web

Version:

SDK for integrating Breeze 1CCO into your Web Application

2 lines (1 loc) 1.83 kB
let t=[],e=[],n=null;function o(i){if("object"==typeof window.BlazeSDK&&"function"==typeof window.BlazeSDK.initiate&&"function"==typeof window.BlazeSDK.process){if(t.length>0&&(window.BlazeSDK.initiate(t.at(0),i,n),t=[]),e.length>0){const t=e;e=[],t.forEach((t=>{window.BlazeSDK.process(t)}))}return!0}{let t=0;const e=setInterval((()=>{t>5&&clearInterval(e);o(i)&&clearInterval(e),t++}))}return!1}function i(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}var a={initiate:function(e,a,r=null){try{const l=document.createElement("script");l.src="https://sdk.breeze.in/electron/191.0.0/index.js",l.type="module",l.id="breeze-script-tag",l.async=!0,t.push(e);const s=i(e)&&i(e.payload)?e.payload:{},c="string"==typeof s.merchantId?s.merchantId:null,d="string"==typeof s.shopUrl?s.shopUrl:null,p="string"==typeof s.shopId?s.shopId:null,u="string"==typeof s.environment?s.environment:"production";null!==c&&l.setAttribute("data-merchantid",c),null!==d&&l.setAttribute("data-shopurl",d),null!==p&&l.setAttribute("data-shopid",p),l.setAttribute("data-environment",u),l.onload=()=>{try{const t=document.createElement("breeze-button");t.style.display="none",document.body.appendChild(t),o(a)}catch(t){console.error("Error creating Breeze button",t)}},n=r,document.body.appendChild(l)}catch(t){}},process:function(t){"object"==typeof window.BlazeSDK&&"function"==typeof window.BlazeSDK.process?window.BlazeSDK.process(t):e.push(t)},terminate:function(){"object"==typeof window.BlazeSDK&&"function"==typeof window.BlazeSDK.terminate&&window.BlazeSDK.terminate()}};class r{static initiatePayload;static callback;static processPayload;static initiate(t,e,n=null){this.callback=e,this.initiatePayload=t,a.initiate(t,e,n)}static process(t){this.processPayload=t,a.process(t)}static terminate(){a.terminate()}}export{r as default};