#lucadaniele_api
1 messages ¡ Page 1 of 1 (latest)
đ 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/1278353410977956033
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello what request ID are you referring to exactly? Can you share an example?
When I create the session I get in response an object like this
{
id: 'cs_test_a10Uo1XrOAxrykvil7N3QtjoYbZ1Hw17iOYVZsnnqwoVkId4Gd1zeMPTy8',
object: 'checkout.session',
after_expiration: null,
allow_promotion_codes: null,
amount_subtotal: 750,
I'm referring about the id field
Gotcha. Taking a step back, what is your end goal? Like
Are you trying to fulfil payments you've recieved with Checkout?
It's a backup system to check if the payment went through and update the status in our DB. Sometimes we are getting some problems with the users that don't wait the redirect to the "success_url" so the status of the order in our DB is not updated and the order can't proceed
In this way I can check if the payment went through even if the user closes the Stripe page before redirect
Gotcha. In that case, ideal way would be to listen to webhook events and update your database when you receive an event for payment success. See: https://docs.stripe.com/checkout/fulfillment
Ok, but I need to make an http request in this way right? Isn't a method provided in the SDK?
Are you asking about front-end SDK or backend?
like are you asking about Stripe.js or stripe-node (or something else)?
We do have an SDK method for server-side libraries: https://docs.stripe.com/api/checkout/sessions/retrieve
But checkout session object only reflects three statuses - open, complete, or expired: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-status
It won't tell you if the payment succeeded or not
for that you'd need to look at the associated PaymentIntent object
Ideally though
Sorry, didn't provide enough informations.
I'm creating the session using the NodeJS SDK of Stripe, so yeah if a method is included it would be great
you can assume checkout succeeded if customer is redirected to success URL
Gotcha. You can use the link I shared above.. We have an example here on how you can use that: https://docs.stripe.com/payments/checkout/custom-success-page
where can I get infos about this object? because if the user close ths the page before redirect it wouldn't work, if I can receive the payment status it would be great
I already implemented this, but if the user closes the Stripe page before redirect all the flow is gone
When you retrieve the checkout session object, You can expand payment_intent parameter and look at its status
https://docs.stripe.com/api/expanding_objects
https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-payment_intent
In the json that is returned when I create the session is "payment_intent: null", if i retrieve it after it would have a value I guess, but what method of the SDK do I need to use?
Sorry found now stripe.checkout.sessions.retrieve
It may be that the session doesn't have an intent until after it has succeeded. You can use the checkout session retrieve call to get the full object
Will try it out thanks
You'd still use
'cs_test_xx'
);```
but add `expand` parameter for payment intent
Thank you very much for your help, best regards
Sorry one last question
Using retrieve method I'm getting "StripeInvalidRequestError: No such checkout.session: cs_test_a1DUQPDHXIG7epZuNNw0lFTZhAB5V2iCGALkv7eYOAClZIHgkRlnmmEg5j"
The ID I pass is cs_test_a1DUQPDHXIG7epZuNNw0lFTZhAB5V2iCGALkv7eYOAClZIHgkRlnmmEg5j
And the code is:
stripe.checkout.sessions.retrieve(sessionID, {
expand: ['payment_intent'],
}).then(session =>{
....
I'm using Stripe Connect, could it be the issue?
yup
you need to set the connected account ID similar to how you set it on checkout creation
using Stripe-Account header
Perfect got it! thank you very much... one last question where can I find the possible statuses for payment intent?