84 lines
2.2 KiB
Python
84 lines
2.2 KiB
Python
"""Balance and payment schemas for cabinet."""
|
|
|
|
from datetime import datetime
|
|
from typing import Optional, List, Dict, Any
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class BalanceResponse(BaseModel):
|
|
"""User balance data."""
|
|
balance_kopeks: int
|
|
balance_rubles: float
|
|
|
|
|
|
class TransactionResponse(BaseModel):
|
|
"""Transaction history item."""
|
|
id: int
|
|
type: str
|
|
amount_kopeks: int
|
|
amount_rubles: float
|
|
description: Optional[str] = None
|
|
payment_method: Optional[str] = None
|
|
is_completed: bool
|
|
created_at: datetime
|
|
completed_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class TransactionListResponse(BaseModel):
|
|
"""Paginated transaction list."""
|
|
items: List[TransactionResponse]
|
|
total: int
|
|
page: int
|
|
per_page: int
|
|
pages: int
|
|
|
|
|
|
class PaymentOptionResponse(BaseModel):
|
|
"""Payment method option (e.g. Platega sub-methods)."""
|
|
id: str
|
|
name: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
class PaymentMethodResponse(BaseModel):
|
|
"""Available payment method."""
|
|
id: str
|
|
name: str
|
|
description: Optional[str] = None
|
|
min_amount_kopeks: int
|
|
max_amount_kopeks: int
|
|
is_available: bool = True
|
|
options: Optional[List[Dict[str, Any]]] = None
|
|
|
|
|
|
class TopUpRequest(BaseModel):
|
|
"""Request to create payment for balance top-up."""
|
|
amount_kopeks: int = Field(..., ge=1000, description="Amount in kopeks (min 10 rubles)")
|
|
payment_method: str = Field(..., description="Payment method ID")
|
|
payment_option: Optional[str] = Field(None, description="Payment option (e.g. Platega method code)")
|
|
|
|
|
|
class TopUpResponse(BaseModel):
|
|
"""Response with payment info."""
|
|
payment_id: str
|
|
payment_url: str
|
|
amount_kopeks: int
|
|
amount_rubles: float
|
|
status: str
|
|
expires_at: Optional[datetime] = None
|
|
|
|
|
|
class StarsInvoiceRequest(BaseModel):
|
|
"""Request to create Telegram Stars invoice for balance top-up."""
|
|
amount_kopeks: int = Field(..., ge=100, description="Amount in kopeks (min 1 ruble)")
|
|
|
|
|
|
class StarsInvoiceResponse(BaseModel):
|
|
"""Response with Telegram Stars invoice link."""
|
|
invoice_url: str
|
|
stars_amount: int
|
|
amount_kopeks: int
|