Paytm Payment Gateway Integration in PHP

Paytm Payment Gateway Integration in PHP

Sometimes, when you 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 with simple and easy way to integrate Paytm payment gateway in PHP.

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

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

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. You need to copy PaytmKit folder in 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 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.

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>Patym 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>

In this index.php file, we are sending some required parameters as hidden input fields 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

Recommended PHP Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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