Hi all, I'm trying to listen to a Stripe event triggered by a Cashier webhook but i always get a 403 in return. This is not the case when I trigger an event via stripe's cli.
output for: stripe trigger checkout.session.completed
Setting up fixture for: product
Running fixture for: product
Setting up fixture for: price
Running fixture for: price
Setting up fixture for: checkout_session
Running fixture for: checkout_session
Setting up fixture for: payment_page
Running fixture for: payment_page
Setting up fixture for: payment_method
Running fixture for: payment_method
Setting up fixture for: payment_page_confirm
Running fixture for: payment_page_confirm
Trigger succeeded! Check dashboard for event details.
In the AppServiceProvider.php class I registered an event and a listener. As i understand it, the event is for a cashier webhook that listens for a stripe event and when that event is fired, i should be notified.
Something like this:
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Event::listen(
WebhookReceived::class,
StripeEventListener::class,
);
}
}
The StripeEventListener should send a response back depending on the outcome of the operation... for now Im simply trying to retrieve a log:
class StripeEventListener
{
public function handle(WebhookReceived $event): void
{
if ($event->payload['type'] === 'checkout.session.completed') {
logger('Listener ejecutado:', $event->payload);
// o
dd('Listener ejecutado:', $event->payload);
}
}
}
At first i was trying to see the response locally but that never returned anything in my terminal.
stripe listen --forward-to http://localhost:8000/stripe/webhook --format JSON
So then I set up Ngrok and the response there is consistent with Stripe.
11:46:07.410 MST POST /stripe/webhook 403 Forbidden
The webhook created within Stripe follows a URL similar to this: "https://abc123.ngrok-free.app/stripe/webhook" but after simulating the payment i get 403, both in Stripe and ngrok.
I don't know what Im missing here or what else is required. I am following the videocast by Philo Hermans here: https://laracasts.com/series/build-a-web-shop-from-a-z/episodes/24