Skip to main content
Webhooks notify your app when events happen (like successful payments). They’re essential for updating your database after a payment completes.

Setup

1. Add Webhook Secret

Add to .env:

2. Create Controller

3. Add Route

In routes/api.php:

4. Disable CSRF

In app/Http/Middleware/VerifyCsrfToken.php:

Event Types

ModemPay sends these event types:

Using Event Listeners (Optional)

For cleaner code, use Laravel events:

1. Create Listener

2. Register Listener

In app/Providers/EventServiceProvider.php:

Testing Webhooks

Test locally with curl:
Always validate webhook signatures! Never trust webhook data without verification.

Security Tips

  • Always validate signatures
  • Use HTTPS in production
  • Handle duplicate events (idempotency)
  • Log all webhook events
  • Return 200 quickly (process async if needed)

Example: Complete Webhook Handler