When working with Cashier Stripe Checkout within my Laravel 10 app, what events do I need to listen to when it comes to an existing product that has been created within the Stripe dashboard?
The app will operate in EU, requring 3Ds for the payments. I tried to go through the docs from Stripe, and it seems that the only imporant event is checkout.session.completed
. I assume that it’s not a good idea to strictly rely only on the success_url
/ cancel_url
, but one event also seems to not be enough. All I need to do is for the user to be able to buy a specific training session, and if the payment is successful, I want to make a reservation for him.
Any advice will be greatly appreciated!
2
Answers
-The
success_url
is the page your customer is redirected to once they successfully complete the Session.-The
cancel_url
is the page your customer is redirected to if they press the ‘back’ arrow on the Session. It’s optional – if you don’t set one your Session will have no ‘back’ arrow.-If the information fails to validate, or the payment is declined, then you customer stays on the Session – the error is displayed in session.
This means that
checkout.session.completed
could be the only event you care about – since it would be ubiquitous with a success.There is one exception : async payment method types.
For EU payments, this means SEPA DD and Sofort [Edit=also Bacs if your account is UK]. Those payment method types are async, meaning the payment is ‘pending’ for a while after the customer completes the Session, and could still fail afterwards.
Stripe triggers the
checkout.session.async_payment_failed
andcheckout.session.async_payment_succeeded
events for these scenarios.The payments would still trigger a
checkout.session.completed
event initially, however you can recognize them by the attributepayment_status=unpaid
.Related guide:
https://stripe.com/docs/payments/checkout/fulfill-orders#delayed-notification
EDIT= one quick clarification – 3DS authentication (or any other type or payment authentication) does not fall under those async payment types (even though you could argue it’s an async process). Authentication modals are presented in Session, and the customer stays in session if this authentication fails.
You don’t need to listen to any events, because Cashier already has a webhook handler that will create subscriptions in your database if a user completes a Stripe checkout session.