Support

Home Forums Event Espresso Premium Square Plugin Failed Again

Square Plugin Failed Again

Posted: November 7, 2023 at 7:29 pm


mkreik

November 7, 2023 at 7:29 pm

The Square plugin failed to reauthorize again. This has been happening every month since we started using the plugin in February. Nine months of this issue without it being resolved. You can see all of my prior support tickets. Please fix it.

Also, why do you prevent comments on open tickets? It requires us to create a new support ticket while the previous ones remain open without comments.


mkreik

November 14, 2023 at 11:33 am

Do you have a status on this issue? In the last support post we were told it was a high priority, but it would be helpful to know where you are in the process of fixing the plugin.


Tony

  • Support Staff

November 14, 2023 at 4:38 pm

This reply has been marked as private.


mkreik

November 16, 2023 at 11:13 am

Thanks for this information. I uploaded and updated the plugin from the link and checked the cron events to see if the AHEEA_Square_oauth_health_check showed up, and it did with the recurrence set to twice daily. In previous support post, you requested that I test that, and it didn’t show up so that’s a good sign.

Regarding the debug run, the output I received is string(2) “21”. Is that good?

Previous support post:
https://eventespresso.com/topic/square-oauth-token-expires-regularly/


Tony

  • Support Staff

November 16, 2023 at 11:45 am

That’s great so far!

So now… the oAuth key should renew after the 6th day (they are valid for 30days)… so 21 means you over that.

The next time the cron runs that should reset and shot 30 again.

So either later or tomorrow, run that code again and see if the number updates to 30/29…. if it does… its working!

Side note… please don’t force the cron go run manually to check the above, that’s going to reset the days but you don’t know if that will happen automatically and will need to wait another 6 days to test again.


mkreik

November 16, 2023 at 12:59 pm

Sounds good. I’ll let you know what I find. As far as the cron jobs, I didn’t do anything manually. I just searched the term AHEEA_Square_oauth_health_check, to see if it was there because the last time we worked on this it wasn’t. Do you recommend deleting the WP-Cron plugin?


mkreik

November 16, 2023 at 1:14 pm

When I logged into the WP dashboard this morning I saw the re-authorization failure message. Since I updated the plugin and ran the tests you requested, I decided right now to disconnect and reconnect Square to start fresh with 30 days. After doing that I ran the code and received this output: string(2) “29”. I’m assuming that’s good news. And that on 12/15 around this time it should refresh for another 30 days. Is that correct? Should I run the debug code on 12/15 to see if it shows 30 days?


Tony

  • Support Staff

November 16, 2023 at 3:39 pm

Do you recommend deleting the WP-Cron plugin?

No, not for now, keep it as it helps when checking if the cron is set.

When I logged into the WP dashboard this morning I saw the re-authorization failure message.

That means the cron ran but couldn’t renew your key… the key is valid for 30 days so if it can’t renew it keeps the current key and displays a notice to give time to fix it.

Since I updated the plugin and ran the tests you requested, I decided right now to disconnect and reconnect Square to start fresh with 30 days.

OK, so we are starting fresh, but…

After doing that I ran the code and received this output: string(2) “29”. I’m assuming that’s good news.

Yes, that’s good news, it means your key correctly connected and is valid for 30 days, but…

And that on 12/15 around this time it should refresh for another 30 days. Is that correct?

No, Square recommends refreshing the key every 6 days and the reason for that is part of what I mentioned above. When you obtain a key, it’s valid for 30 days, if we wait until day say day 29/30 and it doesn’t refresh it doesn’t give you any time to fix it before payments stop working (similar situation you were getting into when the key wouldn’t renew).

So that means:

Should I run the debug code on 12/15 to see if it shows 30 days?

No, you should run that code again in 6/7 days and it should ‘reset’ to show 30/29 days again each time. If the key doesn’t renew on day 6 the notice is displayed in the admin, the square payment method should still work at that point but the key couldn’t renew and will stop working after the key expires at the end of the days.

Give it 6 days, run the code and let me know what it shows…. if at any point from now over the next say 7 days you get a notice about the key not renewing let me know. At that point we’ll need to add some code to the site and see the specific request/response to figure this out (hopefully once and for all).


mkreik

November 16, 2023 at 9:43 pm

Will do. Thanks!


mkreik

November 27, 2023 at 11:51 am

It’s been 11 days and I reran the code and got this: string(2) “19”
which would get me to Dec 16. I will run it again on Dec 4 to see what I get.


