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

witt's avatar
Level 1

Laravel Cashier: Stripe Event Listener not responding to some Stripe Webhooks

I'm updating my application to Laravel 7 and Cashier 12. As part of that upgrade, I need to listen for Stripe webhooks and do some additional processing, as described in the docs:

Cashier emits a Laravel\Cashier\Events\WebhookReceived event when a webhook is received, and a Laravel\Cashier\Events\WebhookHandled event when a webhook was handled by Cashier. Both events contain the full payload of the Stripe webhook.

I have my event listener set up in EventServiceProvider.php:

    protected $listen = [
        'App\Events\Event' => [
            'App\Listeners\EventListener',
        ],
        'Illuminate\Auth\Events\Login' => [
            \App\Listeners\Login::class,
        ],
        'Laravel\Cashier\Events\WebhookHandled' => [
          \App\Listeners\WebhookHandledListener::class,
        ],
    ];

And in app/Listeners/WebhookHandledListener.php:

    public function handle(WebhookHandled $event)
    {

        Log::channel('stripe')->info("Generic Webhook Handled in listener");
        Log::channel('stripe')->info(var_export($event->payload['type'], true));
    }

The problem is that some but not all Stripe events are triggering my listener. For example, when a user purchases an account, according to the Stripe webhooks event logs, stripe sends the following event types:

customer.updated (twice) invoice.paid charge.succeeded

However, in my log file, I see only the two customer.updated events:

[2020-09-04 19:17:55] staging.INFO: Generic Webhook Handled in listener  
[2020-09-04 19:17:55] staging.INFO: 'customer.updated'  
[2020-09-04 19:17:55] staging.INFO: Generic Webhook Handled in listener  
[2020-09-04 19:17:55] staging.INFO: 'customer.updated'

Similarly, if I trigger other events in stripe, such as deleting or changing a subscription, my event listener is responding to some but not all of the events stripe is emitting.

I'd love some pointers on how I can get my event listener to respond to the missing events.

Thank you very much!!

0 likes
1 reply
witt's avatar
Level 1

As I was writing this post, it occurred to me to try listening for the WebhookReceived event instead of the WebhookHandled event, and when I did that I started receiving all of the Stripe webhook events.

Leaving this here in case someone else finds it useful.

2 likes

Please or to participate in this conversation.