setTemplate('module:' . $this->module->name . '/views/templates/front/redirect.tpl'); // Call the parent class's initContent method to perform default initializations. parent::initContent(); $idState = (int) Configuration::get('HUTKO_NEW_ORDER_STATUS_ID', null, null, null, Configuration::get('PS_OS_PREPARATION')); $validationResult = $this->module->validateOrder($this->context->cart->id, $idState, 0, $this->module->displayName); if ($validationResult) { $order = new Order((int)$this->module->currentOrder); $requestData = $this->module->buildPaymentRequestData($order, null, null, null); $responseData = $this->module->sendAPICall($this->module->checkout_url, $requestData); if (isset($responseData['response']['response_status']) && $responseData['response']['response_status'] === 'success') { $orderPayment = new OrderPayment(); $orderPayment->order_reference = $order->reference; $orderPayment->id_currency = $order->id_currency; $orderPayment->amount = 0; $orderPayment->payment_method = $this->module->displayName; $orderPayment->transaction_id = $requestData['order_id']; $orderPayment->card_holder = $responseData['response']['checkout_url']; $orderPayment->add(); Tools::redirect($responseData['response']['checkout_url']); return; } $this->context->smarty->assign([ 'hutko_response' => $responseData['response'], // The URL of the Hutko payment gateway. ]); } } }