#lennard_checkout-success-page
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/1221867697151807488
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Oops, appears the code isn't right...
Here's the code:
import Stripe from 'stripe';
const stripe = new Stripe('xxx');
export async function POST() {
const session = await stripe.checkout.sessions.create({
line_items: [
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
price: 'price_1OxZ1fHpFc1RmriHJn6XwkMJ',
quantity: 1,
},
],
mode: 'payment',
success_url: `http://localhost:3000/api/stripe/sucess?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `http://localhost:3000/api/stripe/?success=true`,
automatic_tax: {enabled: true},
});
console.log("๐ ~ POST ~ session.url:", session.url)
return Response.json({
url: session.url
});
}
Sorry what about the URL or webhook are you saking about here?
So:
All I need is to get the email of the user and then send them an email and a sucess page.
Is it secure for me to just use the sucess_url like above and parse the checkout session there, server side, and render a HTML sucess page? Or am I advised to use a webhook?
Because to me it looks like I do not need the webhook and can do all in sucesss, just wanted to check that to make sure I don't do anything wrong.
It depends on what you want to do with your Success page
All I need is to run one API request with the person's email, and display a form for them to potentially add emails of their team. And some greeting.
In that case you can use the success_url like you have shown here
Just be aware that, if your customer uses asynchronous payment methods, you may not know the outcome of the payment at the time they visit the success URL
What would be examples of that? Are these common?
Any asynchonrous payment method. For instance ACH with a US bank account can take 3 days to complete
Oh okay, I will go with the webhook then instead. Thanks for clarifying!
Sure thing! Happy to help ๐
Hope you have a great day
You too ๐
Ty!