Skip to content

Commit

Permalink
fix: Don't cancel if refund fails
Browse files Browse the repository at this point in the history
  • Loading branch information
soleilcot committed Jun 16, 2023
1 parent 92ea933 commit 00c3f36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Cron/OrderFraudStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ public function updateOrdersFromNoFraudApiResult($orders, $storeId)
}
if ($this->configHelper->getAutoCancel($storeId)) {
if (isset($decision) && ($decision == 'fail' || $decision == "fraudulent")) {
$this->orderProcessor->handleAutoCancel($order, $decision);
// If auto-cancel fails, then update the order status to the configured status
if(!$this->orderProcessor->handleAutoCancel($order, $decision)){
if (!empty($newStatus)) {
$this->orderProcessor->updateOrderStatusFromNoFraudResult($newStatus, $order, $response);
} else {
$order->setNofraudStatus($decision);
}
}
continue;
}
}
Expand Down
3 changes: 3 additions & 0 deletions Order/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ public function handleAutoCancel($order, $decision)
$order->setState(Order::STATE_CANCELED);
$order->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CANCELED));
$order->save();

return true;
}
}
return false;
}

/**
Expand Down

0 comments on commit 00c3f36

Please sign in to comment.