Support

Home Forums Event Espresso Premium Square Payments Token Expiration Update?

Square Payments Token Expiration Update?

Posted: July 30, 2024 at 6:07 pm

Viewing 19 reply threads


pawmedia

July 30, 2024 at 6:07 pm

Are there any updates on the issue concerning token expiration for Square payments? We thought this might have been fixed, but it just happened a day or two ago and it resulted in over $2000 of lost payments before it was brought to our attention. 🙁


Tony

  • Support Staff

July 31, 2024 at 8:38 am

Can you run this code on the site:

https://gist.github.com/Pebblo/e87c230fa2b351ff8a330925f02ef636

And post the result here in a private reply?

The quick way I do it is using Debug Bar and Debug Bar Console.

We swapped out all of the possible calls within the Square plugin to use the latest API versions etc and didn’t run into issues since but I can review the code from the above and see from there.


pawmedia

July 31, 2024 at 11:14 am

This reply has been marked as private.


Tony

  • Support Staff

July 31, 2024 at 1:29 pm

The issue we had with Square is they didn’t return a refresh token for oAuth so we couldn’t refresh the token when it expired after 30 days.

Your data contains a refresh_token and refreshed recently.

How long ago did this this last happen?

Edit – I’m aware you said one or two days ago above, but I’m looking to see if you have anything more specific so I can check into it.


pawmedia

July 31, 2024 at 6:43 pm

I looked for the first complaint we received via email and it was from the 27th. We immediately went to the payment method page, saw that it failed the health check and disconnected / reconnected to square.

I’m guessing you would need this code run after the health check fail and before a reconnect to be useful, right?


Tony

  • Support Staff

July 31, 2024 at 11:33 pm

Not really, the snippet pulls in Square’s metadata and the issue we had with Square is that refresh_token was missing from that (they didn’t send one)… but your site now has one (I can’t tell if it did previously). So that snippet just tells me your site has all of the relevant data it needs to keep Square working right now but it won’t tell me why it failed if it does stop working (for example if it stopped tomorrow and you ran that code, it could show an empty refresh token but it won’t tell me why that happened).

Square tokens are valid for 30 days and the above had 25 days remaining which puts it right on the 27th so it all fits, but it doesn’t explain why.

The token should try to refresh once the $daysLeft variable from the above snippet is at 24 or less.

So if you run that snippet again today, it should show the refresh_token back at 30, the time depends on your server’s time but if by tomorrow that value is at 23 then the token isn’t refreshing even with a refresh_token.

So let’s start with running that snippet again today, can you paste the return here again, please?


pawmedia

August 1, 2024 at 3:35 pm

This reply has been marked as private.


Tony

  • Support Staff

August 6, 2024 at 8:28 am

Ok, can you run that code one more time today, please?

Also, can you check for the cron task on the site? To do that you can use:

https://wordpress.org/plugins/wp-crontrol/

Then go to Tools -> Cron Events.

Search for AHEEA_Square_oauth_health_check

Is it listed and if so, what does it say in the next run column and does it show:


EED_OAuthHealthCheck::scheduledHealthCheck()
wp-content/plugins/eea-square-gateway/modules/EED_OAuthHealthCheck.module.php:109

`

within the Action column?


pawmedia

August 6, 2024 at 3:25 pm

This reply has been marked as private.


Tony

  • Support Staff

August 8, 2024 at 6:48 am

That will likely prevent the token from refreshing.

I have a new version of the Square add-on with some additional checks for that cron to make sure its running, it’s also reworked the refresh call to basically double and triple check it runs.

I can send that over if you’d like to try it?

Failing that I’ll push the update live on Monday. I don’t push updates out for payment method’s right before the weekend just incase anyone runs into issues as I want to make sure support is available.

In terms of getting the cron on the site active again, deactivating and reactivating the Square add-on (or updating it) should re-add the cron as it stands.


pawmedia

August 8, 2024 at 8:41 am

This reply has been marked as private.


Tony

  • Support Staff

August 8, 2024 at 12:27 pm

Email sent 🙂


pawmedia

August 8, 2024 at 1:43 pm

After installing that update, the cron job is now there and set to run twice a day.

I ran it manually and the token now has a new expiration date of September 7th.

I’m hoping this issue is now resolved. Thanks!!


Tony

  • Support Staff

August 8, 2024 at 2:01 pm

Run the snippet above in 7+ days time, if the days remaining goes below 24 days it means the Auth token isn’t being refreshed.

If that happens, let me know.


pawmedia

August 16, 2024 at 11:09 am

I just checked again and the expiration date is now September 13th. Hoping this is finally resolved now. Thanks!


Rio

  • Support Staff

August 17, 2024 at 7:14 am

Awesome. Please keep us updated if there’s problem.

have a wonderful day.


pawmedia

August 21, 2024 at 1:52 pm

This reply has been marked as private.


Tony

  • Support Staff

August 21, 2024 at 4:24 pm

Hmmm, interesting!

So the notice was added for that reason, it gives an indication that something was up with refresh request.

However, based on your Sqaure meta data, your access token was still valid and Square would likely have continued to work for at least another 27 days… possibly refreshing within that time and removing the token.

(You know more in-depth how the payment method and Square connection works than most of our users would, so the idea being that the notice is thrown and the user checks in to see why, usually with us, were we investigate from there but you’ve reconnected to fix)

Doesn’t look like those failures are logged, I’ll check in with our devs as to why as they could be useful.


pawmedia

August 21, 2024 at 6:52 pm

Yeah… the connection might have still been working, but there were two other customers actively checking out at the time so I didn’t want to risk it. I just ran your code and quickly reset it. 🙂

The payments page was also displaying the failed health check error.

When this happens again, I’ll quickly try registering to see if square shows up properly on the payments page.


Tony

  • Support Staff

August 22, 2024 at 4:17 am

Yeah… the connection might have still been working, but there were two other customers actively checking out at the time so I didn’t want to risk it. I just ran your code and quickly reset it. 🙂

Sorry, I wasn’t picking holes at your reconnecting here, I get it. I just meant that generally if people see that notice they would contact us before reconnecting and we could try to see what failed…. you already know you ‘need’ to reconnect before issues come up… but… with that access token still being valid things ‘should’ have still been ok for the remaining of the access token lifetime.

The payments page was also displaying the failed health check error.

In the admin? If so that’s expected.

Once that notice is set it’s shown everywhere so the admin should see it and get it fixed before the token expires.

When this happens again, I’ll quickly try registering to see if square shows up properly on the payments page.

The health check runs on WP_CRON automatically twice daily… what I’m suspecting happened currently is the requested failed for some reason and that triggered the notice. It wouldn’t be a refresh failure as its not due and you refresh_token is valid, so ‘somehting’ happened on the request which triggered the notice…. but it may be something we can set to ignore.

All of that is based on assuming the connection was actually still valid even with the notice shown and will change if we find that wasn’t the case but right now I’m thinking its most likely a false positive on the notice.

Viewing 19 reply threads

The support post ‘Square Payments Token Expiration Update?’ 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