File: /var/www/html/sarvodayahospital/public/paymentgatway/ccavResponseHandler.php
<?php include('Crypto.php')?>
<?php
include '../dbConnection.php';
error_reporting(0);
$workingKey='608934FAD8273DAB1C11371AEE32C597'; //Working Key should be provided here.
$encResponse=$_POST["encResp"]; //This is the response sent by the CCAvenue Server
$rcvdString=decrypt($encResponse,$workingKey); //Crypto Decryption used as per the specified working key.
$order_status="";
$decryptValues=explode('&', $rcvdString);
$dataSize=sizeof($decryptValues);
//echo "<center>";
for($i = 0; $i < $dataSize; $i++)
{
$information=explode('=',$decryptValues[$i]);
if($i==3) $order_status=$information[1];
}
$result = array();
for($i = 0; $i < $dataSize; $i++)
{
$information=explode('=',$decryptValues[$i]);
$result[$information[0]] = urldecode($information[1]);
//echo '<tr><td>'.$information[0].'</td><td>'.urldecode($information[1]).'</td></tr>';
}
//print_r($result);
if($order_status==="Success")
{
$sql = "select max(bill_number) as max from va_order_history where status = '3'";
$query = mysqli_query($conn, $sql);
$max = 1;
while ($row_sms = mysqli_fetch_array($query)) {
$max = $row_sms["max"] + 1;
}
$ORDER_ID = $result["order_id"];
$sql = "UPDATE va_order_history set
bill_json = '".json_encode($result)."'
,status = '3'
,bill_number = '$max'
,message = '".$order_status."'
,reference_id = '".$result["tracking_id"]."'
where id = '".$ORDER_ID."'";
$query = mysqli_query($conn, $sql);
header("location:https://sarvodayahospital.com/v_success/".$ORDER_ID);
}
else if($order_status==="Aborted")
{
$ORDER_ID = $result["order_id"];
$sql = "UPDATE va_order_history set
bill_json = '".json_encode($result)."'
,status = '2'
,message = '".$order_status."'
,reference_id = '".$result["tracking_id"]."'
where id = '".$ORDER_ID."'";
$query = mysqli_query($conn, $sql);
header("location:https://sarvodayahospital.com/v_fail/".$ORDER_ID);
}
else if($order_status==="Failure")
{
$ORDER_ID = $result["order_id"];
$sql = "UPDATE va_order_history set
bill_json = '".json_encode($result)."'
,status = '2'
,message = '".$order_status."'
,reference_id = '".$result["tracking_id"]."'
where id = '".$ORDER_ID."'";
$query = mysqli_query($conn, $sql);
header("location:https://sarvodayahospital.com/v_fail/".$ORDER_ID);
}
else
{
echo "<br>Security Error. Illegal access detected";
}
/*
echo "<br><br>";
echo "<table cellspacing=4 cellpadding=4>";
print_r($result);
echo "</table><br>";
echo "</center>";
*/
?>