
function digio_requirement(data){
	
	// Add your requirement here and if anything goes wrong return false else return true
	var html = '';
	$(".kyc_vendor_fields").html(html);

	html += `<table class="table table-hover tablesorter table-fixed">
				<tr>
					<td>{{Your Name}} (fname)</td>
					<td><input type="text" name="digio_fname" id="digio_fname" class="virt-input"/></td>
				</tr>
				<!-- <tr>
					<td>{{Email Address}} (customer_identifier)</td>
					<td><input type="text" name="digio_customer_identifier" id="digio_customer_identifier" class="virt-input"/></td>
				</tr>-->
				<tr>
					<td>{{Mobile Number}}</td>
					<td><input type="text" name="digio_mobile_number" id="digio_mobile_number" class="virt-input"/></td>
				</tr>
			</table>`;

	$(".kyc_vendor_fields").html(html);
	return true;
};

function digio_process(data){
	return loadJS('https://ext-gateway.digio.in/sdk/v11/digio.js', false, data);
}

function loadJS(FILE_URL, async = true, data) {

	let scriptEle = document.createElement("script");
  
	scriptEle.setAttribute("src", FILE_URL);
	scriptEle.setAttribute("type", "text/javascript");
	scriptEle.setAttribute("async", async);
  
	document.body.appendChild(scriptEle);
  
	// success event 
	scriptEle.addEventListener("load", () => {
		// console.log("File loaded")
	});
	 // error event
	scriptEle.addEventListener("error", (ev) => {
		// console.log("Error on loading file", ev);
	});
	// console.log(data)
	// On loading of the js file we will process ir 
	scriptEle.onload = function(){
		var options = {
			environment: data['mode'],
			callback: function(response) {
				if (response.hasOwnProperty("error_code")){
					return console.log("error occurred in process");
				}
				// console.log("Signing;completed;successfully:");
			},
			logo: data['logo'],
			theme: {
				primaryColor: "#AB3498",
				secondaryColor: "#000000"
			},
			// redirect_url: data['redirect_url']
		};
	
		var digio = new Digio(options);
		digio.init();
			
		digio.submit(data['id'], data['customer_identifier']);
	};
	data['goto'] = 'act=kyc';
	return data;
  }
  