Dear Reader, very pleased to make you understand about “Paytm Payment Gateway Integration using PHP” as Paytm is an Indian Payment Gateway having too much growth in very few years of its birth. PayTM stands for “Payment Through Mobile”. It’s headquarters is in Noida, Uttar Pradesh, India, established by Mr. Vijay Shekhar Sharma in August 2010.
As all types of payment gateways, it is also very easy to integrate in your website. And we are very sure that you will get this by following these very simple steps. So here we go…
Before following these steps, please go through our Paytm Payment Gateway Integration demo Video.
1. At first Download Paytm Web Sample Kit.
2. Copy PaytmKit folder in document root of your server (like /var/www/html).
3. Open config_paytm.php file from the PaytmKit/lib folder and update the below constant values of config_paytm.php.
1 2 3 4 5 6 |
define('PAYTM_ENVIRONMENT', 'PROD'); // Use PAYTM_ENVIRONMENT as 'PROD' if you wanted to do transaction in production environment else //Or define('PAYTM_ENVIRONMENT', 'TEST'); // 'TEST' for doing transaction in testing environment. define('PAYTM_MERCHANT_KEY', 'bKMfNxPPf_QdZppa'); //Change this constant's value with Merchant key downloaded from portal define('PAYTM_MERCHANT_MID', 'DIY12386817555501617'); //Change this constant's value with MID (Merchant ID) received from Paytm define('PAYTM_MERCHANT_WEBSITE', 'DIYtestingweb'); //Change this constant's value with Website name received from Paytm |
These keys are defined as:-
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
4. Now final step to create a sample html form with required filed, You can also find demo html form in PaytmKit/TxnTest.php, You can execute this file and test your Paytm Payment Gateway Integrate is working properly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<form method="post" action="pgRedirect.php"> <table border="1"> <tbody> <tr> <th>S.No</th> <th>Label</th> <th>Value</th> </tr> <tr> <td>1</td> <td><label>ORDER_ID :*</label></td> <td><input id="ORDER_ID" tabindex="1" maxlength="20" size="20" name="ORDER_ID" autocomplete="off" value="<?php echo "ORDS" . rand(10000,99999999)?>"></td> </tr> <tr> <td>2</td> <td><label>CUSTID :*</label></td> <td><input id="CUST_ID" tabindex="2" maxlength="12" size="12" name="CUST_ID" autocomplete="off" value="CUST001"></td> </tr> <tr> <td>3</td> <td><label>INDUSTRY_TYPE_ID :*</label></td> <td><input id="INDUSTRY_TYPE_ID" tabindex="4" maxlength="12" size="12" name="INDUSTRY_TYPE_ID" autocomplete="off" value="Retail"></td> </tr> <tr> <td>4</td> <td><label>Channel :*</label></td> <td><input id="CHANNEL_ID" tabindex="4" maxlength="12" size="12" name="CHANNEL_ID" autocomplete="off" value="WEB"></td> </tr> <tr> <td>5</td> <td><label>TXN_AMOUNT :*</label></td> <td><input title="TXN_AMOUNT" tabindex="10" type="text" name="TXN_AMOUNT" value="1"></td> </tr> <tr> <td></td> <td></td> <td><input value="CheckOut" type="submit" onclick=""></td> </tr> </tbody> </table> </form> |
Here you may need to change the value of CUST_ID from CUST001 to CUST501 or any other than CUST001 for the testing scenario if you will get the issues in the testing environment.
5. You may also need to add 8th parameter “CALLBACK_URL” in pgRedirect.php under
1 2 |
$paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE; $paramList["CALLBACK_URL"] = 'http://localhost/WebPreparations/Paytm/PaytmKit/pgResponse.php'; // var/www/html/WebPreparations/Paytm/PaytmKit/pgRedirect.php |
And after that, you can get your proper result.
Congratulations you have successfully learned “How we can integrate Paytm payment gateway using PHP”, if you like this post and was helpful for you then share this post on social media and if you have any query then please contact us or comment below, Thanks
9 Comments:
niru July 14, 2018
i think this demo is not working please help me to done paytm integrated in my codeignitor site.
thanks
Webpreparations Team July 17, 2018
Dear Reader,
This code is perfectly working in Core PHP, but for running in Codeigniter, you have to follow the rules of CodeIgniter, means Controller, Model, View structures. Thank you for your comments, we will update you about Paytm Integration in CodeIgniter shortly for sure…
Webpreparations Team December 01, 2018
Dear Reader, I think you should change the value of CUST_ID from CUST001 to CUST501 or any other than CUST001 for the testing scenario. I hope this will resolve your issue. If still persists problem, then please send your code. We will resolve for sure.Thanks for your precious comments.
satendra shukla November 26, 2018
Your paytm demo is not working, on your website. please check this and solve erreor
Webpreparations Team December 01, 2018
Dear Reader, have you changed CUST_ID from CUST001 to CUST501 or any other than CUST001. ? Please change that for testing purpose. If still you will get the error, then please send your code, we will help for sure.
swroop January 05, 2019
Your code is not working it was saying checksum mismatch kindly resolve this
Webpreparations Team January 13, 2019
Dear Reader, Please check our Video Update in this post. And you will see , that CheckSum has been matched. Hence please follow proper steps. And if you will be satisfied, then please write positive comments for us, Thank you 🙂
Deepak January 16, 2019
Please say what to do when the page says “checksum is mismatched” when i use paytm environment in “PROD” mode.
Webpreparations Team January 20, 2019
define(‘PAYTM_ENVIRONMENT’, ‘PROD’); // Use PAYTM_ENVIRONMENT as ‘PROD’ if you wanted to do transaction in production environment else
//Or
define(‘PAYTM_ENVIRONMENT’, ‘TEST’); // ‘TEST’ for doing transaction in testing environment.
define(‘PAYTM_MERCHANT_KEY’, ‘bKMfNxPPf_QdZppa’); //Change this constant’s value with Merchant key downloaded from portal
define(‘PAYTM_MERCHANT_MID’, ‘DIY12386817555501617’); //Change this constant’s value with MID (Merchant ID) received from Paytm
define(‘PAYTM_MERCHANT_WEBSITE’, ‘DIYtestingweb’); //Change this constant’s value with Website name received from Paytm
Please use original keys from Paytm Website and then check for Production Environment.
As above written keys are for Testing Environment only.