#yodasgerbil - Checkout Redirect
1 messages · Page 1 of 1 (latest)
Thanks
I am able to create the session
exports.handler = async (event) => {
const body = JSON.parse(event.body);
const session = await stripe.checkout.sessions.create({
success_url: 'http://localhost:8888/thank-you',
cancel_url: 'http://localhost:8888/404',
payment_method_types: ['card'],
line_items: body,
mode: 'payment',
});
but not sure how to call the stripe checkout page with the created session id
After that code runs session.url should contain the link you redirect your customer to.
right, I see the url in the returned session.
do I then call the redirectToCheckout function like this?
.then(async response => {
const { id } = await response.json()
const { error } = await stripe.redirectToCheckout({ sessionId: id })
alert(error.message)
})
.catch(err => alert(err.message))