До змісту
Скачати OpenAPI

Оплати

Оплати угод, повернення та способи оплати організації.

Платники рахунків

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"
}

Поля — як у відповіді Виставити рахунок