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

skoobi's avatar
Level 13

Laravel Cashier Webhook response from stripe

Hi.

I have stripe setup and im having issues with the webhook.

If i test the webhook from Stripe itself i get a Test webhook sent successfully but the Response is none.

Heres my code for the webhook::

<?php

namespace App\Http\Controllers\Webhooks;

use App\Http\Controllers\Controller;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
use Symfony\Component\HttpFoundation\Response;

class StripeController extends CashierController
{


    /**
     * Handle a Stripe webhook.
     *
     * @param  array  $payload
     * @return Response
     */
    public function handleChargeSucceeded($payload)
    {
        try{

            Log::info('Webhook Handled - Charge Success - ' . json_encode($payload['data']['object']['id']));
            return new Response('Webhook Handled - Charge Success - ' . json_encode($payload['data']['object']['id'] ), 200);

        } catch (\Exception $e) {


            return new Response('Webhook Handled - Something Went Wrong' , 422);

        }
    }

}

and the route::

Route::post(
    'webhooks/stripe',
    '\App\Http\Controllers\Webhooks\StripeController@handleWebhook'
);

For some reason im not getting any response back for the test webhook charge.succeeded . Ive also tried spatie/laravel-stripe-webhooks package and it does the exact same thing. It saves the webhook to the database but doesnt show up in the logs or anything like that.

Any ideas

Cheers

0 likes
3 replies
shez1983's avatar

is this your local or staging? on local it wont work - you need a fake URL (search for it that capture the response http bin from memory)

if this is in staging then what i would do is when you do the test from stripe (ie where it says test this hook/end point) then you can copy the Request it sends and use postman to see what your server is doing.. (if you dont get the request this way, use the above way to get a sample request).

also how about dumping the payload before the try { } and see what you get?

Drfraker's avatar

You can fake the webhook in a test to ensure that your logic is working. Then you don't have to manually go to stripe and test it. If you want to test manually you can use laravel valet and type valet share in the console. It will set up a tunnel url to your local application that you can use in the stripe webhooks testing side and actually hit your code from stripe.

I've done it both ways, but I prefer the fake webhook request in a test because it's fast and I don't have to worry about it ever again! :)

skoobi's avatar
Level 13

Hi. Thanks for the response...

@shez1983 Ye the site is on a staging server and local but im using the staging server to test. Ive tried without the ,try{} but still nothing.

With the spatie/stripe-webhookspackage it adds the entry into the database to show the webhook has hit the apps route but it doesn't execute the job/code when hitting, which in this case is \Log::info().

@Drfraker Hi. Ive tried to install valet onto my system but something is blocking it for some reason. It installs but there are parts on brew that fail when trying to share.

Ill take a look at Postman and see what i can come up with .

Many thanks

Please or to participate in this conversation.