GIF89a php
Current File : /home/hencockfreshchic/public_html/ccavResponseHandler.php
<?php include('Crypto.php');
include("connect.php");
?>
<?php

	error_reporting(0);
	
	$workingKey='53165C59344288D5646E3DDB7D636A41';		//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];
		//print_r($decryptValues[$i]."\n");
	}

	

	if($order_status=="Success")
	{
		
		// save cookies
		setcookie("transaction_id", $decryptValues[0], time()+3600);		
		// delete items from the cart	
		$sqlF="UPDATE `incoming_order` SET `payment_id`='".$decryptValues[0]."',`payment_status`='Credit' WHERE `order_id`='".$_COOKIE["order_id"]."'";
		$rsF=mysqli_query($conn,$sqlF);
	
		echo '<script>window.location.href="success.php?name='.$_COOKIE["userName"].'&mobb='.$_COOKIE["mobile"].'&orderid='.$_COOKIE["order_id"].'&price='.$_COOKIE["amount"].'";</script>';
	
		
	}
	else if($order_status=="Aborted")
	{
		
		$sqlF="DELETE FROM `incoming_order` WHERE `order_id`='".$_COOKIE["order_id"]."'";
		$rsF=mysqli_query($conn,$sqlF);
		if($rsF>0)
		{
			echo '<script>window.location.href="failure.php?name='.$_COOKIE["userName"].'&mobb='.$_COOKIE["mobile"].'&orderid='.$_COOKIE["order_id"].'&price='.$_COOKIE["amount"].'";</script>';
		}
		
		
	}
	else if($order_status=="Failure")
	{
		
		$sqlF="DELETE FROM `incoming_order` WHERE `order_id`='".$_COOKIE["uid"]."'";
		$rsF=mysqli_query($conn,$sqlF);
		if($rsF>0)
		{
			echo '<script>window.location.href="failure.php?name='.$_COOKIE["userName"].'&mobb='.$_COOKIE["mobile"].'&orderid='.$_COOKIE["order_id"].'&price='.$_COOKIE["amount"].'";</script>';
		}
			}
	else
	{
		$sqlF="DELETE FROM `incoming_order` WHERE `order_id`='".$_COOKIE["uid"]."'";
		$rsF=mysqli_query($conn,$sqlF);
		echo "<br>Security Error. Illegal access detected";
		echo '<script>window.location.href="failure.php?name='.$_COOKIE["userName"].'&mobb='.$_COOKIE["mobile"].'&orderid='.$_COOKIE["order_id"].'&price='.$_COOKIE["amount"].'";</script>';
	
	}

	echo "<br><br>";

	echo "<table cellspacing=4 cellpadding=4>";
	for($i = 0; $i < $dataSize; $i++) 
	{
		$information=explode('=',$decryptValues[$i]);
	    	//echo '<tr><td>'.$information[0].'</td><td>'.$information[1].'</td></tr>';
	}

	echo "</table><br>";
	echo "</center>";
?>