Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.118.151.211
<?php
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
// following files need to be included
//require_once("./pgRedirect.php");
require_once("./lib/config_paytm.php");
require_once("./lib/encdec_paytm.php");
$servername = "97.74.228.93";
$username = "logisys3_logu";
$password = "Logisys@2106";
$databse = 'logisys3_comexam';
$conn = new mysqli($servername,$username,$password,$databse);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$paytmChecksum = "";
$paramList = array();
$isValidChecksum = "FALSE";
$paramList = $_POST;
$univcode = str_pad(substr($paramList['MERC_UNQ_REF'],1,2),3,"0",STR_PAD_LEFT);
$get_data = "select * from maspg where fbank = 'Paytm' and FENTTYPE = 'exam' and funivcode = '{$univcode}'";
$result=$conn->query($get_data);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$key = $row['fkey'];
$mid = $row['fmid'];
$fworkingid = $row['fworkingid'];
$fmode = $row['fmode'];
$freturnurl = $row['freturnurl'];
}
}
$paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
//Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your application�s MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc.
$isValidChecksum = verifychecksum_e($paramList, $key, $paytmChecksum); //will return TRUE or FALSE string.
if($isValidChecksum == "TRUE") {
$status = $_POST["STATUS"];
echo $status;
$orderid = $_POST["ORDERID"];
$productinfo = $_POST["MERC_UNQ_REF"];
$txnid = $_POST["TXNID"];
$MID = $_POST["MID"];
$CHECKSUMHASH = $_POST["CHECKSUMHASH"];
echo $productinfo;
//$productinfo = '103E3050155';
$MID = $mid;
$requestParamList = array();
$responseParamList = array();
$requestParamList = array("MID" => "{$MID}" , "ORDERID" => "{$orderid}", "MERC_UNQ_REF" => "{$productinfo}");
$checkSum = getChecksumFromArray($requestParamList,$key);
$requestParamList['CHECKSUMHASH'] = urlencode($checkSum);
$data_string = "JsonData=".json_encode($requestParamList);
$ch = curl_init(); // initiate curl
//$url = "https://securegw-stage.paytm.in/merchant-status/getTxnStatus";
// where you want to post data
//$url = "https://securegw.paytm.in/merchant-status/getTxnStatus";
$url = "https://securegw.paytm.in/merchant-status/getTxnStatus";
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); // define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch); // execute
$info = curl_getinfo($ch);
$data = json_decode($output, true);
echo $data;
echo "<b>Checksum matched and following are the transaction details:</b>" . "<br/>";
if ($_POST["STATUS"] == "TXN_SUCCESS") {
echo "<b>Transaction status is success</b>" . "<br/>";
//Process your transaction here as success transaction.
//Verify amount & order id received from Payment gateway with your application's order id and amount.
}
else {
echo "<b>Transaction status is failure</b>" . "<br/>";
}
if (isset($_POST) && count($_POST)>0 )
{
foreach($_POST as $paramName => $paramValue) {
echo "<br/>" . $paramName . " = " . $paramValue;
}
}
}
else {
echo "<b>Checksum mismatched.</b>";
//Process transaction as suspicious.
}
?>
|