#awombmayu_docs
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/1431209138733715477
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello there! Does the request in your Node.js server to create the Checkout Session succeed?
how do i check for this?
I'd suggest adding some logs in the Node.js code that capture the success/failure of the request, then they'll be printed in your terminal
Based on the error in your original message, I suspect that request is failing
you mean like this? app.post('/create-checkout-session', async (req, res) => { console.log('check if app post work');
Yes, but after the API call to Stripe
like this? ```app.post('/create-checkout-session', async (req, res) => {
const session = await stripe.checkout.sessions.create({
ui_mode: 'embedded',
customer_email: 'customer@example.com',
submit_type: 'donate',
billing_address_collection: 'auto',
shipping_address_collection: {
allowed_countries: ['US', 'CA'],
},
line_items: [
{
// Provide the exact Price ID (for example, price_1234) of the product you want to sell
price: 'price_1SKwrwFSXSPNg8P8MDxCRpmY',
quantity: 1,
},
],
mode: 'payment',
return_url: ${YOUR_DOMAIN}/return?session_id={CHECKOUT_SESSION_ID},
});
res.send({clientSecret: session.client_secret});
console.log('does work?')
});``` the log does not get shown in the console
Yes, so as I suspect that code/API request is throwing an error that you're not catching
Can you adapt your code to use a try/catch block?
try {
const session = await stripe.checkout.sessions.create({
ui_mode: 'embedded',
customer_email: 'customer@example.com',
submit_type: 'donate',
billing_address_collection: 'auto',
shipping_address_collection: {
allowed_countries: ['US', 'CA'],
},
line_items: [
{
// Provide the exact Price ID (for example, price_1234) of the product you want to sell
price: 'price_1SKwrwFSXSPNg8P8MDxCRpmY',
quantity: 1,
},
],
mode: 'payment',
return_url: `${YOUR_DOMAIN}/return?session_id={CHECKOUT_SESSION_ID}`,
});
res.send({clientSecret: session.client_secret});
console.log('does work?')
} catch(err) {
console.log('err', err)
}```
Use that, run it again and you should see 'err', ... in the console
i only see this in the console: You may test your Stripe.js integration over HTTP. However, live Stripe.js integrations must use HTTPS. POST http://localhost:5173/create-checkout-session 404 (Not Found) Uncaught (in promise) IntegrationError: fetchClientSecret failed with error "Failed to execute 'json' on 'Response': Unexpected end of JSON input" he resource https://js.stripe.com/v3/fingerprinted/js/checkout-embedded-app-init-45a5ad458d95eca32ad9a52c6454d04e.js was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate as value and it is preloaded intentionally. Error: Timed out waiting for client secret
When I say terminal I don't mean the browser. I mean the place where you start the Node.js server via npm dev or whatever
Have you done that?
yes in the code editor i open the terminal, then write npm run dev and the browser opens with the site i work on
but the errors get shown in the browser console
And therte's nothing in the editor terminal?
POST http://localhost:5173/create-checkout-session 404 (Not Found)
Are you sure your application is running on that port?
Normally it'd be :3000 by default I think
in my code editor there is only this normal vite text: > deso@0.0.0 dev
vite
VITE v5.2.11 ready in 280 ms
โ Local: http://localhost:5173/
โ Network: use --host to expose
โ press h + enter to show help
i dont know how to be sure where its running, but in my browser top there is http://localhost:5173/
Yeah clearly the frontend (React) code that initialises the call to the server can't find the URL, hence the 404 error
but when i change this const YOUR_DOMAIN = 'http://localhost:3000';
to localhost:5173 nothing changes
Hey! Taking over for my colleague. Sorry, but this seems to be a react Js issue rather than Stripe product related issue.
First, you need to be able to interact to your backend (for example using curl or postman), then use that same url in your frontend.
i have never made any backend, i just made the frontend with vite react and then put the app.jsx and server.js code from your docs in, i assumed, that when i use react i automatically have node.js, and when i use the stripe form thats all the backend i need
No, you'll need a backend
The guide you shared intially do use a backend
server.js is a backend
You can download the complete project and run it locally in order to better understand the flow
oh, i thought server.js IS the backend to make this work.. i did download the complete project, but i could not get that running too, ill look at it again
Try downloading it and run it without making any change on it first.
i do, when i go to readme.doc there is a 1. npm install (that works), 2. npm start (there i get error: bernardsorel@unknownea1275a65459 stripe-sample-code % npm start
stripe-sample@0.1.0 start
concurrently "yarn start-client" "yarn start-server"
[0] /bin/sh: yarn: command not found
[1] /bin/sh: yarn: command not found
[0] yarn start-client exited with code 127
[1] yarn start-server exited with code 127
bernardsorel@unknownea1275a65459 stripe-sample-code %
yarn: command not found
you need to install yarn
it works!!! i see it looks similar to my site, only thing i notice is very different is the package.json, so in order to make my site work i need the dependencys and the "homepage": "http://localhost:3000/checkout",
"proxy": "http://localhost:4242" line?
is this what you mean by the backend?
or where do i define/get it from?
It depends how are you setting your backend
But you can use the quickstart project as a base
and continue working on it as your website
okey, thanks