К содержанию

Оплаты

Оплаты сделок, возвраты и способы оплаты организации.

Плательщики счетов

GET /billing-entities

Кто выставляет счета организации: префикс и нумерация номеров, срок оплаты, валюта и часовой пояс. Только чтение; main появляется с первым счётом.

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/billing-entities' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/billing-entities', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/billing-entities",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/billing-entities', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "items": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b0",
      "code": "main",
      "name": "ООО «Кофейная гильдия»",
      "legalName": null,
      "documentNumberPrefix": "KAV",
      "documentNumbering": "per_billing_entity",
      "netPaymentTerm": 0,
      "defaultCurrency": "UAH",
      "timezone": "Europe/Kyiv",
      "pricesIncludeTax": true,
      "taxRateId": "0192f3a1-7c2e-7b4d-9a61-000000000c01"
    }
  ]
}
Поля ответа
  • items object[]

    Вложенные поля: 11
    • code string

    • defaultCurrency string

      шаблон ^[A-Z]{3}$

    • documentNumberPrefix string

    • documentNumbering string

      Значения: per_customer per_billing_entity

    • id string · uuid

    • legalName string | null

    • name string

    • netPaymentTerm integer

      ≥ 0

    • pricesIncludeTax boolean

    • taxRateId string · uuid | null

    • timezone string

Налоги продавца

PATCH /billing-entities/{billingEntityId}

Нужна страница «Товары» в роли. pricesIncludeTax — «Цены включают налог»: налог выделяется из цены строки, иначе добавляется сверху и сумма сделки растёт на него; taxRateId — ставка по умолчанию, которую берёт строка товара без своей ставки (null — без неё). Касается строк, которые добавят после изменения: строка, уже стоящая в сделке, сохраняет свой налог. Поле, которое не прислали, остаётся. Ставки нет — 400, ставка в архиве — 409 tax_rate_archived. Пока счета всех сделок выставляет продавец main, другой продавец — 409 only_main_seller.

Параметры пути

  • billingEntityId string · uuid обязательно

Тело запроса

  • pricesIncludeTax boolean

  • taxRateId string · uuid | null

Пример запроса

bash
curl -X PATCH 'https://your-company.altahub.ai/api/v1/billing-entities/{billingEntityId}' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "pricesIncludeTax": true,
  "taxRateId": "0192f3a1-7c2e-7b4d-9a61-000000000c01"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/billing-entities/{billingEntityId}', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    pricesIncludeTax: true,
    taxRateId: '0192f3a1-7c2e-7b4d-9a61-000000000c01',
  }),
});
const data = await response.json();
python
import requests

response = requests.patch(
    "https://your-company.altahub.ai/api/v1/billing-entities/{billingEntityId}",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "pricesIncludeTax": True,
        "taxRateId": "0192f3a1-7c2e-7b4d-9a61-000000000c01",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://your-company.altahub.ai/api/v1/billing-entities/{billingEntityId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'pricesIncludeTax' => true,
        'taxRateId' => '0192f3a1-7c2e-7b4d-9a61-000000000c01',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b0",
  "code": "main",
  "name": "ООО «Кофейная гильдия»",
  "legalName": null,
  "documentNumberPrefix": "KAV",
  "documentNumbering": "per_billing_entity",
  "netPaymentTerm": 0,
  "defaultCurrency": "UAH",
  "timezone": "Europe/Kyiv",
  "pricesIncludeTax": true,
  "taxRateId": "0192f3a1-7c2e-7b4d-9a61-000000000c01"
}
Поля ответа
  • code string

  • defaultCurrency string

    шаблон ^[A-Z]{3}$

  • documentNumberPrefix string

  • documentNumbering string

    Значения: per_customer per_billing_entity

  • id string · uuid

  • legalName string | null

  • name string

  • netPaymentTerm integer

    ≥ 0

  • pricesIncludeTax boolean

  • taxRateId string · uuid | null

  • timezone string

Счета сделки

GET /deals/{dealId}/invoices

Счета сделки, новые сверху, со строками, оплатами (отменённая остаётся — failed) и возвратами; сколько осталось оплатить и просрочен ли. totals — итоги по валютам. Платёж частями — это счёт в статусе pending с датой paymentDueDate. Суммы — в копейках (*Cents).

