Search code examples
phpsquare-connect

Square Connect php API error


I am new to using Square APIs and am attempting to integrate the PHP version of the API into a website.

I have followed the instructions on their site to the best of my ability, utilizing Sandbox credentials including the location ID. The payment form is created, I fill in the form using the fake credit card information provided in the documentation, I receive the javascript alert indicating the nonce has been created, but receive the following error:

Caught exception!

Response body: null

Response headers: null

Can you please provide me with some guidance on how to fix this?


Solution

  • Square Connect Only allows connections from secure sites. Make sure your site has ssl certificate installed.

    My guess is you are testing on localhost, in that case you try to generate the self signed certificate. Although I dint try generating my own certificate. I just tested it on live website with ssl certificate and that error was gone.

    If you are using the php api v2 sample try printing out the full response by placing print_r($e); in the catch block and view the full description of your errors. Thats how I figured out the problem. Hope it helps.