Post by iSenseLabs » Tue Aug 08, 2017 4:13 pm

We have tested the Square extension on several web servers with different PHP versions, but we have never encountered this error. The only information we have about the issue is the error you reported, and it does not give enough information. This error could be (not necessarily) related to:

Possible cause 1) Forbidden access to curl_exec function (configured in php.ini)
Possible cause 2) Your web server cannot do requests to https://connect.squareup.com/oauth2/token
- there could be name resolution (DNS) issues
- or some kind of security software blocking the requests (firewall for example)
- something else of which we are not aware

The issue could be somewhere else, but we cannot be sure because we are not familiar with your network setup and environment.

To test if CURL is working properly, you may do this:

Create a new PHP file with the following contents:

Code: Select all

<?php
$url = 'https://connect.squareup.com/oauth2/token';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
$error_number = curl_errno($curl);
$error_text = curl_error($curl);
$curl_info = curl_getinfo($curl);
curl_close($curl);

echo '<h1>DATA:</h1>';
echo '<pre>' . htmlentities($data) . '</pre>';
echo '<h1>ERROR (' . $error_number . '):</h1>';
echo '<pre>' . $error_text . '</pre>';
echo '<h1>INFO:</h1>';
echo '<pre>'; print_r($curl_info); echo '</pre>';
?>
Upload the file to your web server and access it from a web browser.

If everything is fine, the result will look like this:

============
DATA:

{
"message": "NotFound",
"type": "not_found"
}
ERROR (0):

INFO:

Array
(
[url] => https://connect.squareup.com/oauth2/token
[content_type] => application/json
[http_code] => 404
[header_size] => 552
[request_size] => 71
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.977268
[namelookup_time] => 3.9E-5
[connect_time] => 0.190473
[pretransfer_time] => 0.784074
[size_upload] => 0
[size_download] => 51
[speed_download] => 52
[speed_upload] => 0
[download_content_length] => 51
[upload_content_length] => -1
[starttransfer_time] => 0.977238
[redirect_time] => 0
[certinfo] => Array
(
)

[primary_ip] => xxx.xxx.xxx.xxx
[primary_port] => 443
[local_ip] => xxx.xxx.xxx.xxx
[local_port] => 39024
[redirect_url] =>
)

============

You may set a different value for the $url variable and see if you will be able to access other URL's, for example yahoo.com

This extension was developed by iSenseLabs. You may try contacting them on sales@isenselabs.com and get support.

Premium OpenCart Extensions and Custom Development


User avatar
Active Member

Posts

Joined
Sat May 19, 2012 7:41 pm

Post by luke213 » Tue Aug 08, 2017 10:45 pm

Thanks so much for the reply. I did realize it was Isenselabs that did it, I was trying not to bother you guys with a community request through business channels if I could help it but that I will try as soon as I have some time;)

I did that upload with php and got back:

Code: Select all

DATA:

ERROR (35):

Unknown SSL protocol error in connection to connect.squareup.com:443 

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] => 10.238828
    [namelookup_time] => 0.028297
    [connect_time] => 0.128432
    [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] => xxx.xxx.xxx.xxx
    [certinfo] => Array
        (
        )

    [primary_port] => 443
    [local_ip] => xxx.xxx.xxx.xxx
    [local_port] => 49608
Which sounds an awful lot like it's related to my SSL being rejected or something on that end. Since my php.ini is stock and doesn't mention curl from what I understand it would only be a problem if it were disabled there. On SSL it's something I've got very limited experience with, and since my site hasn't taken payments over the years I've always run them manually off line, I never had SSL enabled until this recent build of the site. So I had signed up for the most basic of basic SSL certificates from my host 1and1 and now I'm thinking that could be related here.

So I'll do some research into their SSL setups and inform myself a bit more on SSL across the board and see if I can't find what is causing the failure. I'm just glad to hear it's functional on someone else's server then at least I know it's not a code issue more than likely a configuration issue at my host or on my install. Again I really appreciate the reply and help, been banging around on this for a few days at least and any pointers are always appreciated.

Also should mention I'd be happy to give any data that would help, logs etc. Though I'd need to know what you're hunting for or rather where the log is located etc. Since while I've been using OC for years I haven't had huge need to dig around the logs etc for fixing things, it's generally worked after my initial installation.

Take care!

Luke

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by luke213 » Wed Aug 09, 2017 8:57 am

I did some reading and testing, looks like my site is running TLS 1.2 currently and the lower versions as well, so I don't believe that should be a problem. I can't seem to find a link that says what version on openssl or TLS is required to talk to the square API, if anyone knows I'd appreciate it. From the looks of it it's something on 1and1 causing this, which isn't a huge surprise nor the first time it's happened.

I should also mention I'm running the Starter SSL package of sorts, rather than the fancier packages, but I don't see anything listed that says hey I need something more at this stage. But if I'm incorrect there, please feel free to correct me I'm fairly new to working with ssl in general and learning as I go.

