diff --git a/lib/index.js b/lib/index.js index 4ba70c5..7861e2d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -149,12 +149,6 @@ const gatewayModes = Object.freeze({ }; zoop.eSignGatewayInit = function (gatewayOption) { - // Validation of gateway if it's required through error.....if it's optional then assign default value - if (zoop.isNullUndefinedOrEmpty(gatewayOption.company_display_name)) { - throw new Error( - "Customer display name is mandatory to initiate gateway." - ); - } zoop.esignGatewayOptions.company_display_name = gatewayOption.company_display_name; zoop.esignGatewayOptions.color_bg = zoop.check(gatewayOption, "color_bg") @@ -236,10 +230,16 @@ const gatewayModes = Object.freeze({ ); } zoop.esignGatewayOptions.transaction_id = transaction_id; - if ( - zoop.isNullUndefinedOrEmpty(zoop.esignGatewayOptions.company_display_name) - ) { - throw new Error("Company Display Name is mandatory in gateway options."); + if (version == "v3") { + if ( + zoop.isNullUndefinedOrEmpty( + zoop.esignGatewayOptions.company_display_name + ) + ) { + throw new Error( + "Company Display Name is mandatory in gateway options." + ); + } } switch (version) { diff --git a/zoop-sdk.min.js b/zoop-sdk.min.js index 359ab81..10288ff 100644 --- a/zoop-sdk.min.js +++ b/zoop-sdk.min.js @@ -1 +1 @@ -(()=>{const o=Object.freeze({POPUP:"POPUP",TAB:"TAB",REDIRECT:"REDIRECT"});!function(){var e={staging:"https://preprod.aadhaarapi.com",production:"https://prod.aadhaarapi.com",bsaURL:"https://bsa.aadhaarapi.com",itdURL:"https://itd.zoop.one",itdProdURL:"https://itd.zoop.one",itdStagingURL:"https://itd-staging.zoop.one",eSignV4URL:"https://esign.zoop.one",digilockerV1URL:"https://gateway.zoop.one/digilocker/v1",url:"https://prod.aadhaarapi.com",zoopModel:window.document.getElementById("zoop-gateway-model"),zoopWindow:null},t={zoopGateWayModel:{display:"none",position:"fixed","z-index":1,left:0,top:0,width:"100%",height:"100%",overflow:"auto","background-color":"rgba(0, 0, 0, 0.4)"},zoopModelContent:{"border-radius":"10px","background-color":"#fefefe","margin-top":"50px","margin-bottom":"auto","margin-left":"auto","margin-right":"auto",padding:" -1px",width:"700px",height:"675px"},iframe:{"border-radius":"inherit",margin:"0px",padding:"0px",border:"none"}},n={options:e,styles:t,esignGatewayOptions:{gateway_url:"",transaction_id:"",company_display_name:"",color_bg:"0FACF3",color_ft:"FFFFFF",logo_url:"",otp_mode:"y",fp_mode:"y",ir_mode:"y",phone_auth:"null",draggable_sign:"y",google_sign:"null",customer_email:"",customer_phone:"",show_download_btn:"Y",mode:"POPUP"},incomeTaxReturnsOptions:{txt_color:"202020",bg_color:"f5f5f5",btn_color:"0075f3",btn_txt_color:"ffffff",platform:"web",sdk_version:"2",logo_url:""},digilockerGatewayOption:{request_id:"",gatewayURL:e.digilockerV1URL},check:function(o,e){return!!o.hasOwnProperty(e)&&(!!n.isNullUndefinedOrEmpty(o[e])||"undefined"!==e&&null!==e&&0!==e.length)},onError:function(){},onSuccess:function(){},isNullUndefinedOrEmpty:function(o){return null==o||0===o.length},setEnvironment:function(o){switch(o){case"production":n.options.url=n.options.production,n.options.itdURL=n.options.itdProdURL;break;case"staging":n.options.url=n.options.staging,n.options.itdURL=n.options.itdStagingURL}},setStyles:function(o,e,t){let n;if("class"==t){const e=document.getElementByClass(o);n=e&&e.style}else if("id"==t){const e=document.getElementById(o);n=e&&e.style}else n=document.getElementsByTagName(o);if(n&&Object.keys(e).length)for(var i in e)n[i]=e[i]},eSignGatewayInit:function(e){if(n.isNullUndefinedOrEmpty(e.company_display_name))throw new Error("Customer display name is mandatory to initiate gateway.");return n.esignGatewayOptions.company_display_name=e.company_display_name,n.esignGatewayOptions.color_bg=n.check(e,"color_bg")?e.color_bg:n.esignGatewayOptions.color_bg,n.esignGatewayOptions.color_ft=n.check(e,"color_ft")?e.color_ft:n.esignGatewayOptions.color_ft,n.esignGatewayOptions.logo_url=n.check(e,"logo_url")?e.logo_url:n.esignGatewayOptions.logo_url,n.esignGatewayOptions.otp_mode=n.check(e,"otp_mode")?e.otp_mode:n.esignGatewayOptions.otp_mode,n.esignGatewayOptions.fp_mode=n.check(e,"fp_mode")?e.fp_mode:n.esignGatewayOptions.fp_mode,n.esignGatewayOptions.ir_mode=n.check(e,"ir_mode")?e.ir_mode:n.esignGatewayOptions.ir_mode,n.esignGatewayOptions.phone_auth=n.check(e,"phone_auth")?e.phone_auth:n.esignGatewayOptions.phone_auth,n.esignGatewayOptions.draggable_sign=n.check(e,"draggable_sign")?e.draggable_sign:n.esignGatewayOptions.draggable_sign,n.esignGatewayOptions.google_sign=n.check(e,"google_sign")?e.google_sign:n.esignGatewayOptions.google_sign,n.esignGatewayOptions.customer_email=n.check(e,"customer_email")?e.customer_email:n.esignGatewayOptions.customer_email,n.esignGatewayOptions.customer_phone=n.check(e,"customer_phone")?e.customer_phone:n.esignGatewayOptions.customer_phone,n.esignGatewayOptions.show_download_btn=n.check(e,"show_download_btn")?e.show_download_btn:n.esignGatewayOptions.show_download_btn,n.esignGatewayOptions.mode=n.check(e,"mode")?e.mode:n.esignGatewayOptions.mode,e.mode&&e.mode.toUpperCase()===o.TAB?n.esignGatewayOptions.mode=o.TAB:e.mode&&e.mode.toUpperCase()===o.REDIRECT?n.esignGatewayOptions.mode=o.REDIRECT:n.esignGatewayOptions.mode=o.POPUP,n.options.zoopModel=window.document.getElementById("zoop-gateway-model"),!0},eSignGateway:function(e,t="v4"){if(n.isNullUndefinedOrEmpty(e))throw new Error("Gateway Transaction Id is mandatory to initiate gateway.");if(n.esignGatewayOptions.transaction_id=e,n.isNullUndefinedOrEmpty(n.esignGatewayOptions.company_display_name))throw new Error("Company Display Name is mandatory in gateway options.");switch(t){case"v3":n.esignGatewayOptions.gateway_url=n.options.url+"/esign/gateway/v3";break;default:n.esignGatewayOptions.gateway_url=n.options.eSignV4URL+"/v4/viewer",n.esignGatewayOptions.mode===o.POPUP&&(n.esignGatewayOptions.mode=o.TAB)}let i=n.esignGatewayOptions.gateway_url+"/"+n.esignGatewayOptions.transaction_id+"?company_display_name="+n.esignGatewayOptions.company_display_name+"&color_bg="+n.esignGatewayOptions.color_bg+"&color_ft="+n.esignGatewayOptions.color_ft+"&otp_mode="+n.esignGatewayOptions.otp_mode+"&fp_mode="+n.esignGatewayOptions.fp_mode+"&ir_mode="+n.esignGatewayOptions.ir_mode+"&phone_auth="+n.esignGatewayOptions.phone_auth+"&draggable_sign="+n.esignGatewayOptions.draggable_sign+"&google_sign="+n.esignGatewayOptions.google_sign+"&can_select_device="+n.esignGatewayOptions.device_selection_allowed+"&phone="+n.esignGatewayOptions.customer_phone+"&logo_url="+n.esignGatewayOptions.logo_url+"&show_download_btn="+n.esignGatewayOptions.show_download_btn+"&mode="+n.esignGatewayOptions.mode;n.esignGatewayOptions.mode===o.TAB?null==n.options.zoopWindow||n.options.zoopWindow.closed?n.options.zoopWindow=window.open(encodeURI(i),"_blank"):n.options.zoopWindow.focus():n.esignGatewayOptions.mode===o.REDIRECT?window.location=encodeURI(i):n.esignGatewayOptions.mode===o.POPUP&&(window.document.getElementById("zoop-model-content").innerHTML='',n.options.zoopModel.style.display="block")},initBsaGateway:function(o){n.bankStatementAnalysis={url:`${n.options.bsaURL}/?session_id=${o}&platform=web&sdk_v=2`}},openBsaGateway:function(){window.location=n.bankStatementAnalysis.url},initItdGateway:function(o={}){n.incomeTaxReturnsOptions.txt_color=n.check(o,"txt_color")?o.txt_color:n.incomeTaxReturnsOptions.txt_color,n.incomeTaxReturnsOptions.bg_color=n.check(o,"bg_color")?o.bg_color:n.incomeTaxReturnsOptions.bg_color,n.incomeTaxReturnsOptions.btn_color=n.check(o,"btn_color")?o.btn_color:n.incomeTaxReturnsOptions.btn_color,n.incomeTaxReturnsOptions.btn_txt_color=n.check(o,"btn_txt_color")?o.btn_txt_color:n.incomeTaxReturnsOptions.btn_txt_color,n.incomeTaxReturnsOptions.logo_url=n.check(o,"logo_url")?o.logo_url:n.incomeTaxReturnsOptions.logo_url},openItdGateway:function(o){if(n.isNullUndefinedOrEmpty(o))throw new Error("Gateway Transaction Id is mandatory to initiate gateway.");let e=`${n.options.itdURL}/?session_id=${o}&txt_color=${n.incomeTaxReturnsOptions.txt_color}&bg_color=${n.incomeTaxReturnsOptions.bg_color}&btn_color=${n.incomeTaxReturnsOptions.btn_color}&btn_txt_color=${n.incomeTaxReturnsOptions.btn_txt_color}&logo_url=${n.incomeTaxReturnsOptions.logo_url}&platform=${n.incomeTaxReturnsOptions.platform}&sdk_version=${n.incomeTaxReturnsOptions.sdk_version}`;window.document.getElementById("zoop-model-content").innerHTML='',n.options.zoopModel.style.display="block"},initDigilockerGateway:function(o={}){},openDigilockerGateway:function(o){n.digilockerGatewayOption.request_id=o;const e=`${n.digilockerGatewayOption.gatewayURL}/start/${n.digilockerGatewayOption.request_id}`;null==n.options.zoopWindow||n.options.zoopWindow.closed?n.options.zoopWindow=window.open(encodeURI(e),"_blank"):n.options.zoopWindow.focus()}};const i={close:()=>{},"consent-denied":()=>{},"otp-error":()=>{},"gateway-error":()=>{},"esign-result":()=>{},"esign-success":()=>{},"esign-error":()=>{},"itd-error":()=>{},"itd-consent-denied":()=>{},"itd-gateway-terminated":()=>{},"itd-success":()=>{},"digilocker-error":()=>{},"digilocker-success":()=>{}};n.on=function(o="",e=(()=>{})){if("string"!=typeof o)throw new Error("Event name must be a string.");if("function"!=typeof e)throw new Error("Callback must be a function.");Object.keys(i).includes(o)?i[o]=e:console.warn(`No event found named ${o}`)},n.emit=function(o,e){i[o](e)},n.dispatchEvent=function(o){let e;if(![n.options.url,n.options.production,n.options.staging,n.options.bsaURL,n.options.itdURL,n.options.eSignV4URL,n.options.digilockerV1URL].some((e=>e.startsWith(o.origin))))return console.log("Message is not from Zoop Gateway");if(o.data&&(e=o.data,e.hasOwnProperty("action")))switch(e.action){case"close":case"consent-denied":case"otp-error":case"gateway-error":case"esign-result":case"esign-success":case"esign-error":case"itd-error":case"itd-consent-denied":case"itd-gateway-terminated":case"itd-success":case"digilocker-error":case"digilocker-success":return e.payload="string"==typeof e.payload?JSON.parse(e.payload):e.payload,n.options.zoopModel.style.display="none",window.document.getElementById("zoop-model-content").innerHTML="",n.options.zoopWindow&&!n.options.zoopWindow.closed&&n.options.zoopWindow.close(),void n.emit(e.action,e);default:console.warn("Unsupported event: ",e.action)}},n.setStyles("zoop-gateway-model",t.zoopGateWayModel,"id"),n.setStyles("zoop-model-content",t.zoopModelContent,"id"),window.addEventListener("message",n.dispatchEvent,!1),window.zoop=n}()})(); \ No newline at end of file +(()=>{const o=Object.freeze({POPUP:"POPUP",TAB:"TAB",REDIRECT:"REDIRECT"});!function(){var e={staging:"https://preprod.aadhaarapi.com",production:"https://prod.aadhaarapi.com",bsaURL:"https://bsa.aadhaarapi.com",itdURL:"https://itd.zoop.one",itdProdURL:"https://itd.zoop.one",itdStagingURL:"https://itd-staging.zoop.one",eSignV4URL:"https://esign.zoop.one",digilockerV1URL:"https://gateway.zoop.one/digilocker/v1",url:"https://prod.aadhaarapi.com",zoopModel:window.document.getElementById("zoop-gateway-model"),zoopWindow:null},t={zoopGateWayModel:{display:"none",position:"fixed","z-index":1,left:0,top:0,width:"100%",height:"100%",overflow:"auto","background-color":"rgba(0, 0, 0, 0.4)"},zoopModelContent:{"border-radius":"10px","background-color":"#fefefe","margin-top":"50px","margin-bottom":"auto","margin-left":"auto","margin-right":"auto",padding:" -1px",width:"700px",height:"675px"},iframe:{"border-radius":"inherit",margin:"0px",padding:"0px",border:"none"}},n={options:e,styles:t,esignGatewayOptions:{gateway_url:"",transaction_id:"",company_display_name:"",color_bg:"0FACF3",color_ft:"FFFFFF",logo_url:"",otp_mode:"y",fp_mode:"y",ir_mode:"y",phone_auth:"null",draggable_sign:"y",google_sign:"null",customer_email:"",customer_phone:"",show_download_btn:"Y",mode:"POPUP"},incomeTaxReturnsOptions:{txt_color:"202020",bg_color:"f5f5f5",btn_color:"0075f3",btn_txt_color:"ffffff",platform:"web",sdk_version:"2",logo_url:""},digilockerGatewayOption:{request_id:"",gatewayURL:e.digilockerV1URL},check:function(o,e){return!!o.hasOwnProperty(e)&&(!!n.isNullUndefinedOrEmpty(o[e])||"undefined"!==e&&null!==e&&0!==e.length)},onError:function(){},onSuccess:function(){},isNullUndefinedOrEmpty:function(o){return null==o||0===o.length},setEnvironment:function(o){switch(o){case"production":n.options.url=n.options.production,n.options.itdURL=n.options.itdProdURL;break;case"staging":n.options.url=n.options.staging,n.options.itdURL=n.options.itdStagingURL}},setStyles:function(o,e,t){let n;if("class"==t){const e=document.getElementByClass(o);n=e&&e.style}else if("id"==t){const e=document.getElementById(o);n=e&&e.style}else n=document.getElementsByTagName(o);if(n&&Object.keys(e).length)for(var i in e)n[i]=e[i]},eSignGatewayInit:function(e){return n.esignGatewayOptions.company_display_name=e.company_display_name,n.esignGatewayOptions.color_bg=n.check(e,"color_bg")?e.color_bg:n.esignGatewayOptions.color_bg,n.esignGatewayOptions.color_ft=n.check(e,"color_ft")?e.color_ft:n.esignGatewayOptions.color_ft,n.esignGatewayOptions.logo_url=n.check(e,"logo_url")?e.logo_url:n.esignGatewayOptions.logo_url,n.esignGatewayOptions.otp_mode=n.check(e,"otp_mode")?e.otp_mode:n.esignGatewayOptions.otp_mode,n.esignGatewayOptions.fp_mode=n.check(e,"fp_mode")?e.fp_mode:n.esignGatewayOptions.fp_mode,n.esignGatewayOptions.ir_mode=n.check(e,"ir_mode")?e.ir_mode:n.esignGatewayOptions.ir_mode,n.esignGatewayOptions.phone_auth=n.check(e,"phone_auth")?e.phone_auth:n.esignGatewayOptions.phone_auth,n.esignGatewayOptions.draggable_sign=n.check(e,"draggable_sign")?e.draggable_sign:n.esignGatewayOptions.draggable_sign,n.esignGatewayOptions.google_sign=n.check(e,"google_sign")?e.google_sign:n.esignGatewayOptions.google_sign,n.esignGatewayOptions.customer_email=n.check(e,"customer_email")?e.customer_email:n.esignGatewayOptions.customer_email,n.esignGatewayOptions.customer_phone=n.check(e,"customer_phone")?e.customer_phone:n.esignGatewayOptions.customer_phone,n.esignGatewayOptions.show_download_btn=n.check(e,"show_download_btn")?e.show_download_btn:n.esignGatewayOptions.show_download_btn,n.esignGatewayOptions.mode=n.check(e,"mode")?e.mode:n.esignGatewayOptions.mode,e.mode&&e.mode.toUpperCase()===o.TAB?n.esignGatewayOptions.mode=o.TAB:e.mode&&e.mode.toUpperCase()===o.REDIRECT?n.esignGatewayOptions.mode=o.REDIRECT:n.esignGatewayOptions.mode=o.POPUP,n.options.zoopModel=window.document.getElementById("zoop-gateway-model"),!0},eSignGateway:function(e,t="v4"){if(n.isNullUndefinedOrEmpty(e))throw new Error("Gateway Transaction Id is mandatory to initiate gateway.");if(n.esignGatewayOptions.transaction_id=e,"v3"==t&&n.isNullUndefinedOrEmpty(n.esignGatewayOptions.company_display_name))throw new Error("Company Display Name is mandatory in gateway options.");switch(t){case"v3":n.esignGatewayOptions.gateway_url=n.options.url+"/esign/gateway/v3";break;default:n.esignGatewayOptions.gateway_url=n.options.eSignV4URL+"/v4/viewer",n.esignGatewayOptions.mode===o.POPUP&&(n.esignGatewayOptions.mode=o.TAB)}let i=n.esignGatewayOptions.gateway_url+"/"+n.esignGatewayOptions.transaction_id+"?company_display_name="+n.esignGatewayOptions.company_display_name+"&color_bg="+n.esignGatewayOptions.color_bg+"&color_ft="+n.esignGatewayOptions.color_ft+"&otp_mode="+n.esignGatewayOptions.otp_mode+"&fp_mode="+n.esignGatewayOptions.fp_mode+"&ir_mode="+n.esignGatewayOptions.ir_mode+"&phone_auth="+n.esignGatewayOptions.phone_auth+"&draggable_sign="+n.esignGatewayOptions.draggable_sign+"&google_sign="+n.esignGatewayOptions.google_sign+"&can_select_device="+n.esignGatewayOptions.device_selection_allowed+"&phone="+n.esignGatewayOptions.customer_phone+"&logo_url="+n.esignGatewayOptions.logo_url+"&show_download_btn="+n.esignGatewayOptions.show_download_btn+"&mode="+n.esignGatewayOptions.mode;n.esignGatewayOptions.mode===o.TAB?null==n.options.zoopWindow||n.options.zoopWindow.closed?n.options.zoopWindow=window.open(encodeURI(i),"_blank"):n.options.zoopWindow.focus():n.esignGatewayOptions.mode===o.REDIRECT?window.location=encodeURI(i):n.esignGatewayOptions.mode===o.POPUP&&(window.document.getElementById("zoop-model-content").innerHTML='',n.options.zoopModel.style.display="block")},initBsaGateway:function(o){n.bankStatementAnalysis={url:`${n.options.bsaURL}/?session_id=${o}&platform=web&sdk_v=2`}},openBsaGateway:function(){window.location=n.bankStatementAnalysis.url},initItdGateway:function(o={}){n.incomeTaxReturnsOptions.txt_color=n.check(o,"txt_color")?o.txt_color:n.incomeTaxReturnsOptions.txt_color,n.incomeTaxReturnsOptions.bg_color=n.check(o,"bg_color")?o.bg_color:n.incomeTaxReturnsOptions.bg_color,n.incomeTaxReturnsOptions.btn_color=n.check(o,"btn_color")?o.btn_color:n.incomeTaxReturnsOptions.btn_color,n.incomeTaxReturnsOptions.btn_txt_color=n.check(o,"btn_txt_color")?o.btn_txt_color:n.incomeTaxReturnsOptions.btn_txt_color,n.incomeTaxReturnsOptions.logo_url=n.check(o,"logo_url")?o.logo_url:n.incomeTaxReturnsOptions.logo_url},openItdGateway:function(o){if(n.isNullUndefinedOrEmpty(o))throw new Error("Gateway Transaction Id is mandatory to initiate gateway.");let e=`${n.options.itdURL}/?session_id=${o}&txt_color=${n.incomeTaxReturnsOptions.txt_color}&bg_color=${n.incomeTaxReturnsOptions.bg_color}&btn_color=${n.incomeTaxReturnsOptions.btn_color}&btn_txt_color=${n.incomeTaxReturnsOptions.btn_txt_color}&logo_url=${n.incomeTaxReturnsOptions.logo_url}&platform=${n.incomeTaxReturnsOptions.platform}&sdk_version=${n.incomeTaxReturnsOptions.sdk_version}`;window.document.getElementById("zoop-model-content").innerHTML='',n.options.zoopModel.style.display="block"},initDigilockerGateway:function(o={}){},openDigilockerGateway:function(o){n.digilockerGatewayOption.request_id=o;const e=`${n.digilockerGatewayOption.gatewayURL}/start/${n.digilockerGatewayOption.request_id}`;null==n.options.zoopWindow||n.options.zoopWindow.closed?n.options.zoopWindow=window.open(encodeURI(e),"_blank"):n.options.zoopWindow.focus()}};const i={close:()=>{},"consent-denied":()=>{},"otp-error":()=>{},"gateway-error":()=>{},"esign-result":()=>{},"esign-success":()=>{},"esign-error":()=>{},"itd-error":()=>{},"itd-consent-denied":()=>{},"itd-gateway-terminated":()=>{},"itd-success":()=>{},"digilocker-error":()=>{},"digilocker-success":()=>{}};n.on=function(o="",e=(()=>{})){if("string"!=typeof o)throw new Error("Event name must be a string.");if("function"!=typeof e)throw new Error("Callback must be a function.");Object.keys(i).includes(o)?i[o]=e:console.warn(`No event found named ${o}`)},n.emit=function(o,e){i[o](e)},n.dispatchEvent=function(o){let e;if(![n.options.url,n.options.production,n.options.staging,n.options.bsaURL,n.options.itdURL,n.options.eSignV4URL,n.options.digilockerV1URL].some((e=>e.startsWith(o.origin))))return console.log("Message is not from Zoop Gateway");if(o.data&&(e=o.data,e.hasOwnProperty("action")))switch(e.action){case"close":case"consent-denied":case"otp-error":case"gateway-error":case"esign-result":case"esign-success":case"esign-error":case"itd-error":case"itd-consent-denied":case"itd-gateway-terminated":case"itd-success":case"digilocker-error":case"digilocker-success":return e.payload="string"==typeof e.payload?JSON.parse(e.payload):e.payload,n.options.zoopModel.style.display="none",window.document.getElementById("zoop-model-content").innerHTML="",n.options.zoopWindow&&!n.options.zoopWindow.closed&&n.options.zoopWindow.close(),void n.emit(e.action,e);default:console.warn("Unsupported event: ",e.action)}},n.setStyles("zoop-gateway-model",t.zoopGateWayModel,"id"),n.setStyles("zoop-model-content",t.zoopModelContent,"id"),window.addEventListener("message",n.dispatchEvent,!1),window.zoop=n}()})(); \ No newline at end of file