Параметры пути

  • dealId string · uuid обязательно

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "items": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b2",
      "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
      "billingEntityCode": "main",
      "number": "KAV-202610-002",
      "invoiceType": "one_off",
      "status": "finalized",
      "paymentStatus": "pending",
      "paymentOverdue": false,
      "issuingDate": "2026-10-23",
      "paymentDueDate": "2026-10-30",
      "netPaymentTerm": 7,
      "currency": "UAH",
      "feesAmountCents": 600000,
      "taxesAmountCents": 0,
      "totalAmountCents": 600000,
      "totalPaidAmountCents": 0,
      "totalDueAmountCents": 600000,
      "totalRefundedAmountCents": 0,
      "voidedAt": null,
      "method": "Счёт в банке",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "comment": null,
      "paymentFields": [],
      "source": "alta",
      "createdBy": {
        "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
        "name": "Ирина Мельник"
      },
      "version": 1,
      "fees": [
        {
          "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b5",
          "invoiceDisplayName": "Кофемашины для сети кофеен",
          "description": null,
          "units": "1",
          "unitAmountCents": 600000,
          "amountCents": 600000,
          "taxesAmountCents": 0
        }
      ],
      "couponsAmountCents": 0,
      "discounts": [],
      "payments": [],
      "createdAt": "2026-10-23T10:30:00Z"
    },
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
      "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
      "billingEntityCode": "main",
      "number": "KAV-202610-001",
      "invoiceType": "one_off",
      "status": "finalized",
      "paymentStatus": "succeeded",
      "paymentOverdue": false,
      "issuingDate": "2026-10-23",
      "paymentDueDate": "2026-10-23",
      "netPaymentTerm": 0,
      "currency": "UAH",
      "feesAmountCents": 600000,
      "taxesAmountCents": 0,
      "totalAmountCents": 600000,
      "totalPaidAmountCents": 600000,
      "totalDueAmountCents": 0,
      "totalRefundedAmountCents": 0,
      "voidedAt": null,
      "method": "Счёт в банке",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "comment": "Предоплата 50%",
      "paymentFields": [],
      "source": "alta",
      "createdBy": {
        "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
        "name": "Ирина Мельник"
      },
      "version": 1,
      "fees": [
        {
          "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b4",
          "invoiceDisplayName": "Кофемашины для сети кофеен",
          "description": null,
          "units": "1",
          "unitAmountCents": 600000,
          "amountCents": 600000,
          "taxesAmountCents": 0
        }
      ],
      "couponsAmountCents": 0,
      "discounts": [],
      "payments": [
        {
          "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
          "paymentType": "manual",
          "paymentStatus": "succeeded",
          "amountCents": 600000,
          "currency": "UAH",
          "paidAt": "2026-10-23T10:30:00Z",
          "reference": "deal:1042",
          "orderReference": null,
          "method": "Счёт в банке",
          "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
          "comment": "Предоплата 50%",
          "paymentFields": [],
          "canceledAt": null,
          "cancelReason": null,
          "refundableAmountCents": 600000,
          "refunds": [],
          "source": "alta",
          "version": 1,
          "createdAt": "2026-10-23T10:30:00Z"
        }
      ],
      "createdAt": "2026-10-23T10:30:00Z"
    }
  ],
  "totals": [
    {
      "currency": "UAH",
      "totalAmountCents": 1200000,
      "totalPaidAmountCents": 600000,
      "totalRefundedAmountCents": 0,
      "totalDueAmountCents": 600000
    }
  ]
}
Поля ответа
  • items object[]

    Вложенные поля: 34
    • billingEntityCode string

    • comment string | null

    • couponsAmountCents integer

      0–9007199254740991

    • createdAt string · date-time

    • createdBy object | null

      Вложенные поля: 2
      • id string · uuid

      • name string

    • currency string

      шаблон ^[A-Z]{3}$

    • dealId string · uuid

    • discounts object[]

      Вложенные поля: 3
      • amountCents integer

        0–9007199254740991

      • kind string

        Значения: coupon manual

      • name string | null

    • fees object[]

      Вложенные поля: 11
      • amountCents integer

        0–9007199254740991

      • description string | null

      • id string · uuid

      • invoiceDisplayName string | null

      • taxesAmountCents integer

        0–9007199254740991

      • unitAmountCents integer

        0–9007199254740991

      • units string

      • productId string · uuid | null

      • rateId string · uuid | null

      • taxes object[]

        Вложенные поля: 6
        • amountCents integer

          0–9007199254740991

        • baseAmountCents integer

          0–9007199254740991

        • inclusive boolean

        • name string

        • rate string

          шаблон ^[0-9]{1,3}\.[0-9]{2}$

        • taxRateId string · uuid

      • unitAmountExcludingTax string

        шаблон ^[0-9]+(\.[0-9]{1,6})?$

    • feesAmountCents integer

      0–9007199254740991

    • id string · uuid

    • invoiceType string

      Значения: one_off credit

    • issuingDate string · date

    • method string | null

    • methodId string · uuid | null

    • netPaymentTerm integer

      ≥ 0

    • number string

    • paymentDueDate string · date

    • paymentFields object[]

      Вложенные поля: 2
      • fieldId string · uuid

      • value string | boolean | string[] · uuid | object

        Вариант 1 · string

        string

        Вариант 2 · boolean

        boolean

        Вариант 3 · string[] · uuid

        string[] · uuid

        Вариант 4 · object
        • amount string

        • currency string

        Вариант 5 · object
        • city string

        • country string

        • line string

        • postcode string

    • paymentOverdue boolean

    • paymentStatus string

      Значения: pending succeeded failed

    • payments object[]

      Вложенные поля: 19
      • amountCents integer

        0–9007199254740991

      • cancelReason string | null

      • canceledAt string · date-time | null

      • comment string | null

      • createdAt string · date-time

      • currency string

        шаблон ^[A-Z]{3}$

      • id string · uuid

      • method string | null

      • methodId string · uuid | null

      • orderReference string | null

      • paidAt string · date-time | null

      • paymentFields object[]

        Вложенные поля: 2
        • fieldId string · uuid

        • value string | boolean | string[] · uuid | object

          Вариант 1 · string

          string

          Вариант 2 · boolean

          boolean

          Вариант 3 · string[] · uuid

          string[] · uuid

          Вариант 4 · object
          • amount string

          • currency string

          Вариант 5 · object
          • city string

          • country string

          • line string

          • postcode string

      • paymentStatus string

        Значения: pending processing succeeded failed

      • paymentType string

        Значения: manual provider

      • reference string | null

      • refundableAmountCents integer

        0–9007199254740991

      • refunds object[]

        Вложенные поля: 7
        • amountCents integer

          0–9007199254740991

        • createdAt string · date-time

        • createdBy object | null

          Вложенные поля: 2
          • id string · uuid

          • name string

        • id string · uuid

        • reason string | null

        • refundedAt string · date-time | null

        • status string

          Значения: pending succeeded failed

      • source string

      • version integer

        ≥ 1

    • source string

    • status string

      Значения: draft finalized voided failed pending

    • taxesAmountCents integer

      0–9007199254740991

    • totalAmountCents integer

      0–9007199254740991

    • totalDueAmountCents integer

      0–9007199254740991

    • totalPaidAmountCents integer

      0–9007199254740991

    • totalRefundedAmountCents integer

      0–9007199254740991

    • version integer

      ≥ 1

    • voidedAt string · date-time | null

    • appliedTaxes object[]

      Вложенные поля: 6
      • amountCents integer

        0–9007199254740991

      • baseAmountCents integer

        0–9007199254740991

      • inclusive boolean

      • name string

      • rate string

        шаблон ^[0-9]{1,3}\.[0-9]{2}$

      • taxRateId string · uuid

    • declined object

      Вложенные поля: 1
      • reason string

        Значения: payer_canceled refused expired withdrawn insufficient_funds card_velocity_exceeded expired_card incorrect_card_details authentication_failed issuer_declined fraudulent instalment_refused processing_error

    • paymentId string · uuid

  • totals object[]

    Вложенные поля: 5
    • currency string

      шаблон ^[A-Z]{3}$

    • totalAmountCents integer

      0–9007199254740991

    • totalDueAmountCents integer

      0–9007199254740991

    • totalPaidAmountCents integer

      0–9007199254740991

    • totalRefundedAmountCents integer

      0–9007199254740991

