This guide will walk you through installing the Razorpay payment gateway module in your WHMCS installation.
Before installing the module, ensure you have:
- WHMCS 6.0+ (tested on 6.3, 7.10, 8.13)
- PHP 5.6+ (tested on 5.6, 7.0, 7.4, 8.0, 8.1, 8.2)
- Active Razorpay Account with API keys
- SSL Certificate (required for webhook processing)
- Admin access to your WHMCS installation
- Upload the module files to your WHMCS root directory
- Run the installer:
cd /path/to/your/whmcs php install.php - Follow the on-screen prompts
- Configure the gateway in WHMCS Admin
-
Upload main gateway file:
cp razorpay.php /path/to/whmcs/modules/gateways/
-
Upload callback file:
cp callback/razorpay.php /path/to/whmcs/modules/gateways/callback/
-
Upload module directory:
cp -r razorpay/ /path/to/whmcs/modules/gateways/
-
Set proper permissions:
chmod 644 /path/to/whmcs/modules/gateways/razorpay.php chmod 644 /path/to/whmcs/modules/gateways/callback/razorpay.php chmod -R 755 /path/to/whmcs/modules/gateways/razorpay/
- Login to Razorpay Dashboard: https://dashboard.razorpay.com
- Go to Settings → API Keys
- Generate API Keys (if not already done)
- Copy your Key ID and Key Secret
-
Login to WHMCS Admin
-
Go to Setup → Payments → Payment Gateways
-
Find "Razorpay" and click "Configure"
-
Fill in the required fields:
Required Settings:
- Key ID: Your Razorpay Key ID
- Key Secret: Your Razorpay Key Secret
- Webhook Secret: (Leave empty for now, we'll set this up next)
- Enable Webhook: Set to Yes
Optional Settings:
- Gateway Fee Mode: Choose how to handle Razorpay fees
- Merchant Absorbs Fee (Default): You pay the fee
- Client Pays Fee: Customer pays the fee
- Supported Currencies: Add currencies you want to support
- Default:
INR,USD,EUR,GBP,AED,SGD - Add more as needed:
INR,USD,EUR,GBP,AED,SGD,JPY,CAD,AUD
- Default:
-
Save Configuration
-
In Razorpay Dashboard → Settings → Webhooks
-
Click "Add New Webhook"
-
Enter Webhook URL:
https://yourdomain.com/modules/gateways/razorpay/razorpay-webhook.phpReplace
yourdomain.comwith your actual domain. -
Select these events:
- ✅
payment.captured - ✅
order.paid - ✅
refund.created - ✅
refund.processed
- ✅
-
Click "Create Webhook"
-
Copy the Webhook Secret (you'll need this for WHMCS)
- Go back to WHMCS → Setup → Payments → Payment Gateways
- Find "Razorpay" and click "Configure"
- Paste the Webhook Secret from Razorpay Dashboard
- Save Configuration
- Use Razorpay Test API Keys for initial testing
- Create a test invoice in WHMCS
- Process a test payment using Razorpay test cards
- Verify the payment appears in WHMCS
Use these test card numbers in Razorpay test mode:
| Card Number | Description |
|---|---|
4111 1111 1111 1111 |
Successful payment |
4000 0000 0000 0002 |
Failed payment |
4000 0000 0000 0002 |
3D Secure payment |
- Check Gateway Logs: WHMCS Admin → Utilities → Logs → Gateway Log
- Look for "Webhook Received" entries
- Verify invoice status changes to "Paid"
- Check payment appears in WHMCS transactions
To support additional currencies:
- Add currencies to the "Supported Currencies" field
- Ensure currencies are supported by Razorpay
- Test with each currency before going live
Merchant Absorbs Fee (Default):
- Customer pays invoice amount only
- You absorb the Razorpay processing fee
- Recommended for most businesses
Client Pays Fee (Surcharge):
- Customer pays invoice amount + processing fee
- You receive the full invoice amount
- Useful for high-volume merchants
The module automatically uses your WHMCS timezone setting. No additional configuration required.
The module includes several utility scripts for maintenance:
php modules/gateways/razorpay/scripts/sync-payments.php --since=2025-01-01 --limit=50php modules/gateways/razorpay/scripts/webhook-diagnostic.phpphp modules/gateways/razorpay/scripts/cross-check-tool.php --since=2025-01-01Payments not being recorded:
- Check if webhook is enabled in WHMCS
- Verify webhook URL in Razorpay Dashboard
- Check webhook secret matches in both places
- Review Gateway Logs for errors
Signature verification errors:
- Verify API keys are correct
- Check webhook secret is properly configured
- Ensure webhook events are selected in Razorpay
Currency not supported:
- Add currency to supported currencies list
- Verify currency is supported by Razorpay
- Check currency code format (e.g., USD not usd)
Enable debug logging by adding to your WHMCS configuration:
// In includes/configure.php
define('RAZORPAY_DEBUG', true);- Gateway Logs: WHMCS Admin → Utilities → Logs → Gateway Log
- Webhook Logs: Check Gateway Logs for "Webhook Received" entries
- Error Logs: Check your server error logs
- Use HTTPS for webhook URL
- Keep API keys secure and never share them
- Regularly rotate API keys
- Monitor webhook logs for suspicious activity
- Use test mode for development and testing
- GitHub Issues: Report bugs and request features
- WHMCS Community: WHMCS Community Forum
For production environments requiring guaranteed support:
- Email: support@yourcompany.com
- Response time: 24 hours
- Includes: Priority support, custom modifications, installation assistance
- Module files uploaded correctly
- Gateway configured in WHMCS
- Razorpay API keys entered
- Webhook configured in Razorpay Dashboard
- Webhook secret added to WHMCS
- Test payment processed successfully
- Payment appears in WHMCS
- Refund functionality tested
- Multi-currency support configured (if needed)
- Gateway fee mode configured
- Utility scripts tested
- Documentation reviewed
Your Razorpay payment gateway is now installed and configured. You can start accepting payments through Razorpay in your WHMCS installation.
For any issues or questions, please refer to the troubleshooting section or contact support.
Need help? Check out our comprehensive documentation or contact support.