0.1.2 • Published 3 months ago

payload-razorpay v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Payload CMS Razorpay Plugin

⚠️ IMPORTANT NOTICE

This plugin is currently in active development and testing. It is not ready for production use as breaking changes may occur. Use at your own risk in development environments only.

A powerful Payload CMS plugin that integrates the Razorpay payment gateway for handling online payments, refunds, and more in your Payload CMS applications.


🚀 Features & Development Status

FeatureStatusProgress
Configurable Collections❌ Not PlannedNo clear approach yet
API Helpers
- Create Payment🟡 Under TestingPartially completed
- Verify Payment🟡 Under TestingFunctional but needs validation
- Webhook Handler🔵 In ProgressPartially implemented, testing not started
- Config Handler🟡 Under TestingWorks but needs improvements
- Create Subscriptions❌ Not StartedYet to begin implementation
- Reports❌ Not StartedPlanned for later
- Refund APIs❌ Not PlannedNo current plans
UI Components
- Admin Dashboard Reports🟡 Under TestingBasic version available, improvements needed
- Example/Test Payment Component🔵 In ProgressWork ongoing
React Hooks
- createPaymentInRazorpay🟡 Partially ImplementedNeeds further testing
- createSubscriptionInRazorpay❌ Not StartedImplementation pending
- handleRefund🟡 Partially ImplementedNeeds validation and testing
- useRazorpayConfig✅ CompletedTested and stable
- useRazorpayFetch🟡 Under TestingSome improvements required
- getRazorpayInstance✅ CompletedFully functional
Other Features
- Secure Collections (Access Control)🔵 In ProgressNeeds proper implementation
- Razorpay Customizations from Admin Panel❌ Not StartedPlanned but no work done

Legend: ✅ Completed | 🟡 Under Testing | 🔵 In Progress | ❌ Not Started / Not Planned


📦 Installation

# npm
npm install payload-razorpay

# yarn
yarn add payload-razorpay

# pnpm
pnpm add payload-razorpay

🛠 Quick Start

1️⃣ Add the Plugin to Payload CMS

import { buildConfig } from 'payload/config'
import { razorpayPlugin } from 'payload-razorpay'

export default buildConfig({
  plugins: [
    razorpayPlugin({
      razorpay: {
        keyId: process.env.RAZORPAY_KEY_ID ?? '',
        keySecret: process.env.RAZORPAY_KEY_SECRET ?? '',
        webhookSecret: process.env.RAZORPAY_WEBHOOK_SECRET, // Optional
      },
      webhook: {
        enabled: false, // Enable if needed
      },
    }),
  ],
})

2️⃣ Use the Plugin Hooks in Collections

import { CollectionConfig } from 'payload/types'
import { useRazorpay } from 'payload-razorpay/hooks'

export const Orders: CollectionConfig = {
  slug: 'orders',
  fields: [
    // Your fields here
  ],
  hooks: {
    beforeChange: [
      useRazorpay({
        // Configure payment options
      }),
    ],
  },
}

📖 API Reference

Plugin Options

OptionTypeRequiredDescription
razorpay.keyIdstring✅ YesYour Razorpay API Key ID
razorpay.keySecretstring✅ YesYour Razorpay API Key Secret
razorpay.webhookSecretstring❌ NoWebhook secret for verifying Razorpay webhooks
webhook.enabledboolean❌ NoEnable/disable webhook handling (default: false)

Available Hooks

  • createPaymentInRazorpay → Create payments in Razorpay
  • createSubscriptionInRazorpay → Handle subscriptions
  • handleRefund → Process refunds
  • useRazorpayConfig → Retrieve Razorpay configuration
  • useRazorpayFetch → Alternative API handler using Fetch

🌐 Webhook Integration

  1. Set up the webhook URL in Razorpay dashboard: https://your-domain.com/api/razorpay/webhook
  2. Configure the webhook secret in the plugin options.
  3. Handle webhook events using useRazorpayWebhook.

🛠 Development

# Install dependencies
pnpm install

# Run development server
pnpm dev

# Build the plugin
pnpm build

# Run tests
pnpm test

👥 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a pull request.


📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


📢 Support


👨‍💻 Author

Bhuvan BM


0.1.2

3 months ago

0.1.1

3 months ago

0.0.3-alpha.1

3 months ago

1.0.1

4 months ago

1.0.0

4 months ago