I want to integrate paytm payment gateway in codeigniter in my website and i have searched a lot, but i found only in PHP.I have tried with php library but while validating checksum it is not working.Can anyone suggest any library to integrate paytm.
Asked
Active
Viewed 1.4k times
1 Answers
7
I was searching for this same option today and finally had to tweak the library they provided here.
- Cloned their kit to a different folder
- Moved the contents of the folder lib to application/third_party/paytmlib
- In the moved path, Configured config_paytmp.php values according to my site set
- From their kit path moved this file TxnTest.php to views folder and changed form post tag like below
<form method="post" action="paytmpost">
Have added controller methods like below
function paytm() { $this->load->view('TxnTest'); } function paytmpost() { header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); // following files need to be included require_once(APPPATH . "/third_party/paytmlib/config_paytm.php"); require_once(APPPATH . "/third_party/paytmlib/encdec_paytm.php"); $checkSum = ""; $paramList = array(); $ORDER_ID = $_POST["ORDER_ID"]; $CUST_ID = $_POST["CUST_ID"]; $INDUSTRY_TYPE_ID = $_POST["INDUSTRY_TYPE_ID"]; $CHANNEL_ID = $_POST["CHANNEL_ID"]; $TXN_AMOUNT = $_POST["TXN_AMOUNT"]; // Create an array having all required parameters for creating checksum. $paramList["MID"] = PAYTM_MERCHANT_MID; $paramList["ORDER_ID"] = $ORDER_ID; $paramList["CUST_ID"] = $CUST_ID; $paramList["INDUSTRY_TYPE_ID"] = $INDUSTRY_TYPE_ID; $paramList["CHANNEL_ID"] = $CHANNEL_ID; $paramList["TXN_AMOUNT"] = $TXN_AMOUNT; $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE; /* $paramList["MSISDN"] = $MSISDN; //Mobile number of customer $paramList["EMAIL"] = $EMAIL; //Email ID of customer $paramList["VERIFIED_BY"] = "EMAIL"; // $paramList["IS_USER_VERIFIED"] = "YES"; // */ //Here checksum string will return by getChecksumFromArray() function. $checkSum = getChecksumFromArray($paramList,PAYTM_MERCHANT_KEY); echo "<html> <head> <title>Merchant Check Out Page</title> </head> <body> <center><h1>Please do not refresh this page...</h1></center> <form method='post' action='".PAYTM_TXN_URL."' name='f1'> <table border='1'> <tbody>"; foreach($paramList as $name => $value) { echo '<input type="hidden" name="' . $name .'" value="' . $value . '">'; } echo "<input type='hidden' name='CHECKSUMHASH' value='". $checkSum . "'> </tbody> </table> <script type='text/javascript'> document.f1.submit(); </script> </form> </body> </html>"; }
Note : paytmpost()
is modified from the pgRedirect.php
in their kit. The pgResponse.php
could also be tweaked to a controller function to process the output from the payment gateway.

Rajesh
- 934
- 12
- 23
-
this helps me to integrate paytm in my site. But when I click back button from payment page `(https://pguat.paytm.com/oltp-web/processTransaction)` , it just refreshing the page. Can I go back to previous page on click of back button – geeth Jan 15 '18 at 07:02
-
1Sorry for the delayed response. You can set the push state so that the back page would go back accordingly. I guess You might have done this by now. – Rajesh Jan 22 '18 at 07:41
-
@Rajesh https://github.com/Paytm-Payments/Paytm_Web_Sample_Kit_PHP this is not avalable can you please help on same – Mr Coder Nov 06 '21 at 06:31
-
1@MrCoder sorry, just seeing your message. That repository was from Paytm, I didn't fork it then. Please reach out to their support. – Rajesh Dec 03 '21 at 14:07