I need a help in implementing of paytm payment gateway. i am implementing the gateway in android app and i have coded it correctly and i have no errors and the sandbox keys are working fine and i am getting the responses also but then paytm sent me a file naming 'check status API.php' and said this to me i m quoting my email
For Transaction Status API, kindly generate new checksum using MID and ORDER ID and pass it on below link https://pguat.paytm.com/oltp/HANDLER_INTERNAL/getTxnStatus?JsonData={"MID":"MID","ORDERID":"ORDERID","CHECKSUMHASH":"CHECKSUMHASH"}
Please do Url encoding for the CHECKSUMHASH after that pass checksumhash value to status API.
and i have a attachment this file
check status API.php
public function PaytmTransactionStatus($order_id){
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
require_once("lib/config_paytm.php");
require_once("lib/encdec_paytm.php");
$checkSum = "";
$data = array(
"MID"=>"DIY12386817555501617",// please use your own MID.
"ORDER_ID"=>$order_id,
);
$key = 'bKMfNxPPf_QdZppa';
$checkSum =getChecksumFromArray($data, $key);// Please use your own merchant key value.
$request=array("MID"=>'**************',
"ORDERID"=>$order_id,"CHECKSUMHASH"=>$checkSum);
$JsonData =json_encode($request);
$postData = 'JsonData='.urlencode($JsonData);
$url = "https://pguat.paytm.com/oltp/HANDLER_INTERNAL/getTxnStatus";
$HEADER[] = "Content-Type: application/json";
$HEADER[] = "Accept: application/json";
$args['HEADER'] = $HEADER;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $args['HEADER']);
$server_output = curl_exec($ch);
return json_decode($server_output,true);
i modified MID and merchant key with mine and uploaded it to server but the api is not working it is returning me whole code written in the browser but it should return json.
After some research work finally, i wrote something that works fine
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$order_id = $_POST['order_id'];
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
require_once("./lib/config_paytm.php");
require_once("./lib/encdec_paytm.php");
$checkSum = "";
$paramList = array();
$paramList["MID"] = 'YOUR MID'; //Provided by Paytm
$paramList["ORDER_ID"] = $order_id; //unique OrderId for every request
$checkSum = getChecksumFromArray($paramList,"YOUR KEY");
$paramList["CHECKSUMHASH"] = urlencode($checkSum);
$data_string = 'JsonData='.json_encode($paramList);
$ch = curl_init(); // initiate curl
$url = "https://pguat.paytm.com/oltp/HANDLER_INTERNAL/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);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); /
format
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec ($ch); // execute
$info = curl_getinfo($ch);
echo $output;
return json_decode($output, true);
}
?>