Skip to content

All topics  /  PHP

How to Integrate Paytm Payment Gateway In PHP?

PHP ·

Teams applying “How to Integrate Paytm Payment Gateway In PHP?” in a production project can use this reference page to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.

Before copying the example into a live application, confirm version-specific behaviour with the PHP project and test it against the project’s actual database and runtime.

Hi Dev,

This tutorial is focused on how to integrate the Paytm payment gateway in PHP. you'll learn Paytm payment gateway integration in PHP. We will use Paytm payment gateway integration using PHP. if you have a question about how to integrate the Paytm payment gateway using PHP then I will give a simple example with a solution.

Now, let's see the article on how to integrate the Paytm payment gateway using PHP. it's a simple example of Paytm payment gateway integration using PHP. you can understand the concept of Paytm payment gateway integration in PHP. if you have a question about how to integrate the Paytm payment gateway in PHP then I will give a simple example with a solution.

Step 1: Create Paytm Account


First of all, we need to register or create a Paytm merchant account. So go to this link https://paytm.com/business/payments.

After that, paytm provides you some credentials like PAYTM_MERCHANT_KEY, PAYTM_MERCHANT_MID etc.

Step 2: Download Paytm Payment Gateway PHP Kit

In the second step, we need to download the Paytm Payment Gateway PHP Kit. You need to copy the PaytmKit folder in the document root of your local server.

Step 3: Update Paytm Gateways Config File

Thired step, go to PaytmKit/lib folder and open the config_paytm.php. Then You need to update the Paytm payment gateway credentials in the config_paytm.php file.

//set payment mode TEST OR PROD
define('PAYTM_ENVIRONMENT', 'TEST'); 

 
// SET merchent key 
define('PAYTM_MERCHANT_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxx');

 
// Set merchent mid
define('PAYTM_MERCHANT_MID', 'xxxxxxxxxxxxxxxxxxxxxxx'); 

 
//Set merchant website
define('PAYTM_MERCHANT_WEBSITE', 'xxxxxxx'); 

Step 4: Create Payment Form

In this step, go to /Paytm_Web_Sample_Kit_PHP/PaytmKit/ and we need to create one file name index.php inside the PaytmKit folder. And you need to change or set form action like “pgRedirect.php” inside the PaytmKit folder.

<!doctype html>
<html>
<head>
    <title>Paytm Payment Gateway Integration in PHP</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</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="pgRedirect.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>

I hope it could help you...