Выставить счёт

POST /deals/{dealId}/invoices

Строки (fees) или одна сумма (amountCents, строка с названием сделки), валюта, дата оплаты (paymentDueDate; без неё — сразу). С payment счёт сразу оплачен целиком — это «Записать оплату» в один клик; payment.paidAt не в будущем (400). Сделка в корзине — 409. idempotencyKey делает повтор безопасным. В payment.orderReference — ваш номер заказа: в организации один заказ — одна оплата, кто бы её ни записал (API, платёжный сервис, сверка, импорт). У заказа уже есть оплата на этой сделке — ответ 201 со счётом той оплаты, второй не будет; повтор безопасен, даже когда idempotencyKey равен orderReference. Вы важнее импорта и догадки по телефону: оплату от платёжного сервиса, которую по телефону или e-mail положило на другую сделку или которая ждёт в «Неразобранных оплатах», а также оплату, которую импорт записал на другую сделку, перенесём на эту сделку, и именно на неё лягут его возвраты. На другой сделке останется аннулированный счёт без денег и две строки истории: её итоги такие, будто оплаты там не было; следующие шаги импорта её не вернут. Оплату к другой сделке привязал человек — 409 order_linked_by_person; её уже записали на другую сделку через API, положила туда ссылка на оплату или номер сделки в заказе, на сделку, которую вы не можете менять, или сделка в корзине — 409 order_on_another_deal, так что устаревший запрос не вернёт оплату обратно; на ней уже есть возврат — 409 order_refunded_on_another_deal. Сумма оплаты остаётся такой, как записана впервые. Другой запрос записал этот же заказ в ту же секунду — 409 order_taken; оплату заказа в ту же секунду отменили — 409 order_payment_canceled. Оба ответа можно повторить: тот же запрос ещё раз получит ответ по правилу. «Обязательно при оплате» останавливает только оплату, которую записывает человек в Alta: оплату через API не останавливает. Значения таких полей можно передать в customFields — они запишутся в сделку вместе с оплатой. Сумма (amountCents), равная итогу выбранных строк сделки до её купонов и скидки, пока они на этих строках есть, — 409 stale_client_reload: окно открыто до скидок, обновите страницу. manualDiscount («Скидка на всё») — скидка сделки на всю сделку с этого момента, percent (больше 0, не больше 100) от того, что осталось от сделки, или amount в её валюте; null её снимает. Записывается в сделку при выставлении, после скидок строк и товаров окна и до того, как счёт берёт строки, как её пишет PUT /deals/{dealId}/discounts/manual: делится по строкам самой сделки (товар только этой оплаты доли не получает), в пределах «Максимальной скидки, %» роли (403 discount_above_role_cap), с правом «Менять цену в сделке» (403; скидка сделки, отправленная как есть, права не спрашивает); 409 imported_lines, amount_kept_by_sync, amount_not_from_products. Повтор с тем же ключом второй раз её не пишет.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • currency string обязательно

    шаблон ^[A-Z]{3}$

  • idempotencyKey string обязательно

    шаблон ^[\x21-\x7e]{1,255}$

  • amountCents integer

    1–9007199254740991

  • comment string | null

    длина ≤ 1000

  • customFields object[]

    количество ≤ 100

    Вложенные поля: 2
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null обязательно

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

  • fees object[]

    количество 1–100

    Вложенные поля: 4
    • unitAmountCents integer обязательно

      0–9007199254740991

    • description string | null

      длина ≤ 1000

    • invoiceDisplayName string

      длина ≤ 200

    • units string

      шаблон ^[0-9]{1,12}(\.[0-9]{1,6})?$

  • manualDiscount object | null

    Вложенные поля: 2
    • type string обязательно

      A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

      Значения: percent amount

    • value string | number обязательно

      шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • methodId string · uuid | null

  • payment object | null

    Вложенные поля: 2
    • orderReference string

      длина 1–200 · шаблон ^(?=.*\S)[^\u0000-\u001f\u007f-\u009f]+$

    • paidAt string · date-time

  • paymentDueDate string · date | null

  • paymentFields object[]

    количество ≤ 100

    Вложенные поля: 2
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null обязательно

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

  • productLineDiscounts object[]

    A discount given in the payment window to the deal's lines it is for, each line once (another time is 400 `duplicate_product_line` at its place): `discount`, per unit, a `percent` (more than 0, at most 100) or an `amount` of the line's currency (more than 0), off the line's own price before its discount, is the line's discount from now on (`null`: none), as PATCH /deals/{dealId}/products/{lineId} takes it with `discount`. A line that is not among the lines the payment is for (`productLineIds`) is 400 `product_line_not_chosen` at its place; giving, changing or taking off a discount needs deals.price (403 otherwise), one left as it is asks nothing; a line another system recorded is 409 imported_line, a discount given on a deal whose amount another system's import writes 409 amount_kept_by_sync. The payment takes the line at its new price, and the line itself takes it (its history, the deal's amount following) in the same transaction, only when this call issues the payment: a repeat, and an order whose payment stands already, change no line

    количество ≤ 500

    Вложенные поля: 2
    • discount object | null обязательно

      Вложенные поля: 2
      • type string обязательно

        A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

        Значения: percent amount

      • value string | number обязательно

        шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

    • productLineId string · uuid обязательно

  • productLineIds string[] · uuid

    Which of the deal's product lines the invoice bills, by their ids (`GET /deals/{dealId}/products`): absent or `[]`, none. A line that is not this deal's is 400 `product_line_not_found` at its place. Each is copied as it is now: its name, quantity, unit price, product and the rate it sold at

    количество ≤ 500 · без повторов

  • products object[]

    Products of the catalog sold with it, besides the deal's lines (`productLineIds`), each in the deal's currency: `priceId` one of its prices there (absent: the one the catalog offers first there), `quantity` (default 1), or `price`, a unit price of one's own (permission deals.price, 403 otherwise); `discount` (optional, permission deals.price, else 403), per unit, a `percent` (more than 0, at most 100) or an `amount` of the deal's currency (more than 0) off that price, as POST /deals/{dealId}/products takes it: the product sells at that price less the discount, rounded half up to the cent and never below 0 (409 amount_kept_by_sync on a deal whose amount another system's import writes). A product that is not the organization's is 400 `product_not_found` at its place; an archived one 409 `product_archived`; no price in the deal's currency and none typed 409 `no_price_in_currency`. When the organization's «Товар при оплате» says a product chosen at payment is added to the deal's products, each becomes a line of the deal in the same transaction (its amount following, its history), with its discount, unless the deal holds another system's lines

    количество ≤ 100

    Вложенные поля: 5
    • productId string · uuid обязательно

    • discount object

      Вложенные поля: 2
      • type string обязательно

        A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

        Значения: percent amount

      • value string | number обязательно

        шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

    • price string | number

      шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

    • priceId string · uuid

    • quantity string | number

      шаблон ^[0-9]{1,8}(\.[0-9]{1,3})?$ · > 0, ≤ 99999999.999

  • taxAware boolean

    The client knows the deal lines' taxes added on top (ADR-0032 stage 4): an amount equal to the named lines' total without them is a part it means, never taken for a window opened before taxes (409 stale_client_reload otherwise)

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "currency": "UAH",
  "amountCents": 600000,
  "payment": {
    "paidAt": "2026-10-23T10:30:00Z",
    "orderReference": "ORDER-20431"
  },
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
  "comment": "Предоплата 50%",
  "idempotencyKey": "6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    currency: 'UAH',
    amountCents: 600000,
    payment: {
      paidAt: '2026-10-23T10:30:00Z',
      orderReference: 'ORDER-20431',
    },
    methodId: '0192f3a1-7c2e-7b4d-9a61-000000000048',
    comment: 'Предоплата 50%',
    idempotencyKey: '6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07',
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "currency": "UAH",
        "amountCents": 600000,
        "payment": {
            "paidAt": "2026-10-23T10:30:00Z",
            "orderReference": "ORDER-20431",
        },
        "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
        "comment": "Предоплата 50%",
        "idempotencyKey": "6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/invoices', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'currency' => 'UAH',
        'amountCents' => 600000,
        'payment' => [
            'paidAt' => '2026-10-23T10:30:00Z',
            'orderReference' => 'ORDER-20431',
        ],
        'methodId' => '0192f3a1-7c2e-7b4d-9a61-000000000048',
        'comment' => 'Предоплата 50%',
        'idempotencyKey' => '6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 201

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-001",
  "invoiceType": "one_off",
  "status": "finalized",
  "paymentStatus": "succeeded",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-23",
  "netPaymentTerm": 0,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 600000,
  "totalDueAmountCents": 0,
  "totalRefundedAmountCents": 0,
  "voidedAt": null,
  "method": "Счёт в банке",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
  "comment": "Предоплата 50%",
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 1,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b4",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
      "paymentType": "manual",
      "paymentStatus": "succeeded",
      "amountCents": 600000,
      "currency": "UAH",
      "paidAt": "2026-10-23T10:30:00Z",
      "reference": "deal:1042",
      "orderReference": null,
      "method": "Счёт в банке",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "comment": "Предоплата 50%",
      "paymentFields": [],
      "canceledAt": null,
      "cancelReason": null,
      "refundableAmountCents": 600000,
      "refunds": [],
      "source": "alta",
      "version": 1,
      "createdAt": "2026-10-23T10:30:00Z"
    }
  ],
  "createdAt": "2026-10-23T10:30:00Z"
}
Поля ответа
  • billingEntityCode string

  • comment string | null

  • couponsAmountCents integer

    0–9007199254740991

  • createdAt string · date-time

  • createdBy object | null

    Вложенные поля: 2
    • id string · uuid

    • name string

  • currency string

    шаблон ^[A-Z]{3}$

  • dealId string · uuid

  • discounts object[]

    Вложенные поля: 3
    • amountCents integer

      0–9007199254740991

    • kind string

      Значения: coupon manual

    • name string | null

  • fees object[]

    Вложенные поля: 11
    • amountCents integer

      0–9007199254740991

    • description string | null

    • id string · uuid

    • invoiceDisplayName string | null

    • taxesAmountCents integer

      0–9007199254740991

    • unitAmountCents integer

      0–9007199254740991

    • units string

    • productId string · uuid | null

    • rateId string · uuid | null

    • taxes object[]

      Вложенные поля: 6
      • amountCents integer

        0–9007199254740991

      • baseAmountCents integer

        0–9007199254740991

      • inclusive boolean

      • name string

      • rate string

        шаблон ^[0-9]{1,3}\.[0-9]{2}$

      • taxRateId string · uuid

    • unitAmountExcludingTax string

      шаблон ^[0-9]+(\.[0-9]{1,6})?$

  • feesAmountCents integer

    0–9007199254740991

  • id string · uuid

  • invoiceType string

    Значения: one_off credit

  • issuingDate string · date

  • method string | null

  • methodId string · uuid | null

  • netPaymentTerm integer

    ≥ 0

  • number string

  • paymentDueDate string · date

  • paymentFields object[]

    Вложенные поля: 2
    • fieldId string · uuid

    • value string | boolean | string[] · uuid | object

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string

      • currency string

      Вариант 5 · object
      • city string

      • country string

      • line string

      • postcode string

  • paymentOverdue boolean

  • paymentStatus string

    Значения: pending succeeded failed

  • payments object[]

    Вложенные поля: 19
    • amountCents integer

      0–9007199254740991

    • cancelReason string | null

    • canceledAt string · date-time | null

    • comment string | null

    • createdAt string · date-time

    • currency string

      шаблон ^[A-Z]{3}$

    • id string · uuid

    • method string | null

    • methodId string · uuid | null

    • orderReference string | null

    • paidAt string · date-time | null

    • paymentFields object[]

      Вложенные поля: 2
      • fieldId string · uuid

      • value string | boolean | string[] · uuid | object

        Вариант 1 · string

        string

        Вариант 2 · boolean

        boolean

        Вариант 3 · string[] · uuid

        string[] · uuid

        Вариант 4 · object
        • amount string

        • currency string

        Вариант 5 · object
        • city string

        • country string

        • line string

        • postcode string

    • paymentStatus string

      Значения: pending processing succeeded failed

    • paymentType string

      Значения: manual provider

    • reference string | null

    • refundableAmountCents integer

      0–9007199254740991

    • refunds object[]

      Вложенные поля: 7
      • amountCents integer

        0–9007199254740991

      • createdAt string · date-time

      • createdBy object | null

        Вложенные поля: 2
        • id string · uuid

        • name string

      • id string · uuid

      • reason string | null

      • refundedAt string · date-time | null

      • status string

        Значения: pending succeeded failed

    • source string

    • version integer

      ≥ 1

  • source string

  • status string

    Значения: draft finalized voided failed pending

  • taxesAmountCents integer

    0–9007199254740991

  • totalAmountCents integer

    0–9007199254740991

  • totalDueAmountCents integer

    0–9007199254740991

  • totalPaidAmountCents integer

    0–9007199254740991

  • totalRefundedAmountCents integer

    0–9007199254740991

  • version integer

    ≥ 1

  • voidedAt string · date-time | null

  • appliedTaxes object[]

    Вложенные поля: 6
    • amountCents integer

      0–9007199254740991

    • baseAmountCents integer

      0–9007199254740991

    • inclusive boolean

    • name string

    • rate string

      шаблон ^[0-9]{1,3}\.[0-9]{2}$

    • taxRateId string · uuid

  • declined object

    Вложенные поля: 1
    • reason string

      Значения: payer_canceled refused expired withdrawn insufficient_funds card_velocity_exceeded expired_card incorrect_card_details authentication_failed issuer_declined fraudulent instalment_refused processing_error

  • paymentId string · uuid

