#Kikkoman

1 messages · Page 1 of 1 (latest)

neat inletBOT
true seal
#

Hello

lavish moat
#

if the payment fails, would we want to get an event for that?

true seal
#

Yes you should see a payment_intent.payment_failed Event in that case.

#

Should be easy to test out as well

lavish moat
#

so would it be safe to assume this:

#

if a payment is successful, we would get a checkout.session.completed and also a payment_intent.succeeded

true seal
#

Yep

#

Assuming it is a synchronous payment method type

lavish moat
#

got it understood

#

thank you so much

true seal
#

Sure thing

lavish moat
#

Follow up question

#

say we create a checkout session, and forward the user to the checkout page, how would we know which payment_intent is associated with that checkout? (so that we can monitor for the failure)

#

My guess would be that when creating the checkout session, the id of the payment_intent is already returned, for us to listen to the event

true seal
#

That will be present in the checkout.session.completed event

lavish moat
#

Do you think the sesion.completed event will always be before the payment_intent.failed / succeeded event?

true seal
lavish moat
#

Why I ask, is if the session.completed event is where I would get the id of the payment_Intent, how can I handle the event coming from payment_intent.failed scenario when we don't have a relationship to the checkout session yet?

true seal
#

Well you have your Checkout Session ID from creating the Checkout Session on your server

lavish moat
#

Ah, would the following be a reliable process then? When checkout.session.completed is received --> retrieve the payment_intent Id associated with the session --> request via API the payment_intent object from stripe, and then check if it failed / succeeded?

#

(or pending if it's an async method)

true seal
#

You don't need to check anything when you receive checkout.session.completed

#

That event will only fire if the payment is successful

lavish moat
#

What do most people usually do? Just check for success and expired?

#

Cause it seems like the payment_intent returned from a failed event wouldn't let me know which checkout_session it came from

true seal
#

Why do you care about a failure?

#

Like the customer will still be in the Checkout UI if the payment fails

#

They will see an error presented in that UI

#

You don't need to do anything in this case

lavish moat
#

Ok, then if the user fails multiple times, and stopped continuing. Would it ended up as just expired?

#

e.g. they close the browser

true seal
#

Yep eventually it would expire

lavish moat
#

Understood. I think thats acceptable

true seal
#

Either in 24 hours or less if you set a lower expiry

lavish moat
#

We could certainly re-use the same checkout session if they want to close and come back to it later (assuming it hasn't expired yet?)

true seal
#

That's up to you

#

Either way is totally fine

#

The benefit of re-using it is that they don't accidentally save the link and then somehow make a duplicate payment if you create a new one

lavish moat
#

Ok, then it opens up to new possibilities. Yup. that's all I have, I think i got into too much of a nitty gritty, thanks for bearing with me.

true seal
#

No worries at all