How to Integrate Paytm Test API in Node.js ?

26 May, 2021
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.
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.
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.
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
Node.js-Methods
NodeJS-Questions
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Installation of Node.js on Windows
JWT Authentication with Node.js
Difference between dependencies, devDependencies and peerDependencies
Mongoose Populate() Method
Mongoose find() Function
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React