#Quisk - errors

1 messages ยท Page 1 of 1 (latest)

gusty nest
#

Hello, can you paste the text of the errors that you are getting to here?

coral harbor
#

card.js:15 POST http://127.0.0.1:5500/create-payment-intent 405 (Method Not Allowed)
(anonymous) @ card.js:15
VM264:1 Uncaught (in promise) SyntaxError: Unexpected end of JSON input
at card.js:28:27
at async HTMLFormElement.<anonymous> (card.js:15:53)

gusty nest
#

That indicates that your server is returning a 405 error when your client-side code tries to reach out to it

coral harbor
#

everything is fine with it, and I get no errors when I run it.

gusty nest
#

Then it could be a server configuration issue. Can you access other paths and pages on that server properly?

#

This looks like it may be a routing error outside of your code

coral harbor
#

ok. Thank you.

ashen olive
#

๐Ÿ‘‹

coral harbor
#

hi

#

do you want me to send the links again?

ashen olive
#

No this is fine

#

If you look at the error it shows you are posting to port 5500

#

But your server is running on 4242

#

So you need those to align

coral harbor
#

ok, I changed the port on my server to 5500, but I'm still getting the same error:

ashen olive
#

Hmm

coral harbor
#

when I first load the page, I now get this error:

Stripe.js requires 'allow-same-origin' if sandboxed.

ashen olive
#

Can I see your HTML?

coral harbor
#

sure

ashen olive
#

Huh that all looks fine. The above error really should only come up if you are running in an iframe

#

You are just running this locally, correct?

coral harbor
#

this is where I get the error:

ashen olive
#

Your code looks fine as far as I can tell... so a bit stumped on what would be causing this

#

Let's try to strip your server down a bit

coral harbor
#

this is my package.json, i don't know if it matters but I changed the stripe version:

#

{
"name": "stripe-sample-demo",
"version": "1.0.0",
"description": "A Stripe demo",
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "echo "Error: no test specified" && exit 1"
},
"author": "stripe-demos",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"dotenv": "^16.0.0",
"express": "^4.17.1",
"stripe": "^10.1.0"
}
}

ashen olive
#

Since it seems that it doesn't like this for some reason

#

Nah that shouldn't matter

coral harbor
#

ok

ashen olive
#

can you comment out body parser

#

And what is resolve doing?

coral harbor
#

resolve is used on this line:
const path = resolve(process.env.STATIC_DIR + "/index.html");

#

I still get the error if I comment out bodyParser

#

I'll be back in 10 mins. Let me know if there is a fix, I might make a post on reddit in case someone has encountered something similar.

ashen olive
#

Let's try hardcoding the entire route in your client code. Can you change your fetch to fetch(http://127.0.0.1:5500/create-payment-intent, {...

coral harbor
#

I still get the 405 error, what is the second error saying: VM530:1 Uncaught (in promise) SyntaxError: Unexpected end of JSON input
at card.js:28:27
at async HTMLFormElement.<anonymous> (card.js:15:53)

#

maybe we can start with that.

ashen olive
#

That's just related to your server not liking your request

#

Can you try setting "proxy": localhost:5500 at the top level of your package.json and then restarting your server (and change your fetch back to how it was before)?

coral harbor
#

same error.

#

should my server be running when I try to make the payment?,

#

or does that not matter.

ashen olive
#

What does that mean? Your server has to be running to serve that webpage, no?

#

And yes, you need your server running to hit it in order to create the PaymentIntent

deep obsidian
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

coral harbor
#

Yes, I inputted npm start on the server, the server starts "listening", I try to enter a payment but it doesn't work.

#

Hi tarzan

deep obsidian
#

I really wish we could help you with your journey into development but it's really not our job. I would really suggest you put Stripe aside for a sec, and focus on learning how to setup a fully working app before jumping on adding the Stripe integration

#

are you using a specific library/framework on the frontend?

coral harbor
#

no, I'm just using vanilla js.

deep obsidian
#

I would recommend searching on the internet on how to do a simple todo app with node/vanilla js

#

there are also a lot of boilerplates that you could clone

#

once that's done, start integrating Stripe, and then when you have a specific Stripe implementation Qs we're going to be here for you and helping you achieve it ๐Ÿ™‚