Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PaySelection - универсальное платежное решение дл

Плагин не учитывает настройку налогообложения по отдельным товарам.

**Поддерживаемые ставки НДС:** 22%, 20%, 10%, 7%, 5%, Без НДС.

## Установка

Плагин можно установить с помощью Инсталера со [страницы плагина](https://www.webasyst.ru/store/plugin/payment/payselection/) либо вручную из этого репозитория.
Expand Down Expand Up @@ -63,6 +65,9 @@ CVC 123
# Changelog
Все значимые изменения плагина перечислены здесь.

## [1.0.4] - 2025-12-22
- Добавлены новые ставки НДС

## [1.0.3] - 2023-04-06
- Добавлена возможность настроить СНО, признак способа расчета и вид оплаты

Expand Down
2 changes: 1 addition & 1 deletion lib/config/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'description' => 'Online payment service',
'logo' => 'img/payselection2.png',
'icon' => 'img/payselection.png',
'version' => '1.0.3',
'version' => '1.0.4',
'vendor' => '1274583',
'partial_refund' => true,
'partial_capture' => false,
Expand Down
32 changes: 32 additions & 0 deletions lib/config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,26 @@
'title' => /*_w*/('Из карточки товара'),
'value' => ''
),
array(
'title' => /*_w*/('НДС 22%'),
'value' => '22'
),
array(
'title' => /*_w*/('НДС 20%'),
'value' => '20'
),
array(
'title' => /*_w*/('НДС 10%'),
'value' => '10'
),
array(
'title' => /*_w*/('НДС 7%'),
'value' => '7'
),
array(
'title' => /*_w*/('НДС 5%'),
'value' => '5'
),
array(
'title' => /*_w*/('Без НДС'),
'value' => '-1'
Expand All @@ -154,10 +170,26 @@
'title' => /*_w*/('Источник значения НДС для доставки'),
'control_type' => waHtmlControl::SELECT,
'options' => array(
array(
'title' => /*_w*/('НДС 22%'),
'value' => '22'
),
array(
'title' => /*_w*/('НДС 20%'),
'value' => '20'
),
array(
'title' => /*_w*/('НДС 10%'),
'value' => '10'
),
array(
'title' => /*_w*/('НДС 7%'),
'value' => '7'
),
array(
'title' => /*_w*/('НДС 5%'),
'value' => '5'
),
array(
'title' => /*_w*/('Без НДС'),
'value' => '-1'
Expand Down
81 changes: 45 additions & 36 deletions lib/payselectionPayment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@ public function getWebhookSignature()
return $signature;
}

/**
* Map numeric tax percentage to API vat type string
* Supported: 22, 20, 10, 7, 5, none
*/
protected function mapVatType($tax)
{
$t = (float)$tax;
if ($t <= 0) {
return 'none';
}
if (abs($t - 22) < 0.01) {
return 'vat22';
}
if (abs($t - 20) < 0.01) {
return 'vat20';
}
if (abs($t - 10) < 0.01) {
return 'vat10';
}
if (abs($t - 7) < 0.01) {
return 'vat7';
}
if (abs($t - 5) < 0.01) {
return 'vat5';
}
// Fallbacks for non-standard values
if ($t >= 20) {
return 'vat20';
}
if ($t > 10) {
return 'vat10';
}
return 'none';
}

public function query($api_method, $content, $method = waNet::METHOD_POST, $type_host = 'gw')
{
$url = $this->getUrl($api_method, $type_host);
Expand Down Expand Up @@ -138,17 +173,11 @@ public function apiCreateArray($order_data)
} else {
foreach ($order_data['items'] as $item) {
$tax = empty($this->tax) ? $item['tax_rate'] : $this->tax;
if ($tax > 10) {
$tax = 'vat20';
} else if ($tax > 0) {
$tax = 'vat10';
} else {
$tax = 'none';
}
$tax = $this->mapVatType($tax);

if($this->payment_type == 'Block') {
$tax = str_replace('vat', 'vat1', $tax);
}
// if($this->payment_type == 'Block') {
// $tax = str_replace('vat', 'vat1', $tax);
// }

$content['ReceiptData']['receipt']['items'][] = array(
'name' => mb_substr($item['name'], 0, 128),
Expand All @@ -164,18 +193,11 @@ public function apiCreateArray($order_data)
}

if (!empty($order_data['shipping'])) {
$tax = $this->tax_delivery;
if ($tax > 10) {
$tax = 'vat20';
} else if ($tax > 0) {
$tax = 'vat10';
} else {
$tax = 'none';
}
$tax = $this->mapVatType($this->tax_delivery);

if($this->payment_type == 'Block') {
$tax = str_replace('vat', 'vat1', $tax);
}
// if($this->payment_type == 'Block') {
// $tax = str_replace('vat', 'vat1', $tax);
// }
$content['ReceiptData']['receipt']['items'][] = array(
'name' => 'Доставка',
'price' => round($order_data['shipping'],2),
Expand Down Expand Up @@ -243,13 +265,7 @@ public function apiRefundArray($transaction_raw_data, $order_data)
$refund_items = waRequest::post('refund_items', array());
foreach ($order_data['items'] as $item) {
$tax = empty($this->tax) ? $item['tax_rate'] : $this->tax;
if ($tax > 10) {
$tax = 'vat20';
} else if ($tax > 0) {
$tax = 'vat10';
} else {
$tax = 'none';
}
$tax = $this->mapVatType($tax);

if(waRequest::post('refund_mode') == 'full') {
$content['ReceiptData']['receipt']['items'][] = array(
Expand Down Expand Up @@ -284,14 +300,7 @@ public function apiRefundArray($transaction_raw_data, $order_data)
}

if (!empty($order_data['shipping']) && waRequest::post('refund_mode') == 'full') {
$tax = $this->tax_delivery;
if ($tax > 10) {
$tax = 'vat20';
} else if ($tax > 0) {
$tax = 'vat10';
} else {
$tax = 'none';
}
$tax = $this->mapVatType($this->tax_delivery);

$content['ReceiptData']['receipt']['items'][] = array(
'name' => 'Доставка',
Expand Down