diff --git a/controllers/front/redirect.php b/controllers/front/redirect.php
index 8fd4001..156a9a5 100644
--- a/controllers/front/redirect.php
+++ b/controllers/front/redirect.php
@@ -10,7 +10,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-use Symfony\Component\Serializer\Encoder\JsonEncode;
+
if (!defined('_PS_VERSION_')) {
exit;
diff --git a/controllers/front/return.php b/controllers/front/return.php
new file mode 100644
index 0000000..3277e1e
--- /dev/null
+++ b/controllers/front/return.php
@@ -0,0 +1,121 @@
+smarty The Smarty instance for templating (though not used here).
+ * @property \Customer $context->customer The currently logged-in customer.
+ * @property \Link $context->link The PrestaShop Link class instance for URL generation.
+ * @extends ModuleFrontController
+ * @package Modules\Hutko
+ * @author Panariga
+ * @copyright Hutko
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) // Adjust if using a different license
+ * @version 1.0.0 // Start with a version number
+ */
+class HutkoReturnModuleFrontController extends ModuleFrontController
+{
+ /**
+ * Initializes the content for the controller.
+ *
+ * This method is the main entry point for this controller. It retrieves
+ * the `hutkoPV` parameter from the request, decodes and parses it,
+ * validates the required data, and redirects the customer to the
+ * order confirmation page if successful.
+ *
+ * @throws PrestaShopException If the `hutkoPV` parameter is missing,
+ * invalid, or the secure key validation fails.
+ * The exception message indicates the nature
+ * of the failure.
+ */
+ public function initContent()
+ {
+ // Retrieve the 'hutkoPV' parameter from the GET or POST request.
+ // It is expected to be a URL-safe encoded string.
+ $hutkoPV = Tools::getValue('hutkoPV');
+
+ // Decode the URL-safe string using the module's custom function.
+ // If the decoding fails or the input is empty, $hutkoPV will be false or empty.
+ $decodedHutkoPV = $this->module->urlSafeDecode($hutkoPV);
+
+ // Check if decoding was successful and the result is not empty.
+ if ($decodedHutkoPV) {
+ // Attempt to decode the JSON string into a PHP array.
+ $decodedPV = json_decode($decodedHutkoPV, true);
+
+ // Validate the decoded JSON:
+ // 1. Check if json_decode returned an array.
+ // 2. Check if all expected keys ('id_cart', 'id_module', 'id_order', 'key') exist in the array.
+ // 3. Check if the 'key' from the decoded data matches the secure key of the currently logged-in customer.
+ // This is a critical security step to prevent unauthorized access to order details.
+ if (
+ is_array($decodedPV)
+ && isset($decodedPV['id_cart'])
+ && isset($decodedPV['id_module'])
+ && isset($decodedPV['id_order'])
+ && isset($decodedPV['key'])
+ && $decodedPV['key'] == $this->context->customer->secure_key // Secure key validation
+ ) {
+ // If validation passes, generate the URL for the standard order confirmation page.
+ // The URL includes the validated parameters necessary for the order-confirmation controller
+ // to load and display the correct order details.
+ $orderConfirmationUrl = $this->context->link->getPageLink(
+ 'order-confirmation', // The controller to redirect to
+ true, // Use SSL
+ $this->context->language->id, // Current language ID
+ [ // Parameters for the order-confirmation page
+ 'id_cart' => (int)$decodedPV['id_cart'], // Cast to int for safety
+ 'id_module' => (int)$decodedPV['id_module'], // Cast to int
+ 'id_order' => (int)$decodedPV['id_order'], // Cast to int
+ 'key' => pSQL($decodedPV['key']), // Sanitize key before using in URL (though link generation does some)
+ ]
+ );
+
+ // Redirect the customer to the order confirmation page.
+ Tools::redirect($orderConfirmationUrl);
+
+ // Stop script execution after redirection.
+ exit;
+ }
+ // If decoding was successful but validation failed:
+ else {
+ // Throw an exception indicating a validation failure (broken data).
+ throw new PrestaShopException('hutkoPV data validation failed or structure is incorrect.');
+ }
+ }
+
+ // If hutkoPV parameter was missing or decoding failed:
+ // Throw an exception indicating the parameter is missing or unusable.
+ throw new PrestaShopException('hutkoPV parameter is missing or broken.');
+ }
+}
diff --git a/hutko.php b/hutko.php
index 62a8816..237223b 100644
--- a/hutko.php
+++ b/hutko.php
@@ -443,12 +443,12 @@ class Hutko extends PaymentModule
$customerEmail = $customer->email;
// 8. Generate the customer redirection URL after payment.
- $responseUrl = $this->context->link->getPageLink('order-confirmation', true, $order->id_lang, [
+ $responseUrl = $this->context->link->getModuleLink($this->name, 'return', ['hutkoPV' => $this->urlSafeEncode(json_encode([
'id_cart' => $order->id_cart,
'id_module' => $this->id,
'id_order' => $order->id,
'key' => $customer->secure_key,
- ]);
+ ]))], true);
@@ -1221,4 +1221,58 @@ class Hutko extends PaymentModule
$logger->setFilename($logdirectory . 'dayly.log');
$logger->logInfo($data);
}
+
+
+ /**
+ * URL-safe encodes a string using a Base64-like approach.
+ * Replaces '+' with '-', '/' with '_', and removes trailing '=' padding.
+ * Useful for encoding arbitrary binary data into a URL-friendly format
+ * that can be safely passed in URLs (e.g., within query parameters
+ * or path segments without needing standard percent encoding for + and /).
+ *
+ * @param string $string The string or binary data to encode.
+ * @return string The URL-safe encoded string.
+ */
+ public function urlSafeEncode($string)
+ {
+ // Standard Base64 encode
+ $encoded = base64_encode($string);
+
+ // Replace '+' with '-' and '/' with '_'
+ // This avoids characters that have special meaning in URLs
+ $encoded = str_replace(['+', '/'], ['-', '_'], $encoded);
+
+ // Remove trailing '=' padding
+ // Padding is not necessary for decoding if the length is known or can be inferred.
+ // Removing it makes the string shorter and avoids another problematic character (=).
+ $encoded = rtrim($encoded, '=');
+
+ return $encoded;
+ }
+
+ /**
+ * Decodes a URL-safe encoded string back to its original form.
+ * Replaces '-' with '+', '_' with '/', and adds back trailing '=' padding.
+ *
+ * @param string $string The URL-safe encoded string.
+ * @return string|false The decoded string, or false on failure (if the input is not valid base64 after adjustments).
+ */
+ public function urlSafeDecode($string)
+ {
+ // Replace '-' with '+' and '_' with '/'
+ $decoded = str_replace(['-', '_'], ['+', '/'], $string);
+
+ // Add back trailing '=' padding.
+ // Base64 strings (before decoding) must have a length that is a multiple of 4.
+ // We calculate how many characters short we are from a multiple of 4
+ // and add the corresponding number of '=' characters back.
+ $padding = strlen($decoded) % 4;
+ if ($padding > 0) {
+ $decoded .= str_repeat('=', 4 - $padding);
+ }
+
+ // Standard Base64 decode
+ // base64_decode returns the original data or FALSE on failure.
+ return base64_decode($decoded);
+ }
}
diff --git a/translations/ru-RU/ModulesHutkoAdmin.ru-RU.xlf b/translations/ru-RU/ModulesHutkoAdmin.ru-RU.xlf
index 89a3e22..1314844 100644
--- a/translations/ru-RU/ModulesHutkoAdmin.ru-RU.xlf
+++ b/translations/ru-RU/ModulesHutkoAdmin.ru-RU.xlf
@@ -1,212 +1,212 @@
-
-
-
- Hutko is a payment platform whose main function is to provide internet acquiring.
- Hutko — це платіжна платформа, основною функцією якої є забезпечення інтернет-еквайрингу.
- Line:
-
-
- Довідка specify the Hutko account details for customers
- Пожалуйста, уточніть реквізити акаунту Hutko для клієнтів
- Line:
-
-
- Enter merchant id. Use 1700002 for test setup.
- Введіть ідентифікатор продавця. Використовуйте 1700002 для тестового налаштування.
- Line:
-
-
- Merchant ID.
- Merchant ID.
- Line:
-
-
- Enter a secret key. use "test" for test setup
- Введіть секретний ключ. Використовуйте тест для налаштування тесту.
- Line:
-
-
- Secret key
- Секретний ключ
- Line:
-
-
- Status after success payment
- Статус після успішної оплати
- Line:
-
-
- Status for new orders before payment
- Статус нових замовлень до оплати
- Line:
-
-
- Include shipping cost to payment
- Включити вартість доставки до оплати
- Line:
-
-
- Yes
- Так
- Line:
-
-
- No
- Ні
- Line:
-
-
- Shipping Name
- Назва для доставки
- Line:
-
-
- Назва продукту/сервісу для використання в fiscalization for shipping amount
- Назва продукту/послуги для використання у фіскалізації для суми доставки
- Line:
-
-
- Shipping Code
- Код доставки
- Line:
-
-
- Code product/service для використання в fiscalization for shipping amount
- Код товару/послуги для використання у фіскалізації для суми доставки
- Line:
-
-
- Show Visa/MasterCard logo
- Показати логотип Visa/MasterCard
- Line:
-
-
- Save
- Зберегти
- Line:
-
-
- Merchant ID is required.
- Потрібен ідентифікатор продавця (Merchant ID).
- Line:
-
-
- Merchant ID must be numeric.
- Ідентифікатор продавця має бути числовим.
- Line:
-
-
- Secret key is required.
- Потрібен секретний ключ.
- Line:
-
-
- Секрет key must be at least 10 characters long and cannot be entirely numeric.
- Секретний ключ повинен містити щонайменше 10 символів і не може бути повністю числовим.
- Line:
-
-
- Pay via payment system Hutko
- Оплата через платіжну систему Hutko
- Line:
-
-
- Pay via Hutko
- Оплата через Hutko
- Line:
-
-
- Order payment #
- Оплата замовлення #
- Line:
-
-
- Order payment not found.
- Оплата замовлення не знайдена.
- Line:
-
-
- Invalid transaction ID format.
- Недійсний формат ідентифікатора транзакції.
- Line:
-
-
- Refund success.
- Повернення коштів успішне.
- Line:
-
-
-
- Платежі та повернення коштів Hutko
- Line:
-
-
- Transaction ID
- Transaction ID
- Line:
-
-
- Amount
- Сума
- Line:
-
-
- Payment Date
- Дата платежу
- Line:
-
-
- Actions
- Дії
- Line:
-
-
- Refund
- Повернення коштів
- Line:
-
-
- Status
- Статус
- Line:
-
-
- Initiate Refund
- Ініціювати повернення коштів
- Line:
-
-
- Refund Amount
- Сума відшкодування
- Line:
-
-
- Виберіть гроші для того, щоб скористатися цим платежом.
- Введіть суму для повернення коштів за цей платіж.
- Line:
-
-
- Refund Reason/Comment
- Причина/коментар повернення коштів
- Line:
-
-
- Optional: A brief reason for the refund.
- Необов'язково: Коротка причина повернення коштів.
- Line:
-
-
- Cancel
- Скасувати
- Line:
-
-
- Process Refund
- Виконати повернення коштів
- Line:
-
-
-
+
+
+
+ Hutko is a payment platform whose main function is to provide internet acquiring.
+ Hutko — це платіжна платформа, основною функцією якої є забезпечення інтернет-еквайрингу.
+ Line:
+
+
+ Please specify the Hutko account details for customers
+ Пожалуйста, укажите реквизиты учетной записи Hutko для клиентов
+ Line:
+
+
+ Enter a merchant id. Use 1700002 for test setup.
+ Введите идентификатор продавца. Используйте 1700002 для тестовой настройки.
+ Line:
+
+
+ Merchant ID.
+ Merchant ID.
+ Line:
+
+
+ Enter a secret key. Use "test" for test setup
+ Введите секретный ключ. Используйте "test" для настройки теста
+ Line:
+
+
+ Secret key
+ Секретний ключ
+ Line:
+
+
+ Status after success payment
+ Статус після успішної оплати
+ Line:
+
+
+ Status for new orders before payment
+ Статус нових замовлень до оплати
+ Line:
+
+
+ Include shipping cost to payment
+ Включити вартість доставки до оплати
+ Line:
+
+
+ Yes
+ Так
+ Line:
+
+
+ No
+ Ні
+ Line:
+
+
+ Shipping Name
+ Назва для доставки
+ Line:
+
+
+ Name of product/service to use in fiscalization for shipping amount
+ Наименование продукта/услуги для использования при фискализации суммы доставки
+ Line:
+
+
+ Shipping Code
+ Код доставки
+ Line:
+
+
+ Code of product/service to use in fiscalization for shipping amount
+ Код продукта/услуги для использования при фискализации суммы доставки
+ Line:
+
+
+ Show Visa/MasterCard logo
+ Показати логотип Visa/MasterCard
+ Line:
+
+
+ Save Logs
+ Сохранить логи
+ Line:
+
+
+ Save
+ Зберегти
+ Line:
+
+
+ Merchant ID is required.
+ Потрібен ідентифікатор продавця (Merchant ID).
+ Line:
+
+
+ Merchant ID must be numeric.
+ Ідентифікатор продавця має бути числовим.
+ Line:
+
+
+ Secret key is required.
+ Потрібен секретний ключ.
+ Line:
+
+
+ Secret key must be at least 10 characters long and cannot be entirely numeric.
+ Секретный ключ должен быть длиной не менее 10 символов и не может состоять только из цифр.
+ Line:
+
+
+ Pay via payment system Hutko
+ Оплата через платіжну систему Hutko
+ Line:
+
+
+ Pay via Hutko
+ Оплата через Hutko
+ Line:
+
+
+ Order payment #
+ Оплата замовлення #
+ Line:
+
+
+ Order payment not found.
+ Оплата замовлення не знайдена.
+ Line:
+
+
+ Invalid transaction ID format.
+ Недійсний формат ідентифікатора транзакції.
+ Line:
+
+
+ Refund success.
+ Повернення коштів успішне.
+ Line:
+
+
+ Refund Failed. Please check actual amount in Hutko account page.
+ Возврат не удался. Проверьте фактическую сумму на странице учетной записи Hutko.
+ Line:
+
+
+
+ Платежі та повернення коштів Hutko
+ Line:
+
+
+ Transaction ID
+ Transaction ID
+ Line:
+
+
+ Amount
+ Сума
+ Line:
+
+
+ Payment Date
+ Дата платежу
+ Line:
+
+
+ Actions
+ Дії
+ Line:
+
+
+ Refund
+ Повернення коштів
+ Line:
+
+
+ Refund Amount
+ Сума відшкодування
+ Line:
+
+
+ Enter the amount to refund for this payment.
+ Введите сумму возврата по данному платежу.
+ Line:
+
+
+ Refund Reason/Comment
+ Причина/коментар повернення коштів
+ Line:
+
+
+ Optional: A brief reason for the refund.
+ Необов'язково: Коротка причина повернення коштів.
+ Line:
+
+
+ Cancel
+ Скасувати
+ Line:
+
+
+ Process Refund
+ Виконати повернення коштів
+ Line:
+
+
+
diff --git a/translations/ru-RU/ModulesHutkoShop.ru-RU.xlf b/translations/ru-RU/ModulesHutkoShop.ru-RU.xlf
index b1122e6..58b3d41 100644
--- a/translations/ru-RU/ModulesHutkoShop.ru-RU.xlf
+++ b/translations/ru-RU/ModulesHutkoShop.ru-RU.xlf
@@ -1,22 +1,22 @@
-
-
-
- Payment failure.
- Сбой оплаты.
- Line:
-
-
- Допустить попытку
- Попробуйте еще раз
- Line:
-
-
- Order validation failure
- Ошибка проверки заказа
- Line:
-
-
-
+
+
+
+ Payment failure.
+ Сбой оплаты.
+ Line:
+
+
+ Please try again
+ Попробуйте еще раз.
+ Line:
+
+
+ Order validation failure
+ Ошибка проверки заказа
+ Line:
+
+
+
diff --git a/translations/uk-UA/ModulesHutkoAdmin.uk-UA.xlf b/translations/uk-UA/ModulesHutkoAdmin.uk-UA.xlf
index 378ed7a..db031c8 100644
--- a/translations/uk-UA/ModulesHutkoAdmin.uk-UA.xlf
+++ b/translations/uk-UA/ModulesHutkoAdmin.uk-UA.xlf
@@ -1,212 +1,212 @@
-
-
-
- Hutko is a payment platform whose main function is to provide internet acquiring.
- Hutko – это платежная платформа, основной функцией которой является обеспечение интернет-эквайринга.
- Line:
-
-
- Связать specify the Hutko account details for customers
- Пожалуйста, уточните реквизиты учетной записи Hutko для клиентов
- Line:
-
-
- Enter для merchant id.
- Введите идентификатор продавца. Используйте 1700002 для тестовой настройки.
- Line:
-
-
- Merchant ID.
- Merchant ID.
- Line:
-
-
- Enter a secret key.
- Введите секретный ключ.
- Line:
-
-
- Secret key
- Секретный ключ
- Line:
-
-
- Status after success payment
- Статус после успешной оплаты
- Line:
-
-
- Status for new orders before payment
- Статус новых заказов к оплате
- Line:
-
-
- Включая плату за выплату
- Включить стоимость доставки в оплату
- Line:
-
-
- Yes
- Да
- Line:
-
-
- No
- Нет
- Line:
-
-
- Shipping Name
- Название для доставки
- Line:
-
-
- Имя продукта/сервиса для использования в fiscalization for shipping amount
- Имя продукта/услуги для использования в фискализации для суммы доставки
- Line:
-
-
- Shipping Code
- Код доставки
- Line:
-
-
- Code Product/Service для использования в fiscalization for shipping amount
- Код товара/услуги для использования в фискализации для суммы доставки
- Line:
-
-
- Show Visa/MasterCard logo
- Показать логотип Visa/MasterCard
- Line:
-
-
- Save
- Сохранить
- Line:
-
-
- Информационный идентификатор не требуется.
- Требуется идентификатор продавца (Merchant ID).
- Line:
-
-
- Merchant ID должен быть нумерен.
- Идентификатор продавца должен быть числовым.
- Line:
-
-
- Неверный key не требуется.
- Требуется секретный ключ.
- Line:
-
-
- Секрет key должен быть в пределах 10 characters long and cannot be entirely numeric.
- Секретный ключ должен содержать не менее 10 символов и не может быть полностью числовым.
- Line:
-
-
- Pay via payment system Hutko
- Оплата через платежную систему Hutko
- Line:
-
-
- Pay via Hutko
- Оплата через Hutko
- Line:
-
-
- Order payment #
- Оплата заказа #
- Line:
-
-
- Order payment not found.
- Оплата заказа не найдена.
- Line:
-
-
- Invalid transaction ID format.
- Недействительный формат идентификатора транзакции.
- Line:
-
-
- Refund success.
- Восстановление средств успешно.
- Line:
-
-
-
- Платежи и возврат средств Hutko
- Line:
-
-
- Transaction ID
- Transaction ID
- Line:
-
-
- Amount
- Сумма
- Line:
-
-
- Payment Date
- Дата платежа
- Line:
-
-
- Actions
- Действия
- Line:
-
-
- Refund
- Возврат средств
- Line:
-
-
- Status
- Статус
- Line:
-
-
- Initiate Refund
- Инициировать возврат средств
- Line:
-
-
- Refund Amount
- Сумма возмещения
- Line:
-
-
- Воспользуйтесь темой для оплаты этого платежа.
- Введите сумму для возврата средств за этот платеж.
- Line:
-
-
- Refund Reason/Comment
- Причина/комментарий возврата средств
- Line:
-
-
- Optional: A brief reason for the refund.
- Необязательно: краткая причина возврата средств.
- Line:
-
-
- Cancel
- Отменить
- Line:
-
-
- Process Refund
- Выполнить возврат средств
- Line:
-
-
-
-
\ No newline at end of file
+
+
+
+ Hutko is a payment platform whose main function is to provide internet acquiring.
+ Hutko — це платіжна платформа, основною функцією якої є забезпечення інтернет-еквайрингу.
+ Line:
+
+
+ Please specify the Hutko account details for customers
+ Будь ласка, уточніть реквізити облікового запису Hutko для клієнтів
+ Line:
+
+
+ Enter a merchant id. Use 1700002 for test setup.
+ Введіть ідентифікатор продавця. Використовуйте 1700002 для тестового налаштування.
+ Line:
+
+
+ Merchant ID.
+ Merchant ID.
+ Line:
+
+
+ Enter a secret key. Use "test" for test setup
+ Введіть секретний ключ. Використовуйте «test» для налаштування тесту.
+ Line:
+
+
+ Secret key
+ Секретний ключ
+ Line:
+
+
+ Status after success payment
+ Статус після успішної оплати
+ Line:
+
+
+ Status for new orders before payment
+ Статус нових замовлень до оплати
+ Line:
+
+
+ Include shipping cost to payment
+ Включити вартість доставки до оплати
+ Line:
+
+
+ Yes
+ Так
+ Line:
+
+
+ No
+ Ні
+ Line:
+
+
+ Shipping Name
+ Назва для доставки
+ Line:
+
+
+ Name of product/service to use in fiscalization for shipping amount
+ Назва продукту/послуги для використання у фіскалізації для суми доставки
+ Line:
+
+
+ Shipping Code
+ Код доставки
+ Line:
+
+
+ Code of product/service to use in fiscalization for shipping amount
+ Код товару/послуги для використання у фіскалізації для суми доставки
+ Line:
+
+
+ Show Visa/MasterCard logo
+ Показати логотип Visa/MasterCard
+ Line:
+
+
+ Save Logs
+ Зберігати лог запитів від/до серверу Hutko
+ Line:
+
+
+ Save
+ Зберегти
+ Line:
+
+
+ Merchant ID is required.
+ Потрібен ідентифікатор продавця (Merchant ID).
+ Line:
+
+
+ Merchant ID must be numeric.
+ Ідентифікатор продавця має бути числовим.
+ Line:
+
+
+ Secret key is required.
+ Потрібен секретний ключ.
+ Line:
+
+
+ Secret key must be at least 10 characters long and cannot be entirely numeric.
+ Секретний ключ повинен містити щонайменше 10 символів і не може бути повністю числовим.
+ Line:
+
+
+ Pay via payment system Hutko
+ Оплата через платіжну систему Hutko
+ Line:
+
+
+ Pay via Hutko
+ Оплата через Hutko
+ Line:
+
+
+ Order payment #
+ Оплата замовлення #
+ Line:
+
+
+ Order payment not found.
+ Оплату замовлення не знайдено.
+ Line:
+
+
+ Invalid transaction ID format.
+ Недійсний формат ідентифікатора транзакції.
+ Line:
+
+
+ Refund success.
+ Повернення коштів успішне.
+ Line:
+
+
+ Refund Failed. Please check actual amount in Hutko account page.
+ Повернення коштів не вдалося. Будь ласка, перевірте фактичну суму на сторінці облікового запису Hutko.
+ Line:
+
+
+
+ Платежі та повернення коштів Hutko
+ Line:
+
+
+ Transaction ID
+ Transaction ID
+ Line:
+
+
+ Amount
+ Сума
+ Line:
+
+
+ Payment Date
+ Дата платежу
+ Line:
+
+
+ Actions
+ Дії
+ Line:
+
+
+ Refund
+ Повернення коштів
+ Line:
+
+
+ Refund Amount
+ Сума відшкодування
+ Line:
+
+
+ Enter the amount to refund for this payment.
+ Введіть суму для повернення коштів за цей платіж.
+ Line:
+
+
+ Refund Reason/Comment
+ Причина/коментар повернення коштів
+ Line:
+
+
+ Optional: A brief reason for the refund.
+ Необов’язково: Коротка причина повернення коштів.
+ Line:
+
+
+ Cancel
+ Скасувати
+ Line:
+
+
+ Process Refund
+ Виконати повернення коштів
+ Line:
+
+
+
+