Paytm PHP Integration

In this tutorial I have explain how to develop Paytm PHP Integration payment gateway for our web application. Actually payment gateway is very important part for our business to collect amount from customers. Number of providers are available in the market but not everyone is best in industry. For example Payu documentation is not good however some developers are suggest to use PayUmoney. But PayU not provide good customer support for end users.

Razorpay is one of the best provider who give us good support, clear documentation for every script like PHP, Python, Java, React, Flutter etc. Already I integrate two or more my client website that’s like both of webview & web android application. I have clearly explained the documentation for integrate PHP project into Razorpay. Support is very good with various languages like Tamil, English, Hindi and more.

paytm razorpay comparison payment gateway

Paytm or Razorpay?

Here my personal opinion, Razorpay is best because they are professional do the job with one of Payment Gateway. On the other hand Paytm is a large business like they have own UPI application, E-Commerce apps, ticket booking etc. As a result they are struggle to sort out developer issues on integrate with our projects. This is one of the drawback for Paytm and razorpay provide 100% clear support with proper guidelines. And the interfaces also very nice to understand even if we are in beginner level.

Moreover till date I did not integrate Paytm in live mode for my client. But in test mode I develop all the things which is need to execute the code for collecting payment from customer side. Just we need to change the API key only to shift test mode to live mode. Actually test mode used for testing our application and it’s processing only virtual payment.

Create Project – Paytm PHP Integration

Okay let’s see the steps for how integrate Paytm Payment Gateway into our PHP program and MySQL database. Before start this just choose your doing in framework or Core PHP, some developers are using both code at a same to time to implement the functionalities. Laravel is best framework for large scalability projects like Shopping sites, management system, banking sector and more. Otherwise Core also good, if you are beginner ? then go for Core PHP code to integrate with Paytm.


  1. Skill on PHP & MySQL database
  2. HTML, CSS, JavaScript, jQuery
  3. Business PAN & Bank Account, GST mandatory for complete the KYC form. Because without KYC we can’t able to create and ink into our website.
  4. Finally Submit Your Live Website to get Approval.

Documentation – Paytm PHP Integration

I hope above all requirements are complete by yourself. Hereafter you have to follow below documentation steps for how successfully integrate into our website. Suppose if you are work with framework then use composer to install the SDK, otherwise manually download the SDK from GitHub site.

1. Install SDK

SDK File Download

Actually SDK is must for configure our project so without adding SDK we can’t able to communicate with Paytm payment gateway. Therefore first download the file via above mentioned link and then follow then steps.

2. Generate API Key

After downloading the SDK just place into your particular project file. So the next step is we have to generate API key with help of official documentation. For that first you have to create account on Paytm website. Then choose test mode and click to generate API key for integrate with our project file.

Sample Code

In below for example purpose here I have share code, once check this code and proceed with your existing projects.

// For Staging 
$environment = LibraryConstants::STAGING_ENVIRONMENT;

// For Production 
// $environment = LibraryConstants::PRODUCTION_ENVIRONMENT;
// Find your mid, key, website in your Paytm Dashboard at 
$mid = "YOUR_MID_HERE";
$key = "YOUR_KEY_HERE";
$website = "YOUR_WEBSITE_NAME";
$client_id = "YOUR_CLIENT_ID_HERE";


MerchantProperties::initialize($environment, $mid, $key, $client_id, $website);
// If you want to add log file to your project, use below code
Config::$monologName = '[PAYTM]';
Config::$monologLevel = MonologLogger::INFO;
Config::$monologLogfile = '/path/log/file.log';

Source Code – Paytm PHP Integration

For example purpose here I share test application source code. So first download and run this project on your system. After that you get some idea like how to customize the source code into your existing project. Later that handle the payment methods like UPI Collect, Intent, Netbanking, Debit & Credit Card/Pay Later (EMI) etc.

paytm php integration
Image Credits – Paytm

Leave a Reply