#hero.xyz
1 messages · Page 1 of 1 (latest)
hi there!
Hi
can you share the Checkout Session ID (cs_xxx)?
where can I find this 😅
I see it in the screenshot you shared, in red
Yeah, but I don't know from where it is coming
can you copy paste it here?
Okay
cs_test_xxx
Error: {"digest":"NEXT_REDIRECT;replace;https://checkout.stripe.com/c/pay/cs_test_a15p4t4Z1mkFTbWDDC0nZysTEM36MGql38FqLHUbGcsO9nNjpOLf0x8moJ#fidkdWxOYHwnPyd1blpxYHZxWjA0SmNVN2xWQ21vU2Rgf0ZIZ2Y9NDBGdWFOVG0ybV9qXGpXNGFcMVRvM19Ra2BHR1BCQzR8RDZvM1JLTnNOMEZmM0dfM0s9Z0p%2FZHMzTUs2X0l2SGZ8QUpANTVxcGhAcjdVRCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl;303;","mutableCookies":
You need to move redirect outside of the try/catch block: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#redirecting
Assuming it's a Server Action, which is what it looks like
ya it's a server action
Ok
this is the ID: cs_test_a15p4t4Z1mkFTbWDDC0nZysTEM36MGql38FqLHUbGcsO9nNjpOLf0x8moJ
it looks like it was correct created. so when do you get that error? when you try to redirect the user to the Checkout Session page?
when i try to move the redirect out of the try catch
Yes
Move the const to be a let outside the try/block scope
let checkoutSession: Stripe.Checkout.Session;
try {
checkoutSession = await stripe.checkout.sessions.create({});
} catch {
...
}
redirect(checkoutSession.url as string)
Issue fixed
redirect(session.url!)
} catch (error) {
throw error;
};
Just need to change that error section
Cool!
Tysm for the time
No problem, glad I could help!
Really appreciate the quick responses