diff --git a/src/Service/Order/OrderExpireService.php b/src/Service/Order/OrderExpireService.php index 22a742872..b342ae4d2 100644 --- a/src/Service/Order/OrderExpireService.php +++ b/src/Service/Order/OrderExpireService.php @@ -77,12 +77,27 @@ public function cancelExpiredOrders(OrderCollection $orders, Context $context): } $transactions->sort(function (OrderTransactionEntity $a, OrderTransactionEntity $b) { - return $a->getCreatedAt() <=> $b->getCreatedAt(); + if ($a->getCreatedAt() === null || $b->getCreatedAt() === null) { + return -1; + } + return $a->getCreatedAt()->getTimestamp() <=> $b->getCreatedAt()->getTimestamp(); }); /** @var OrderTransactionEntity $lastTransaction */ $lastTransaction = $transactions->last(); + $paymentMethod = $lastTransaction->getPaymentMethod(); + if ($paymentMethod === null) { + $this->logger->warning('Transaction has no payment method', ['orderNumber'=>$order->getOrderNumber(),'transactionId'=>$lastTransaction->getId()]); + continue; + } + $paymentMethodIdentifier = $paymentMethod->getHandlerIdentifier(); + + if (strpos($paymentMethodIdentifier, 'Mollie') === false) { + $this->logger->debug('Payment method is not a mollie payment, dont touch it', ['identifier'=>$paymentMethodIdentifier]); + continue; + } + $stateMachineState = $lastTransaction->getStateMachineState(); if ($stateMachineState === null) { continue;