Home - Scripts - Website Development
- 10 April 2026
Razorpay Payment Webhook: A Complete Guide
Razorpay webhooks notify your server immediately of payment events, allowing secure, real-time updates and automatic transaction recording in your database.
Key Points
- 99.9% of payments captured trigger instant webhook notifications.
- 100% of webhook requests verified using HMAC SHA256 signatures.
- Logs store 100% of events for tracking and debugging purposes.
1. Introduction
A webhook is a feature that enables Razorpay to send payment updates directly to your server whenever a payment event occurs. Without webhooks, your application would have to repeatedly call Razorpay APIs to check payment status, which is inefficient.
With webhooks, Razorpay sends a POST request to your server immediately when a payment event occurs, allowing your system to receive updates in real time. This is particularly useful for businesses that hire PHP developers to build payment systems as part of their custom web or mobile app development projects.
Common webhook events include:
- payment.captured – Payment completed successfully
- payment.failed – Payment attempt failed
- order.paid – Order payment has been completed
- refund.processed – Refund has been successfully processed
Using webhooks ensures your system automatically updates payment status in your database, which is a best practice when hiring professionals for flawless integration in custom web development solutions.
2. How Webhooks Work
The webhook process is straightforward:
Customer makes payment → Razorpay processes payment → Razorpay triggers webhook → Your server receives webhook → Database updates automatically.
This process guarantees your application always has the correct payment status without manual checks, which is essential when integrating payments into web or app projects.
3. Creating a Webhook Endpoint
To receive webhook notifications, you need a backend URL (endpoint) where Razorpay will send the webhook data. Businesses often hire PHP developers to build such endpoints as part of their custom web and mobile app development projects.
Example URL:
When a payment event occurs, Razorpay sends a POST request with JSON data to this URL. Your server automatically reads and processes this data.
4. Webhook Script Example (PHP)
Create a file called razorpay-webhook.php. The following PHP script verifies the Razorpay request and handles payment events:
This script is frequently used by teams to incorporate payment systems into custom web or mobile app projects.
5. Understanding the Webhook Payload
Razorpay sends webhook data in JSON format, which includes details about the event and payment.
Example payload:
Important fields:
| Field | Description |
|---|---|
| event | Type of event triggered |
| payment.id | Razorpay payment ID |
| order_id | Order linked to the payment |
| amount | Payment amount |
These values can be stored in your database to track transactions, which is a key step when hiring developers for secure mobile app development.
6. Verifying the Webhook Signature
Verification ensures the request is genuinely from Razorpay.
Steps:
- Receive the webhook request body
- Generate a hash using your webhook secret
- Compare it with the X-Razorpay-Signature header
- If both match, the request is valid; otherwise, reject it
Hiring experts for this verification ensures strong security in your custom web or mobile app development projects.
7. Configuring Webhook in Razorpay Dashboard
After creating the webhook script, register it in the Razorpay dashboard:
- Log in to Razorpay Dashboard
- Navigate to Settings → Webhooks
- Click Add New Webhook
- Enter your webhook URL
- Select events to receive (e.g., payment.captured, payment.failed, order.paid)
- Set a webhook secret
Once saved, Razorpay will send webhook notifications to your server. Teams that hire developers typically handle this as part of broader custom web or mobile app development services.
8. Testing Webhooks
Razorpay allows testing webhooks from the dashboard:
- Go to the Webhooks section
- Select your webhook
- Click Send Test Webhook
You can also test locally using tools like ngrok:
Testing is crucial when hiring PHP developers for custom web or mobile app development to ensure payments are processed properly.
9. Logging Webhook Requests
Logging webhook requests aids in debugging and monitoring payment events. Example:
This saves every webhook request to webhook_log.txt, a practice often recommended when teams hire PHP developers for custom web or app development.
10. Best Practices
- Always verify webhook signatures
- Use HTTPS endpoints for security
- Store webhook logs for debugging
- Handle duplicate webhook events properly
- Update the database using transactions
- Never trust payment status from the frontend
These best practices ensure a secure and reliable payment system, which is a critical consideration when it comes to custom web development or mobile app development.
Final Words
Razorpay webhooks provide a simple and reliable way to receive real-time payment updates. By verifying signatures and handling events correctly, your system can automatically update payment records and maintain accurate transaction data. Businesses that hire PHP developers for custom web development or mobile app development can integrate Razorpay webhooks seamlessly to improve payment automation and security.
+91-8727000867
+64 22 003 5555



Request Instant Call
Hire Remotely