#adam_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/1231004568624562267
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
// Handle Preflight request
app.options('*', (req, res) => {
res.status(204).send('');
});
// Handle create checkout session request
app.post('/create-checkout-session', async (req, res) => {
const { tier } = req.body;
console.log('Received request with tier:', tier);
// Your logic to determine the price and other details based on the tier
let priceId;
switch (tier) {
case 'silver':
priceId = 'price_1Oft1yKGOtHP6zWlhbVWdWtZ';
break;
case 'gold':
priceId = 'price_1OLUlyKGOtHP6zWlvC0qN8gf';
break;
case 'diamond':
priceId = 'price_1OLUo1KGOtHP6zWl5nnnsoEy';
break;
default:
return res.status(400).json({ error: 'Invalid tier' });
}
try {
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price: priceId,
quantity: 1,
}
],
mode: 'payment',
success_url: 'https://thewirednomad.com/successfulOrder?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://thewirednomad.com/cancel.html',
});
// Include clientSecret in the response
res.json({ id: session.id, clientSecret: session.client_secret });
} catch (error) {
console.error('Error creating checkout session:', error);
res.status(500).json({ error: 'Internal server error' });
}
});
Hello! I'm sorry but I don't really know anything about Firebase, but it would be really something in your own code/logic right now, you configure the success URL and that needs to be valid
It should just be res.send(<html><body><h1>Thanks for your order, ${customer.name}!</h1></body></html>);
But my client got this
yeah but that's your own code here really. Your page renders that
You need to debug your own code to check why that /successfulOrder page doesn't work
Gotcha.