diff --git a/Plugin/SendCustomMetadataAfterPlaceOrder.php b/Plugin/SendCustomMetadataAfterPlaceOrder.php index 1b9b742b..9e2ffc13 100644 --- a/Plugin/SendCustomMetadataAfterPlaceOrder.php +++ b/Plugin/SendCustomMetadataAfterPlaceOrder.php @@ -4,6 +4,7 @@ namespace Payplug\Payments\Plugin; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Api\CartManagementInterface; use Magento\Sales\Api\OrderRepositoryInterface; @@ -40,7 +41,12 @@ public function __construct( */ public function afterPlaceOrder(CartManagementInterface $cartManagement, int $orderId): int { - $order = $this->orderRepository->get($orderId); + try { + $order = $this->orderRepository->get($orderId); + } catch (LocalizedException) { + return $orderId; + } + $method = $order->getPayment()?->getMethod(); if ($this->payplugDataHelper->isCodePayplugPayment($method) === false) {