Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pv-pushkarverma/SkillRise/llms.txt
Use this file to discover all available pages before exploring further.
Overview
SkillRise uses Stripe for processing course payments (Note: The codebase actually uses Razorpay as the payment provider, not Stripe. This documentation covers the Razorpay implementation).Features
- Secure checkout: Razorpay embedded payment UI
- Multiple payment methods: Cards, UPI, Netbanking, Wallets
- Webhook verification: HMAC-SHA256 signature validation
- Order tracking: Purchase status management
- Fallback enrollment: Webhook ensures enrollment even if frontend fails
Environment Variables
Server Configuration
Add these to yourserver/.env file:
server/.env
Get your keys from the Razorpay Dashboard. Create an account and generate API keys under Settings → API Keys.
Setup Instructions
Create Razorpay Account
- Go to Razorpay
- Sign up for an account
- Complete KYC verification (required for live mode)
- Start with Test Mode for development
Generate API Keys
- Go to Settings → API Keys
- Click Generate Test Keys (or Generate Live Keys for production)
- Copy the Key ID and Key Secret
- Add them to
server/.env:
Configure Webhooks
- Go to Settings → Webhooks
- Click Add New Webhook
- Enter your webhook URL:
- Development: Use ngrok →
https://your-ngrok-url.ngrok.io/razorpay - Production:
https://your-domain.com/razorpay
- Development: Use ngrok →
- Select events:
payment.captured
- Click Create Webhook
- Copy the Webhook Secret and add it to
server/.env:
Payment Flow
The payment flow consists of three steps:- Create Order: Backend creates a Razorpay order
- Process Payment: Frontend opens Razorpay checkout modal
- Verify Payment: Backend verifies signature and completes enrollment
- Webhook Fallback: Razorpay webhook ensures enrollment even if step 3 fails
1. Create Order
When a user initiates a purchase, the backend creates a Razorpay order:server/services/payments/razorpay.service.js
2. Frontend Integration
Open Razorpay checkout modal on the frontend:client/src/components/Checkout.jsx
client/index.html
3. Verify Payment Signature
The backend verifies the payment signature using HMAC-SHA256:server/services/payments/razorpay.service.js
4. Webhook Implementation
Webhook acts as a reliable fallback if the frontend verification fails (network drop, browser close, etc.):server/controllers/webhooks.js
server/server.js
Rate Limiting
Protect payment endpoints from abuse:server/server.js
Testing Payments
Test Cards
Razorpay provides test cards for development:| Card Number | Type | Result |
|---|---|---|
4111 1111 1111 1111 | Visa | Success |
5555 5555 5555 4444 | Mastercard | Success |
4000 0000 0000 0002 | Visa | Declined |
- CVV: Any 3 digits
- Expiry: Any future date
- Name: Any name
Test UPI
Usesuccess@razorpay as the UPI ID in test mode.
Testing Webhooks Locally
Production Checklist
Switch to Live Mode
- Complete KYC verification in Razorpay Dashboard
- Generate Live API Keys
- Update
RAZORPAY_KEY_IDandRAZORPAY_KEY_SECRETwith live keys
Enable HTTPS
Razorpay requires HTTPS for webhooks in production. Use:
- Let’s Encrypt (free SSL)
- Cloudflare (free SSL + CDN)
- Your hosting provider’s SSL
Common Issues
Webhook signature verification fails
Webhook signature verification fails
- Ensure you’re using
express.raw()middleware for the webhook route - Verify
RAZORPAY_WEBHOOK_SECRETmatches the secret in Razorpay Dashboard - Check that the webhook route is registered before
express.json() - Confirm headers
x-razorpay-signatureis being sent
Payment succeeds but enrollment fails
Payment succeeds but enrollment fails
- Check server logs for errors in
completePurchase()function - Verify MongoDB connection is active
- Ensure the
purchaseIdis correctly stored in Razorpay order notes - Check that the webhook is subscribed to
payment.capturedevent
Amount mismatch
Amount mismatch
- Razorpay amounts are in paise (smallest currency unit)
- Convert rupees to paise:
amount * 100 - Example: ₹2999 → 299900 paise
Duplicate enrollments
Duplicate enrollments
- Both frontend verification and webhook can trigger enrollment
- Ensure
completePurchase()is idempotent (checks if already completed) - Add unique constraints on
Purchasemodel
Security Best Practices
Verify Signatures
Always verify webhook signatures using
crypto.timingSafeEqual() to prevent timing attacks.Use HTTPS
Never send API keys or handle payments over HTTP. Always use HTTPS in production.
Rate Limiting
Apply strict rate limits to payment endpoints to prevent abuse and fraud attempts.
Secure Keys
Never commit API keys to git. Use environment variables and keep secrets secure.
Resources
Razorpay Docs
Official Razorpay documentation
Payment Gateway
Web integration guide
Webhooks
Webhook integration guide
Test Cards
Test card numbers