Simplifying PHP Integration of Paytm Payment Gateway

PHP Integration

Even with the availability of multiple Content Management Systems like WooCommerce, Magento, Shopify, etc., where integrating a payment gateway is easier, online businesses in India prefer to set up their own e-commerce platform.

Patching a payment gateway with an e-commerce website or app requires a little bit of coding. Although, it’s not strictly necessary, knowing tidbits of computer languages like C#, Java, and PHP will make the integration easier. Else, you might have to take help from a software developer just to make sure there are no inadvertent hiccups.

We will try to give as much information as possible to at least make you familiar with what you are going to deal with if you choose to integrate a payment gateway in PHP.

What is PHP?

PHP is a server-side computer language that is also used for web development. This open-source language was created by a Danish-Canadian programmer, Rasmus Lerdorf, and has been around for over two decades now. Despite its falling popularity, it’s used by popular websites such as WordPress and Facebook.

It’s one of those programming languages that can be easily picked up even with little to no coding background. The entry barriers are almost none as the syntax and command functions are easy to pick up.

PHP is compatible with most applications and can run on different operating systems. PHP gives web developers better control and a few simple lines of code do the job.

Integrating a payment gateway in PHP

Integrating a payment gateway with the online commerce website and app will require some tech know-how. The payment gateway company must provide as much assistance as it can.

Right from helping with the documentation to providing APIs, the onus is on the payment gateway. You should ensure that the payment gateway you are working with helps you with these technical details beforehand.

Paytm Payment Gateway has streamlined these technical details meticulously, so much so, that you only have to do minimal coding from your end.

Here we try to explain the process in detail.

How to integrate Paytm Payment gateway in PHP

Integrating Paytm Payment gateway with your e-commerce portal in PHP is quite easy.

You will have to first create an account with Paytm Payment Gateway. While creating your account, keep in mind to choose the option that requires a website or app for integrating Paytm Payment Gateway.

The sign up process will also ask for a URL where you want your customers to be redirected after the payment. Provide information such as business name, type, address, bank details, and verification documents.

Once you are done with providing all the relevant information, you will get staging credentials from Paytm. These include MID, Merchant Key, Industry Type, Website Name, and Channel ID. You will get testing wallet information to try out the transaction flow on the checkout page.

Ok, you are done with the basic stuff. Now we move on to the interesting part of the integration process. Let’s get our hands dirty.

To make things easy, we have put all the necessary files in one place, which you can download from here. After extracting the PaytmKit folder, look for the ‘config_paytm.php’ file.

This file contains the following information. We will go through them one by one and see what changes you need to make in the code.

define(‘PAYTM_ENVIRONMENT’, ‘TEST’);

define(‘PAYTM_MERCHANT_KEY, ‘xxxxxxxxxxxxxx’);

define(‘PAYTM_MERCHANT_MID’, ‘xxxxxxxxxxxxxx’)

define(‘PAYTM_MERCHANT_WEBSITE’, ‘WEBS***ING’);

In the first line, replace “TEST” with “PROD” — this will allow you to make transactions in the production environment. If you want to test it first, leave it as it is.

In the second, third, and fourth lines of the code, enter the merchant key, MID, and website name that you were given after signing up with Paytm Payment Gateway.

You are almost good to go.

The next step requires you to create a simple form in HTML where users can fill in their payment information. In the HTML code, the ‘Form action’ tag should point to the file “pgRedirect.php”, which is inside the PaytmKit folder you downloaded earlier.

After making this change you don’t have to worry about anything after that as the PaytmKit will handle everything like verify payment amount, etc. It will redirect your users to Paytm’s payment page.

In a nutshell

If you want to own the checkout flow of the payment page on your website, PHP is the easiest and the most flexible way to integrate the payment gateway. With Paytm Payment Gateway’s easy reckoner to the whole integration process makes it even easier.

Sign up with Paytm Payment Gateway today and integrate it easily with your e-commerce platform in PHP.

Switch to Paytm Payment Gateway

You May Also Like
Accept Payments at Zero fees
Read More

Accept Payments Online at Zero Fees with Paytm

While there is no extra cost associated with making online payments on the consumer side, businesses need to pay certain charges. That’s the reason why they look for ways to accept payments at a 0% fee.