Paytm Payment Gateway Integration in PHP

Paytm Payment gateway integration in php; In this tutorial, we will learn how to integrate paytm payment gateway in PHP.

And as well as, you can use free source code of paytm gateway integration in php.

Sometimes, when we work in PHP with an eCommerce or a payment system application and you want to integrate the paytm payment gateway into PHP. This tutorial helps you to simple and easy way to integrate paytm payment gateway in PHP.

Paytm Payment Gateway Integration in PHP

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

  • Step 1 – Create Paytm Account
  • Step 2 – Download Paytm Payment Gateway PHP kit
  • Step 3 – Update Paytm Gateways Config File
  • Step 4 – Create Payment Form

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 from this link https://github.com/paytm-payments/Paytm-_Web_Sample_kit_PHP.

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 config_paytm.php file.

//set payment mode TEST
define('PAYTM_ENVIRONMET', 'TEST');

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

//Set merchant mid
define('PAYTM_MERCHANT_MID', 'XXXXXXXXXXXXXXX');

//Set merchant website
define('PAYMT_MERCHANT_WEBSITE', 'XXXXXXX');

Step 4 – Create Payment Form

In this step, go to /Paytm_Web_Sample_Kit_PHP/PaytmKit/ and we need to create 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.

pgRedirect.php 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.

Now we need to update the below code into your index.php file.

<!DOCTYPE html>
<html>
<head>
<title>Paytm Payment Gateway Integration in PHP</title>
       <link rel="stylesheet" href="https://strackpath.bootstrapcdn.com/boostrap/4.1.3./css/bootstrap.min.css">
</head>
<body>
<div classs="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" size="20" maxlength="20" autocomplete="off"

tabindex="1" value="<?php echo "ORDER" . rand(10000, 99999999)?>">
                  </div>t
                  <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>
                       

Leave a Reply

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