<?php
require "conn.php";

$refno = mysqli_real_escape_string($con, $_POST['refno']);
$status = mysqli_real_escape_string($con, $_POST['status_id']);
$reason = mysqli_real_escape_string($con, $_POST['reason']);
$billcode = mysqli_real_escape_string($con, $_POST['billcode']);
$order_id = mysqli_real_escape_string($con, $_POST['order_id']);
$amount = mysqli_real_escape_string($con, $_POST['amount']);
$transaction_time = mysqli_real_escape_string($con, $_POST['transaction_time']);




/*
Callback URL will be supplied with the following datas in POST format:-

refno : Payment reference no
status : Payment status. 1= success, 2=pending, 3=fail
reason : Reason for the status received
billcode : Your billcode / permanent link
order_id : Your external payment reference no, if specified
amount : Payment amount received
transaction_time : Datetime of the transaction status received.
*/

mysqli_query($con, "UPDATE transactions SET billStatus = '".$status."' WHERE billcode = ".$order_id);

///$quporder=sqlquery("update tblorder set status=?, tarikh=now() where id=?");
//$quporder->bindValue(1, $status);
//$quporder->bindValue(2, $order_id);
//$quporder->execute();

switch ($status) {
	case 1:
?>
	<div class="text-center mt-5">
		<h2 class="text-success">Thank You For You Payment</h2>
		<p class="lead">We have received your payment. Our staff will process your order shortly.</p>
		<p>Please refer to <a href="">My Purchase</a> section for order status</p>
	</div>
<?
	break;

	case 2:
?>
	<div class="text-center mt-5">
		<h2 class="text-success">Thank You For You Purchase</h2>
		<p class="lead">Your payment status is <span class="text-warning font-weight-bold">PENDING</span><br>We will process your order after payment is success</p>
		<p>Please refer to <a href="">My Purchase</a> section for order status</p>
	</div>
<?
	break;

	case 3:
?>
	<div class="text-center mt-5">
		<h2 class="text-success">Thank You For You Purchase</h2>
		<p class="lead">Your payment status is <span class="text-danger font-weight-bold">FAIL</span></p>
		<p>Click <a href="https://toyyibpay.com/<?= $billcode ?>">HERE</a> to make a payment</p>
	</div>
<?
	break;
}
?>

