додано переклади
This commit is contained in:
@@ -32,16 +32,32 @@ class HutkoRedirectModuleFrontController extends ModuleFrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
// Call the parent class's initContent method to perform default initializations.
|
||||
parent::initContent();
|
||||
|
||||
// Assign Smarty variables to be used in the redirect template.
|
||||
$this->context->smarty->assign([
|
||||
'hutko_url' => $this->module->checkout_url, // The URL of the Hutko payment gateway.
|
||||
'hutko_inputs' => $this->module->buildInputs(), // An array of input parameters required by Hutko.
|
||||
]);
|
||||
|
||||
// Set the template to be used for displaying the redirection form.
|
||||
$this->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.
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user