#adam_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
๐ 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/1212020332802744402
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
โฒ๏ธ 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. Thank you for your patience!
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- thewirednomad, 3 days ago, 4 messages
- thewirednomad, 4 days ago, 23 messages
- thewirednomad, 4 days ago, 2 messages
try {
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price: priceId,
quantity: 1,
adjustable_quantity: {
enabled: true,
minimum: 1,
maximum: 10,
},
quantity: 1,
},
],
mode: 'payment',
success_url: 'https://thewirednomad.com/success?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) {
res.status(500).json({ error: 'Internal server error' });
}
});
// Handle successful order
app.get('/successfulOrder', async (req, res) => {
const session_id = req.query.session_id;
try {
const session = await stripe.checkout.sessions.retrieve(session_id);
const customer = await stripe.customers.retrieve(session.customer);
res.send(`<html><body><h1>Thanks for your order, ${customer.name}!</h1></body></html>`);
} catch (error) {
res.status(500).json({ error: 'Internal server error' });
}
});
// Export the Express app as a Firebase Cloud Function
exports.api = functions.https.onRequest(app);
๐ happy to help
Payment successful, but no success page still
you're creating a normal checkout session here, instead of an embedded one
oh?
as you can see you need to specify ui_mode: 'embedded' in order to create an embedded form
I was following this https://docs.stripe.com/payments/checkout/custom-success-page
I saw that, but I don't see where to specify that
All I want to do is have the redirect behavior as described in the link I just posted
It's true I don't need my own success.html for that?
oh I see now
that should fix it..
actually you need a success url in all cases
whether it's an embedded or a hosted Checkout Session
oh.
but my success html is not the same as res.send(<html><body><h1>Thanks for your order, ${customer.name}!</h1></body></html>);
so which one is it? does it use success.html or does it do <html><body><h1>Thanks for your order, ${customer.name}!</h1></body></html>
I guess you named your success url /successfulOrder from the code you mentioned above
app.get('/successfulOrder',
actually it's success.html. but again, I thought this wouldn't use my success.html
because why else would the code have res.send(<html><body><h1>Thanks for your order, ${customer.name}!</h1></body></html>);
?
@cedar quiver your app has a /successfulOrder URL that you can use, why redirect to success.html I'm not sure I understand
where am I directing to success.html?
I even purposely removed the success.html I previously had from the folder
ah crap
so I should change this to success_url: 'https://thewirednomad.com/successfulOrder?session_id={CHECKOUT_SESSION_ID}',
yes
nice. thanks
lastly, is there anyway to test this without actually needing to go through a real payment?
yes in test mode you can create checkout sessions and pay with the test cards
Perfect thanks