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

zabarah's avatar

Laravel/Cashier Stripe Webhook on Failed Subscription

Hey All,

I am trying to implement the following function once cashier receives the cancelled subscription webhook from stripe, but I dont understand where to put it.

if($user->subscription('team')){
     $user->team->members()->detach();
}

I found the webhook functions in the WebhookController@handleWebhook, but it wasn't super clear to me where the cancelled subscription function was.

If anyone can shed some light for me that would be awesome.

0 likes
2 replies
bobbybouwmann's avatar
Level 88

You need to extend the webhook controller and add a method that matches with the canceled webhook. So the event from Stripe is customer.subscription.deleted. In that case, you need to add the following method to some controller

use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;

class WebhookController extends CashierController
{
    public function handleCustomerSubscriptionDeleted($payload)
    {
        // Handle The Event
    }
}

Make sure you add this controller to the route as well

Route::post(
    'stripe/webhook',
    '\App\Http\Controllers\WebhookController@handleWebhook'
);

Documentation: https://laravel.com/docs/7.x/billing#defining-webhook-event-handlers

zabarah's avatar

Got it. Just to be clear. This will just extend it, it wont over ride the current controller for the subscription deleted, in the cashier controller.

Thank you so much!

Please or to participate in this conversation.