• Resolved cvstock33

    (@cvstock33)


    Every few months my wife’s website loses the ability to take online orders via Square which is connected through WooCommerce in her WordPress site. We don’t know it’s down until a customer tells us they can’t place their order.

    I contacted Square who said to talk to WooCommerce about it. WooCommerce has paid support options but first they suggest going to this www.remarpro.com forum for help.

    This is not a problem that is unresolved right now if you look at my wife’s site. I just fixed it again (September 26th) but suspect it will pop up again in a month or 2. This has happened 2 or 3 times since first of the year.

    Everything gets working again fine if I disconnect from Square in WordPress admin panel and then reconnect Square by authenticating it with account email and password. WooCommerce pops up and says we are authenticated. Then orders go through again just fine until it happens again. I always place a test order after re-authenticating and it integrates and processes my credit card just as it is designed to do.

    So the web developer who designed site originally using a custom WP template he made tells me I fixed the problem and everything must be fine (?) But then it will stop processing orders again in a few weeks or months and we have no way of knowing it until a customer gets a failed transaction and lets us know our site is not accepting credit cards. He’s not returning my calls at the moment, he may not be interested in helping me with an intermittent problem like this.

    Does anyone have any ideas why it would do this periodically? Can you see anything in the coding that suggests the problem? I’m not a designer or web developer but have a working knowledge of WordPress.

    When we have this credit card disconnect problem the customers sees this message in their checkout page:

    “Error: Square was unable to complete the transaction. Please choose another means of payment”

    I update WooCommerce manually when I have this problem, just because I’m in the admin page, but simply updating does not get anything going again. I don’t use auto-updates just because when Square is functioning properly I really don’t want to have an auto-update cause a problem. The only fix to this problem is to disconnect and reconnect Square to Woo Commerce, just updating Woo or WordPress itself does not bring Square back online. I’ve tried that to try to isolate the problem but had no luck.

    It’s frustrating because we don’t know it’s stopped working unless someone tells us their order failed. Makes for a very lousy first impression with a customer. Does it somehow have something to do with WooCommerce or WordPress updates? I generally don’t update plugins often, its a part-time business site and I don’t get into the admin panel very often. If its not broke why fix it. If its processing credit cards I just leave it alone. This week’s breakdown happened without me being in the admin panel in several months, so I also updated WP as well yesterday, along with WooCommerce to latest versions.

    Thanks for any insight or direction on this issue. We love Square and my wife uses the app on her phone all the time, so it was a no-brainer to connect it to her website and have all credit card processing flow through 1 account. Her app never shuts down, it’s only the integration of Square for online orders that causes the problem for customers online on a pretty regular basis.

    • This topic was modified 6 years, 6 months ago by cvstock33. Reason: typo in subject line
    • This topic was modified 6 years, 6 months ago by cvstock33. Reason: another typo

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hi @cvstock33,

    This is something that happens when the OAuth access token expires. It is also something that requires Square to be disconnected/reconnected on the WooCommerce side, but it is due to the token passed from Square expiring. We are working on an item that will display a message if the token expires, and we will have it in a future update though no time table is currently set.

    I know this is not the answer you were hoping for, but it is on our radar and something we are working on. Feel free to let us know more if you like, and thank you very much for the details you have provided so far. Please keep watch for updates for more!

    Thread Starter cvstock33

    (@cvstock33)

    Thanks so much for the reply. I thought this was something beyond my control and was going on behind the scenes with Square, WOO and/or WP.

    Do you have any idea how long a token usually lasts before expiring? i.e. Is it a fixed time frame set by Square such as 60 days or 90 days? Then I could make a calendar entry to login and reset the connection at the right time so a customer never sees this problem again.

    Thank you very much..!

    • This reply was modified 6 years, 6 months ago by cvstock33.
    Thread Starter cvstock33

    (@cvstock33)

    Another thought, you mention working on an item to display a message if a token expires, would that message appear on the public website or would it be something that appears only if I login to the admin page?

    Ideally we won’t want it displayed on public portion of website, but it would be amazing if that message could generate an email to a site manger that a token has expired. That way casual webmasters like myself would be notified to login immediately as I don’t have any need to login much to the admin page for a rather static, part-time business website. Big-time users would be in the admin page every day and deal with notifications/messages right away because that’s there full-time job.

    If not an email directly regarding an expired token, is there already a function we can set in WordPress that allows for an email notice whenever there is a new message or update notification appearing in our admin page? That functionality may already exist in WP but as a novice user I have not uncovered it yet. If not existing now, perhaps that’s another improvement you can consider to WP updates.

    Thank you!!

    Hi @cvstock33 – in your Square logs, are you seeing errors that start with Renewing expired token error... ?

    Square allows the token to live for 30 days before it expires. Then it gives 15 days grace period for the application to renew itself. This plugin should handle the renewal for you given the condition that your site has been accessed within the 15 days so that cron jobs can fire.

    Thread Starter cvstock33

    (@cvstock33)

    Where do I find Square logs? I am not experienced with WP. I don’t have any cron jobs that I have set up knowingly.

    The problem according to Square support is the expiration of the OAuth token every 30 + 15 days. A website like mine that is used infrequently will always see this problem. It’s really dumb but I guess they do it for security reasons.

    Square says the token must be reauthorized by connecting/disconnecting Woo Commerce at least every 45 days which me and others have figured out. This is really dumb for Square to put us through this but they are passing the buck. They say talk to Woo Commerce who says talk to Square or WordPress. Infuriating!

    * Does anyone know if the token is automatically reauthorized if you have live orders placed within the 45 day period? Or is every Square user regardless of order volume having this issue?

    1) Is there some way to write a cron job in WordPress that will reauthorize the token for all of us suffering from this problem? Can WordPress bypass the WooCommerce plugin and reauthorize the token directly for us with this cron job?

    2) How do you add a cron job to WordPress? I don’t see anything in the dashboard referring to cron jobs.

    3) What would be the code/syntax for the cron job?

    Many thanks for your input.

    @cvstock33 – go to woocommerce in your menu and select status. Then on that page go to the “Logs” tab and there will be a dropdown which you can choose the log you want to view. Find ones related to Square and click on view. From there you can search for the error term I described.

    Don’t worry about the cron jobs as those are setup for you when you activated the plugin. We need to first determine if your issue is indeed to do with the expiring tokens NOT able to renew itself.

    Thread Starter cvstock33

    (@cvstock33)

    Hi Royho. Thanks for getting right back to me. Unfortunately all I see on the logs page in WooCommerce plugin is a single one that says “test-log.log” and its date is today at 3:44 PM. So it has not been generated yet (?) and when I view it it is blank. Is there some kind of setting that needs to be turned on to store logs?

    I see in WooCommerce settings a green check mark next to “log directory writable” and then a long directory ending with ..wc-logs/

    Is there another way to find logs? Or maybe it’s never written any logs because Woo doesn’t interpret expired Token as an error?

    Thanks

    @cvstock33 – If you don’t see it, it could mean you didn’t turn on your logs for Square. You can see where that setting is here https://cld.wthms.co/7aW5k6

    Yes it will generate the error I am referring to if that was the cause. So if you turn it on now, you would have to wait until the next occurrence of this issue before you will see any logs. Feel free to reply back once you have that data.

    Thread Starter cvstock33

    (@cvstock33)

    You are correct. I checked the box in Square settings to log error messages. I’ll get back to you in a month when it shuts down again.

    Meanwhile, do you know if the token reauthorizes automatically if I have live orders come through prior to it expiring every 30 + 15 days?

    One troubleshooting site I read mentioned that the problem relates to inactivity, if no orders come through at least every 45 days then Square assumes the site it is linked to is shut down and closes down the connection for security reasons. But if it’s a regularly active site taking orders frequently, the token stays authorized because each new order re-initiates another 45 day authorization period. Thus active sites never run into this problem like a small infrequently-used site does.

    Thanks again for your help today.

    Yes it is possible if you have zero activity with Square whether that is transactions or syncing, then your token may not renew in time of the 45 days and requires a full user authentication.

    So a possible work around for this is turn on auto inventory sync. This would still require “some” activity on your site but at least it won’t require a transaction. So even if a single person visits your site, this cron would trigger.

    Thread Starter cvstock33

    (@cvstock33)

    I will set up the auto inventory sync and see what happens. I know there are several choices in WooCommerce settings.

    1) Do I enable both? or just auto inventory sync?
    2) It says “items must have an SKU to sync” We have no SKUs for my wife’s services. Does that matter? Or is it just a question of getting the cron job to get WooCommerce and Square to talk thereby re-authorizing the token?

    Many Thanks!!

    This is what it says in WooCommerce Square settings:

    Synchronization

    Determine which aspects of your product catalog to synchronize between WooCommerce and Square. Products need to have SKUs set for each variation.
    Enabled

    Enabled
    Products

    Basic Product information will be synced, excluding Categories and Inventory.
    Square Inventory Sync

    Square Inventory Sync
    Enable

    For automatic inventory syncing from Square to WooCommerce, this needs to be enabled. It will poll the inventory from Square on an hourly basis.

    Thread Starter cvstock33

    (@cvstock33)

    I have been studying more about WooCommerce Square and several troubleshooting sites mention creating a cron job specifically for refreshing the square token. If your suggested work-around to have the site sync inventory does not work to refresh the token, perhaps a simple script in a cron job is the best answer? I’m not a PHP expert at all but did some research today.

    I have found that WooCommerce Square plug-in has a file that is called:
    “class-wc-square-admin-integration.php ( PHP script text )”

    Within that script are the instructions for obtaining the token from the best I can understand it. It contains this code, but I do not know what all the syntax means, but notice it speaks about the token:

    class WC_Square_Integration extends WC_Integration {
    private $oauth_connect_url;
    private $merchant_access_token;

    /**
    * Constructor
    */
    public function __construct() {
    $this->id = ‘squareconnect’;
    $this->method_title = __( ‘Square’, ‘woocommerce-square’ );
    $this->method_description = __( ‘Connect with Square to start syncing your products and inventory and also accept credit card and debit card payments in your checkout.’, ‘woocommerce-square’ );
    $this->merchant_access_token = get_option( ‘woocommerce_square_merchant_access_token’ );

    $this->maybe_save_token();
    $this->maybe_delete_token();

    $this->init_form_fields();
    $this->init_settings();

    $this->oauth_connect_url = ‘https://connect.woocommerce.com/login/square’;

    if ( WC_SQUARE_ENABLE_STAGING ) {
    $this->oauth_connect_url = ‘https://connect.woocommerce.com/login/squaresandbox’;
    }

    add_action( ‘woocommerce_update_options_integration_’ . $this->id, array( $this, ‘process_admin_options’ ) );
    add_filter( ‘woocommerce_settings_api_form_fields_’ . $this->id, array( $this, ‘maybe_render_locations’ ) );

    Would creating a cron job to simply run this PHP file script every month refresh the token directly? Or could we edit/create a similar script that contains pieces of the above code to do a direct refresh? Other developer sites I have seen today mention running the “square_handler.php” every 30 days or so via a cron job, but the WooCommerce Square plugin does not seem to have a file script by that name.

    I’m just trying to find the best answer to this issue so that my wife does not lose any future orders. She had 2 sales that were abandoned when the online transactions failed due to Square token being expired and those customers never came back. So that was a couple hundred dollars in lost revenue.

    Thanks again for your help.

    Just enable the inventory sync is enough I believe. Even without SKU, it still goes through the authentication first and at that time it should process the renewal if token is expired.

    Thread Starter cvstock33

    (@cvstock33)

    OK, I’ll watch this and try a test order in 45 days to see if Square has been deactivated. And see if I get any error logs too.

    Thanks for the help and I hope this thread helps others who have seen this issue; without doing a lot of research it’s very hard to figure out the token is behind the credit card failures. I just assumed that once the account was properly integrated with WooCommerce it would stay that way forever but obviously websites with few transactions run into the 45 day expiration issue that bigger sites never think about. I appreciate your time helping me get a handle on this.

    We will go ahead and mark this issue as resolved, but if you keep seeing it happen feel free to open a new thread – the more visibility the better ??

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Every few months Square stops working in WooCommerce and we can’t take orders’ is closed to new replies.