• By :  Piyush Rishi Singh
  • Last Updated :  December 3, 2022
  • Words Count :  385 Words
  • Est. Reading Time :  3 mins

How to install the sample kit on a web server:

  1. Copy PaytmKit folder in document root of your server (like /var/www/html)
  2. Open config_paytm.php file from the PaytmKit/lib folder and update the below constant values
    • PAYTM_MERCHANT_KEY – Can be downloaded from the Paytm portal. One time downloadable
    • PAYTM_MERCHANT_MID – MID (Merchant ID) can be collected from Paytm team
    • PAYTM_MERCHANT_WEBSITE – Website name can be collected from Paytm team
  3. PaytmKit folder is having following files:
    • TxnTest.php – Testing transaction through Paytm gateway.
    • pgRedirect.php – This file has the logic of checksum generation and passing all required parameters to Paytm PG.
    • pgResponse.php – This file has the logic for processing PG response after the transaction processing.
    • TxnStatus.php – Testing Status Query API

 

Note: This code is only for testing purpose. Do not deploy it on production server.

 

Usage of CheckSum Utility:


Include provided “encdec_paytm.php” in your project.
Generate CheckSum API as well as Verify CheckSum API are available as follows:

Function to generate checksum:

String getChecksumFromArray($paramList, $merchantKey)

Function to verify checksum:

String verifychecksum_e($paramList, $merchantKey, $paytmChecksum)

For Generating CheckSum, use following snippet code:


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.

 

Download Source    

Demo

Share :
Piyush Rishi Singh

Piyush Rishi Singh

www.piyushrishisingh.com
(Founder & Business Head At Techzax Innovations Pvt. Ltd.)

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.

Table Of Contents