How can i fire an event when the stripe subscription is renewed?
I am using Laravel Cashier (Stripe).
I have a requirement that whenever a subscription is renewed, I want to send an email to the user and also create a transaction for internal analytics.
I have searched the web and found out that the customer.subscription.updated webhook is sent when the subscription is renewed.
I am using a custom WebHookController that extends the default Laravel cashier stripe WebHookController.
I'm not sure, how can I write the logic to trigger an event so that I can do all the side effects required when a subscription is renewed.
Create a new stripe webhook endpoint and add the subscription event you need ( check stripe docs for that )
Make sure you define another env variable for the package's signing_secret config value and add the webhook's secret to that (it won't work if you use 1 webhook for both cashier and spatie's webhook package)
Create a new listener and listen for your specific event. Ex: