Paytm is no doubt is most payment gateway now a days. If you have a website or app that receive payment in any way then you should strongly consider using paytm as a new and major payment gateway on your website. Not just popular, it is also one of the most secure payment geteway.

How to integrate Paytm payment gateway with PHP in your website

Well to integrate paytm with php in your website, you just have to follow these 3 steps.

Step 1: Download your Paytm Payment Gateway PHP Kit

you have to download Paytm Payment Gateway PHP Kit from the given link of github. Then you have to copy PaytmKit folder in document root of your server/website.

Step 2: Update and edit your Paytm Gateways Configurations.

You have to open config_paytm.php file from the PaytmKit/lib folder and edit the below values.

//Use PAYTM_ENVIRONMENT as 'PROD' if you wanted to do transaction in production environment else 'TEST' for doing transaction in testing environment.
//Change this constant's value with Merchant key downloaded from portal
define('PAYTM_MERCHANT_KEY', 'bKMfNxPPf_QdZppa');
//Change this constant's value with MID (Merchant ID) received from Paytm
define('PAYTM_MERCHANT_MID', 'DIY12386817555501617');
//Change this constant's value with Website name received from Paytm
define('PAYTM_MERCHANT_WEBSITE', 'DIYtestingweb');

Step 3 : Create a payment form with required fields.

We have to create form with required fields with values. As we are using Paytmkit, so you just need to pass action to pgRedirect.php and it will handle all, you don’t need to worry as the Paytmkit will handle everything like verifying CheckSum and other details.

<form method="post" action="pgRedirect.php">
		<table border="1">
					<td><input id="ORDER_ID" tabindex="1" maxlength="20" size="20"
						name="ORDER_ID" autocomplete="off"
						value="<?php echo  "ORDS" . rand(10000,99999999)?>">
					<td><label>CUSTID ::*</label></td>
					<td><input id="CUST_ID" tabindex="2" maxlength="12" size="12" name="CUST_ID" autocomplete="off" value="CUST001"></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>
					<td><label>Channel ::*</label></td>
					<td><input id="CHANNEL_ID" tabindex="4" maxlength="12"
						size="12" name="CHANNEL_ID" autocomplete="off" value="WEB">
				woring	</td>
					<td><input title="TXN_AMOUNT" tabindex="10"
						type="text" name="TXN_AMOUNT"
				woring	<td></td>
					<td><input value="CheckOut" type="submit"	onclick=""></td>
		* - Mandatory Fields

You can have a look at the official Paytm Api documentation for more information and to know more about how Paytm payment gateway works.

Sahil Ahlawat

I am a Sr. Web Developer passionate about blogging and teaching. When I am not coding or writing blogs, I prefer traveling (Which I like most). I am also doing a bit or research on Indian Startups now a days.

1 Comment

How To Integrate PayUMoney Payment Gateway In PHP - 13 facts : 13 facts · August 31, 2017 at 6:46 am

[…] Integrating PayTM Payment Gateway In PHP […]

Leave a Reply

Your email address will not be published. Required fields are marked *