Overview
The Webhooks API endpoint receives and validates notifications from Mercado Pago about events such as payment updates, refunds, and other transaction-related activities. This endpoint is always active and is the primary way to receive real-time updates from Mercado Pago.Unlike other demo endpoints, the webhook endpoint is always active in all environments and is essential for production use.
Receive Webhook
Receives and processes webhook notifications from Mercado Pago.Endpoint
Request Headers
HMAC signature for webhook validation. Format:
ts={timestamp},v1={hash}Required when
MERCADOPAGO_WEBHOOK_SECRET is configured. Used to verify the authenticity of the webhook.Unique request identifier from Mercado Pago. Required for signature validation.
Query Parameters
Resource ID (alternative to data.id in body)
Notification topic (alternative to type in body)
Request Body Parameters
Action that triggered the notification (e.g., “payment.created”, “payment.updated”)
Mercado Pago API version
Notification type/topic (e.g., “payment”, “merchant_order”)
Notification data object
Whether the notification is from production (true) or sandbox (false)
Mercado Pago user ID
Request Example
Response
Indicates if the webhook was received successfully
Processed webhook information
Additional metadata (typically empty)
Response Example
cURL Example
Error Responses
Invalid Signature (401)
General Error (500)
Signature Validation
WhenMERCADOPAGO_WEBHOOK_SECRET is configured, the package validates the webhook signature to ensure authenticity.
Validation Process
- Extract
ts(timestamp) andv1(hash) fromx-signatureheader - Get
x-request-idfrom headers - Get resource
idfrom query string or request bodydata.id - Construct manifest:
id={id}&request-id={request-id}&ts={ts} - Compute HMAC-SHA256 hash using webhook secret
- Compare computed hash with provided
v1hash
Signature Header Format
Implementation Notes
Availability
The webhook endpoint is always active regardless of environment or demo route settings. This is necessary to receive production notifications.
Controller Reference
Implemented in:src/Http/Controllers/Api/WebhookController.php:13
Request validation: src/Http/Requests/StoreWebhookRequest.php:16
Related Services
- WebhookService - Service layer for webhook processing and validation
Related Guides
- Webhook Integration - Complete guide on webhook setup
- Webhook Security - Security best practices for webhooks
Webhook Topics
Mercado Pago sends notifications for various events:| Topic | Description |
|---|---|
payment | Payment created, updated, or cancelled |
merchant_order | Order created or updated |
subscription | Subscription events |
point_integration_wh | Point of sale integration events |
Best Practices
Verify Resource: Always fetch the actual resource from Mercado Pago to verify its current state. Don’t rely solely on webhook data for critical operations.
Recommended Workflow
- Receive webhook → Return 200 immediately
- Validate signature → If configured
- Dispatch job → Process asynchronously
- Fetch resource → Get current state from Mercado Pago
- Update database → Persist the current state
- Trigger actions → Send emails, update orders, etc.
Example Production Implementation
Example Queued Job
Configuration
Required Environment Variables
Configuring in Mercado Pago
- Go to your Mercado Pago dashboard
- Navigate to Developers → Webhooks
- Add your webhook URL:
https://your-domain.com/api/mercadopago/webhooks - Copy the Secret and set it as
MERCADOPAGO_WEBHOOK_SECRET - Select the events you want to receive
Testing Webhooks
Local Testing
- Use a tunneling service (ngrok, expose, etc.) to expose your local server:
- Configure the public URL in Mercado Pago’s webhook settings
- Trigger test events from Mercado Pago dashboard or by performing test transactions
Manual Testing
When testing locally without
MERCADOPAGO_WEBHOOK_SECRET, the webhook will be processed but validated will be false.