Skip to content

Commit

Permalink
NTR: do not cancel orders, when a new payment method is not mollie
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Nov 27, 2024
1 parent b4961c2 commit 5308738
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Service/Order/OrderExpireService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5308738

Please sign in to comment.