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: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:11Request
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
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
Verify Renewal
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
- React Example
- Vanilla JavaScript
Error Handling
Payment Initialization Errors
Payment Initialization Errors
Verification Errors
Verification Errors
Renewal Errors
Renewal Errors
Security Best Practices
- Never expose KEY_SECRET: Keep Razorpay secret in environment variables
- Always verify server-side: Never trust client payment success
- Validate signature: Use HMAC-SHA256 verification
- Check order status: Prevent duplicate processing
- Use HTTPS: All payment endpoints must use SSL
- Implement rate limiting: Prevent abuse of payment endpoints
- Log all transactions: Maintain audit trail
- 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