File: /var/www/html/sarvodayahospital/public/mapp/paymentgatway/Sarvo_payment.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include('Crypto.php')?>
<?php
$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>';
}
//echo '<pre>';
//print_r($result);
// exit();
if($order_status==="Success")
{
$amount = $result["amount"];
//echo $order_status;
$curl = curl_init();
$ORDER_ID = $result["order_id"];
$ORDER_ID = str_replace("Sarvo_","",$ORDER_ID);
//$ORDER_ID = '658298a6420ba2999979fcc9';
$data = '{
"orderId":"'.$ORDER_ID.'",
"json" : '.json_encode($result).',
"status":"SUCCESS"
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sarvodayahospital19.com/eventsarvodaya/confirm_payment.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Basic dm9pY2VvY19nc2hfQHBwX3ZvaWNlb2M6dm9pY2VvY19nc2hfQHBwX3ZvaWNlb2NAMjAyMQ=='
),
));
$response = curl_exec($curl);
curl_close($curl);
// echo $response;
include 'html/success.php';
//echo $data;
}
else if($order_status==="Aborted")
{
// echo $order_status;
$curl = curl_init();
$ORDER_ID = $result["order_id"];
$ORDER_ID = str_replace("Sarvo_","",$ORDER_ID);
//$ORDER_ID = '658298a6420ba2999979fcc9';
$data = '{
"orderId":"'.$ORDER_ID.'",
"json" : '.json_encode($result).',
"status":"Aborted"
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sarvodayahospital19.com/eventsarvodaya/confirm_payment.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Basic dm9pY2VvY19nc2hfQHBwX3ZvaWNlb2M6dm9pY2VvY19nc2hfQHBwX3ZvaWNlb2NAMjAyMQ=='
),
));
$response = curl_exec($curl);
curl_close($curl);
include 'html/fail.php';
}
else if($order_status==="Failure")
{
$curl = curl_init();
$ORDER_ID = $result["order_id"];
$ORDER_ID = str_replace("Sarvo_","",$ORDER_ID);
//$ORDER_ID = '658298a6420ba2999979fcc9';
$data = '{
"orderId":"'.$ORDER_ID.'",
"json" : '.json_encode($result).',
"status":"Aborted"
}';
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sarvodayahospital19.com/eventsarvodaya/confirm_payment.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Basic dm9pY2VvY19nc2hfQHBwX3ZvaWNlb2M6dm9pY2VvY19nc2hfQHBwX3ZvaWNlb2NAMjAyMQ=='
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
include 'html/fail.php';
}
else
{
echo "<br>Security Error. Illegal access detected";
}
?>