diff --git a/README.md b/README.md index 26a72da..bd51ab7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![PHP](https://img.shields.io/badge/PHP-5.6%2B-purple) ![License](https://img.shields.io/badge/License-MIT-green) -> **📦 Версия модуля: 1.0.1** +> **📦 Версия модуля: 1.0.2** > **ℹ️ Совместимость версий OpenCart:** > 3.0.0.0, 3.0.1.1, 3.0.1.2, 3.0.2.0, 3.0.3.0, 3.0.3.1, 3.0.3.2, 3.0.3.3, 3.0.3.4, 3.0.3.5, 3.0.3.6, 3.0.3.7, 3.0.3.8, 3.0.3.9, 3.0.4.0, 3.0.4.1, 3.0.5.0 @@ -76,7 +76,7 @@ | **Тестовый режим** | `Нет` | | **Check URL** | `https://your_site_name/index.php?route=extension/payment/payanyway/callback` | | **Pay URL** | `https://your_site_name/index.php?route=extension/payment/payanyway/callback` | -| **HTTP method** | `GET` / `POST` | +| **HTTP method** | `GET` | | **Можно переопределять настройки в URL** | `Да` | | **Подпись формы оплаты обязательна** | `Да` | | **Код проверки целостности данных** | `ваш_код` (произвольный набор символов) | diff --git a/install.xml b/install.xml index 1935d74..b4a2813 100644 --- a/install.xml +++ b/install.xml @@ -2,7 +2,7 @@ PayAnyWay payanyway - 1.0.1 + 1.0.2 PayAnyWay https://payanyway.ru/ diff --git a/upload/admin/controller/extension/payment/payanyway.php b/upload/admin/controller/extension/payment/payanyway.php index 86cec80..7f630b3 100755 --- a/upload/admin/controller/extension/payment/payanyway.php +++ b/upload/admin/controller/extension/payment/payanyway.php @@ -9,7 +9,7 @@ class ControllerExtensionPaymentPayanyway extends Controller { const CMS_NAME = 'OpenCart'; const MODULE_NAME = 'payanyway'; - const MODULE_VERSION = '1.0.1'; + const MODULE_VERSION = '1.0.2'; const MODULE_DEFAULT_SORT_ORDER = 0; private $supportedCurrencies = array('RUB'); @@ -289,9 +289,10 @@ class ControllerExtensionPaymentPayanyway extends Controller { $cmsName = $this->detectCmsByPatterns($textFooter); $cmsVersion = defined('VERSION') ? constant('VERSION') : '.unknown'; - return sprintf('%s v%s | %s v%s', + return sprintf('%s v%s|PHP %s|%s v%s', $cmsName, $cmsVersion, + PHP_VERSION, self::MODULE_NAME, self::MODULE_VERSION ); diff --git a/upload/admin/view/image/payment/payanyway.png b/upload/admin/view/image/payment/payanyway.png old mode 100755 new mode 100644 index 724d34b..859c44f Binary files a/upload/admin/view/image/payment/payanyway.png and b/upload/admin/view/image/payment/payanyway.png differ diff --git a/upload/admin/view/template/extension/payment/payanyway.twig b/upload/admin/view/template/extension/payment/payanyway.twig index 45b0db8..1725f98 100755 --- a/upload/admin/view/template/extension/payment/payanyway.twig +++ b/upload/admin/view/template/extension/payment/payanyway.twig @@ -27,7 +27,7 @@
- PayAnyWay + PayAnyWay
diff --git a/upload/catalog/controller/extension/payment/payanyway.php b/upload/catalog/controller/extension/payment/payanyway.php index 85d55b7..aa598c5 100755 --- a/upload/catalog/controller/extension/payment/payanyway.php +++ b/upload/catalog/controller/extension/payment/payanyway.php @@ -13,6 +13,7 @@ class ControllerExtensionPaymentPayanyway extends Controller { const TRANSACTION_ID_STRING_DELIMITER = '|'; const DESCRIPTION_MAX_LENGTH = 500; + const CLIENT_NAME_MAX_LENGTH = 256; const INVENTORY_ITEM_NAME_MAX_LENGTH = 128; const INVENTORY_ITEM_DEFAULT_PAYMENT_METHOD = 'full_payment'; const INVENTORY_ITEM_DEFAULT_PAYMENT_OBJECT = 'commodity'; @@ -91,14 +92,15 @@ class ControllerExtensionPaymentPayanyway extends Controller { $this->integrityCode ); $data['MNT_SIGNATURE'] = $signature; - $data['MNT_SUCCESS_URL'] = $this->url->link('extension/payment/payanyway/success', 'language=' . $this->config->get('config_language'), true); - $data['MNT_FAIL_URL'] = $this->url->link('extension/payment/payanyway/fail', 'language=' . $this->config->get('config_language'), true); - $data['MNT_RETURN_URL'] = $this->url->link('checkout/checkout', 'language=' . $this->config->get('config_language'), true); + $data['MNT_SUCCESS_URL'] = $this->url->link('extension/payment/payanyway/success', '', true); + $data['MNT_FAIL_URL'] = $this->url->link('extension/payment/payanyway/fail', '', true); + $data['MNT_RETURN_URL'] = $this->url->link('checkout/checkout', '', true); + $data['moneta_locale'] = $this->language->get('text_locale'); $data['MNT_CMS'] = $this->cmsModuleVersion; $data['btn_confirm'] = $this->language->get('text_paw_pay'); - $data['confirm_url'] = $this->url->link('extension/payment/payanyway/confirm', 'language=' . $this->config->get('config_language'), true); + $data['confirm_url'] = $this->url->link('extension/payment/payanyway/confirm', '', true); return $this->load->view('extension/payment/payanyway', $data); } @@ -125,7 +127,11 @@ class ControllerExtensionPaymentPayanyway extends Controller { */ public function success() { $this->load->language('extension/payment/payanyway'); - $this->addOrderHistory($this->pendingOrderStatusId, $this->language->get('text_payment_processing')); + + $orderStatusId = isset($this->orderInfo['order_status_id']) ? (int)$this->orderInfo['order_status_id'] : null; + if ((null !== $orderStatusId) && ($orderStatusId !== $this->successOrderStatusId)) { + $this->addOrderHistory($this->pendingOrderStatusId, $this->language->get('text_payment_processing')); + } $this->response->redirect($this->url->link('checkout/success', '', true)); } @@ -180,14 +186,11 @@ class ControllerExtensionPaymentPayanyway extends Controller { /** @return string */ private function getDescription() { - $clientFirstName = isset($this->orderInfo['firstname']) ? $this->orderInfo['firstname'] : ''; - $clientLastName = isset($this->orderInfo['lastname']) ? $this->orderInfo['lastname'] : ''; - $clientName = trim($clientFirstName . ' ' . $clientLastName); - $orderId = isset($this->orderInfo['order_id']) ? $this->orderInfo['order_id'] : null; $description = "Оплата заказа" . (!empty($orderId) ? " №{$orderId}" : ''); - if ('' !== $clientName) { + $clientName = $this->getClientName(); + if (null !== $clientName) { $description .= " от {$clientName}"; } @@ -230,16 +233,14 @@ class ControllerExtensionPaymentPayanyway extends Controller { /** @return string */ private function getSubscriberId() { - $email = isset($this->orderInfo['email']) - ? filter_var($this->orderInfo['email'], FILTER_SANITIZE_EMAIL) - : ''; - if ('' !== $email) { + $email = $this->getClientEmail(); + if (null !== $email) { return $email; } - return isset($this->orderInfo['telephone']) - ? preg_replace('/[^0-9+]/', '', $this->orderInfo['telephone']) - : ''; + $phone = $this->getClientPhone(); + + return (null !== $phone) ? $phone : ''; } /** @@ -428,7 +429,7 @@ class ControllerExtensionPaymentPayanyway extends Controller { $deliveryPrice = $this->getDeliveryPrice(); $data['inventory'] = $this->getInventoryJson($products) ?: null; - $data['client'] = $callbackData['MNT_SUBSCRIBER_ID']; + $data['client'] = $this->getClientInfoJson() ?: null; $data['sno'] = null; $data['delivery'] = (null !== $deliveryPrice) ? $this->formatPrice($deliveryPrice) : null; @@ -516,6 +517,30 @@ class ControllerExtensionPaymentPayanyway extends Controller { return json_encode($inventory, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } + /** @return false|string */ + private function getClientInfoJson() + { + $clientInfo = array(); + $name = $this->getClientName(); + if (null !== $name) { + $clientInfo['name'] = $name; + } + $email = $this->getClientEmail(); + if (null !== $email) { + $clientInfo['email'] = $email; + } + $phoneNumber = $this->getClientPhone(); + if (null !== $phoneNumber) { + $clientInfo['phone'] = $phoneNumber; + } + + if (empty($clientInfo)) { + return false; + } + + return json_encode(array($clientInfo), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + } + /** * @param int $orderStatusId * @return string @@ -599,6 +624,41 @@ class ControllerExtensionPaymentPayanyway extends Controller { return (false !== $xml) ? $xml : 'FAIL'; } + /** + * @return non-empty-string|null + */ + private function getClientName() + { + $firstname = isset($this->orderInfo['firstname']) ? $this->orderInfo['firstname'] : ''; + $lastname = isset($this->orderInfo['lastname']) ? $this->orderInfo['lastname'] : ''; + + $name = trim($firstname . ' ' . $lastname); + + return ('' !== $name) ? $this->validateString($name, self::CLIENT_NAME_MAX_LENGTH) : null; + } + + /** + * @return non-empty-string|null + */ + private function getClientEmail() + { + $email = isset($this->orderInfo['email']) ? $this->orderInfo['email'] : ''; + $email = trim((string)$email); + + return ('' !== $email) ? filter_var($email, FILTER_SANITIZE_EMAIL) : null; + } + + /** + * @return non-empty-string|null + */ + private function getClientPhone() + { + $telephone = isset($this->orderInfo['telephone']) ? $this->orderInfo['telephone'] : ''; + $digits = preg_replace('/\D/', '', trim((string)$telephone)); + + return ('' !== $digits) ? '+' . $digits : null; + } + /** * @param array $params * @param string $key diff --git a/upload/catalog/language/en-gb/extension/payment/payanyway.php b/upload/catalog/language/en-gb/extension/payment/payanyway.php index b48dddf..beede39 100755 --- a/upload/catalog/language/en-gb/extension/payment/payanyway.php +++ b/upload/catalog/language/en-gb/extension/payment/payanyway.php @@ -1,5 +1,6 @@ +