Tony

  • Support Staff

November 27, 2023 at 2:19 pm

It’s been 11 days and I reran the code and got this: string(2) “19”

The token should have already refreshed and that gives us 19 days to troubleshoot before you end up back in the same old situation.

This is why this has been so tricky to troubleshoot, that version is refreshing the access token fine for me on multiple different servers/sites.

Install this plugin: https://wordpress.org/plugins/log-http-requests/

Once that has been installed and activated… go to Settings -> Cron Events.

Find ‘AHEEA_Square_oauth_health_check’, is that set to run EED_OAuthHealthCheck::scheduledHealthCheck() within the action column?

Hover over it and click run now.

Then re-run that test code I gave you above, still 19?


mkreik

November 28, 2023 at 2:07 pm

In cron events, I clicked on Run Now under AHEEA_Square_oauth_health_check where the action is EED_OAuthHealthCheck::scheduledHealthCheck() and then re-ran the test code in the Debug Console and the output is 17. How long does it take for the Run Now to complete. Is it instantaneous? Or should I wait a few minutes and re-run the debug?


Tony

  • Support Staff

November 28, 2023 at 2:23 pm

How long does it take for the Run Now to complete. Is it instantaneous?

It should be instant.

If you now go to Tools -> Log HTTP Requests.

Do you see a request to https://connect.eventespresso.com/square_sandbox/refresh?

If so, what is the request/response for that?

Or if you prefer I take a look directly within the admin you can send temp login details over using this form:

https://eventespresso.com/send-login-details/


mkreik

November 28, 2023 at 2:29 pm

When I go to Tools> Log Http Requests, there isn’t a request for https://connect.eventespresso.com/square_sandbox/refresh

I only see URLS for ipecho.net, tnedi.me, ident.me, font.google.apis, and api.wordpress.org


mkreik

November 28, 2023 at 2:36 pm

This reply has been marked as private.


Tony

  • Support Staff

November 28, 2023 at 3:44 pm

Thank you, so you’re site is missing the refresh token so Square isn’t going to refresh.

Can you disconnect Square and Reconnect it please, I want to view the logs ona connect request to confirm a value for the refresh token is being received by Square when you connect.


mkreik

November 28, 2023 at 4:58 pm

This reply has been marked as private.


mkreik

November 28, 2023 at 5:14 pm

This reply has been marked as private.


Tony

  • Support Staff

November 28, 2023 at 6:00 pm

Hmmm ok! Very strange.

The request to reconnect doesn’t provide a refresh_token when you authorize.

I’ve asked for some feedback on this and will let you know what we find.


mkreik

November 28, 2023 at 9:50 pm

Thanks! I look forward to learning the reason.


mkreik

January 9, 2024 at 12:45 pm

Do you have any updates on this post that is now closed to new comments: https://eventespresso.com/topic/square-plugin-failed-again/

Is there a way you can keep support posts open to new comments until they’re resolved? I have had create several while this issue has been open.


Tony

  • Support Staff

January 10, 2024 at 4:20 pm

Hi there,

I’ve reopened your thread and merged your latest reply into it, the forum automatically closes threads after a set amount of time but we can re-open them and merge new threads.

I have a new version of the Square add-on available to test a fix for this, we’ve updated the payment method to use the latest Square API version, refactored the authorization workflow and added some additional logged to the connect server.

I’ll include a link to download the latest version in a follow up reply to this.

Download the .zip then install it through Dashboard -> Plugins -> Add new -> Upload plugin, select the zip.

WordPress should tell you there is a version already installed and ask if you want to replace it, do so.

Make sure the Log HTTPS Requests plugin is enabled after replacing the Square plugin, disconnect and reconnect.

If you can then send me login details again I’ll review the logs again:

https://eventespresso.com/send-login-details/


Tony

  • Support Staff

January 10, 2024 at 4:21 pm

This reply has been marked as private.


mkreik

January 11, 2024 at 9:36 am

I have installed the plugin and disconnected and reconnected Square.


mkreik

January 11, 2024 at 9:36 am

This reply has been marked as private.


mkreik

January 17, 2024 at 4:01 pm

Any updates?


mkreik

January 17, 2024 at 4:02 pm

This reply has been marked as private.


mkreik

January 24, 2024 at 2:54 pm

Any update?


mkreik

January 24, 2024 at 3:13 pm

This reply has been marked as private.


Tony

  • Support Staff

