Hi @suncountryiris,
Thanks for reaching out, and I’m sorry to hear you’re running into this with your Square payments. I completely understand how disruptive that can be for your customers.
The error is related to Square access tokens expiring. WPForms handles token refreshing automatically in Live Mode through a scheduled background task, but there are cases where it may not be running frequently enough, which can cause tokens to expire before they’re renewed.
Here are a couple of things to check and try:
1. Confirm you’re using Live Mode
In your WordPress dashboard, go to WPForms > Settings > Payments > Square and make sure your connection is set to Live Mode (not Test Mode). In Test/Sandbox Mode, tokens are not refreshed automatically, and you’d need to click the Refresh Tokens button manually each time.
2. Verify the scheduled task is running
If you’re already in Live Mode, you can also confirm the background task is active by going to WPForms > Tools > Scheduled Actions and looking for a task named wpforms_square_refresh_connection. If it’s not listed there, it may not be running on your server. In that case, I’d recommend reaching out to your hosting provider and letting them know the Action Scheduler task isn’t being created.
3. Increase the token refresh frequency
If the Action Scheduler tasks have the Complete status and you’re still seeing the error, you can increase how often WPForms refreshes the Square tokens by adding the following code snippet to your site:
function as_square_callback($interval) {
// Set the time in seconds for the desired interval
$interval = 14400;
return $interval;
}
add_filter( 'wpforms_square_admin_connect_schedule_refresh_interval', 'as_square_callback', 10 );
This sets the refresh interval to every 4 hours (14,400 seconds), which should prevent the tokens from expiring between refreshes. You can adjust that number if needed — just keep in mind that Square recommends refreshing tokens at least every 7 days.
In case it helps, here’s our tutorial with the most common ways to add custom code like this. For the most beginner-friendly option in that tutorial, I’d recommend using the WPCode plugin.
Hope this gets things sorted out for you! Let me know how it goes.