#xzel_api

1 messages ยท Page 1 of 1 (latest)

cold quarryBOT
#

๐Ÿ‘‹ 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.

gleaming current
#

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.

thorn basalt
#

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

gleaming current
#

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

thorn basalt
#

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?

gleaming current
#

You should be able to test this pretty easily.

#

Of course, the actual data will depend on how you create the Session

thorn basalt
#

the session.status === complete is the recommened way to do it?

gleaming current
#

I don' t know what you are talking about here. Recomnended way to do what?

thorn basalt
#

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?

gleaming current
#

To know whether the payment was complete you would need to retrieve the related Payment Intent

thorn basalt
#

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?

gleaming current
#

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

cold quarryBOT