function cashfree_requirement(){

	var html = '';
	html += '<script src="https://sdk.cashfree.com/js/v3/cashfree.js"></script><p>You will be redirected to Cashfree secure checkout.</p>';
	

	$('.payment_gateway_fields').html(html);
}

function cashfree_process(){

	var data = $('#make_payment_form').serializeArray();
	var uri = $('#make_payment_form').attr('action') + '&api=json';

	$.ajax({
		url: uri,
		method: 'POST',
		data: data,
		success: function(res){

			var finalData = JSON.parse(res);

			if(finalData['payment_session_id']){
				const cashfree = Cashfree({
					mode: finalData['payment_mode'],
				});
				
				let checkoutOptions = {
					paymentSessionId: finalData['payment_session_id'],
					redirectTarget: "_self",
				};
				cashfree.checkout(checkoutOptions);
				
			}else{
				alert("Unable to initiate Cashfree payment");
			}

		   
		}
	});
	// $('#make_payment_form').submit();
}
