Hello everyone, I am at the very last step of the biggest project I’ve ever done and I have walked out of the area of my expertise.
I am using stripe to handle payments, I followed a youtube tutorial but I really have no idea what I am doing.
My backend code is most likely the problem, I’ve never done backend before.
My front end code is visible here.
I am just trying to get the Stripe payments working, can anyone tell me what I am doing wrong?
Thank you all in advance.
Probably you just don’t see the response from stripe as you have a typo on the back-end:
// Line 38
.carth(err => console.log(err))
Fix it and see if that will log the err?
I do have a working example with stripe if you would like to see it. It was over a year ago I had it setup, and albeit very basic, it should be able to set you up. I would also recommend putting your node_modules on the backend code in a .gitignore.
Okay, I think try to make the route async, and use await on the stripe charge.
I would like to see that yes.
Typo fixed! Thanks for that.
So now I am getting the error “Uncaught (in promise) Error: Network Error”
I changed nothing but the typo. What do you guys think I am doing wrong?
Also if anyone knows a good tutorial, I would accept that as a solution too.
I’ve spent quite some time just digging through docs to understand stripe in my last project. It’s complex. And complicated. But transactions themselves are darn simple. Create a new charge and execute it. Send transaction ID to backend so that backend could retrieve it from stripe separately.
If you get a network error, that means you lose connection somewhere or stripe can’t connect. Start with troubleshooting your backend (can it connect to any external API?), then move on to stripe’s test API. You can make virtual transactions with virtual cards and see real responses from a real API.
A good tutorial for stripe online payments: https://stripe.com/docs/testing
There’s a ton of information in related links, take your time, study, test, use test api, cover the common cases using their test cards.
Debugging is a primary skill of a software developer, you need to be able to do it yourself if you want to succeed in this role.