Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: do not cancel orders, when a new payment method is not mollie #898

Merged
Merged
Changes from all commits
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
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