Получить счёт

GET /invoices/{invoiceId}

Один счёт сделки со строками, оплатами и возвратами.

Параметры пути

  • invoiceId string · uuid обязательно

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/invoices/{invoiceId}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/invoices/{invoiceId}', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/invoices/{invoiceId}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/invoices/{invoiceId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-001",
  "invoiceType": "one_off",
  "status": "finalized",
  "paymentStatus": "succeeded",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-23",
  "netPaymentTerm": 0,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 600000,
  "totalDueAmountCents": 0,
  "totalRefundedAmountCents": 0,
  "voidedAt": null,
  "method": "Счёт в банке",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
  "comment": "Предоплата 50%",
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 1,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b4",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
      "paymentType": "manual",
      "paymentStatus": "succeeded",
      "amountCents": 600000,
      "currency": "UAH",
      "paidAt": "2026-10-23T10:30:00Z",
      "reference": "deal:1042",
      "orderReference": null,
      "method": "Счёт в банке",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "comment": "Предоплата 50%",
      "paymentFields": [],
      "canceledAt": null,
      "cancelReason": null,
      "refundableAmountCents": 600000,
      "refunds": [],
      "source": "alta",
      "version": 1,
      "createdAt": "2026-10-23T10:30:00Z"
    }
  ],
  "createdAt": "2026-10-23T10:30:00Z"
}

