Razorpay Integration
Secure payment processing
CodePlanet uses Razorpay for secure payment processing. This document covers how payments work, the integration architecture, and troubleshooting common issues.
Overview
Razorpay handles all payment processing for CodePlanet subscriptions. We support:
- π³ Credit/Debit Cards β Visa, Mastercard, RuPay
- π¦ Net Banking β All major Indian banks
- π± UPI β Google Pay, PhonePe, Paytm, etc.
- π° Wallets β Paytm, PhonePe, Amazon Pay
Payment Flow
Step 1: Order Creation
When a user initiates a payment, we create a Razorpay order:
Important: Amount is always determined server-side from the plan ID. We never trust client-provided amounts.
Step 2: Checkout
The Razorpay checkout modal opens in the browser:
Step 3: Signature Verification
After payment, we verify the signature to ensure authenticity:
Security Note: We use
crypto.timingSafeEqualto prevent timing attacks on signature comparison.
Webhook Integration
Razorpay sends webhook events for payment lifecycle events:
Supported Events
| Event | Description |
|---|---|
payment.authorized | Payment authorized, awaiting capture |
payment.captured | Payment successfully captured |
payment.failed | Payment failed |
refund.created | Refund initiated |
subscription.activated | Subscription started |
subscription.cancelled | Subscription cancelled |
Webhook Endpoint
UPI Direct Integration
For faster UPI payments, we support direct UPI intent:
Users can either:
- Scan the QR code with any UPI app
- Click the UPI intent link on mobile
Security Measures
1. Server-Side Pricing
Amount is always calculated server-side from the plan ID:
2. Input Validation
All payment endpoints validate:
- UUID format for user IDs
- Valid plan IDs only
- Signature presence and format
3. Rate Limiting
Payment endpoints are rate-limited:
- 10 orders per hour per user
- 3 verification attempts per order
4. Idempotency
Each order has a unique receipt to prevent duplicate charges.
Testing
In test mode, use Razorpay test cards:
| Card Number | Type | Result |
|---|---|---|
| 4111 1111 1111 1111 | Visa | Success |
| 5267 3181 8797 5449 | Mastercard | Success |
| 4000 0000 0000 0002 | Any | Failure |
Test UPI ID: success@razorpay
Error Handling
Common payment errors and their handling:
| Error Code | Meaning | User Message |
|---|---|---|
BAD_REQUEST_ERROR | Invalid parameters | "Please check your payment details" |
GATEWAY_ERROR | Bank/gateway issue | "Payment failed, please try again" |
SERVER_ERROR | Our server error | "Something went wrong, please retry" |
Subscription States
| State | Description |
|---|---|
active | Subscription is active and paid |
pending | Payment initiated but not completed |
cancelled | User cancelled subscription |
expired | Subscription period ended |
Troubleshooting
Payment Not Completing
- Check browser console for errors
- Ensure popup blocker is disabled
- Try a different payment method
- Contact support with order ID
Subscription Not Activating
- Check webhook delivery in Razorpay dashboard
- Verify webhook secret is correct
- Check server logs for errors
Refund Issues
Refunds are processed within 5-7 business days. Contact support with:
- Order ID
- Payment ID
- Reason for refund
Next Steps
- Subscription Lifecycle β Managing subscriptions
- Billing FAQ β Common billing questions
- Pricing Plans β Compare plans