Skip to content
Related Articles

Related Articles

Improve Article

How to Integrate Paytm Test API in Node.js ?

  • Last Updated : 26 May, 2021
Geek Week

Paytm stands for Pay through mobile is used for online transactions. We can integrate it with our node.js application using Paytm developer API.

This API can be used for testing as well as for development purposes.  There are two methods for doing so: Test API and Production API. Production API will only work when the Merchant account is linked to a bank account. In this article, we will implement using Test API.

Setting up the environment:

Initialize NPM package: 

npm init -y

Installing dependencies:

npm install express ejs

 



app.js




const express= require('express');
var app= express();
var bodyParser= require('body-parser');
const ejs= require('ejs');
  
  
app.use(express.static(__dirname + '/views'));
app.engine('html', require('ejs').renderFile);
app.set("view engine", "html"); 
app.set("views", __dirname + "/views"); 
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
  
app.use('/', require('./routes/server'));
  
let port = process.env.PORT || 1234;
  
app.listen(port,()=>{
    console.log("Server is started");
});
  • Create routes in /routes/server.js file:
  • Create views in /views folder
  • Connect views in app.js file
app.use('/', require('./routes/server'));
  • For integrating Paytm, go to paytm.com in web mode and click “Accept Payments“:

  • Choose the “Developer” option:

  • Log in/Sign up with your Paytm account:

  • After login, the developer dashboard will be displayed. After this, click Developer Settings:

  • Use your Merchant ID, Merchant KEY in the node.js application.
    • There are two methods for doing this:
      • Test API: In testing mode.
      • Production API: In production mode. Production mode is active only when the Merchant account is linked to his bank account.

  • After creating an application, run the server and Enter details like Name, Email, mobile, amount, etc.

  • In the next step, click proceeds to payment, and you will receive an OTP on your mobile number. Enter the OTP and process and your transaction will be done

  • We can also pay using a Credit card, Debit card, and net banking.

  • Place config.js file in /routes/Paytm/ folder with your mid and key.

File Name : config.js

Javascript




var PaytmConfig = {
    mid: "YOUR MERCHANT ID",
    key: "YOUR MERCHANT KEY",
    website: "WEBSTAGING",
  };
  module.exports.PaytmConfig = PaytmConfig;

Complete code is available on https://github.com/singhteekam/Paytm_Integration




My Personal Notes arrow_drop_up
Recommended Articles
Page :