Поля — как в ответе Выставить счёт

Оплатить счёт

POST /invoices/{invoiceId}/payments

Ручная оплата счёта на всю сумму к оплате (amountCents): меньшая — 409 partial_payment_not_supported, большая — 409 exceeds_amount_due. paidAt — когда пришли деньги, не в будущем. idempotencyKey делает повтор безопасным. orderReference — ваш номер заказа: в организации один заказ — одна оплата, кто бы её ни записал (API, платёжный сервис, сверка, импорт). У заказа уже есть оплата на этой сделке — ответ 201 со счётом той оплаты, второй не будет; повтор безопасен, даже когда idempotencyKey равен orderReference. Вы важнее импорта и догадки по телефону: оплату от платёжного сервиса, которую по телефону или e-mail положило на другую сделку или которая ждёт в «Неразобранных оплатах», а также оплату, которую импорт записал на другую сделку, перенесём на эту сделку, и именно на неё лягут его возвраты. На другой сделке останется аннулированный счёт без денег и две строки истории: её итоги такие, будто оплаты там не было; следующие шаги импорта её не вернут. Оплату к другой сделке привязал человек — 409 order_linked_by_person; её уже записали на другую сделку через API, положила туда ссылка на оплату или номер сделки в заказе, на сделку, которую вы не можете менять, или сделка в корзине — 409 order_on_another_deal, так что устаревший запрос не вернёт оплату обратно; на ней уже есть возврат — 409 order_refunded_on_another_deal. Сумма оплаты остаётся такой, как записана впервые. Счёт той же суммы, выставленный на этой сделке для этого заказа, аннулируется: он больше ничего не требует. Другой запрос записал этот же заказ в ту же секунду — 409 order_taken; оплату заказа в ту же секунду отменили — 409 order_payment_canceled. Оба ответа можно повторить: тот же запрос ещё раз получит ответ по правилу. «Обязательно при оплате» останавливает только оплату, которую записывает человек в Alta: оплату через API не останавливает. Значения таких полей можно передать в customFields — они запишутся в сделку вместе с оплатой.

