• Resolved suncountryiris

    (@suncountryiris)


    On my website (suncountryiris.org) I have installed WPForms lite and are using Square for payments on a couple forms. It has been working great until recently when an error message is received by the user indicating that the square token is not valid…. Apparently the tokens need to be renewed. I have searched for the data supporting on how to renew tokens but have come up empty… Any guidance would be appreciated.

    Darol

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    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.

    Thread Starter suncountryiris

    (@suncountryiris)

    Thank you for your response. I verified that WPForms was running in the live mode and checked the scheduled actions for “wpforms_square_refresh_connection”. I saw “completed” actions during the entire period (no “failed” actions)….. Go figure. In researching my issue a day or two ago I read something that was posted about purging the website cache… I purged the cache AND I did a little snooping around the dashboard under wpforms > settings > payments and disconnected and reconnected the Square settings. I presume one of these additional actions resolved the issue as the club member who had the token issue was able to complete the transaction earlier today. Thanks for your assistance.

    Darol

    Plugin Support Ralden Souza

    (@rsouzaam)

    Hi @suncountryiris,

    Thanks for the update!

    It’s great to hear the issue resolved itself after purging the cache and reconnecting Square. Really glad to hear your club member was able to complete the transaction after the troubleshooting steps.

    Wishing you smooth transactions from here on out! If you ever have any other questions, feel free to ask.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.