update translation. added retirn controller
This commit is contained in:
58
hutko.php
58
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user