Параметры пути

  • invoiceId string · uuid обязательно

Тело запроса

  • amountCents integer обязательно

    1–9007199254740991

  • idempotencyKey string обязательно

    шаблон ^[\x21-\x7e]{1,255}$

  • paidAt string · date-time обязательно

  • comment string | null

    длина ≤ 1000

  • customFields object[]

    количество ≤ 100

    Вложенные поля: 2
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null обязательно

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

  • methodId string · uuid | null

  • orderReference string

    длина 1–200 · шаблон ^(?=.*\S)[^\u0000-\u001f\u007f-\u009f]+$

  • paymentFields object[]

    количество ≤ 100

    Вложенные поля: 2
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null обязательно

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/payments' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "amountCents": 600000,
  "paidAt": "2026-10-24T16:45:00Z",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
  "orderReference": "ORDER-20431",
  "idempotencyKey": "6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/payments', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    amountCents: 600000,
    paidAt: '2026-10-24T16:45:00Z',
    methodId: '0192f3a1-7c2e-7b4d-9a61-000000000049',
    orderReference: 'ORDER-20431',
    idempotencyKey: '6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07',
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/payments",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "amountCents": 600000,
        "paidAt": "2026-10-24T16:45:00Z",
        "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
        "orderReference": "ORDER-20431",
        "idempotencyKey": "6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/payments', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'amountCents' => 600000,
        'paidAt' => '2026-10-24T16:45:00Z',
        'methodId' => '0192f3a1-7c2e-7b4d-9a61-000000000049',
        'orderReference' => 'ORDER-20431',
        'idempotencyKey' => '6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 201

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b2",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-002",
  "invoiceType": "one_off",
  "status": "finalized",
  "paymentStatus": "succeeded",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-30",
  "netPaymentTerm": 7,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 600000,
  "totalDueAmountCents": 0,
  "totalRefundedAmountCents": 0,
  "voidedAt": null,
  "method": "Карта",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
  "comment": null,
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 2,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b5",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
      "paymentType": "manual",
      "paymentStatus": "succeeded",
      "amountCents": 600000,
      "currency": "UAH",
      "paidAt": "2026-10-24T16:45:00Z",
      "reference": "deal:1042",
      "orderReference": "ORDER-20431",
      "method": "Карта",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
      "comment": null,
      "paymentFields": [],
      "canceledAt": null,
      "cancelReason": null,
      "refundableAmountCents": 600000,
      "refunds": [],
      "source": "alta",
      "version": 2,
      "createdAt": "2026-10-24T16:45:00Z"
    }
  ],
  "createdAt": "2026-10-23T10:30:00Z"
}

Поля — как в ответе Выставить счёт

Аннулировать счёт

POST /invoices/{invoiceId}/void

Только счёт, по которому ничего не оплачено: он остаётся с voided и больше ничего не требует. Оплаченный — 409 invoice_paid (сначала отмените ошибочную оплату).

Параметры пути

  • invoiceId string · uuid обязательно

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/void' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/void', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/void",
    headers={"Authorization": "Bearer alta_…"},
    json={},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/invoices/{invoiceId}/void', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => new \stdClass(),
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b2",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-002",
  "invoiceType": "one_off",
  "status": "voided",
  "paymentStatus": "pending",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-30",
  "netPaymentTerm": 7,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 0,
  "totalDueAmountCents": 0,
  "totalRefundedAmountCents": 0,
  "voidedAt": "2026-10-24T16:45:00Z",
  "method": "Счёт в банке",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
  "comment": null,
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 2,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b5",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [],
  "createdAt": "2026-10-23T10:30:00Z"
}

Поля — как в ответе Выставить счёт

Способы оплаты

GET /payment-methods

Группы способов оплаты и сами способы: сначала активные, по названию.

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/payment-methods' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/payment-methods', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/payment-methods",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/payment-methods', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "groups": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000046",
      "name": "Безналичные",
      "version": 1
    },
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000047",
      "name": "Наличные",
      "version": 1
    }
  ],
  "methods": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "name": "Счёт в банке",
      "groupId": "0192f3a1-7c2e-7b4d-9a61-000000000046",
      "active": true,
      "bankFinanced": false,
      "importedFrom": null,
      "version": 1
    },
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000049",
      "name": "Карта",
      "groupId": "0192f3a1-7c2e-7b4d-9a61-000000000046",
      "active": true,
      "bankFinanced": false,
      "importedFrom": null,
      "version": 1
    },
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000004a",
      "name": "Касса",
      "groupId": "0192f3a1-7c2e-7b4d-9a61-000000000047",
      "active": true,
      "bankFinanced": false,
      "importedFrom": null,
      "version": 1
    }
  ]
}
Поля ответа
  • groups object[]

    Вложенные поля: 3
    • id string · uuid

    • name string

    • version integer

      ≥ 1

  • methods object[]

    Вложенные поля: 7
    • active boolean

    • bankFinanced boolean

    • groupId string · uuid | null

    • id string · uuid

    • importedFrom string | null

    • name string

    • version integer

      ≥ 1

Исправить оплату

PATCH /payments/{paymentId}

Дата поступления, способ оплаты и комментарий оплаты, внесённой в Alta. С version изменение пройдёт, только если оплату не меняли после вашего чтения (иначе 409). Импортированная — только для чтения.

Параметры пути

  • paymentId string · uuid обязательно

Тело запроса

  • comment string | null

    длина ≤ 1000

  • methodId string · uuid | null

  • paidAt string · date-time

  • paymentFields object[]

    количество ≤ 100

    Вложенные поля: 2
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null обязательно

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

  • version integer

    ≥ 1