January 25, 2024 at 6:19 am

Hi there,

My apologies for the delayed reply, we are currently waiting on a response from Square regarding this and I don’t have any extra info until they respond, but I realised it looks like I’m just ignoring your thread.

The issue currently is that the request to generate an access_token from Square, should (and usually does) generate a refresh_token. The access_token is valid for 30 days and needs to be refresh within that timeframe using th refresh_token…. but you don’t have one as they didn’t return one when generating earlier.

The odd part, is that the requests are set up to work as the documentation states, it works for some and not others so it appears to be account specific (which also explains why we had such a hard time tracking this down, our accounts work!).

So, we’ve opened up a case with Square and asked them to investigate this which is what we are currently waiting on.

I ran the debug and can see 16 days left until the authorization expires so it still isn’t refreshing.

Thank you for checking this, it does indeed help to confirm the issue.

To prevent you running into issues after 16 days you can manually disconnect and reconnect at any time to ‘reset’ that limit back to 30 days, you don’t need to wait for it to expire.

Side note – today I tried logging back into the site to copy the request details again and confirm but it looks like the password has been changed, could you resubmit the details again?


mkreik

January 25, 2024 at 7:35 am

While the debug says we have 16 days left, we have this message in our dashboard, “Authorization health check failed with error: “Could not refresh the token” Please try to re-authorize (reConnect) for the Square payment method to function properly.”

If that debug run was something we could rely on to tell us when the refresh token was to expire, it does not appear to be the case.

We don’t have any failed transactions yet, but I will need to reconnect anyway. A few questions about the refresh/reauthorization:

1) Does an EE or EE Square plugin update require us to disconnect and reconnect Square?
2) Does Square two factor authentication prevent the token from refreshing? I asked this question in February or March 2023 and at the time support said that Square two factor authentication should not be the issue.
3) If we have the WooCommerce Square plugin, will that affect the refresh? I also asked that last year and was told it shouldn’t be the issue.


mkreik

January 25, 2024 at 7:48 am

This reply has been marked as private.


Tony

  • Support Staff

January 25, 2024 at 4:15 pm

1) Does an EE or EE Square plugin update require us to disconnect and reconnect Square?

Not usually no, updates do not require re-auth, they still us the same keys.

However, a refresh_token is only generated when the access_token is generated, you can’t request them after that. So in your case, because your not getting a refresh token at all, to test a fix you need to disconnect and reconnect as we make changes to see if you get a refresh_token.

That’s not something you should need to do once we get this fixed.

2) Does Square two factor authentication prevent the token from refreshing? I asked this question in February or March 2023 and at the time support said that Square two factor authentication should not be the issue.

No, two-factor authentication shouldn’t be a problem. You use that to log into the account and grant access.

3) If we have the WooCommerce Square plugin, will that affect the refresh? I also asked that last year and was told it shouldn’t be the issue.

No, it shouldn’t.

“Authorization health check failed with error: “Could not refresh the token” Please try to re-authorize (reConnect) for the Square payment method to function properly.”

This is telling you the access_token could not be refreshed, when you connect the Square payment method will no try to refresh the access_token there less than 24 days remaining on the refresh_token. So when the above notice pops up, it means that your access token will expire 30 days after the connection was originally made.

We don’t have any failed transactions yet, but I will need to reconnect anyway. A few questions about the refresh/reauthorization:

We’ve made some changes to the payment method Square API version number and made a couple of changes server side to see if it helps so if you are about to reconnect I’ll upload the latest changes and add a link in private reply for you to try that and see if pulls in a refresh_token.


Tony

  • Support Staff

January 25, 2024 at 4:16 pm

This reply has been marked as private.


Tony

  • Support Staff

January 25, 2024 at 4:20 pm

This reply has been marked as private.


mkreik

January 29, 2024 at 3:47 pm

I’ve uploaded the new plugin. FYI, the “Please try to re-authorize (reConnect) for the Square payment method to function properly.” is on the dashboard all of the time even though I’ve reconnected last week and even though transactions continue to process correctly.


Tony

  • Support Staff

January 31, 2024 at 6:36 pm

The above message sitting on the admin page means the Square payment method couldn’t refresh the oauth token (yours can’t as it has no refresh_token). It’s intended as a ‘nag’ notice to show there is an issue with Square which needs to be fixed before the Auth token expires.

Just noting, we are still waiting on a response from Square to move forward with this.

The support post ‘Square Plugin Failed Again’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso