From 4e83a7f4dfb49c8bcabe5bb0352750356bc51fb4 Mon Sep 17 00:00:00 2001 From: Shubham Kumar Date: Mon, 12 Jan 2026 10:40:12 +0100 Subject: [PATCH 1/2] [ECP-9487] Add exception handling to getInvoiceContext in AdyenLogger --- Logger/AdyenLogger.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Logger/AdyenLogger.php b/Logger/AdyenLogger.php index 671783b0ee..df5821979f 100755 --- a/Logger/AdyenLogger.php +++ b/Logger/AdyenLogger.php @@ -120,18 +120,22 @@ public function getOrderContext(MagentoOrder $order): array public function getInvoiceContext(MagentoOrder\Invoice $invoice): array { - $stateName = $invoice->getStateName(); + try { + $stateName = $invoice->getStateName(); - return [ - 'invoiceId' => $invoice->getEntityId(), - 'invoiceIncrementId' => $invoice->getIncrementId(), - 'invoiceState' => $invoice->getState(), - 'invoiceStateName' => $stateName instanceof Phrase ? $stateName->getText() : $stateName, - 'invoiceWasPayCalled' => $invoice->wasPayCalled(), - 'invoiceCanCapture' => $invoice->canCapture(), - 'invoiceCanCancel' => $invoice->canCancel(), - 'invoiceCanVoid' => $invoice->canVoid(), - 'invoiceCanRefund' => $invoice->canRefund() - ]; + return [ + 'invoiceId' => $invoice->getEntityId(), + 'invoiceIncrementId' => $invoice->getIncrementId(), + 'invoiceState' => $invoice->getState(), + 'invoiceStateName' => $stateName instanceof Phrase ? $stateName->getText() : $stateName, + 'invoiceWasPayCalled' => $invoice->wasPayCalled(), + 'invoiceCanCapture' => $invoice->canCapture(), + 'invoiceCanCancel' => $invoice->canCancel(), + 'invoiceCanVoid' => $invoice->canVoid(), + 'invoiceCanRefund' => $invoice->canRefund() + ]; + } catch (\Exception $e) { + return []; + } } } From 78199f7ff60a78a35300374ea7c5fd8e4e466713 Mon Sep 17 00:00:00 2001 From: Shubham Kumar Date: Mon, 12 Jan 2026 16:15:39 +0100 Subject: [PATCH 2/2] [ECP-9487] Catch Throwable and log warning --- Logger/AdyenLogger.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Logger/AdyenLogger.php b/Logger/AdyenLogger.php index df5821979f..b963e71a48 100755 --- a/Logger/AdyenLogger.php +++ b/Logger/AdyenLogger.php @@ -134,7 +134,8 @@ public function getInvoiceContext(MagentoOrder\Invoice $invoice): array 'invoiceCanVoid' => $invoice->canVoid(), 'invoiceCanRefund' => $invoice->canRefund() ]; - } catch (\Exception $e) { + } catch (\Throwable $e) { + $this->addAdyenWarning('Failed to retrieve invoice context: ' . $e->getMessage()); return []; } }