fix: switch DataService to JSON serialization to survive QuickBooks schema drift

The SDK's XML deserializer reflects on declared properties of its Data
classes and throws a RuntimeException when QuickBooks returns a field
the installed SDK version doesn't define yet (e.g. the new invoice
AllowOnlinePayPalPayment field), breaking every invoice create/update.
The JSON path builds instances from the class's own known properties
and silently ignores unrecognised response fields instead, so it
tolerates QuickBooks adding fields ahead of the SDK.
This commit is contained in:
Joel Male
2026-07-27 07:03:21 +03:00
parent 473103c243
commit 9002e0ebca
3 changed files with 88 additions and 60 deletions
+22
View File
@@ -1,5 +1,6 @@
<?php
use QuickBooksOnline\API\Core\Http\Serialization\SerializationFormat;
use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\Exception\ServiceException;
use Wearepixel\QuickBooks\Client;
@@ -130,6 +131,27 @@
it('returns a report service using the data service')
->skip('Once we figure out how to test around the static DataService::Configure');
it('configures the data service to use JSON serialization so unrecognised QuickBooks response fields do not throw', function () {
$this->token_mock
->shouldReceive('getAttribute')
->twice()
->with('hasValidAccessToken')
->andReturnFalse();
$this->token_mock
->shouldReceive('getAttribute')
->once()
->with('hasValidRefreshToken')
->andReturnFalse();
$format = $this->client
->getDataService()
->getServiceContext()
->IppConfiguration->Message->Request->SerializationFormat;
expect($format)->toBe(SerializationFormat::Json);
});
it('has logging off by default')
->skip('Have to figure out how to test this with the new code in 5.x');