#habi-checkout-aws
1 messages · Page 1 of 1 (latest)
Hey there
hello
That sounds like an issue with your client reaching your server
Have you set up a /create-checkout-session endpoint on your server?
I have the following code in my server.js file, let me know if this is what you're referring to:
const YOUR_DOMAIN = 'http://localhost:4242';
app.post('/create-checkout-session', async (req, res) => {
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_1MKiukALuWMO1BsDXy1FdTAD}}',
quantity: 1,
},
],
mode: 'payment',
success_url: `http://localhost:3000`,
cancel_url: `http://localhost:3000`,
});
res.redirect(303, session.url);
});
app.listen(4242, () => console.log('Running on port 4242'));
Okay so looks like you are using an Express server
on my actual website its running on AWS but I'm trying to get it to work on proxy before pushing it out
Ah okay
I tried going by the docs and examples they have and couldn't get it to work yet
So I'm not too familiar with using AWS with proxy but the first thing I would do is to add a log at the first line below your app.post('/create-checkout-session', async (req, res) => { that will identify if you are reaching your server or not
okay ill try that real quick, for more context, everything else on the site is working, aws auth, and frontend works and no compile errors or anything
Okay but you haven't done anything to confirm you can reach your backend correct?
Like, do you have another backend endpoint working already?
Locally that is
habi-checkout-aws
sorry I'm back I had to step out for a call
I added the log where you said and I'm not seeing the message
if I'm not reaching the backend correctly, what do you think would be the issue here?
@hoary kestrel it's going to be hard to say with almost no information. Did you write the code end to end or mostly just clone a demo? Are you experienced as a developer and have built websites/web apps end to end before?
I didn't write it end to end, the server packaging is premade from node, and I'm fairly new I've been learning for a few months now
I'm sorry if this is confusing I appreciate your help
what is some more context I could give that might be useful?
I guess: what doc are you following?
okay so what's blocking you? Like did you follow all the steps there? Did you start the server? what do you see?
I followed all the steps there on the doc, and when I click the checkout button to be brought to the checkout session page, it says "Cannot POST /create-checkout-session stripe"
but what else do you see? Is your server started? Do you see any other logs?
Yes the server is running on my localhost, the frontend is fine, but the server log I put in the suggest place earlier isn't showing up either
This is what comes up on the console:
did you restart the server after adding the log?
yes, and this is the only console output:
POST http://localhost:3000/create-checkout-session 404 (Not Found)
why do you hit localhost:3000 when your whole code seems to be on localhost:4242?
good catch, thats my mistake thank you, let me fix that
now it says local host refused to connect, with this message in the console:
crbug/1173575, non-JS module files deprecated.
(anonymous) @ (index):6745
I have no idea what this means, this errors seems completely unrelated
Step 1: add a clear log to that and remove Stripe to confirm that works. Sorry you really need to go step by step here
okay I'll get on that, again thank you for your help I truly appreciate it