Paytm Payment Gateway Integration in PHP Step by Step

Throughout Paytm payment gateway integration in php example; In this tutorial you will learn how to integrate paytm payment gateway in PHP. You can easily implement the paytm payment system in php with the free source code mentioned below.

Now a days many eCommerce or other service websites start using Paytm payment gateway to send or receive payment via your Mobile Phone. So, no doubt Paytm is a better service for online payment for your Website or Mobile App.

Let’s see the simple and easy way to integrate paytm payment gateway in PHP step by step.

Paytm Payment Gateway Integration in PHP

Follow the following steps to integrate paytm payment gateway in PHP;

  • Step 1: Register Paytm Account
  • Step 2: Download Paytm Payment Gateway PHP Kit
  • Step 3: Configure Paytm Gateways Config File
  • Step 4: Create Payment Form

Step 1: Register Paytm Account

First we need to Sign Up for a Paytm business account from here: https://paytm.com/business/payments/online

During creating Paytm business account process, you need to choose the option that Paytm Payment Gateway requires for a Website or APP. Also submit a valid Redirect URL, where you want to redirect the user after successful payment received.

In this process, they ask for some official information like Business Types, addresses, Verification proof, Bank Details, etc. Although you can get Paytm sandbox credential without complete this process. But for production, you have to provide all required information.

After this, you will get Paytm Staging Credentials, which included Staging MID, Merchant Key, Industry Type, Website Name, and Channel ID. Paytm also send testing wallet details, which you can use for test transaction flow.

Note: All users must use Paytm with only an Indian registered number because the company hasn’t gone overseas except for Canada.

Step 2: Download Paytm PHP Kit

Paytm official announced library source code in all languages. Just download Paytm Payment Gateway kit in PHP from GitHub. Extract the Zip file, there is the ‘PaytmKit’ folder which has all required files.

Step 3: Setup Paytm Credentials

For configuration the paytm credentials in php you need to open config_paytm.php file in PaytmKit -> lib folder and update with the access credential you got from Paytm.

define('PAYTM_ENVIRONMENT', 'TEST'); // change value PROD for production
define('PAYTM_MERCHANT_KEY', 'vsbi51****uKL333 ');
define('PAYTM_MERCHANT_MID', 'codefi*****858343');
define('PAYTM_MERCHANT_WEBSITE', 'WEBS***ING');

By default source code ready for staging site. When you want to move to Production update the ‘PAYTM_ENVIRONMENT’ value by ‘PROD’.

Step 4: Create Payment Form

After configuring the credential, your code is ready to process. Now create an HTML form to make the online transactions.

Form action should be to this file page-redirect.php inside PaytmKit folder. This file handle checksum and other require details and redirect to you Paytm payment page. After click on checkout button user can process the payment via the paytm wallet.

<!doctype html>
<html>
<head>
<title>Patym Payment Gateway Integration in PHP</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="container" style="padding-top:100px;">
    <div class="col-xs-6 col-xs-offset-3">
        <div class="panel panel-default">
            <div style="background-color: #000000; color:#fff" class="panel-heading">
                <h3 class="text-center">Paytm Payment Gateway Demo</h3>
            </div>
            <div class="panel-body">
            <form action="page-redirect.php" method="post">
				<input type="hidden" id="CUST_ID" name="CUST_ID" value="CUST001">
					<input type="hidden" id="INDUSTRY_TYPE_ID" name="INDUSTRY_TYPE_ID" value="Retail">
					<input type="hidden"  id="CHANNEL_ID" name="CHANNEL_ID" value="WEB">
                <div class="form-group">
					
					<label>Order ID:</label>
                    <input type="text" class="form-control" id="ORDER_ID" name="ORDER_ID" size="20" maxlength="20" autocomplete="off" 

tabindex="1" value="<?php echo  "ORDER" . rand(10000,99999999)?>">
                </div>
               
                <div class="form-group">
					<label>Amount to Pay:</label>
                    <input type="text" class="form-control" id="TXN_AMOUNT" name="TXN_AMOUNT" autocomplete="off" tabindex="5" 

value="20">
                </div>
                <div class="form-group">
                    <input type="submit" name="submit" value="CheckOut" class="btn btn-success btn-lg" style="background-

color:#0000FF; margin-left: 37%;">
                </div>
            </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>

In this form we are sending some required parameter as hidden variable like Channel ID, Industry Type and Customer ID. You have to pass these parameters along with form submit.

Now go to your browser and hit the below-given URL in your browser:

http://localhost/Paytm_Web_Sample_Kit_PHP/PaytmKit/index.php

I hope you enjoy this php paytm payment gateway integration example tutorial;

Leave a Comment