Other test scripts or things I can test would be as always appreciated. I did send off an email to isenselabs, and hopefully they will be able to be of some help as well. Thanks though for all the help thus far it's certainly appreciated.

Luke

EDIT: Forgot to mention I'm running the stock php.ini as well as PHP version 7 currently on the site, so I don't believe I've got any issues with curl from what I've read with that version of php. Most of the issues I saw seemed to be 5.6 and earlier, but I do have 7.1 as an option though I haven't tried that. I did drop to 5.6 at one point to try that but no dice same issues.

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by luke213 » Thu Aug 10, 2017 12:37 am

For anyone watching this thread with the same issue. I don't have an answer yet Isenselabs is working with me to try and solve it. Currently it looks like it's either something on the backend of square(unlikely IMHO), or something on the host side(much more likely). I'm running the site through 1and1 on a shared server and according to them that's causing the issue, however I'm not sure it's not related to the version of curl etc.

So more testing but hopefully I'll have an answer before too long and be able to post a fix for other guys running into this issue.

Luke

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by luke213 » Thu Aug 10, 2017 7:16 am

And it's working. I'm not sure what changed on which end either square or 1and1 but either way one of them fixed the issue at least on my server and it's functional. So if someone else has this issue probably worth posting just to say it happened.

Take care!

Luke

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by iSenseLabs » Thu Aug 10, 2017 1:43 pm

The issue has been resolved. If anyone has connectivity issue on 1AND1 hosting with Square — please run the script above to check if you are successfully connecting and if not, feel free to post the error you are having on this forum thread. You can also bring the result to 1AND1's support team by providing them the isolated PHP script example with the result.

Premium OpenCart Extensions and Custom Development


User avatar
Active Member

Posts

Joined
Sat May 19, 2012 7:41 pm

Post by luke213 » Sat Aug 12, 2017 7:32 am

Just a note to guys who may be reading and not posting. The extension went down again, well it's not connecting. Isense and I have been talking about it and I do want to say it doesn't look at all like it's their code. Rather it's either something on 1and1 or square causing the issue in the way they talk. So right now it's down again, not sure when/if it will get fixed again;) Since we're not sure what happened in the first place on which end to have them start communicating properly.

So I'll update when it goes back to working and hopefully this time we'll know what caused it and that it's a permanent change rather than something temporary;)

Luke

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by shulmax » Fri Aug 18, 2017 9:47 am

Thanks a lot for the info contained in this thread! I'm also unable to connect to square successfully. I'm running opencart 2.3.0.2 - i ran the CURL php script and received the following output (same error 35 as listed further up in this thread). If anybody can shed more light on getting the issue fixed it would be much appreciated.

DATA:

ERROR (35):

Unknown SSL protocol error in connection to connect.squareup.com:443
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] => 10.23879
[namelookup_time] => 0.028362
[connect_time] => 0.128539
[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.xxx.xxx.xxx
[certinfo] => Array
(
)

[primary_port] => xxx
[local_ip] => xx.xxx.xxx.xxx
[local_port] => xxxxx
)

User avatar
Newbie

Posts

Joined
Mon Apr 18, 2016 10:37 am

Post by iSenseLabs » Fri Aug 18, 2017 2:42 pm

@shulmax: Can you share which one is your hosting provider? There is currently a known issue with 1and1 and Square is working with them to resolve it.

Premium OpenCart Extensions and Custom Development


User avatar
Active Member

Posts

Joined
Sat May 19, 2012 7:41 pm

Post by ScottDellinger » Sun Aug 27, 2017 10:43 am

I'm also encountering this exact issue, on 1and1.com. Any update on this at all?


Posts

Joined
Sun Aug 27, 2017 4:31 am

Post by ScottDellinger » Mon Aug 28, 2017 3:11 am

I've spent a good chunk of today speaking to techs at 1and1, and basically they told me they have no idea why the issue is happening, but they know it's happening. They cannot provide any ETA on it.

I've contacted Square as well, but have not yet heard back. I'll post again when I have more info.


Posts

Joined
Sun Aug 27, 2017 4:31 am

Post by luke213 » Mon Aug 28, 2017 3:19 am

I forgot to mention but basically that's what I've heard from I sense via email as well. It's funny because they had it working for 24 hours there wish someone at square or 1and1 knew what they did during that stretch to get it back working ;)

Take care

Luke

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by luke213 » Wed Oct 04, 2017 3:13 am

So just an update for others in the same boat, as of right now it's back to communicating properly on my site. I don't know when it started, I've been checking my script every few weeks and hadn't had any results until just now. I'm waiting for word about whether this is temporary like last time or fixed, but let's hope that it's fixed and running properly;)

Luke

User avatar
New member

Posts

Joined
Thu Jul 08, 2010 2:35 am


Post by computrav » Mon Jan 15, 2018 11:46 am

This was also not working for me...

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
)
Note that I'm getting ERROR 60 whereas others in this thread are getting ERROR 35. In any case, they are both related to SSL issues.

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);
** This should of course NOT ever be used in any Production capacity, as it is telling cURL to ignore SSL cert issues. **

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"
3) Restart apache

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!

