#xzel_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1247221549107384442
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi ๐
What kind of success/failure are you interested in here? The Checkout Session will report on the successful completion of the Checkout Session but the Payment Intent is what will have the details of whether the payment itself was successful.
So I originally built this session-update api to follow the stripe guide. I'm interested in returning checkout data, basically the line items from the session + some user data. Will that be in the sessions.retrieve
And then the same API should contain the status for the payment?
We are using a return_url and then deciding if its a failure / succes based on the response of sessions.retrieve
Let me know if what I'm saying isn't clear
If you need data about the Checkout session (line_items, etc.) that will be on the Checkout Session object. So that is what you should retrieve
Are you able to provide example data for a checkout session, sessions.retrieve, response? The docs are a bit lacking for actual data.
And which attribute can I use to determine if the checkout was successful or a failure?
You should be able to test this pretty easily.
But you can see the full Session object in our docs here: https://docs.stripe.com/api/checkout/sessions/object
Of course, the actual data will depend on how you create the Session
the session.status === complete is the recommened way to do it?
I don' t know what you are talking about here. Recomnended way to do what?
They way we have this build, we have a return_url for our checkout. I assumed the best way to figure out if it was successful was to poll that session and use a single return_url. That page polls the session.retrive API. I'm asking how can I determine if the payment was successful or failed? Does session.status === open imply failure and session.status === 'complete' mean success?
Should I rewrite this and just use success_url instead of polling?
To know whether the payment was complete you would need to retrieve the related Payment Intent
That is what I just had rewritten this to do actually. So that is a good sign haha.
Okay so just run this back, to do this polling correctly via a return_url, get session from CHECKOUT_SESSION_ID passed via sessions.create and then check the paymentIntent return the status for that.
Does that make sense to do vs. relying the session.status?
Sorry not really. I would retrieve the session Id from the return URL,pass it back to my server, and from there retrieve the session object and the payment intent and pass that data back to the client.
You can get both the Session and Intent in the same API request by passing expand: ['payment_intent'] when you retrieve the session.
https://docs.stripe.com/expand