From 76514e7f60dc3e899098424a74744ef43ba35103 Mon Sep 17 00:00:00 2001 From: viniciusThalesBring Date: Mon, 3 Aug 2026 13:19:01 -0300 Subject: [PATCH] Implement cancellation for declined or canceled payments Add order cancellation logic for declined payments --- Model/Method/AbstractCc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Model/Method/AbstractCc.php b/Model/Method/AbstractCc.php index bca689e..06424bc 100644 --- a/Model/Method/AbstractCc.php +++ b/Model/Method/AbstractCc.php @@ -230,6 +230,20 @@ public function processPayment($payment) list($status, $message) = $this->_ipagHelper->getStatusFromResponse($transactionResponse); + if (in_array((int) $status, [3, 7], true)) { + if ($order->canCancel()) { + $order->cancel(); + } + + $order->addStatusHistoryComment( + __('iPag response received. Payment was declined or canceled. Message response: %1.', $message) + )->setIsCustomerNotified(false); + + $order->save(); + + return $this; + } + $this->_ipagHelper->registerOrderStatusHistory($order, $status, $message); return $this;