Добавлен адаптер к tbank и формирование ссылки на оплату

This commit is contained in:
Раис Юсупалиев
2026-04-12 18:56:41 +03:00
parent ab0b66e1c2
commit 2b201a08be
34 changed files with 1322 additions and 268 deletions
+18 -17
View File
@@ -1,20 +1,20 @@
"""Schemas for CDEK order registration."""
"""Schemas for delivery payment initialization."""
from typing import Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
class OrderPhone(BaseModel):
class PaymentPhone(BaseModel):
number: str = Field(min_length=1)
class OrderParty(BaseModel):
class PaymentParty(BaseModel):
model_config = ConfigDict(extra="forbid")
name: str = Field(min_length=1)
email: str = Field(min_length=1)
phone: OrderPhone
phone: PaymentPhone
@model_validator(mode="before")
@classmethod
@@ -24,18 +24,18 @@ class OrderParty(BaseModel):
return value
class OrderLocation(BaseModel):
class DeliveryLocation(BaseModel):
address: str = Field(min_length=1)
city: str = Field(min_length=1)
country_code: str = Field(min_length=2, max_length=2)
class OrderService(BaseModel):
class PaymentService(BaseModel):
code: str = Field(min_length=1)
parameter: str = Field(min_length=1)
class OrderPackage(BaseModel):
class PaymentPackage(BaseModel):
number: str = Field(min_length=1)
weight: int = Field(gt=0)
length: int = Field(gt=0)
@@ -44,18 +44,19 @@ class OrderPackage(BaseModel):
comment: str | None = None
class OrderCreateRequest(BaseModel):
class InitPaymentRequest(BaseModel):
order_uuid: str = Field(min_length=1)
price: int = Field(gt=0, strict=True, description="Payment amount in kopecks.")
type: Literal[2]
tariff_code: Literal[535]
comment: str | None = None
sender: OrderParty
recipient: OrderParty
from_location: OrderLocation
to_location: OrderLocation
services: list[OrderService] | None = Field(default=None, min_length=1)
packages: list[OrderPackage] = Field(min_length=1)
sender: PaymentParty
recipient: PaymentParty
from_location: DeliveryLocation
to_location: DeliveryLocation
services: list[PaymentService] | None = Field(default=None, min_length=1)
packages: list[PaymentPackage] = Field(min_length=1)
class OrderCreateResponse(BaseModel):
provider: str = Field(min_length=1)
order_uuid: str = Field(min_length=1)
class InitPaymentResponse(BaseModel):
payment_url: str = Field(min_length=1)