Im trying to do a simple Webhook connection. I have setup my WordPress database using Xampp and activated a webhook for whenever an order is created in the ‘shop’. It works fine since I managed to insert data into a DB by using a PHP file, but now, im trying to do the same with Laravel (requested for a project)

Im fairly new to it, and so far I’ve set the route in web.php as follows:

Route::post('webhook', [WebhookController::class, 'WebhookController']);

Then again, due to some recommendations I have added this line to the VerifyCsrfToken.php file:

protected $except = ['webhook'];

I have created a controller for the webhook as well, WebhookController.php:

class WebhookController extends Controller{
    public function handle(Request $request) {
        return response()->json('éxito');

However, im not sure how it’s supposed to work since I find little documentation on how to handle webhooks. Am I supposed to be seeing any sort of response in the Network tab of Developer Tools? Cause I see none.

In the project folder (and webhook config in wordpress), the webhook is pointing towards webhook/webhook.php. I have tried different configurations both changing the route in the Laravel config and where it points towards in WordPress (I could make it point towards webhook/ in the Laravel route, but the WooCommerce plugin wont let me save changes if it isn’t pointing towards a file).

Any clue as to what I could try? Sorry if its pretty obvious!

New contributor

Jo Amon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.