<?php
$servername = "localhost";
$username = "savarnai_payment";
$password = "techno@123";
$dbname = "savarnai_payment_db";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

	$s=$_SERVER["SERVER_NAME"];
$school_name= strstr($s, '.', true);


$status=$_REQUEST['status'];
$data=$_REQUEST['data1'];
//='{"isConsentPayment":"0","mihpayid":"324248222","mode":"","status":"failure","unmappedstatus":"userCancelled","key":"5LHZD2ry","txnid":"bps_179_1590639809522","amount":"1719.65","addedon":"2020-05-28 09:53:53","productinfo":"{"paymentParts":[{"name":"splitID1","value":1680,"merchantId":"6787722","description":"test description","commission":"39.65"}]}","firstname":"Kumar Ranjan","lastname":"","address1":"","address2":"","city":"","state":"","country":"","zipcode":"","email":"jfkdkdfkkfof@gmil.com","phone":"9685094177","udf1":"","udf2":"","udf3":"","udf4":"","udf5":"","udf6":"","udf7":"","udf8":"","udf9":"","udf10":"","hash":"29db837c158cc1597ca3a49574416e6c32f4eecc753d27b488c59c3eead307cff7036bf0443f01132624acef98d64beb4c86204d6c1368c3fe84c60b9b4603b1","field1":"","field2":"","field3":"","field4":"","field5":"","field6":"","field7":"","field8":"","field9":"Cancelled by user","PG_TYPE":"PAISA","bank_ref_num":"324248222","bankcode":"PAYUW","error":"E000","error_Message":"No Error","payuMoneyId":"324248222"}';

$txnid=$school_name."_".$_REQUEST['txnid'];


echo $sql = "UPDATE mss_pay_log SET status='$status', data='$data' WHERE txnid='$txnid'";


if ($conn->query($sql) === TRUE) {

         $status = 1;

 $array = array("status"=>$status,);
  echo json_encode($array);
}   
 else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}
?>