Skip to main content

Overview

DeployHub uses Razorpay as the payment gateway for all Pro plan subscriptions. Razorpay supports UPI, cards, net banking, and wallets for seamless payments.
Payment integration is implemented in /prototype/backend/src/controllers/slices/Payments/

Razorpay Setup

The backend initializes Razorpay with environment credentials:
Never expose your Razorpay KEY_SECRET in client-side code. All payment verification must happen server-side.

Required Environment Variables

.env

Payment Flow

The complete payment process follows this workflow:
1

Initialize Payment

Client sends plan selection to server
2

Create Razorpay Order

Server calculates amount and creates order
3

Store Pending Order

Server saves pending order in database
4

User Completes Payment

Client opens Razorpay checkout with order detailsUser pays via UPI/Card/Net Banking/Wallet
5

Verify Payment

Client sends payment response to server for verification
6

Activate Subscription

Server verifies signature, creates project, activates Pro features

Initialize Payment Endpoint

Implementation: /prototype/backend/src/controllers/slices/Payments/init.controller.js:11

Request

Validation

The endpoint validates:

Free Plan Handling

Free plan projects are created without payment:

Pro Plan Processing

For Pro plans, amount is calculated with discounts:

Response

Payment Verification

Payment verification is CRITICAL for security. Never trust client-side payment success without server verification.

Signature Verification Process

The server uses HMAC-SHA256 to verify Razorpay signatures:
This verification ensures the payment response came from Razorpay and wasn’t tampered with.

Verify Payment Endpoint

Validation Checks

Duplicate Order Prevention

Subscription Activation

After successful verification:
In development (NODE_ENV !== "production"), subscriptions last only 1 hour for testing purposes.

Success Response

Subscription Renewal

Renewal Information

Get renewal details:
Renewals automatically use the same duration as the previous subscription.

Initiate Renewal

There’s a pricing inconsistency: renewal uses 81900 paise (₹819) while initial purchase uses 79900 paise (₹799).This is from renew.controller.js:17 - consider standardizing to planPrice.js constants.

Verify Renewal

Renewal extends subscription from the current end date:

PendingOrder Auto-Expiry

Unpaid orders automatically expire:
MongoDB automatically deletes pending orders after 2 hours using TTL index.

Subscription Lifecycle Events

The system schedules automated events:

Expiry Warning Notification

Users receive a notification 5 days before subscription expires (25 days after start for 30-day month).

Subscription Start Email

Subscription Expiry Handler

Client-Side Integration

Error Handling

Security Best Practices

Follow these critical security guidelines:
  1. Never expose KEY_SECRET: Keep Razorpay secret in environment variables
  2. Always verify server-side: Never trust client payment success
  3. Validate signature: Use HMAC-SHA256 verification
  4. Check order status: Prevent duplicate processing
  5. Use HTTPS: All payment endpoints must use SSL
  6. Implement rate limiting: Prevent abuse of payment endpoints
  7. Log all transactions: Maintain audit trail
  8. Handle failures gracefully: Don’t leak sensitive error details

Testing Payments

Razorpay provides test mode for development:

Test Card Numbers

In development mode, subscriptions last 1 hour instead of the full duration for easier testing.

Next Steps

View Plans

See pricing and features

Invoices

Access billing history

Usage Limits

Monitor plan quotas

API Reference

Payment API documentation