Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions Logger/AdyenLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While handling the exception is correct to prevent process interruption, swallowing it silently can hide potential issues. It's better to log the exception to be aware of any problems occurring during context retrieval. This will help with debugging in the future without stopping the webhook processing.

            $this->addAdyenWarning('Failed to get invoice context: ' . $e->getMessage());
            return [];

}
}
}
Loading