> For the complete documentation index, see [llms.txt](https://docs.easydonate.ru/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.easydonate.ru/plugin/easydonate.surcharge.md).

# Доплата

## Получение настроек

<mark style="color:blue;">`GET`</mark> `https://easydonate.ru/api/v3/plugin/EasyDonate.Surcharge/getSettings`

Запрос вернет настройки плагина.

#### Headers

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| Shop-Key<mark style="color:red;">\*</mark> | string | Уникальный ключ магазина |

{% tabs %}
{% tab title="200 Запрос успешно обработан" %}

```
{
   "success": true,
   "response": {
      "enabled": true,
      "disallow_with_promocodes": false,
      "duration": 0,
      "enableForGroup": true,
      "enableForItem": false,
      "enableForCurrency": false,
      "enableForOther": false
   }
}
```

{% endtab %}

{% tab title="400 Ошибка" %}

```
{
   "success": false,
   "error_code": 5,
   "response": "Плагин неактивен."
}
```

{% endtab %}
{% endtabs %}

## Получение индивидуальных акций для пользователя

<mark style="color:blue;">`GET`</mark> `https://easydonate.ru/api/v3/plugin/EasyDonate.Surcharge/getDiscounts`

Запрос вернет список товаров, доступных пользователю для доплаты.

#### Query Parameters

| Name                                       | Type   | Description                           |
| ------------------------------------------ | ------ | ------------------------------------- |
| username<mark style="color:red;">\*</mark> | string | Имя пользователя. Например: Player123 |

#### Headers

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| Shop-Key<mark style="color:red;">\*</mark> | string | Уникальный ключ магазина |

{% tabs %}
{% tab title="200: OK Запрос успешно обработан" %}

```
{
   "success": true,
   "response": [
      {
         "id": 2553,
         "name": "Premium",
         "price": 200,
         "old_price": 200,
         "type": "group",
         "number": 1,
         "is_hidden": 0,
         "commands": [
            "lp user {user} parent add premium"
         ],
         "withdraw_commands": null,
         "withdraw_commands_days": null,
         "additional_fields": null,
         "description": null,
         "category_id": 1524,
         "image": "https://cp.easydonate.ru/storage/app/uploads/public/606/099/d07/606099d079c0c935816621.png",
         "first_delete": 0,
         "shop_id": 609,
         "created_at": "2021-01-30 19:00:24",
         "updated_at": "2021-08-26 19:18:35",
         "sort_index": 0,
         "target": {
            "id": 11722
         },
         "discount": 100 // Сумма скидки
      }
   ]
}
```

{% endtab %}

{% tab title="400: Bad Request Ошибка" %}

```
{
   "success": false,
   "response": "Не передан обязательный параметр `username`.",
   "error_code": 3
}
```

{% endtab %}
{% endtabs %}

## Проверка доплаты для товара по его ID

<mark style="color:blue;">`GET`</mark> `https://easydonate.ru/api/v3/plugin/EasyDonate.Surcharge/getDiscountFor`

В случае, если пользователю недоступна доплата для данного товара, запрос вернет пустой ответ.&#x20;

#### Query Parameters

| Name                                          | Type    | Description                           |
| --------------------------------------------- | ------- | ------------------------------------- |
| username<mark style="color:red;">\*</mark>    | string  | Имя пользователя. Например: Player123 |
| product\_id<mark style="color:red;">\*</mark> | integer | Идентификатор товара                  |

#### Headers

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| Shop-Key<mark style="color:red;">\*</mark> | string | Уникальный ключ магазина |

{% tabs %}
{% tab title="200: OK Запрос успешно обработан" %}

```
{
   "success": true,
   "response": {
      "id": 2553,
      "name": "Premium",
      "price": 200,
      "old_price": 200,
      "type": "group",
      "number": 1,
      "is_hidden": 0,
      "commands": [
         "lp user {user} parent add premium"
      ],
      "withdraw_commands": null,
      "withdraw_commands_days": null,
      "additional_fields": null,
      "description": null,
      "category_id": 1524,
      "image": "https://cp.easydonate.ru/storage/app/uploads/public/606/099/d07/606099d079c0c935816621.png",
      "first_delete": 0,
      "shop_id": 609,
      "created_at": "2021-01-30 19:00:24",
      "updated_at": "2021-08-26 19:18:35",
      "sort_index": 0,
      "target": {
         "id": 11722
      },
      "discount": 100 // Сумма скидки
   }
}
```

{% endtab %}

{% tab title="400: Bad Request Ошибка" %}

```
{
   "success": false,
   "response": "Для данного товара доплата не действует.",
   "error_code": 3
}
```

{% endtab %}
{% endtabs %}
