Долями (tbank.dolyame)

Оплата частями (BNPL) от Т-Банка: клиент платит 25% сразу и ещё 3 платежа по 25% каждые 2 недели, а магазин получает всю сумму сразу после подтверждения.

  • Хост: https://partner.dolyame.ru/v1/ (demo-хост выдаётся при онбординге через base_url).

  • Аутентификация: mTLS-сертификат (cert) + HTTP Basic (логин/пароль) + заголовок X-Correlation-ID (SDK генерирует сам).

  • Суммы: Decimal в рублях.

  • Провод: snake_case (совпадает с Python).

  • Клиенты: tbank.dolyame.DolyameClient (async) и tbank.dolyame.sync.DolyameClient (sync).

Жизненный цикл заказа

from decimal import Decimal
from tbank.dolyame import DolyameClient
from tbank.dolyame.models import CreateOrderRequest, Order, Item, ClientInfo, CommitRequest

client = DolyameClient(
    login="shop", password="secret",
    cert=("client.pem", "client-key.pem"),   # mTLS-сертификат из ЛК (обязателен)
)

# 1) создать заказ → ссылка для клиента
info = await client.create_order(CreateOrderRequest(
    order=Order(id="order-1", amount=Decimal("6700.00"),
                items=[Item(name="Товар", quantity=1, price=Decimal("6700.00"))]),
    client_info=ClientInfo(first_name="Иван", phone="+79993334444"),
    notification_url="https://shop.example/webhook",
))
print(info.link)                              # клиент оформляет рассрочку здесь

# 2) статус, подтверждение, возврат, доставка:
info = await client.get_order("order-1")      # info.status, info.payment_schedule, ...
await client.commit("order-1", CommitRequest(
    amount=Decimal("6700.00"),
    items=[Item(name="Товар", quantity=1, price=Decimal("6700.00"))],
))
await client.cancel("order-1")
# refund / correction / complete_delivery — см. справочник клиента ниже

Вебхуки

Долями шлёт нотификации POST на notification_url. Проверяйте, что запрос пришёл из диапазона IP Долями, и перепроверяйте статус через get_order:

from tbank.dolyame.webhooks import parse_notification, is_allowed_ip

if not is_allowed_ip(request_remote_ip):     # диапазон 91.194.226.0/23
    return
note = parse_notification(await request.json())
if note.status is OrderStatus.COMMITTED:
    ...

Примечание

Точный алгоритм подписи signature в публичной доке не формализован — полагайтесь на allowlist IP и перезапрос статуса через get_order.

Клиент

class tbank.dolyame.aio.DolyameClient(login, password, *, cert=None, base_url='https://partner.dolyame.ru/v1', verify=True, retry=None, transport=None)[исходный код]

Базовые классы: BaseAsyncClient

Асинхронный клиент «Долями» (BNPL Т-Банка).

Требует mTLS-сертификат (cert) + логин/пароль (Basic). Суммы — рубли (Decimal). Жизненный цикл заказа: create → commit → refund/cancel/delivery.

Параметры:
decimal_body: ClassVar[bool] = True

True → тело парсится с parse_float=Decimal (точные денежные суммы).

async create_order(request)[исходный код]

Создать заказ (вернёт link для клиента и статус).

Параметры:

request (CreateOrderRequest)

Тип результата:

OrderInfo

async get_order(order_id)[исходный код]

Актуальная информация и статус заказа.

Параметры:

order_id (str)

Тип результата:

OrderInfo

async commit(order_id, request)[исходный код]

Подтвердить заказ (магазин получает деньги, стартует график).

Параметры:
Тип результата:

OrderInfo

async cancel(order_id)[исходный код]

Отменить заказ.

Параметры:

order_id (str)

Тип результата:

OrderInfo

async refund(order_id, request)[исходный код]

Возврат (полный или частичный).

Параметры:
Тип результата:

RefundResponse

async correction(order_id, request)[исходный код]

Коррекция корзины заказа.

Параметры:
Тип результата:

RefundResponse

async complete_delivery(order_id, request)[исходный код]

