I ran that cURL test script and got the following output (IPs masked):
Code: Select all
DATA:
ERROR (60):
SSL certificate problem: unable to get local issuer certificate
INFO:
Array
(
[url] => https://connect.squareup.com/oauth2/token
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 1
[redirect_count] => 0
[total_time] => 0.11
[namelookup_time] => 0.032
[connect_time] => 0.078
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => xx.xx.xx.xx
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => xx.xx.xx.xx
[local_port] => 58345
)
I highly suspected it was due to the use of a self-signed SSL certificate on my dev box. When I ran the PHP script from a PROD server it appears to be successful (ERROR 0). I don't have my OpenCart store setup on the PROD server, however, so I can't verify if things work via the Square Extension from within OpenCart.
When I add the following in the cURL test script (e.g., next to the other curl_setopt() line), the script returns successfully (ERROR 0) on my dev box:
Code: Select all
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
So, to work around this, here's what I did:
1) I did some Googling and found this page and downloaded the cacert.pem file provided: https://docs.bolt.cm/3.4/howto/curl-ca-certificates
2) I modified my php.ini file and added the following as indicated on the page (update the path based on where you saved cacert.pem):
Code: Select all
curl.cainfo = "C:\php\extras\ssl\cacert.pem"
After doing the above, the test cURL script returned successfully (ERROR 0) - even without the CURLOPT_SSL_VERIFYPEER workaround.
I was also then able to go back to the Square extension and authenticate and it worked! I received the green box message, "Successfully refreshed the connection to your Square account.", and the blue "Connect" button was replaced with two different blue buttons, "Reconnect" and "Refresh token".
I then did a test transaction (I have Sandbox setup via the Extension) and it went through!