ok

Mini Shell

Direktori : /home/ngwcolle/public_html/ICICI_MS_LIVE/
Upload File :
Current File : /home/ngwcolle/public_html/ICICI_MS_LIVE/responseSale.php

<?php
date_default_timezone_set('Asia/Kolkata');
require_once('lib/Utility.php');
require_once('lib/config.php');
include_once('dbconfig.php');
include_once('amountinword.php');
$utility = new Utility();
$logFilePath = 'sale_log.log';

$EncKey = ENC_KEY;
$SECURE_SECRET = SECURE_SECRET;

/* Get the response from url */
$paymentResponse = $_GET['paymentResponse'];

// URL decode the parameter
$decodedJson = urldecode($paymentResponse);

// Parse the JSON
$jsonData 	= json_decode($decodedJson, true);
$EncData 	= $jsonData['EncData'];
$merchantId = $jsonData['MerchantId'];
$bankID  	= $jsonData['BankId'];
$terminalId = $jsonData['TerminalId'];

if ($bankID == "" || $merchantId == "" || $terminalId == "" || $EncData == "") {
	echo "Invalid data";
	exit;
}
if (empty($bankID) || empty($merchantId) || empty($terminalId) || empty($EncData)) {
	echo "Invalid data";
	exit;
}

$fomattedEncData = str_replace(" ", "+", $EncData);
$data = $utility->decrypt($fomattedEncData, $EncKey);

$dataArray = explode("::", $data);
foreach ($dataArray as $key => $value) {
	$valuesplit = explode("||", $value);
	$dataFromPostFromPG[$valuesplit[0]] = urldecode($valuesplit[1]);
}

/* SecureHash got in reply */
$SecureHash = $dataFromPostFromPG['SecureHash'];

/* Log the response */
$currentTime = date('d-m-Y H:i:s'); // Get current timestamp with date and time
$logRequest = 'Response:' . "[$currentTime]"; // Include timestamp in the log message
$logRequest .= json_encode($dataFromPostFromPG);
$logFile = fopen($logFilePath, 'a');
fwrite($logFile, $logRequest . PHP_EOL . PHP_EOL);
fclose($logFile);

/* remove SecureHash from data */
unset($dataFromPostFromPG['SecureHash']);
/* remove null or empty data */
$resData = array_filter($dataFromPostFromPG);

/* sort data array */
ksort($resData);

/* convert hash to uppercase becuase gateway needs it in uppercase  */
$SecureHash_final = strtoupper($utility->generateSecurehash($resData));

$hashValidated = 'Invalid Hash';
$hashValidated = 'CORRECT';

if ($SecureHash_final == $SecureHash) {
	$hashValidated = 'CORRECT';
	// echo 'Correct Hash';
} else {
	$hashValidated = 'Invalid Hash';
	echo 'Invalid Hash';
}

//$hashValidated = 'CORRECT'; //remove the comment from this if you are getting 'Invalid Hash' error. this will show you actual result.