Подтвердить успешную доставку.

Параметры:
Тип результата:

OrderInfo

Модели

class tbank.dolyame.models.DolyameModel[исходный код]

Базовые классы: BaseModel

База Долями: провод — snake_case (совпадает с Python), без алиасов.

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.Item(*, name, quantity, price, sku=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • name (str)

  • quantity (int)

  • price (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • sku (str | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.ClientInfo(*, first_name=None, last_name=None, middle_name=None, birthdate=None, phone=None, email=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • first_name (str | None)

  • last_name (str | None)

  • middle_name (str | None)

  • birthdate (date | None)

  • phone (str | None)

  • email (str | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.Order(*, id, amount, items, prepaid_amount=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • id (str)

  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • items (List[Item])

  • prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.CreateOrderRequest(*, order, client_info=None, notification_url=None, success_url=None, fail_url=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • order (Order)

  • client_info (ClientInfo | None)

  • notification_url (str | None)

  • success_url (str | None)

  • fail_url (str | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.CommitRequest(*, amount, items, prepaid_amount=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • items (List[Item])

  • prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.RefundRequest(*, amount, returned_items, refunded_prepaid_amount=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • returned_items (List[Item])

  • refunded_prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.CorrectionRequest(*, amount, refunded_prepaid_amount=None, new_items=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • refunded_prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

  • new_items (List[Item] | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.DeliveryOrder(*, amount, items, prepaid_amount=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • items (List[Item])

  • prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.CompleteDeliveryRequest(*, order=None)[исходный код]

Базовые классы: DolyameModel

Параметры:

order (DeliveryOrder | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.ScheduleItem(*, amount, payment_date, status)[исходный код]

Базовые классы: DolyameModel

Параметры:
model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.RefundInfoItem(*, refund_id, refunded_amount, refunded_prepaid_amount, status)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • refund_id (str)

  • refunded_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • refunded_prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • status (RefundStatus)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.RefundInfo(*, total_refunded_amount, total_refunded_prepaid_amount, items=<factory>)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • total_refunded_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • total_refunded_prepaid_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • items (List[RefundInfoItem])

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.InstallmentInfo(*, term, loan_number=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • term (int)

  • loan_number (str | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.OrderInfoItem(*, name, price, quantity, sku=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • name (str)

  • price (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • quantity (int)

  • sku (str | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.OrderInfo(*, status, amount, residual_amount, link, payment_schedule=<factory>, refund_info=None, installment_info=None, items=None, end_cooling_period=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.RefundResponse(*, amount, refund_id)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)])

  • refund_id (str)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class tbank.dolyame.models.WebhookNotification(*, id, status, amount=None, residual_amount=None, demo=None, client_info=None, payment_schedule=<factory>, cid=None, signature=None)[исходный код]

Базовые классы: DolyameModel

Параметры:
  • id (str)

  • status (OrderStatus)

  • amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

  • residual_amount (Annotated[Decimal, PlainSerializer(func=~tbank.dolyame.models.<lambda>, return_type=float, when_used=json)] | None)

  • demo (bool | None)

  • client_info (ClientInfo | None)

  • payment_schedule (List[ScheduleItem])

  • cid (str | None)

  • signature (str | None)

model_config = {'extra': 'ignore', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Перечисления

class tbank.dolyame.enums.OrderStatus(*values)[исходный код]

Базовые классы: str, Enum

NEW = 'new'
APPROVED = 'approved'
WAIT_FOR_COMMIT = 'wait_for_commit'
COMMITTED = 'committed'
COMPLETED = 'completed'
REJECTED = 'rejected'
CANCELED = 'canceled'
class tbank.dolyame.enums.ScheduleStatus(*values)[исходный код]

Базовые классы: str, Enum

SCHEDULED = 'scheduled'
HOLD = 'hold'
PAID = 'paid'
class tbank.dolyame.enums.RefundStatus(*values)[исходный код]

Базовые классы: str, Enum

PENDING = 'pending'
PROCESSED = 'processed'