#PARAS DOCS-expire-checkout-session
1 messages ยท Page 1 of 1 (latest)
HI there ๐ those appear to be two separate things.
What version of our node.js sdk are you using?
const session = await stripe.checkout.sessions.retrieve(id);
if (!session) return res.redirect("/premium")
const mode = session.payment_status
if (mode === "paid") {
await stripe.checkout.sessions.expire(id);
}
res.redirect(`/dashboard/`);
})
16.6.0 nodejs version
Can you double check that, the latest version is only 8.210.0?
@royal prawn when a successfull payment happen it just loading won't redirect
if i remove session expire line it works fine
Thank you, wanted to confirm you were on a new enough version to have the expire function. Oh, are you trying to expire already completed sessions?
yes i am using expire session after successfull payment
Ah, so that won't work as only open sessions can be expired. Is that function not throwing an error when you try to pass it an already completed session?
i don't think session has expire because i just retrive it
@royal prawn you can see this code
Checkout sessions are single use, once they've successfully collected payment they can't be reused.
As mentioned in the expire docs,
A Session can be expired when it is in one of these statuses:
open
https://stripe.com/docs/api/checkout/sessions/expire?lang=node
Once a session has collected payment it moves to a completed status:
https://stripe.com/docs/api/checkout/sessions/object?lang=node#checkout_session_object-status
Just tested and confirmed, that expire function should be raising an error if you try to use it to expire an already completed session.