Howdy!
I’m going through the walkthrough for integrating square payments in a website.
Everything through step 1 works great. I see the CC input form, I enter the 4111 test CC and hit Pay, and I am alerted the nonce. It appears to work as expected.
I continue through the walkthrough by modifying server.js with my access token, and replacing the nonce alert with the backend server processing code provided by the walkthrough. And the trouble begins.
After I enter the 4111 CC and hit Pay, it errors saying the payment failed and to check the developer console. At first, I had the following:
VM149:1 GET https://****/process-payment/ 404 (Not Found)
(anonymous) @ VM149:1
cardNonceResponseReceived @ (index):90
mt._cardNonceResponseReceived @ paymentform:1
mt.receiveMessageCallback @ paymentform:1
(index):114 SyntaxError: Unexpected end of JSON input
at (index):105
So I tried to figure out why /process-payment wasn’t being found. I ended up adding a location block in nginx on my server to that directory, although I don’t think that should be necessary.
So my assumption is nodejs isn’t creating the endpoint /process-payment/ for some reason? And thus it appears to be invalid?
After I added a location block in nginx for it, it removed the error but I still get the “Unexpected end of JSON input” error. So I’m led to believe the nginx adjustment is likely not necessary, and something else is creating the problem.
To provide additional info, if I alert the JSON.stringify({ nonce: nonce }), it shows:
{“nonce”:“cnon:CBASEKBhcwr091WbBmMH2gho8-Q”}
So it appears the JSON is formatted correctly, even though it’s complaining about the unexpected end of JSON input?
Thanks for any help!