Newbie

Posts

Joined
Mon Jan 15, 2018 9:41 am

Post by spacedvb » Tue Feb 27, 2018 2:41 pm

Cause
PHP cURL is not using an updated set of root certificates to verify server certificates.

Around early September 2014, Mozilla removed the trust bits from the certs in their CA bundle that were still using RSA 1024 bit keys. This may lead to TLS libraries having a hard time to verify some sites if the library in question doesn't properly support "path discovery" as per RFC 4158. (That includes OpenSSL and GnuTLS.):

For Plesk 12.5 and higher:

Since 12.5 the URL http://curl.haxx.se/ca/cacert.pem can be specified in %plesk_dir%\admin\conf\panel.ini file:
[php]
curlCertificatesUrl="http://curl.haxx.se/ca/cacert.pem"


By default, curlCertificatesUrl setting is not specified in %plesk_dir%admin\conf\panel.ini.

During an upgrade or the Daily Maintenance task Plesk exports certificates to %plesk_dir%\Additional\PHPSettings\cacert.pem file.

If certificate does not work, try to download certificate from http://curl.haxx.se/ca/cacert.pem and put it into %plesk_dir%\Additional\PHPSettings directory.

This solution most be apply for Mozilla also

Newbie

Posts

Joined
Mon Feb 12, 2018 10:31 am

Post by giantherbs » Tue Apr 30, 2019 2:42 am

Php version 5.4.13 Curl is on and functioning. No errors in the curl test. Most recent version of Opencart, new install. Most recent version of the square extension.
Just a couple of things regarding this post: Initially my webhooks fields did not appear on setup, after trying to figure out why this was happening for a bit, I finally cleared my cache then the fields appeared. Once I was able to enter these, then the extension could connect. Here are some log files for errors that I was getting on setting up:
1) 2019-04-29 16:42:08 - PHP Notice: Undefined index: payment_squareup_sync_source in /var/www/vhosts/xxxxx.com/httpsdocs/store/admin/controller/extension/payment/squareup.php on line 1448
2) 2019-04-29 18:09:07 - PHP Warning: unlink(/var/www/vhosts/xxxxx.com/httpsdocs/store/admin/view/stylesheet/bootstrap.css): Permission denied in /var/www/vhosts/xxxxx.com/httpsdocs/store/admin/controller/common/developer.php on line 94
3) 2019-04-29 18:09:07 - PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxxxx.com/httpsdocs/store/admin/controller/common/developer.php on line 99
4) 2019-04-29 18:12:06 - The Apple Pay domain verification could not finish. The target directory does not exist, or has no write permissions: /var/www/vhosts/xxxxx.com/httpsdocs/.well-known

The only current error is the Apple Pay. I post the error logs here for the developers. With the first error, it was having a hard time finding the currency, even though it was enabled. I am unsure what error 2 and 3 are doing. Error 4, throws this alert on the square extension:
"There was an error when trying to sync locations and token: The Apple Pay domain verification could not finish. The target directory does not exist, or has no write permissions: /var/www/vhosts/xxxx.com/httpsdocs/.well-known"

There is also a warning at the top of the page in the square extension that says: "Make sure to enable online payments for your Square account. "

I have not run a test yet to see if the system is actually accepting cards or not. But I thought I would say, prior to refreshing my cache, when I tried to "connect" it would log me completely out, and send me to the opencart login screen. I am assuming it was doing this because, when it does connect - it sends you to the squareup.com login.

I don't really need Apple Pay as long as the system works, but I did want to post the data for the developers so that they could have data about what might be misfiring.

Thanks for building this!

Newbie

Posts

Joined
Fri Apr 26, 2019 11:15 am

Post by franktroy » Sat Aug 31, 2019 7:20 pm

I am just curious if there is a resolution to this issue. I ran into it as well on a new installation and get the following error.

Your Square access token has expired or has been revoked! Click here to re-authorize the Square extension.

When I click the connect button in the Square Extension I get the following.

Notice: Undefined index: access_token in /home/dooverta/public_html/opencart/admin/controller/extension/payment/squareup.php on line 633Warning: Cannot modify header information - headers already sent by (output started at /home/dooverta/public_html/opencart/admin/controller/startup/error.php:34) in /home/dooverta/public_html/opencart/system/library/response.php on line 36

New member

Posts

Joined
Sun Aug 18, 2019 5:32 pm

Post by cdowner » Sun Nov 17, 2019 10:20 pm

An error was encountered while refreshing the token: The `Authorization` http header of your request was malformed. The header value is expected to be of the format "Bearer TOKEN" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. "Bearer ABC123def456GHI789jkl0"). For more information, see https://docs.connect.squareup.com/api/c ... nseheaders. If you are seeing this error message while using one of our officially supported SDKs, please report this to developers@squareup.com.

Your Square access token has expired or has been revoked! Click here to re-authorize the Square extension

Newbie

Posts

Joined
Sat Feb 03, 2018 1:37 pm
Who is online

Users browsing this forum: No registered users and 6 guests