Note: This code is only for testing purpose. Do not deploy it on production server.
Include provided “encdec_paytm.php” in your project.
Generate CheckSum API as well as Verify CheckSum API are available as follows:
String getChecksumFromArray($paramList, $merchantKey)
String verifychecksum_e($paramList, $merchantKey, $paytmChecksum)
header(“Pragma: no-cache”);
header(“Cache-Control: no-cache”);
header(“Expires: 0”);
include(“encdec_paytm.php”);
$paramList = array();
$merchantKey = ‘xxxxxxxxxxxxxxxxx’; //Key provided by Paytm
$paramList[“MID”] = “xxxxxxxxxxxxxxxxxxxxxx”; // Merchant ID (MID) provided by Paytm
$paramList[“ORDER_ID”] = “nnnnnnnnn”; // Merchant’s order id
$paramList[“CUST_ID”] = “CUST001”; // Customer ID registered with merchant
$paramList[“TXN_AMOUNT”] = “1”;
$paramList[“CHANNEL_ID”] = “WEB”;
$paramList[“INDUSTRY_TYPE_ID”] = “Retail”; //Provided by Paytm
$paramList[“WEBSITE”] = “xxxxxxxxxxx”; //Provided by Paytm
//Note: Above mentioned parameters are not complete list of parameters. Please refer integration document for additional parameters which need to be passed.
$checkSum = getChecksumFromArray($paramList, $ merchantKey);
For Verifying CheckSum, use following snippet code:
header(“Pragma: no-cache”);
header(“Cache-Control: no-cache”);
header(“Expires: 0”);
include(“encdec_paytm.php”);
$paramList = $_POST;
$merchantKey = ‘xxxxxxxxxxxxxxxxx’; //Key provided by Paytm
$isValidChecksum = “FALSE”;
$paytmChecksum = $_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, $merchantKey, $paytmChecksum); //will return TRUE or FALSE Boolean.
Piyush Rishi Singh
www.piyushrishisingh.com
A Digital Entrepreneur & Content Creator who loves simplifying tech.
Expertise: A Full Stack & highly skilled 10+ years experienced WordPress developer who specializes in complete custom tailored WordPress Websites development.