Добавлен адаптер к 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
+62
View File
@@ -0,0 +1,62 @@
"""Schemas for delivery payment initialization."""
from typing import Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
class PaymentPhone(BaseModel):
number: str = Field(min_length=1)
class PaymentParty(BaseModel):
model_config = ConfigDict(extra="forbid")
name: str = Field(min_length=1)
email: str = Field(min_length=1)
phone: PaymentPhone
@model_validator(mode="before")
@classmethod
def reject_company_field(cls, value: object) -> object:
if isinstance(value, dict) and "company" in value:
raise ValueError("company is not allowed")
return value
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 PaymentService(BaseModel):
code: str = Field(min_length=1)
parameter: str = Field(min_length=1)
class PaymentPackage(BaseModel):
number: str = Field(min_length=1)
weight: int = Field(gt=0)
length: int = Field(gt=0)
width: int = Field(gt=0)
height: int = Field(gt=0)
comment: str | None = None
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: 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 InitPaymentResponse(BaseModel):
payment_url: str = Field(min_length=1)