Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andreasb's avatar

How to work with Webhooks (not Stripe, Braintree or the like)

Good evening, tonight I have a question about how to use webhooks with Laravel. I am working with a European billing platform and not Stripe or Braintree (for several reasons, but that is not the point here). This platform offers webhooks, now for example I want to do something in my application when I get the info from the billing system that a invoice has been paid. Setting up the webhook is simple: I provide a URL and the state as well as a secret key if I like.

Now my question is: how to best process the webhook in Laravel?

The easiest solution I can think of is setting up a POST route directing it to a method in a controller (which is exempt of CSRF checking). This method simply accepts the JSON received, processes it and we are done.

Is it that simple or am I missing out on something here? (I found https://github.com/mpociot/captainhook for example and was wondering why I would need such a package?)

Thanks Andreas

0 likes
2 replies
lmxdev's avatar
lmxdev
Best Answer
Level 5

yes it is that simple

in your method:

// Retrieve the request's body and parse it as JSON
$input = @file_get_contents("php://input");
$event_json = json_decode($input);

// Do something with $event_json
mpociot's avatar

As I'm the developer of the package you mentioned, I just wanted to tell you that it's purpose is for your app to easily provide webhooks - not consuming webhooks from other services.

So if you want to send a POST message to a custom URL every time an event gets fired - use my package :)

Please or to participate in this conversation.