<?php
// echo "<pre>";
// print_r($_POST);
// die();
require_once('config.php');
require_once('lib/AhkWeb_Config.php');
require_once('lib/AhkWebCheckSum.php');
if(isset($_POST['txnAmount']) && $_POST['txnAmount']!= NULL ){
$amount = $_POST['txnAmount'];
$checkSum = "";
$upiuid = "paytmqr190auy2f4q@paytm";
$paramList = array();

$orderId = "TXN".time();
$txnAmount = $amount;
$txnNote = "Note" ;
$callback_url = "https://gyandigitalcenter.online/admin/pay/txnResponse.php";
$AHKWEB_TXN_URL='https://columbuspay.in/order/paytm';
$upiuid = 'paytmqr190auy2f4q@paytm'; // Its Your Self UPI ID.
$token = "7b940d-b15933-f61ffc-e8fed3-dfae68";
$secret = "N6JYbgmzrb";
$userid = $_SESSION['userid'];
$cust_Email = $_SESSION['emailid'];
date_default_timezone_set("Asia/Kolkata");   //India time (GMT+5:30)
$date = date('d-m-y h:i:s');
$phone = $_SESSION['phone'];

$insert = mysqli_query($connection,"INSERT INTO `qrtxn`(`txnid`, `emailid`,`amount`,`date`, `status`) VALUES ('$orderId','$cust_Email','$txnAmount','$date','Failed')");
if($insert){
        // Create an array having all required parameters for creating checksum.
    $paramList["upiuid"] = $upiuid;
    $paramList["token"] = $token;
    $paramList["orderId"] = $orderId ;
    $paramList["txnAmount"] = $txnAmount;
    $paramList["txnNote"] = $txnNote;
    $paramList["cust_Email"] = $cust_Email;
    $paramList["cust_Mobile"] = "8053357651";
    $paramList["callback_url"] = $callback_url;
    
    $checkSum = AhkWebCheckSum::generateSignature($paramList,$secret);
    if($checkSum!=NULL){
        ?>
        <html>
    <head>
    <title>Gateway Check Out Page</title>
    </head>
    <body>
    	<center><h1>Please do not refresh this page...</h1></center>
    		<form method="post" action="<?php echo $AHKWEB_TXN_URL ?>" name="pform">
    		<table border="1">
    			<tbody>
    			<?php
    			foreach($paramList as $name => $value) {
    				echo '<input type="hidden" name="' . $name .'" value="' . $value . '">';
    			}
    			?>
    			<input type="hidden" name="checksum" value="<?php echo $checkSum ?>">
    			</tbody>
    		</table>
    		<script type="text/javascript">
    			document.pform.submit();
    		</script>
    	</form>
    </body>
    </html>
        <?php
    }
}else{
    echo "data Coult Not  be Insert" . mysqli_error($connection);
}


}
?>