#tadpole
1 messages · Page 1 of 1 (latest)
Hello! I recommend listening for checkout.session.completed and then check the Checkout Session's payment_status: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-payment_status
You can then also listen for payment_intent.succeeded to catch the async payments that complete later.
Wouldnt that lead to duplication? As in a single event will be handled by checkout.session.completed where payment_status is true and payment_intent.succeeded.
Also Im a bit confused as to why payment_intent.succeeded is emitted for async payments given there already exists checkout.session.async_payment_succeeded
Yeah, you would only care about the payment_intent.succeeded Events where the Checkout Session wasn't paid.
There are historical reasons the Events ended up this way. I agree it's a bit confusing.
The best thing to do is test a lot in test mode to get a feel for which Events fire when, and for what methods of payment.
That will let you build a system that works exactly the way you want.
wait are you saying inside the handler for that event, I would check where payment_status is unpaid? So i guess that checks for if it was an async payment as opposed to whether the payment was made given that the payment_intent.succeeded event signifies payment
Yeah. I mean, ultimately it's up to you and what works best for what you're building, that's just one approach.
definitely makes sense, i wasnt sure if i could test delayed payments or how to about doing that as ive never worked with those or used them as far as i remember
You can also just listen for payment_intent.succeeded if you don't really care about the Checkout Session Events, but a lot of people want the Checkout Session data.
yeah my usecase is quite simple, 1 time payment, and i want to propagate some info about the purchased item and user such that when payment is made, don't care how it is, I can get that info so I can create a record in my db
So it seems, I can just do payment_intent succeeded and it will handle that, whether they paid with async or not, right? If I wanted to also handle failures the same way irrespective of how or for what payment, could I also listen to payment_intent.payment_failed?
Yep.
And I am assuming I can pass in the info I need to create my db entry with in paymentintent metadata to access it in those web hooks
Yep, that approach should work.
okay thanks a lot for your time and help!
No problem!