Handle Webhooks in Laravel with Receiver

Packages

September 15th, 2022

Handle Webhooks in Laravel with Receiver

Laravel Receiver is a drop-in webhook handling library for Laravel. It makes handling incoming webhooks easy, with built-in support for:

The built-in providers are also secured using each provider's prescribed verification method (i.e., signatures). This package takes the pain out of the setup and boilerplate about handling the request, letting you focus on the code for handling webhooks.

Receiver also makes it easy to define custom providers that work with webhooks from any source. Once you specify webhook providers, you can handle them using conventions provided by the package in handler classes which you can also send to a Laravel queue for processing.

The Receiver package takes care of the controller code, so the heart of your integration with this package would be within handlers. Here's an example handler from the readme for Stripe's customer.created webhook:

1namespace App\Http\Handlers\Stripe;
2 
3class CustomerCreated
4{
5 public function __construct(public string $event, public array $data)
6 {
7 }
8 
9 public function handle()
10 {
11 // Your code here
12 }
13}

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.