craftcms / stripe

Sync and extend Stripe products and subscriptions.
MIT License
5 stars 0 forks source link

Listen to Webhook events #17

Open knufri opened 1 month ago

knufri commented 1 month ago

Description

I'm trying to figure out how to listen to the webhook events. The CheckoutSessionEvent works perfectly. But I would like to create a user in craft after successful subscription via module. I can't find anything in the documentation. Is there a way to react to the customer.subscription.created?

Additional info

i-just commented 1 month ago

Hi, thanks for reaching out! The Stripe plugin is already listening to the customer.subscription.created event (among others) and reacting to it. Technically, listening to the events from your plugin/module is already achievable, but you’d have to do it all yourself - create your own endpoint, listen and react. That being said, I think it makes sense for the plugin to provide an event you can tap into to take the hassle out of it. I just raised a PR for it.

knufri commented 1 month ago

Hello @i-just,

Many thanks for the quick reply and the associated PR. I really appreciate it. I'm looking forward to when the PR has been merged and I can test the extension. If I understand correctly, you can intercept all webhooks sent by Stripe via the event type?

Greetings Jan