Integrate Razorpay with Node.js & React to facilitate secure online transactions, providing a smooth checkout experience with real-time payment processing.
Key Points
- 40% faster checkout with Razorpay in Node.js & React increases conversions.
- Smart retry reduces payment failures by 80% with Node.js backend integration.
- Razorpay APIs provide 99.9% uptime with React & Express for hassle-free payments.
With Over 14 years of Experience in the IT Field, Helping Companies Optimise there Products for more Conversions

Introduction
Integrating Razorpay into your Node.js and React applications allows for hassle-free online transactions that help businesses accept payments from credit/debit cards, UPI, net banking, and wallets. It allows businesses to handle online transactions securely and efficiently. Whether you are using an eCommerce website, mobile app development, or SaaS development, integrating a trusted payment gateway increases user experience and makes payment seamless.
This guide will walk you through the integration of Razorpay with a Node/Express backend and a React frontend for a full-stack application step by step.
Why Razorpay for Payment Integration?
- Supports Various Payment Modes: Accept payments through UPI, credit/debit cards, net banking, or wallets.
- Easy Integration to API: Well-documented APIs that speed up and simplify integration for all developers working with the web app or payment app.
- Secure Transactions: Razorpay ensures encrypted payments, following industry standards.
- Real-Time Payment Tracking: Stay updated with real-time transaction monitoring.
- Webhook Notifications: Automate transaction updates in your system.
- International Payments: Expand your reach with multi-currency support.
Subscription or one-time? Find the best payment gateway for your business model and maximize your revenue efficiently.
Prerequisites
Before starting, ensure that you have the following:
- Node.js Installed: Download and install Node.js.
- Razorpay Account: Sign up at Razorpay and generate API keys.
- Basic Knowledge of JavaScript, Node.js, and React.
- Postman (optional but recommended) for testing APIs.
Setting Up Razorpay Account
Go to Razorpay Dashboard
- Sign up or log in.
- Navigate to Settings > API Keys.
- Click on Generate Live/Test Key.
- Save the key_id and key_secret.
Note: Use test keys for development. Switch to live keys when deploying.
Backend (Node.js + Express)
Step 1: Install Dependencies
npm init -y
npm install express dotenv cors axios crypto razorpay
Step 2: Create EndPoints
POST /create-order - Create a Payment Order
This endpoint generates a new order using the Razorpay API and returns an orderId, which is needed to initialize the payment process.
Request Format
- Method: POST
- Endpoint: /api/create-order
- Headers: Content-Type: application/json
- Body:
Process
- The frontend sends the amount and currency (default: INR).
- The backend communicates with Razorpay to create an order.
- Razorpay responds with an orderId, which is sent to the fronten
Response Format
POST /api/verify-payment - Verify Payment Signature
This endpoint verifies whether the payment made by the user is genuine by validating the Razorpay signature.
Request Format
- Method: POST
- Endpoint: /api/verify-payment
- Headers: Content-Type: application/json
- Body:
Process
- The frontend sends orderId, paymentId, and signature after a successful payment.
- The backend generates a hash using crypto.createHmac and compares it with Razorpay’s signature.
- If the generated hash matches, the payment is considered valid.
Response Format
Successful Payment
Invalid Signature
Step 3: Code Implementation
Frontend (React)
Step 1: Create a React App And install packages
npm install axios
Step 2: Create RazorpayPayment.jsx
Step 3: Add Component to App.js
Step 4: Load Razorpay Script
In public/index.html, add the Razorpay checkout script inside the <head> tag:
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
Final Steps
- Start your backend (node server.js)
- Start your frontend (npm start)
- Enter an amount and complete the Razorpay payment
- Backend verifies the payment
- Redirects to success or failure page
Final Words
Integrating Razor Pay with Node.js and React is the most important aspect of the e-commerce, mobile app development and SaaS business for transaction payments. With the help of APIs and SDKs, you can easily integrate such seamless and secure payment solutions into your web development projects.
This guide will help the developers in implementing effective Razorpay payment integration in the applications, ensuring secure transactions and better user experience.
+91-8727000867
+64 22 003 5555




Request Instant Call
Hire Remotely