Korvith Logo
KORVITH TECHNOLOGIES
HomeBlogTechnical TutorialsIntegrating Payment Gateways into an E-commerce Website
Back to all articles
Technical Tutorials9 min read•October 2026

Integrating Payment Gateways into an E-commerce Website

Part of our E-Commerce Architecture & Payments Topic Cluster
Explore Full Service Capabilities
Executive Summary:Complete developer tutorial on integrating Razorpay with React & Node.js—order creation, client checkout modal, and cryptographically verified webhook handlers.

The 3-Step Payment Lifecycle

A payment gateway integration involves three distinct steps:

1Server Order Creation: Your backend calculates the cart total securely (never trust client-side prices!) and calls the payment gateway API to create an order_id.
2Client Checkout Modal: Your frontend opens the gateway modal with the generated order_id.
3Webhook Verification: The payment gateway's server notifies your backend via an asynchronous webhook that the payment succeeded.

Node.js Webhook Verification Implementation:

javascriptKorvith Code Snippet
import crypto from "crypto";

export const handleRazorpayWebhook = async (req, res) => {
  const secret = process.env.RAZORPAY_WEBHOOK_SECRET;
  const signature = req.headers["x-razorpay-signature"];

  // Cryptographically verify payload authenticity
  const expectedSignature = crypto
    .createHmac("sha256", secret)
    .update(JSON.stringify(req.body))
    .digest("hex");

  if (expectedSignature !== signature) {
    return res.status(400).json({ error: "Invalid cryptographic signature" });
  }

  const event = req.body.event;
  if (event === "payment.captured") {
    const payment = req.body.payload.payment.entity;
    // Mark order as paid in database
    await updateOrderStatus(payment.order_id, "PAID", payment.id);
  }

  res.status(200).json({ status: "ok" });
};

Always respond with HTTP 200 immediately to prevent the gateway from retrying the webhook unnecessarily.

Related Tags:#Razorpay#Payment Gateway#Node.js#Webhooks
About the Author
SP
Samir Pandey
Lead Software Engineer

Samir Pandey is a software developer working on web applications, business software, AI integrations and automation solutions at Korvith. He shares practical insights on software engineering, web development, application performance and building digital products for businesses.

Put This Strategy Into Practice

Ready to implement this in your business?

Our engineering team in Dehradun audits your existing workflows and engineers custom software, web, and automation architectures.

Chat on WhatsApp
Get In Touch

Let's Engineer Your Digital Growth

Have a project brief, software inquiry, or technical requirement? Send us a message below.

Send Project Brief

Tell us what you want to build

Confidential & Direct

🔒 Confidential & Direct. By submitting, you agree to our Privacy Policy and Terms of Service. We never share your data.