Пример запроса

bash
curl -X PATCH 'https://your-company.altahub.ai/api/v1/payments/{paymentId}' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/payments/{paymentId}', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    methodId: '0192f3a1-7c2e-7b4d-9a61-000000000049',
  }),
});
const data = await response.json();
python
import requests

response = requests.patch(
    "https://your-company.altahub.ai/api/v1/payments/{paymentId}",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://your-company.altahub.ai/api/v1/payments/{paymentId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'methodId' => '0192f3a1-7c2e-7b4d-9a61-000000000049',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-001",
  "invoiceType": "one_off",
  "status": "finalized",
  "paymentStatus": "succeeded",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-23",
  "netPaymentTerm": 0,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 600000,
  "totalDueAmountCents": 0,
  "totalRefundedAmountCents": 0,
  "voidedAt": null,
  "method": "Карта",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
  "comment": "Предоплата 50%",
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 2,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b4",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
      "paymentType": "manual",
      "paymentStatus": "succeeded",
      "amountCents": 600000,
      "currency": "UAH",
      "paidAt": "2026-10-23T10:30:00Z",
      "reference": "deal:1042",
      "orderReference": null,
      "method": "Карта",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000049",
      "comment": "Предоплата 50%",
      "paymentFields": [],
      "canceledAt": null,
      "cancelReason": null,
      "refundableAmountCents": 600000,
      "refunds": [],
      "source": "alta",
      "version": 2,
      "createdAt": "2026-10-23T10:30:00Z"
    }
  ],
  "createdAt": "2026-10-23T10:30:00Z"
}

Поля — как в ответе Выставить счёт

Отменить ошибочную оплату

POST /payments/{paymentId}/cancel

Ручную оплату, внесённую по ошибке, отменяют с причиной: она остаётся как failed, а счёт снова ждёт оплаты. Оплату с возвратами или импортированную не отменяют (409).

Параметры пути

  • paymentId string · uuid обязательно

Тело запроса

  • reason string обязательно

    длина 1–500 · шаблон \S

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/payments/{paymentId}/cancel' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "reason": "Возврат за одну позицию"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/payments/{paymentId}/cancel', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    reason: 'Возврат за одну позицию',
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/payments/{paymentId}/cancel",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "reason": "Возврат за одну позицию",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/payments/{paymentId}/cancel', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'reason' => 'Возврат за одну позицию',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-001",
  "invoiceType": "one_off",
  "status": "finalized",
  "paymentStatus": "pending",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-23",
  "netPaymentTerm": 0,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 0,
  "totalDueAmountCents": 600000,
  "totalRefundedAmountCents": 0,
  "voidedAt": null,
  "method": "Счёт в банке",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
  "comment": "Предоплата 50%",
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 2,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b4",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
      "paymentType": "manual",
      "paymentStatus": "failed",
      "amountCents": 600000,
      "currency": "UAH",
      "paidAt": "2026-10-23T10:30:00Z",
      "reference": "deal:1042",
      "orderReference": null,
      "method": "Счёт в банке",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "comment": "Предоплата 50%",
      "paymentFields": [],
      "canceledAt": "2026-10-24T16:45:00Z",
      "cancelReason": "Возврат за одну позицию",
      "refundableAmountCents": 0,
      "refunds": [],
      "source": "alta",
      "version": 2,
      "createdAt": "2026-10-23T10:30:00Z"
    }
  ],
  "createdAt": "2026-10-23T10:30:00Z"
}

Поля — как в ответе Выставить счёт

Засчитать оплату

PUT /payments/{paymentId}/credit

Кому засчитана оплата («Засчитано» под оплатой в сделке): по нему аналитика считает продажи сотрудников. Без этого оплата засчитана ответственному сделки на момент оплаты; если ответственного тогда не было — первому, кого назначат после, а до того никому (pending). Так внешняя система, которая записала оплату, засчитывает её тому, кто продал. paymentId — id оплаты в payments счёта (ответ «Выставить счёт», «Оплатить счёт» или «Счета сделки»), а не paymentId самого счёта. member — сотрудник: memberId — его id из «Сотрудников» (уволенный тоже: продажа остаётся его); team — группа без человека: teamId из «Групп сотрудников»; automatic — снова автоматически, и тогда в ответе credit: null, пока Alta не засчитает оплату заново. Засчитанное вручную остаётся, пока его не изменят или не вернут automatic. Пока засчитанное никто не менял, тот же запрос ещё раз ничего не меняет, поэтому повтор после потерянного ответа безопасен; но условия по версии нет, и поздний повтор перепишет то, что после вас исправил другой. Изменение — строка истории сделки от имени автора ключа. Нужен ключ с правом записи и право «Зачёт оплат» в роли автора ключа (по умолчанию оно есть у владельца и администратора), иначе — 403 FORBIDDEN; оплата сделки, которую автор ключа не видит, — 404, как несуществующая. Оплата не оплачена или отменена — 409 payment_not_paid; сделка в корзине — 409.

Параметры пути

  • paymentId string · uuid обязательно

Тело запроса

  • credit object обязательно

    Вариант 1 · object
    • kind string обязательно

      Значения: member

    • memberId string · uuid обязательно

    Вариант 2 · object
    • kind string обязательно

      Значения: team

    • teamId string · uuid обязательно

    Вариант 3 · object
    • kind string обязательно

      Значения: automatic

Пример запроса

bash
curl -X PUT 'https://your-company.altahub.ai/api/v1/payments/{paymentId}/credit' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "credit": {
    "kind": "member",
    "memberId": "0192f3a1-7c2e-7b4d-9a61-000000000002"
  }
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/payments/{paymentId}/credit', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    credit: {
      kind: 'member',
      memberId: '0192f3a1-7c2e-7b4d-9a61-000000000002',
    },
  }),
});
const data = await response.json();
python
import requests

