Results 1 to 10 of 821

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,732
    Plugin Contributions
    27

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    Square Credit Card Payments - SQ-NONCE-FAILURE

    Error Log:

    PHP Notice: Exception when calling LocationsApi->listLocations: [HTTP/2 401] {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"This request could not be authorized."}]} in /home/***/public_html/shop/includes/modules/payment/square.php on line 703

    On-screen error in checkout:
    We could not initiate your transaction because of a problem with the card data you entered. Please correct the card data, or report this error to the Store Owner: SQ-NONCE-FAILURE


    The fix:
    Turn off javascript loading for features in the site not needed in the checkout pages.

    Found in:
    includes/templates/YOUR_TEMPLATE/common/html_header.php

    also may be in tpl_header.php (not in my case with this site)
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

  2. #2
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    Square did a change to their API that has broken this module. Customers are seeing HTTP 500 after clicking Confirm Order on Step 3. I'm getting the following error in my logs:

    Code:
    [04-Mar-2020 13:37:39 America/Chicago] PHP Fatal error:  Uncaught Error: Call to undefined method SquareConnect\Configuration::callApi() in \www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php:134
    Stack trace:
    #0 \www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php(78): SquareConnect\Api\OAuthApi->obtainTokenWithHttpInfo(Object(SquareConnect\Model\ObtainTokenRequest))
    #1 \www\store\includes\modules\payment\square.php(692): SquareConnect\Api\OAuthApi->obtainToken(Object(SquareConnect\Model\ObtainTokenRequest))
    #2 \www\store\includes\modules\payment\square.php(557): square->renewOAuthToken()
    #3 \www\store\includes\modules\payment\square.php(492): square->token_refresh_check()
    #4 \www\store\includes\modules\payment\square.php(356): square->getAccessToken()
    #5 \www\store\includes\classes\payment.php(245): square->before_process()
    #6 \www\store\includes\modules\checkout_process.php(84): payment->before_process()
    #7 \www\store\includes\modules\pages\checkout_process\header_php.php(14): require('\\www\\sto...')
    #8 \www\store\index.php(36): require('\\www\\sto...')
    #9 {main}
      thrown in \www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php on line 134
    The last successful order I had with this module was on the 26th of February.

    Unfortunately, because of this problem, I'm not able to use the Admin site Payments Module configuration page to disable this module so I can enable another. Help!

  3. #3
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    Quote Originally Posted by Fjolsvith View Post
    Square did a change to their API that has broken this module.
    Um ... The error suggests that you've changed the PHP files associated with this module. If it was something Square did only on their end, the error would be different.

    What's the back-story of changes to the PHP files?

    Which set of files are you using? v0.9xxx? or 1.0-beta? Or a hybrid of files that you've changed independently?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    Quote Originally Posted by DrByte View Post
    Um ... The error suggests that you've changed the PHP files associated with this module. If it was something Square did only on their end, the error would be different.

    What's the back-story of changes to the PHP files?

    Which set of files are you using? v0.9xxx? or 1.0-beta? Or a hybrid of files that you've changed independently?
    Ah, you are correct. I modified modules\payment\square.php around line 318 to add extra information about the order to the description passed to square:

    Code:
    	if (sizeof($order->products) < 100) {
    	    $p = '';
                for ($i = 0; $i < sizeof($order->products); $i++) {
                    $p2 = $order->products[$i];
    				if (!$p == '') {
    					$p .= ', ';
    				}
    				$p .= '(' . $p2['qty'] . ') ' . $p2['name'] ;
                }
            }
    		$p = 'Item(s) Ordered:' . $p;
    		
    		$d = 'Delivery Address: ' . $order->delivery['street_address'] . ', ' . $order->delivery['city'] . ', ' . $order->delivery['state'] . '  ' . $order->delivery['postcode'] . '  tel:' . $order->customer['telephone'];
    		$p .= '; ' . $d;
    
            $note = htmlentities(trim($order->billing['firstname'] . ' ' . $order->billing['lastname'] . ' ' . $p . ' ' . STORE_NAME));
    I had done this for the Stripe module and it worked great there because it basically duplicated the order information on the email that Stripe sent out to customers, which helped reassure them. The average order at my store is $3.5k, and some people are apprehensive about making such big purchases on the internet.

    I recently switched from Stripe to Square, and that is the reason for the module change. I will go read up how long the note field can be and modify the code to fit.

    Edit: So I reverted the payment module files back to the 1.0-beta (which is the version I'm using) and I still have the OAuthApi.php line 134 error.
    Last edited by Fjolsvith; 5 Mar 2020 at 03:54 AM.

  5. #5
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    I did receive an email from the Square Developer Team about new API updates and deprications yesterday, so I am pretty sure it is something to do with their API changes. I can forward it to you if you like, just send me a private message.

  6. #6
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    Quote Originally Posted by Fjolsvith View Post
    Ah, you are correct. I modified modules\payment\square.php around line 318 to add extra information about the order to the description passed to square:

    Code:
        if (sizeof($order->products) < 100) {
            $p = '';
                for ($i = 0; $i < sizeof($order->products); $i++) {
                    $p2 = $order->products[$i];
                    if (!$p == '') {
                        $p .= ', ';
                    }
                    $p .= '(' . $p2['qty'] . ') ' . $p2['name'] ;
                }
            }
            $p = 'Item(s) Ordered:' . $p;
            
            $d = 'Delivery Address: ' . $order->delivery['street_address'] . ', ' . $order->delivery['city'] . ', ' . $order->delivery['state'] . '  ' . $order->delivery['postcode'] . '  tel:' . $order->customer['telephone'];
            $p .= '; ' . $d;
    
            $note = htmlentities(trim($order->billing['firstname'] . ' ' . $order->billing['lastname'] . ' ' . $p . ' ' . STORE_NAME));
    After reviewing it, I figured it makes sense to incorporate this too, so (a modified form of) this is now in v1.0.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    bug Re: Square Payment Module for Zen Cart [Support Thread]

    Okay, I found a bug in the 1.0 beta. It is in includes\modules\payments\square.php line 664:

    Code:
            $oauthApi = new SquareConnect\Api\OAuthApi($this->_sqConfig);
    The OAuthApi class initializes NOT with SquareConfiguration, but rather with ApiClient. See lines 34-45 of includes\classes\vendors\square\connect\lib\Api\OAuthApi.php:

    Code:
        /**
         * Constructor
         * @param \SquareConnect\ApiClient|null $apiClient The api client to use
         */
        function __construct($apiClient = null)
        {
            if ($apiClient == null) {
                $apiClient = new ApiClient();
                $apiClient->getConfig()->setHost('https://connect.squareup.com');
            }
      
            $this->apiClient = $apiClient;
        }
    So this is the error that is being thrown by this bug. This is the problem I have been experiencing:

    Code:
    [15-Mar-2020 20:47:11 America/Chicago] PHP Fatal error:  Uncaught Error: Call to undefined method SquareConnect\Configuration::callApi() in C:\wamp\www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php:134
    Stack trace:
    #0 C:\wamp\www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php(78): SquareConnect\Api\OAuthApi->obtainTokenWithHttpInfo(Object(SquareConnect\Model\ObtainTokenRequest))
    #1 C:\wamp\www\store\includes\modules\payment\square.php(676): SquareConnect\Api\OAuthApi->obtainToken(Object(SquareConnect\Model\ObtainTokenRequest))
    #2 C:\wamp\www\store\includes\modules\payment\square.php(541): square->renewOAuthToken()
    #3 C:\wamp\www\store\includes\modules\payment\square.php(476): square->token_refresh_check()
    #4 C:\wamp\www\store\includes\modules\payment\square.php(718): square->getAccessToken()
    #5 C:\wamp\www\store\includes\modules\payment\square.php(733): square->getLocationsList()
    #6 C:\wamp\www\store\includes\modules\payment\square.php(1264): square->getLocationsPulldownArray()
    #7 C:\wamp\www\store\wEn-nImda4eman\modules.php(307) : eval()'d code(1): zen_cfg_pull_down_square_locations('', 'MODULE_PAYMENT_...')
    #8 C:\wamp\www\store\wEn-nImda4eman\modules.php(307): eval()
    #9 {main}
      thrown in C:\wamp\www\store\includes\classes\vendors\square\connect\lib\Api\OAuthApi.php on line 134
    I believe I fixed it by modifying line 664 to:

    Code:
            $oauthApi = new SquareConnect\Api\OAuthApi($this->_apiConnection);
    Last edited by Fjolsvith; 16 Mar 2020 at 03:31 AM.

  8. #8
    Join Date
    Mar 2016
    Location
    Norcatur, Kansas, USA
    Posts
    80
    Plugin Contributions
    3

    Default Re: Square Payment Module for Zen Cart [Support Thread]

    Ah, good. I see you fixed the above bug in the 1.0 release. And, I'm proud of myself for devising the correct fix!

 

 

Similar Threads

  1. WordPress® for Zen Cart® (wp4zen) [Support Thread]
    By DivaVocals in forum All Other Contributions/Addons
    Replies: 109
    Last Post: 1 Dec 2024, 01:36 PM
  2. Bambora/Beanstream Payment Module Support Thread
    By swguy in forum Addon Payment Modules
    Replies: 127
    Last Post: 26 Mar 2021, 04:13 PM
  3. v154 Support Thread: AddToAny for Zen Cart (The Universal Sharing Platform)
    By DivaVocals in forum All Other Contributions/Addons
    Replies: 8
    Last Post: 8 Apr 2019, 02:39 PM
  4. Layaway Payment Module Support Thread
    By Danielle in forum Addon Payment Modules
    Replies: 0
    Last Post: 21 Nov 2006, 06:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg