<?php
include "include.php";
$result['error'] = 1;
$result['error_msg'] = "Invalid Parameters";
$result['ip'] = $_SERVER['REMOTE_ADDR'];
if (isset($_GET['uname']) && isset($_GET['api_token']) && isset($_GET['BiometricData']) && isset($_GET['order_id']) && isset($_GET['latitude'])
	&& isset($_GET['longitude']) && isset($_GET['type']) && isset($_GET['amount']) && isset($_GET['deviceIMEI']) && isset($_GET['aadhar']) && isset($_GET['bank_code'])) {
	$uname = $_GET['uname'];
	$api_token = $_GET['api_token'];
	$BiometricData = $_GET['BiometricData'];
	$order_id = $_GET['order_id'];
	$latitude = $_GET['latitude'];
	$longitude = $_GET['longitude'];
	$type = $_GET['type'];
	$amount = $_GET['amount'];
	$deviceIMEI = $_GET['deviceIMEI'];
	$aadhar = $_GET['aadhar'];
	$bank_code = $_GET['bank_code'];
} else {
	echo json_encode($result);
	die();
}
if ($uname == "" || $api_token == "" || $BiometricData == "" || $order_id == "" || $latitude == "" || $longitude == "" || $type == "" || $amount == "" || $deviceIMEI == "" || $aadhar == "" || $bank_code == "") {
	echo json_encode($result);
	die();
}

$ip_address = $_SERVER['REMOTE_ADDR'];
$sql_user = "Select user_id from users where user_name = '" . $uname . "' and is_active = 1";
$res_user = getXbyY($sql_user);
$row_users = count($res_user);
if ($row_users == 1) {
	$o = $factory->get_object($res_user[0]['user_id'], "users", "user_id");

	$sql_auth = "Select * from api_ip_key where user_id = " . $o->user_id . " and ip_address = '" . $ip_address . "' and authorization_key = '" . $api_token . "' and is_active = 1";
	$res_auth = getXbyY($sql_auth);
	$row_auth = count($res_auth);
	if ($row_auth == 1) {
		
       echo '<pre>'; print_r($o);die;
} else {
	echo json_encode($result);
	die();
}
}


echo json_encode($result);
?>