codenikin

payload razorpay

by codenikin
Payments
v3
^3.85.1
MIT

Overview

Summary generated from the README

Adds Razorpay as a payment method for the Payload Ecommerce plugin. It creates Razorpay orders on the server, verifies payment signatures when an order is confirmed, and records transactions. Requires a Razorpay account, the Payload Ecommerce plugin and your own frontend checkout UI.

Features

  • Registers as a payment method in the Payload Ecommerce plugin
  • Creates Razorpay orders through the Orders API
  • Verifies payment signatures before the order is created
  • Creates transactions automatically
  • Provides a client adapter for the storefront
  • Typed with TypeScript and compatible with Next.js

Use cases

  • Accept Razorpay payments in a Payload-based storefront targeting India
  • Add Razorpay alongside other payment methods in Payload Ecommerce

From the author

Razorpay adapter for Payload Ecommerce

Installation

npm i @codenik/payload-razorpay

0

Stars

0

Forks

0

Open Issues

2 months ago

Last Updated

4

Weekly Downloads

v1.0.2

npm Version

34.6 KB

Unpacked Size

2

Dependencies

GitHub stars

Trends appear after 7 days of data. Collecting since Oct 22 — 5 daily snapshots so far.

npm weekly downloads

Trends appear after 7 days of data. Collecting since Oct 22 — 5 daily snapshots so far.

Each point is npm's rolling 7-day download count.

Health Score

60/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1314210045-root.svg)](https://payloaddirectory.dev/plugins/1314210045-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1314210045-root"><img src="https://payloaddirectory.dev/badge/1314210045-root.svg" alt="Payload Directory"></a>
Updated Aug 6, 2026Created Jul 27, 2026Published Aug 6, 2026

README

@codenik/payload-razorpay

A production-ready Razorpay payment adapter for the Payload CMS Ecommerce Plugin.

Integrate Razorpay into your Payload CMS storefront with minimal configuration. This adapter provides seamless payment processing, secure payment verification, and native integration with the Payload Ecommerce payment system.

Built for Payload CMS 3.x, TypeScript, ESM, and Next.js.


✨ Features

  • 💳 Native Razorpay Checkout integration
  • 🛒 Razorpay Orders API support
  • 🔒 Secure payment signature verification
  • 📦 Automatic transaction creation
  • ⚡ Fully typed with TypeScript
  • 🚀 ESM compatible
  • 🎯 Payload CMS 3.x compatible
  • 🌐 Next.js compatible
  • 🔧 Customisable payment labels
  • 🧩 Seamless integration with Payload Ecommerce
  • 🇮🇳 Optimised for India and all Razorpay-supported regions

Requirements

Before installing the adapter, ensure your project meets the following requirements.

RequirementVersion
Payload CMS3.x
@payloadcms/plugin-ecommerceLatest
Node.js20+
Razorpay AccountRequired

Installation

Install the package using your preferred package manager.

pnpm

pnpm add @codenik/payload-razorpay

npm

npm install @codenik/payload-razorpay

yarn

yarn add @codenik/payload-razorpay

Environment Variables

Add the following variables to your .env file.

RAZORPAY_SECRET=your_secret_key
NEXT_PUBLIC_RAZORPAY_KEY_ID=your_publishable_key

Note

Use Test Keys during development and Live Keys in production.


Backend Configuration

Register the Razorpay adapter with the Payload Ecommerce plugin.

import { ecommercePlugin } from '@payloadcms/plugin-ecommerce'
import { razorpayAdapter } from '@codenik/payload-razorpay'

plugins: [
  ecommercePlugin({
    payments: {
      paymentMethods: [
        razorpayAdapter({
          publishableKey: process.env.NEXT_PUBLIC_RAZORPAY_KEY_ID!,
          secretKey: process.env.RAZORPAY_SECRET!,
        }),
      ],
    },
  }),
]

Frontend Configuration

Import the client adapter into your frontend application.

import { razorpayAdapterClient } from '@codenik/payload-razorpay'

Initialise the adapter.

const adapter = razorpayAdapterClient({
  publishableKey: process.env.NEXT_PUBLIC_RAZORPAY_KEY_ID!,
})

Checkout Integration

This package provides the Payload CMS payment adapter. To open the Razorpay Checkout on the frontend, install the official react-razorpay package.

Step 1 — Install React Razorpay

pnpm

pnpm add react-razorpay

npm

npm install react-razorpay

yarn

yarn add react-razorpay

Step 2 — Import Razorpay

Import the required hook and types into your checkout component.

import { RazorpayOrderOptions, useRazorpay } from 'react-razorpay'

Step 3 — Initialise Razorpay

const { Razorpay } = useRazorpay()

Step 4 — Open Razorpay Checkout

After calling initiatePayment(), launch the Razorpay Checkout using the returned payment details.

const options: RazorpayOrderOptions = {
  key: process.env.NEXT_PUBLIC_RAZORPAY_KEY_ID!,
  amount: (paymentData.amount as number) * 100,
  currency: 'INR',
  name: 'Your Store',
  description: 'Order Payment',
  order_id: paymentData.paymentIntentID,

  handler: async (response) => {
    await confirmOrder('razorpay', {
      additionalData: {
        paymentIntentID: paymentData.paymentIntentID,
        razorpay_payment_id: response.razorpay_payment_id,
        razorpay_signature: response.razorpay_signature,
      },
    })
  },
}

const razorpay = new Razorpay(options)
razorpay.open()

Important

This package only provides the Payload CMS payment adapter. You are responsible for implementing the checkout UI and calling initiatePayment() and confirmOrder() from your frontend application.


Payment Flow

Customer clicks Pay
        │
        ▼
initiatePayment()
        │
        ▼
Payload creates a Razorpay Order
        │
        ▼
Open Razorpay Checkout
        │
        ▼
Customer completes payment
        │
        ▼
confirmOrder()
        │
        ▼
Payment verified
        │
        ▼
Payload creates the Order
        │
        ▼
Redirect to Order Confirmation Page

Supported Features

FeatureStatus
Razorpay Checkout✅
Razorpay Orders API✅
Payment Verification✅
Transaction Creation✅
Payload Ecommerce Integration✅
TypeScript✅
ESM✅
Next.js✅

Security

  • Never expose your Razorpay Secret Key to the frontend.
  • Always verify the Razorpay payment signature.
  • Use HTTPS in production.
  • Use Test Keys for development and Live Keys for production.

Compatibility

PackageVersion
Payload CMS3.x
Node.js20+
Next.js15+

Contributing

Contributions are welcome!

If you'd like to improve this project, feel free to open an issue or submit a pull request.


License

MIT License


Support

If you encounter an issue, please include the following information when creating a GitHub issue:

  • Payload CMS version
  • Plugin version
  • Node.js version
  • Error logs
  • Steps to reproduce the issue

Similar plugins