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

Nadiya's avatar

Cashier stripe: Invoke framework webhook event listener before invoking custom implementation

I've a webhook event listener StripeEventListener (which i followed from the doc) for listening Cashier stripe events. I've wrote the code for each event i needed there (apart from the framework default).

so, there is one event named customer.subscription.created which requires the framework default code to be run first.

Because, i need to fetch $user->subscription() for implementing one logic. But, this subscription is only created on this framework core codes. But sadly, this code (framework WebhookController events) will only get invoked after running the codes in StripeEventListener.

Is there any method i can use to trigger the framework default events first?

0 likes
1 reply
Nadiya's avatar
Nadiya
OP
Best Answer
Level 1

I've solved it by using WebhookHandled::class which calls this event listener only after handling cashier events.

so, i've added two listeners, one is to handle event before cahier's and one is to handle event after cashier's.

        WebhookReceived::class => [
            StripeEventListener::class,
        ],
        
        WebhookHandled::class => [
            StripeEventPostListener::class,
        ],

i've moved customer.subscription.created to this new StripeEventPostListener

Please or to participate in this conversation.