Exception bzgl. jsonToArray() im osc_amazonpay Modul

Technische Frage bzgl. einer Exception, welche vom osc_amazonpay Modul in der Version 2.1.4 im Sandbox ausgelöst wird. Wahrscheinlich tritt das Problem dann auch im Prod-Modus auf, allerdings noch nicht getestet, weil schon in der Sandbox kaputt. Scheint ein Bug im Modul bei der Kommunikation mit der Amazon Pay Schnittstelle zu sein.

[2024-01-08 11:24:33] OXID Logger.ERROR: Argument 1 passed to OxidSolutionCatalysts\AmazonPay\Core\Helper\PhpHelper::jsonToArray() must be of the type string, array given, called in /oxideshop/vendor/oxid-esales/amazon-pay-module/src/Core/AmazonService.php on line 562 ["[object] (TypeError(code: 0): Argument 1 passed to OxidSolutionCatalysts\\AmazonPay\\Core\\Helper\\PhpHelper::jsonToArray() must be of the type string, array given, called in /oxideshop/vendor/oxid-esales/amazon-pay-module/src/Core/AmazonService.php on line 562 at /oxideshop/vendor/oxid-esales/amazon-pay-module/src/Core/Helper/PhpHelper.php:16) [stacktrace] #0 /oxideshop/vendor/oxid-esales/amazon-pay-module/src/Core/AmazonService.php(562): OxidSolutionCatalysts\\AmazonPay\\Core\\Helper\\PhpHelper::jsonToArray(Array) #1 /oxideshop/vendor/oxid-esales/amazon-pay-module/src/Controller/DispatchController.php(109): OxidSolutionCatalysts\\AmazonPay\\Core\\AmazonService->processCharge('xxx', Object(OxidSolutionCatalysts\\AmazonPay\\Core\\Logger)) #2 /oxideshop/vendor/oxid-esales/oxideshop-ce/source/Core/ShopControl.php(471): OxidSolutionCatalysts\\AmazonPay\\Controller\\DispatchController->render() #3 /oxideshop/source/modules/aggrowawi/extensions/views/aggrowawi_oxshopcontrol.php(64): OxidEsales\\EshopCommunity\\Core\\ShopControl->_render(Object(OxidSolutionCatalysts\\AmazonPay\\Controller\\DispatchController)) #4 /oxideshop/vendor/oxid-esales/oxideshop-ce/source/Core/ShopControl.php(359): aggrowawi_oxshopcontrol->_render(Object(OxidSolutionCatalysts\\AmazonPay\\Controller\\DispatchController)) #5 /oxideshop/vendor/oxid-esales/oxideshop-ce/source/Core/ShopControl.php(282): OxidEsales\\EshopCommunity\\Core\\ShopControl->formOutput(Object(OxidSolutionCatalysts\\AmazonPay\\Controller\\DispatchController)) #6 /oxideshop/vendor/oxid-esales/oxideshop-ce/source/Core/ShopControl.php(142): OxidEsales\\EshopCommunity\\Core\\ShopControl->_process('OxidSolutionCat...', NULL, NULL, NULL) #7 /oxideshop/vendor/oxid-esales/oxideshop-ce/source/Core/Oxid.php(27): OxidEsales\\EshopCommunity\\Core\\ShopControl->start() #8 /oxideshop/source/index.php(16): OxidEsales\\EshopCommunity\\Core\\Oxid::run() #9 {main}

Zudem mal die Response aus dem amazonpay.log, welche die Exception ausgelöst hat

[2024-01-08 11:24:31] amazonpaylog.INFO: Completed & Captured {"status":200,"method":"POST","url":"https://pay-api.amazon.eu/sandbox/v2/checkoutSessions/xxx/complete","headers":["accept:application/json","authorization:AMZN-PAY-RSASSA-PSS PublicKeyId=xxx, SignedHeaders=accept;content-type;x-amz-pay-date;x-amz-pay-host;x-amz-pay-region, Signature=xxx==","content-type:application/json","user-agent:amazon-pay-api-sdk-php/2.6.4 (PHP/7.4.33; Linux/x86_64/5.10.0-25-amd64)","x-amz-pay-date:20240108T102430Z","x-amz-pay-host:pay-api.amazon.eu","x-amz-pay-language-version:7.4.33","x-amz-pay-region:eu","x-amz-pay-sdk-type:PHP","x-amz-pay-sdk-version:2.6.4"],"request":"{\"chargeAmount\":{\"amount\":\"9.85\",\"currencyCode\":\"EUR\"}}","response":"{\"checkoutSessionId\":\"xxx\",\"webCheckoutDetails\":null,\"productType\":null,\"paymentDetails\":null,\"chargePermissionType\":\"OneTime\",\"orderType\":null,\"recurringMetadata\":null,\"paymentMethodOnFileMetadata\":null,\"merchantDetails\":null,\"merchantMetadata\":null,\"supplementaryData\":null,\"buyer\":null,\"billingAddress\":null,\"paymentPreferences\":null,\"statusDetails\":{\"state\":\"Completed\",\"reasonCode\":null,\"reasonDescription\":null,\"lastUpdatedTimestamp\":\"20240108T102430Z\"},\"shippingAddress\":null,\"platformId\":null,\"chargePermissionId\":\"xxx\",\"chargeId\":\"xxx\",\"constraints\":null,\"creationTimestamp\":\"20240108T102426Z\",\"expirationTimestamp\":null,\"storeId\":null,\"providerMetadata\":null,\"releaseEnvironment\":null,\"checkoutButtonText\":null,\"deliverySpecifications\":null,\"tokens\":null}","request_id":"xxx","retries":0,"duration":579}

In OxidSolutionCatalysts\AmazonPay\Core\AmazonService::processCharge() kommt als $result[‘response’ ] kein JSON-String sondern ein Array zurück. Soweit ich es einschätzen kann ist der Aufruf von jsonToArray() unnötig und $result könnte stattdessen direkt der $response zugewiesen werden, korrekt? Anderer Vorschlag? Werden weitere Infos benötigt?

Ich kann das Verhalten bestätigen. Nur hatte ich noch keine Zeit dies an OXID weiter zugeben.
Wir hatten das letzte Woche im Livemodus.

Ich habe mir erst einmal damit beholfen:
if(is_array($result[‘response’]))
{
$response = $result[‘response’];
}else{
$response = PhpHelper::jsonToArray($result[‘response’]);
}

Danke fürs Feedback! Vorher prüfen, ob es denn bereits ein Array ist, ist sogar noch besser, ja :slight_smile:

Hatte OXID parallel schon angeschrieben und die Rückmeldung erhalten, dass es bereits einen OXID Bugtracker Eintrag unter 0007576: OXID Logger.ERROR: OxidSolutionCatalysts\AmazonPay\Core\Helper\PhpHelper::jsonToArray(): - 2.1.4 - OXID eShop bugtrack dazu gibt. Sollte in der nächsten Version gefixt sein.