#nollix_checkout-payment-status

1 messages Β· Page 1 of 1 (latest)

west mirageBOT
#

πŸ‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

πŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1445097281119588362

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

stable kite
#

What statuses are you unsure about?

#

For what it's worth, waiting for the Checkout Session to expire may take a while.

#

The default is 24 hours

ancient gust
#

Theoretically I'm not sure about every state. The states you see above are my guesses on how I might proceed. I would like to know if the states that I have written are correct OR if you know a better way to understand the state of the payment (succeeded, in progress, failed) that the client has completed

stable kite
#

If the payment fails, Stripe will send a payment_intent.payment_failed event

#

The Checkout Session object (https://docs.stripe.com/api/checkout/sessions/object) will contain the status values you mentioned but you can also find more granular details about the success/failure of the payment by reviewing the Payment Intent that is generated when a Customer confirms the payment.

ancient gust
#

Ok I have seen now that the PaymentIntent object has a "status" attribute that can have several values like canceled, processing and succeeded. But is this true also for asyncronoush payment?

stable kite
#

Yes. The payment intent will be processing for async payments until they settle and then transition to a terminal state

ancient gust
#

Thank you so much

stable kite
#

Sure thing! I'm happy to shed what πŸ’‘ I can πŸ™‚

ancient gust
#

I have another question: If my client is redirected from the Stripe host page to my error page through the cancelUrl is sure that the payment can't succeeded, right?

stable kite
#

I strongly recommend against reyling on any redirect to determine the status of the payment. I think you would always retrieve the Checkout Session and/or Payment Intent to validate the status.

west mirageBOT
#

nollix_checkout-payment-status

ancient gust
#

Another doubt: I have a webhook that is connected to the checkot.session.completed event. In this way when I receive this type of event, the webhook is called and my back-end is sure that the payment is succeeded. But accordind to what we have discussed so far I should call the API to be sure that the payment is really succeeded. Is this true even if I use payment_intent.succeeded event? Because it should happen just if the payment is succeeded, right?

stable kite
#

If you listen for the payment_intent.succeeded in addition to the checkout_session.completed event, you should have all the information you need to be certain the payment was successful

ancient gust
#
  1. But I will receive two times the same message if I have two event to listen, right?
  2. Is it right that if I have to manage asyncronous payment the payment_intent.succeeded's event will just tell me that the proecess has started?
stable kite
#
  1. But I will receive two times the same message if I have two event to listen, right?

Not exactly. The checkout.session.completed event tells you the Customer completed the Checkout Session. The payment_intent.succeeded tells you the payment was successful and the funds are coming to your Stripe balance.

#
  1. Is it right that if I have to manage asyncronous payment the payment_intent.succeeded's event will just tell me that the proecess has started?

No. the payment_intent.succeeded event means the payment was successful

ancient gust
stable kite
#

Yes. That is perfectly normal

ancient gust
#

I'm a littble bit confused now because another developer told me this when I have asked a similar question. Maybe I have misunderstood the asnwer

stable kite
#

Can you clarify exactly what is confusing?

ancient gust
# stable kite > 2) Is it right that if I have to manage asyncronous payment the payment_intent...

Above I have asked you if I will receive payment_intent.succeeded's event when I manage asyncronous payment and you told me that in general this event means that the payment was successful (I think for both asyncronous payment and instant payment) BUT I had another conversation with another developer and he told me that in case of async payment the payment_intent.processing just occurs when the process starts (and it's still processing).

Maybe I misurderstood everything

stable kite
#

I think you are mixing up succeeded and processing events. They are two different things.

#

payment_intent.processing fires when the Payment Intent begins it's async process

#

payment_intent.succeeded fires when the Payment Intent has successfully completed

ancient gust
#

Sorry I have seen now the difference of the name! So payment_intent.succeeded is for both sync and async payment, right?

Most documentation pages suggest to use checkout.session.completed, but since my main goal is to know when the payment is confirmed or not I think that payment_intent.succeeded is better than checkout.session.completed, is it right? are there cases where is correct to listen the checkout.session.completed event?

stable kite
#

Sorry I have seen now the difference of the name! So payment_intent.succeeded is for both sync and async payment, right?

Correct!

#

As for which events to listen for, that depends on your integration. Like I said, they mean different things.

  • checkout,.session.completed <-Means a Customer has completed the Checkout page.
  • payment_intent.succeeded <- Means the Payment from that Checkout Session has been successfully processed

Both are important but they tell you different things.

Let's say you have a Customer who goes through your checkout process and uses an async payment method with a long settlement time. checkout.session.completed tells you they have completed the checkout process so you should record that in your system and take some action like sending an initial thank you email. Then, payment_intent.succeeded tells you their payment has been successfully processed and you can trigger fulfillment of their order.

Most payment methods complete processing in seconds so, for the majority of the time, just using checkout.session.completed is fine. But if you want to ensure your integration can handle the few async payment methods that take a while to complete, we recommend using both.

#

Let me know if that doesn't make sense and I can try to clarify

ancient gust
#

Yeah now it's a little bit clear! Thank you so much! But I’d like to know if there is a way to call the webhook only when one of two events arrives (whichever comes first). I don’t want to call the same webhook twice if both events occur it should only be triggered once by the first event that arrives.

stable kite
#

Stripe sends webhook event requests for every event type you listen for. That isn't something that can be changed on Stripe's end. You would need to set up something in your code that handles receiving the webhook event requests to check whether you have already processed a Customer's order or not and skip the operation if you have.

#

For example, if I was building something like this I would have a database table for these orders. A new record would get created along with the Checkout Session and, when I receive either checkout.session.completed or payment_intent.succeeded webhook events I would

  • first check if the order is already processed. If true, skip. If false, process the order
  • If I process the order, set the value of processed: true so the next event gets skipped.
#

Wait... never mind. I would NOT do that.

#

There are too many race conditions

#

I would ONLY process the order when I receive payment_intent.succeeded

ancient gust
#

Ok, in this way I'm sure that the client succeed to pay indipendently of the payment method.

stable kite
#

Correct

ancient gust
#

You are so great! Clean and clear answers! Thank you so much for everything. This conversation is precious for me

stable kite
#

wonderful πŸŽ‰ I'm happy to help πŸ™‚

Just for your information, we close threads after a period of inactivity. This means you won't be able to come back and ask new questions direclty in this thread. But you can still read and reference this thread and all the information.

If you have new questions at a later time, feel free to use the form in the #help channel to open a new thread and we will be happy to help you.