echo "<center><h3 class='p-3' style='color:#fc4a1a;'>PRINCIPAL NIRANJAN GOVT WOMEN'S COLLEGE,ASKA</h3></center><hr>";
if ($hashValidated == 'CORRECT') {
?>

	<?php
	$timestamp = date('Y-m-d H:i:s');
	//print_r($dataFromPostFromPG);
	$n = 0;
	$status = "SUCCESS";
	$RetRefNo = "";
	$ResponseCode = "03";
	$Message = "";
	$feepaymntid = $dataFromPostFromPG["UDF04"];
	$remark = $dataFromPostFromPG["UDF02"];

	// echo $dataFromPostFromPG["ResponseCode"] . "</br>";
	$TerminalId = $dataFromPostFromPG["TerminalId"];
	$BankId = $dataFromPostFromPG["BankId"];
	$MCC = $dataFromPostFromPG["MCC"];
	$TxnRefNo = $dataFromPostFromPG["TxnRefNo"];
	$orderid = $dataFromPostFromPG["OrderInfo"];
	$rollno = $dataFromPostFromPG["UDF01"];
	$fullname = $dataFromPostFromPG["UDF03"];
	$amountpaid = $dataFromPostFromPG["Amount"] / 100;
	$bankrefno = $dataFromPostFromPG["RetRefNo"];
	if (isset($dataFromPostFromPG["Message"])) {
		$Message = $dataFromPostFromPG["Message"];
	}
	if (isset($dataFromPostFromPG["ResponseCode"])) {
		$ResponseCode = $dataFromPostFromPG["ResponseCode"];
	}
	if (isset($dataFromPostFromPG["Status"])) {
		$status = $dataFromPostFromPG["Status"];
	}
	if ($dataFromPostFromPG["ResponseCode"] == '03') {
		$status = 'FAILED';
		$amountpaid = 0;
	}
	$query = "INSERT INTO  tbl_payment_history (feepaymntid,rollno, amountpaid, orderid, remark, pmtmessage, pmtstatus, mertxrefno,TxnRefNo,mcc,responsecode,terminalid,bankid,txdatetime) 
		VALUES('$feepaymntid','$rollno', '$amountpaid', '$orderid', '$remark', '$Message', '$status', '$TxnRefNo','$bankrefno','$MCC','$ResponseCode','$TerminalId','$BankId','$timestamp')";
	$result_in = $con->query($query);
	$last_id = $con->insert_id;
	if ($ResponseCode == '00') {
		$query_update = "UPDATE  tbl_payment_order set pmtstatus='1',amountpaid='$amountpaid' where id='$feepaymntid'";
		$result_update = $con->query($query_update);
	}
	header("Location:thanku.php?user=" . $last_id);
	?>
	<!DOCTYPE html>
	<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>NGWC Thank You Message</title>
		<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet">
		<style id="table_style" type="text/css">
			body {
				font-family: Arial;
				font-size: 10pt;
			}

			table {
				border: 1px solid #ccc;
				border-collapse: collapse;
			}

			table th {
				background-color: #F7F7F7;
				color: #333;
				font-weight: bold;
			}

			table th,
			table td {
				padding: 5px;
				border: 1px solid #ccc;
			}
		</style>

	</head>

	<body>
		<div class="vh-100 d-flex justify-content-center align-items-center">
			<div class="col-md-9">
				<div class="border border-3 border-success"></div>
				<div class="card bg-white shadow p-4">
					<div class="mb-2 text-center">
						<svg xmlns="http://www.w3.org/2000/svg" class="text-success" width="75" height="75" fill="currentColor" class="bi bi-check-circle" viewBox="0 0 16 16">
							<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
							<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z" />
						</svg>
					</div>
					<div id="printMe">
						<div class="text-center">
							<h1>Thank You for payment!</h1>
							<!-- <h3>PRINCIPAL NIRANJAN GOVT. WOMEN'S COLLEGE,ASKA</h3> -->
							<p class="h4" style="color:#fc4a1a;">Dear, <?php echo $fullname; ?></p>
							<p class="h6 text-default">Your Transaction Details is given below for your reference.</p>
							<table class="table table-responsive table-striped table-bordered border-success">
								<tr>
									<th>Payment For</th>
									<td><?php echo $fullname; ?></td>
									<th>Payment Date</th>
									<td><?php echo date('d-m-Y h:i:s A', strtotime($timestamp)); ?></td>
								</tr>
								<tr>
									<th>Roll No</th>
									<td><?php echo $rollno; ?></td>
									<th>Fee Description</th>
									<td><?php echo $remark; ?></td>
								</tr>
								<tr>
									<th>NGWC Reference No.</th>
									<td><?php echo $TxnRefNo; ?></td>
									<th>Transaction ID</th>
									<td><?php echo $bankrefno; ?></td>
								</tr>
								<tr>
									<th>Fee Amount.</th>
									<td>INR <?php echo $amountpaid; ?></td>
									<th>Paid Amount</th>
									<td>INR <?php echo $amountpaid; ?></td>
								</tr>
								<tr>
									<th>Paid Amount In Words.</th>
									<td colspan="3"><?php echo getConvertNumberToWord($amountpaid); ?></td>

								</tr>
							</table>



						</div>
						<!-- <button class="btn btn-outline-success">Back Home</button> -->
						<a href="https://ngwcollege.in/ICICI_MS_UAT" class="btn btn-outline-success">Back Home</a>
						<button onclick="PrintTable();" class="btn btn-outline-danger">Print Receipt</button>
					</div>


				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		function PrintTable() {
			var printWindow = window.open('', '', 'height=400,width=800');
			printWindow.document.write('<html><head><title>PAYMENT DETAILS</title>');
			//Print the Table CSS.
			var table_style = document.getElementById("table_style").innerHTML;
			printWindow.document.write('<style type = "text/css">');
			printWindow.document.write(table_style);
			printWindow.document.write('</style>');
			printWindow.document.write('</head>');

			//Print the DIV contents i.e. the HTML Table.
			printWindow.document.write('<body>');
			var divContents = document.getElementById("printMe").innerHTML;
			printWindow.document.write(divContents);
			printWindow.document.write('</body>');

			printWindow.document.write('</html>');
			printWindow.document.close();
			printWindow.print();
		}
	</script>

	</html>

<?php } ?>

Zerion Mini Shell 1.0