diff --git a/controllers/front/callback.php b/controllers/front/callback.php index 7450410..f299b4e 100644 --- a/controllers/front/callback.php +++ b/controllers/front/callback.php @@ -113,7 +113,7 @@ class HutkoCallbackModuleFrontController extends ModuleFrontController } // If order still doesn't exist, proceed with validation. $idState = (int)Configuration::get('HUTKO_SUCCESS_STATUS_ID'); - return $this->module->validateOrderFromCart((int)$cart->id, $amountReceived, $transaction_id, $idState); + return $this->module->validateOrderFromCart((int)$cart->id, $amountReceived, $transaction_id, $idState, true); }; // Postpone validation to seconds ending in 8 to avoid collision with result controller (ending in 3). diff --git a/hutko.php b/hutko.php index ba8776b..b20ac9a 100644 --- a/hutko.php +++ b/hutko.php @@ -468,11 +468,15 @@ class Hutko extends PaymentModule * @return bool True if the order validation was successful, false otherwise. * @see PaymentModule::validateOrder() */ - public function validateOrderFromCart(int $id_cart, float $amount, string $transaction_id = '', int $idState = 0): bool + public function validateOrderFromCart(int $id_cart, float $amount, string $transaction_id = '', int $idState = 0, bool $fromCallBack = false): bool { if (!$idState) { $idState = (int) Configuration::get('PS_OS_PREPARATION'); } + if (!$fromCallBack) { + $cart = new Cart($id_cart); + $this->context->customer = new Customer($cart->id_customer); + } // Call the parent validateOrder method with the "preparation" status. return $this->validateOrder($id_cart, $idState, $amount, $this->displayName, null, ['transaction_id' => $transaction_id], null, false, $this->context->customer->secure_key); } @@ -828,7 +832,6 @@ class Hutko extends PaymentModule if ($response['response']['response_status'] === 'success') { $result->success = true; $result->description = $this->trans('Refund success.', [], 'Modules.Hutko.Admin'); - } $order = new Order($orderId);