#awombmayu_docs

1 messages ยท Page 1 of 1 (latest)

queen shaleBOT
#

๐Ÿ‘‹ 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.

polar harness
#

Hello there! Does the request in your Node.js server to create the Checkout Session succeed?

west rock
#

how do i check for this?

polar harness
#

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

west rock
#

you mean like this? app.post('/create-checkout-session', async (req, res) => { console.log('check if app post work');

polar harness
#

Yes, but after the API call to Stripe

west rock
#

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

polar harness
#

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

west rock
#

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

polar harness
#

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?

west rock
#

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

polar harness
#

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

west rock
#

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

queen shaleBOT
west rock
polar harness
#

Yeah clearly the frontend (React) code that initialises the call to the server can't find the URL, hence the 404 error

west rock
tawdry hemlock
#

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.

west rock
#

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

tawdry hemlock
#

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

west rock
#

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

tawdry hemlock
#

Try downloading it and run it without making any change on it first.

west rock
#

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 %

tawdry hemlock
#

yarn: command not found
you need to install yarn

west rock
#

is this what you mean by the backend?

#

or where do i define/get it from?

tawdry hemlock
#

But you can use the quickstart project as a base

#

and continue working on it as your website

west rock
#

okey, thanks