# app/modules/payments/schemas/__init__.py """ Payments module Pydantic schemas. """ from datetime import datetime from typing import Any from pydantic import BaseModel, Field from app.modules.payments.schemas.payment import ( # Balance PaymentBalanceResponse, # Configuration PaymentConfigResponse, PaymentConfigUpdate, PaymentConfigUpdateResponse, # Methods PaymentMethodInfo, PaymentMethodsResponse, # Refunds (config version) PaymentRefundRequest, PaymentRefundResponse, # Stripe StripeConnectRequest, StripeConnectResponse, StripeDisconnectResponse, # Transactions TransactionInfo, TransactionsResponse, ) class PaymentRequest(BaseModel): """Request to process a payment.""" amount: int = Field(..., gt=0, description="Amount in cents") currency: str = Field(default="EUR", max_length=3) payment_method_id: str | None = None gateway: str = Field(default="stripe") description: str | None = None metadata: dict[str, Any] = Field(default_factory=dict) class PaymentResponse(BaseModel): """Response from a payment operation.""" success: bool transaction_id: str | None = None gateway: str | None = None status: str amount: int currency: str error_message: str | None = None created_at: datetime | None = None class RefundRequest(BaseModel): """Request to issue a refund.""" transaction_id: str amount: int | None = Field(None, gt=0, description="Amount in cents, None for full refund") reason: str | None = None class RefundResponse(BaseModel): """Response from a refund operation.""" success: bool refund_id: str | None = None transaction_id: str amount: int status: str error_message: str | None = None class PaymentMethodCreate(BaseModel): """Request to create a payment method.""" gateway: str = "stripe" token: str # Gateway-specific token is_default: bool = False class PaymentMethodResponse(BaseModel): """Response for a payment method.""" id: str gateway: str type: str # card, bank_account, etc. last4: str | None = None is_default: bool created_at: datetime class GatewayResponse(BaseModel): """Response for gateway info.""" code: str name: str status: str enabled: bool supports_refunds: bool supports_recurring: bool supported_currencies: list[str] __all__ = [ # Core payment schemas "PaymentRequest", "PaymentResponse", "RefundRequest", "RefundResponse", "PaymentMethodCreate", "PaymentMethodResponse", "GatewayResponse", # Configuration schemas "PaymentConfigResponse", "PaymentConfigUpdate", "PaymentConfigUpdateResponse", # Stripe integration "StripeConnectRequest", "StripeConnectResponse", "StripeDisconnectResponse", # Payment methods info "PaymentMethodInfo", "PaymentMethodsResponse", # Transactions "TransactionInfo", "TransactionsResponse", # Balance "PaymentBalanceResponse", # Refunds (config version) "PaymentRefundRequest", "PaymentRefundResponse", ]