Laravel Cashier Events

I am using Laravel cashier 7.0 and I would like to run some methods after a successful subscription. I was hoping there would be some events that I could listen to, but this does not seem to be the case (unless I missed them).

Eliminate the payment provider that I use, if that matters. (stripe-php package.)

Am I missing something obvious?

I know that there are many ways to do this myself, but I'm looking for an elegant solution.

+5
source share
1 answer

Just create an API endpoint in your /api.php routes, and then add them to your stripe account. Stripe will treat these APIs as webhooks. After someone subscribes to one of your services, Stripe will call the provided webhook on your server to report a new subscription event.

In your routes /api.php or (better) in a separate API controller add any event you need to fire there.

in Laravel, make sure:

1- uninstall middleware('auth:api') on these websites.

2- then analyze the payload sent by the strip to confirm the payment.

You can refer to the Stripe documentation here for more details.

0
source

Source: https://habr.com/ru/post/1272663/


All Articles