Quote Originally Posted by carlwhat View Post
ok. you have new credentials. and you are trying to get the details of an order that made use of previous credentials. that is the problem you are experiencing.

i would like to point out that i do not use square (nor do any of the few clients i have); and i only decided to code this module at the request of one of the admins.

i tried to follow the path of the previous square module, and really i never liked the idea of making an API call every time someone is looking at an order in the admin. it is a waste of bandwidth IMO, and totally unnecessary. if one looks at my authorize.net card on file module, i only make API calls when needed, ie when refunded or doing an add-on transaction, etc.

for those of you that are experiencing this error, here is the solution. script:

includes/modules/payment/square_webPay.php

lines 912 -913 on version 1.0.4

PHP Code:
//from
                
$response $this->processResult($apiResponse$request);
                return 
$response['results']->getOrders(); 

//to
                
$response $this->processResult($apiResponse$request);
                if (
$response['errors']) {
                    return [];
                }
                return 
$response['results']->getOrders(); 
It doesn't work for me.

Here is what I have
Code:
            $request = new Models\BatchRetrieveOrdersRequest($ids);

            try {
                $apiResponse = $this->client->getOrdersApi()->batchRetrieveOrders($request);
//orders fix (https://www.zen-cart.com/showthread.php?228750-Square-WebPay-support-thread&p=1397245#post1397245)
                //$response = $this->processResult($apiResponse, $request);
                //return $response['results']->getOrders(); 
                $response = $this->processResult($apiResponse, $request);
                if ($response['errors']) {
                    return [];
                }
                return $response['results']->getOrders(); 
            } catch (\SquareConnect\ApiException $e) {
                return new Models\Order;
            }
        }
Here is the error

[06-Oct-2023 10:10:23 America/New_York] Request URI: /XX/index.php?cmd=orders&page=1&oID=10030684&action=edit, IP address: 000.000.000.000
--> PHP Fatal error: Uncaught Error: Call to a member function getOrders() on array in /home/XXX/public_html/includes/modules/payment/square_webPay.php:919
Stack trace:
#0 /home/XXX/public_html/includes/modules/payment/square_webPay.php(526): square_webPay->lookupOrderDetails(10030684)
#1 /home/XXX/public_html/XX/orders.php(741): square_webPay->admin_notification(10030684)
#2 /home/XXX/public_html/XX/index.php(11): require('/home/XXX/...')
#3 {main}
thrown in /home/XXX/public_html/includes/modules/payment/square_webPay.php on line 919.