#Quisk - errors
1 messages ยท Page 1 of 1 (latest)
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)
this is my code: https://ctxt.io/2/AADgr7XBFg
That indicates that your server is returning a 405 error when your client-side code tries to reach out to it
I see, but I have the same server side code as the tot: here it is: https://ctxt.io/2/AADgdybiFQ
everything is fine with it, and I get no errors when I run it.
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
ok. Thank you.
๐
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
Hmm
when I first load the page, I now get this error:
Stripe.js requires 'allow-same-origin' if sandboxed.
Can I see your HTML?
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?
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
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"
}
}
ok
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.
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, {...
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.
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)?
same error.
should my server be running when I try to make the payment?,
or does that not matter.
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
๐ taking over for my colleague. Let me catch up.
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
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?
no, I'm just using vanilla js.
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 ๐