intuit / QuickBooks-V3-PHP-SDK

Official PHP SDK for QuickBooks REST API v3.0: https://developer.intuit.com/
Apache License 2.0
241 stars 240 forks source link

Call to a member function Log() on null #487

Closed z0lo13 closed 1 year ago

z0lo13 commented 1 year ago
$service = DataService::Configure(array(
                'auth_mode' => $settings->get('auth_mode'),
                'ClientID' => $settings->get('ClientID'),
                'ClientSecret' => $settings->get('ClientSecret'),
                'RedirectURI' => $settings->get('RedirectURI'),
                'scope' => $settings->get('scope'),
                'baseUrl' => $settings->get('baseUrl'),
            ));
$dataService->disableLog();
$dataService->throwExceptionOnError(false);
$theResourceObj = Customer::create([
            "BillAddr" => [
                "Line1" => "123 Main Street",
                "City" => "Mountain View",
                "Country" => "USA",
                "CountrySubDivisionCode" => "CA",
                "PostalCode" => "94042"
            ],
            "Notes" => "Here are other details.",
            "Title" => "Mr",
            "GivenName" => "James",
            "MiddleName" => "B",
            "FamilyName" => "King",
            "Suffix" => "Jr",
            "FullyQualifiedName" => "King Groceries",
            "CompanyName" => "King Groceries",
            "DisplayName" => "King's Groceries Displayname",
            "PrimaryPhone" => [
                "FreeFormNumber" => "(555) 555-5555"
            ],
            "PrimaryEmailAddr" => [
                "Address" => "jdrew@myemail.com"
            ]
        ]);
$resultingObj = $dataService->Add($theResourceObj);

$resultingObj = $dataService->Add($theResourceObj); triggers the following error: Error: Call to a member function Log() on null in /home/crm/public_html/vendor/quickbooks/v3-php-sdk/src/Core/Http/Serialization/XmlObjectSerializer.php:51 Stack trace:

0 /home/crm/public_html/vendor/quickbooks/v3-php-sdk/src/Core/Http/Serialization/XmlObjectSerializer.php(74): QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer::getXmlFromObj(Object(QuickBooksOnline\API\Data\IPPCustomer))

1 /home/crm/public_html/vendor/quickbooks/v3-php-sdk/src/Core/Http/Serialization/XmlObjectSerializer.php(199): QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer::getPostXmlFromArbitraryEntity(Object(QuickBooksOnline\API\Data\IPPCustomer), 'customer')

2 /home/crm/public_html/vendor/quickbooks/v3-php-sdk/src/DataService/DataService.php(1440): QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer->Serialize(Object(QuickBooksOnline\API\Data\IPPCustomer))

3 /home/crm/public_html/vendor/quickbooks/v3-php-sdk/src/DataService/DataService.php(807): QuickBooksOnline\API\DataService\DataService->executeObjectSerializer(Object(QuickBooksOnline\API\Data\IPPCustomer), NULL)

4 /home/crm/public_html/app/Integrations/QuickBooksIntegration/Synchronizer/CustomerSync.php(225): QuickBooksOnline\API\DataService\DataService->Add(Object(QuickBooksOnline\API\Data\IPPCustomer))

...

10 {main}

Is there any requirements/dependencies for SDK? Or how can i debug it further?

GameCharmer commented 1 year ago

If you want to debug, open src/Core/Http/Serialization/XmlObjetSerializer.php and remove the try/catch around $php2xml->getXml so that the exception isn't being buried. Also, wrap lines starting with self::$IDSLogger-> in if(self::$IDSLogger) { so they don't run when IDSLogger is null.

If you're on PHP 8.2, update the following file by adding #[\AllowDynamicProperties] immediate above the class Php2Xml extends Common line src/XSD2PHP/src/com/mikebevz/xds2php/Php2XML.php

6+ months in and simple "fixes" like these are just beyond the QB skillset :P

z0lo13 commented 1 year ago

php version mismatch