#ImRonBarnes - clienterror
1 messages · Page 1 of 1 (latest)
Hello, can you send me the URL from that error?
It looks like this is something client-side but I want to make sure we didn't send anything wonky
Exactly, thank you
to further explain: my teacher was trying to get us to use netlify but netlify was giving me some weird errors so I decided to just make my own API to do what I needed netlify for.
So it looks like that error is coming from stripe.js but I am not immediately sure why. Can you send your code that is getting this error?
I can send some screenshots of all those files
Send the actual text please
Easier for me to use to reproduce and whatnot
You can just send snippets, not full tiles
ok whats the best way to send the text, literally just copy paste?
im pretty new to coding in general, much less 'talking' code
Then it is formatted like this
well it's a 401 (Unauthorised) error so most likely it's an issue with your publishable key pk_test_xxx , you're supposed to have a line with loadStripe to set that up (https://stripe.com/docs/payments/accept-card-payments?platform=web&ui=elements#add-stripe.js-and-elements-to-your-page)
Thank you for catching that!
ill try putting my secret key in line 2 without the process.env and see what happens
Sounds good, let us know if that resolves your 401
it did not..
could the issue be coming from line 6 where I am parsing over event.body?
One thing we might want to try is actually using the loadStripe function that karlekko mentioned
I don't think so, that url had confirm in it which means it likely came from your confirmCardPayment call
One quick thing to check though:
Do you know if your new test actually used your new code with the hard coded public key?
Sometimes things need a deploy or whatnot, not sure about your setup but I have seen this trip people up
Side question: Why is your secret key in your client side code?
API set up on port 8080 because netlify wasn't working nicely with me
I had it in an env file but was trying to narrow down potential issues.
Ah gotcha, just making sure because that actually making it client side is very bad news.
Looking in to what else might be happening with this setup
Like karlekko said, this looks like it has something to do with your public key setup. Is this page able to make any other Stripe calls?
this isnt for a real project, this is just a local thing I'm not planning on actually publishing
now that im looking at it, it appears that most of the content of that API is also on a file called create-payment-intent in my react app
and it looks like the publishable key is greyed out in my API, like it isnt being used anywhere
Are you still initiating stripe with the secret key like in that screenshot?
I am looking through our React example code to see what you might need to do here
i put my secret directly in it just now to try it and it made no difference
i can change it back
Do that, the secret key is not relevant here. You will only need the publishable key
Where are you setting up your ElementsProvider?
Where is your stripePromise defined?
Gotcha, and have you double checked that your publishable key env variable is being populated as you expect there?
how can i confirm that
hovering over the REACT_APP_STRIPE_PUBLISHABLE_KEY tells me undefined
That sounds promising, can you try hardcoding in the publishable key to check if that helps?
replace that whole process.env.....etc with the publishable key?
Yeah, just for this test
You can also try figuring out why it is defined and do that, I just wanted to quickly make sure that that is what will work
look right?
Yep
Haha thank you, glad we could identify what is going on. So it sounds like you just need to fix that config and you are golden
so my env file apparently isn't communicating properly ?
Hard to say, can you pull other values from it properly?
it's interesting because my issue i had with netlify had to do partly with that env file as well.. So perhaps had that env file been working right, I wouldn't have run into a lot of issues lol
Yeah env files can be easy to screw up a number of ways at first. Good luck getting that configured properly!