response = requests.put(
    "https://your-company.altahub.ai/api/v1/payments/{paymentId}/credit",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "credit": {
            "kind": "member",
            "memberId": "0192f3a1-7c2e-7b4d-9a61-000000000002",
        },
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://your-company.altahub.ai/api/v1/payments/{paymentId}/credit', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'credit' => [
            'kind' => 'member',
            'memberId' => '0192f3a1-7c2e-7b4d-9a61-000000000002',
        ],
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "paymentId": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
  "invoiceId": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
  "credit": {
    "kind": "member",
    "member": {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
      "name": "Ирина Мельник"
    },
    "team": {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000005c",
      "name": "Киев"
    }
  },
  "manual": true
}
Поля ответа
  • credit object | null

    Вариант 1 · object
    • kind string

      Значения: member

    • member object

      Вложенные поля: 2
      • id string · uuid

      • name string

    • team object | null

      Вложенные поля: 2
      • id string · uuid

      • name string | null

    Вариант 2 · object
    • kind string

      Значения: team

    • team object

      Вложенные поля: 2
      • id string · uuid

      • name string | null

    Вариант 3 · object
    • kind string

      Значения: pending

  • invoiceId string · uuid | null

  • manual boolean

  • paymentId string · uuid | null

Оформить возврат

POST /payments/{paymentId}/refunds

Сумма в копейках — не больше остатка к возврату (refundableAmountCents), дата — между днём оплаты и сегодня, причина. Нужно право на возвраты; idempotencyKey делает повтор безопасным. orderReference говорит: это возврат того самого заказа в платёжном сервисе (409 order_reference_mismatch, когда оплата не этого заказа). Кто быстрее, тот и записывает: если сервис уже сообщил об этой сумме, ответ 201 и ничего нового, а если ваш запрос опередил следующий частичный возврат, его запишет сам сервис, и итог всегда равен тому, что он сообщил. Пример: сервис сообщил о 300 грн, вы присылаете те же 300 грн — возвратов остаётся 300 грн. Без orderReference это обычный возврат, например наличными.

Параметры пути

  • paymentId string · uuid обязательно

Тело запроса

  • amountCents integer обязательно

    1–9007199254740991

  • idempotencyKey string обязательно

    шаблон ^[\x21-\x7e]{1,255}$

  • orderReference string

    длина 1–200 · шаблон ^(?=.*\S)[^\u0000-\u001f\u007f-\u009f]+$

  • reason string | null

    длина ≤ 1000

  • refundedAt string · date-time

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/payments/{paymentId}/refunds' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "amountCents": 100000,
  "refundedAt": "2026-10-24T14:00:00Z",
  "reason": "Возврат за одну позицию",
  "orderReference": "ORDER-20431",
  "idempotencyKey": "6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/payments/{paymentId}/refunds', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    amountCents: 100000,
    refundedAt: '2026-10-24T14:00:00Z',
    reason: 'Возврат за одну позицию',
    orderReference: 'ORDER-20431',
    idempotencyKey: '6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07',
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/payments/{paymentId}/refunds",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "amountCents": 100000,
        "refundedAt": "2026-10-24T14:00:00Z",
        "reason": "Возврат за одну позицию",
        "orderReference": "ORDER-20431",
        "idempotencyKey": "6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/payments/{paymentId}/refunds', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'amountCents' => 100000,
        'refundedAt' => '2026-10-24T14:00:00Z',
        'reason' => 'Возврат за одну позицию',
        'orderReference' => 'ORDER-20431',
        'idempotencyKey' => '6f1c2a9e-3b7d-4e58-9c0a-5d4b3e2f1a07',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 201

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b1",
  "dealId": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "billingEntityCode": "main",
  "number": "KAV-202610-001",
  "invoiceType": "one_off",
  "status": "finalized",
  "paymentStatus": "succeeded",
  "paymentOverdue": false,
  "issuingDate": "2026-10-23",
  "paymentDueDate": "2026-10-23",
  "netPaymentTerm": 0,
  "currency": "UAH",
  "feesAmountCents": 600000,
  "taxesAmountCents": 0,
  "totalAmountCents": 600000,
  "totalPaidAmountCents": 600000,
  "totalDueAmountCents": 0,
  "totalRefundedAmountCents": 100000,
  "voidedAt": null,
  "method": "Счёт в банке",
  "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
  "comment": "Предоплата 50%",
  "paymentFields": [],
  "source": "alta",
  "createdBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "version": 1,
  "fees": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b4",
      "invoiceDisplayName": "Кофемашины для сети кофеен",
      "description": null,
      "units": "1",
      "unitAmountCents": 600000,
      "amountCents": 600000,
      "taxesAmountCents": 0
    }
  ],
  "couponsAmountCents": 0,
  "discounts": [],
  "payments": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b3",
      "paymentType": "manual",
      "paymentStatus": "succeeded",
      "amountCents": 600000,
      "currency": "UAH",
      "paidAt": "2026-10-23T10:30:00Z",
      "reference": "deal:1042",
      "orderReference": null,
      "method": "Счёт в банке",
      "methodId": "0192f3a1-7c2e-7b4d-9a61-000000000048",
      "comment": "Предоплата 50%",
      "paymentFields": [],
      "canceledAt": null,
      "cancelReason": null,
      "refundableAmountCents": 500000,
      "refunds": [
        {
          "id": "0192f3a1-7c2e-7b4d-9a61-0000000000b6",
          "amountCents": 100000,
          "status": "succeeded",
          "refundedAt": "2026-10-24T14:00:00Z",
          "reason": "Возврат за одну позицию",
          "createdBy": {
            "id": "0192f3a1-7c2e-7b4d-9a61-000000000001",
            "name": "Андрей Шевченко"
          },
          "createdAt": "2026-10-24T14:00:00Z"
        }
      ],
      "source": "alta",
      "version": 1,
      "createdAt": "2026-10-23T10:30:00Z"
    }
  ],
  "createdAt": "2026-10-23T10:30:00Z"
}

Поля — как в ответе Выставить счёт