Feature/merge main to release

This commit is contained in:
2026-07-03 15:11:52 +03:00
committed by Git Moneta
parent 83f1d8d101
commit c3189d2439
9 changed files with 88 additions and 24 deletions
@@ -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<string, mixed> $params
* @param string $key
@@ -1,5 +1,6 @@
<?php
// Text
$_['text_locale'] = 'en';
$_['text_title'] = 'PayAnyWay (MIR, VISA, MasterCard and 30+ other ways)';
$_['text_ap_pay_with'] = 'Pay with';
$_['text_ap_and_other'] = 'or another payment method';
@@ -1,5 +1,6 @@
<?php
// Text
$_['text_locale'] = 'ru';
$_['text_title'] = 'PayAnyWay (МИР, Visa, MasterCard и более 30-и способов оплаты)';
$_['text_ap_pay_with'] = 'Оплатить с';
$_['text_ap_and_other'] = 'или другой способ оплаты';
@@ -10,6 +10,7 @@
<input type="hidden" name="MNT_SUCCESS_URL" value="{{ MNT_SUCCESS_URL }}"/>
<input type="hidden" name="MNT_FAIL_URL" value="{{ MNT_FAIL_URL }}"/>
<input type="hidden" name="MNT_RETURN_URL" value="{{ MNT_RETURN_URL }}"/>
<input type="hidden" name="moneta.locale" value="{{ moneta_locale }}"/>
<input type="hidden" name="MNT_CMS" value="{{ MNT_CMS }}"/>
<div class="buttons">
<div class="{% if ap_use %} text-center {% else %} pull-right {% endif %}">