Skip to content

Commit

Permalink
Improve error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
srenon committed Jan 25, 2024
1 parent cdf74e6 commit c3b232b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,26 @@ public function getOrderDataLayer(SalesOrder $order)
*/
public function getPaymentMethod(SalesOrder $order)
{
$method = [
'title' => '',
'code' => ''
];

try {
/** @var Payment $payment */
$payment = $order->getPayment();
$methodInstance = $payment->getMethodInstance();

if (!$payment) {
return $method;
}

$methodInstance = $payment->getMethodInstance();
$method = [
'title' => $methodInstance->getTitle(),
'code' => $methodInstance->getCode()
];
} catch (Exception $e) {
$method = [
'title' => '',
'code' => ''
];
/** return empty method */
}

return $method;
Expand Down

0 comments on commit c3b232b

Please sign in to comment.