Files
orion/app/modules/payments/schemas/__init__.py
Samir Boulahtit f20266167d
Some checks failed
CI / ruff (push) Failing after 7s
CI / pytest (push) Failing after 1s
CI / architecture (push) Failing after 9s
CI / dependency-scanning (push) Successful in 27s
CI / audit (push) Successful in 8s
CI / docs (push) Has been skipped
fix(lint): auto-fix ruff violations and tune lint rules
- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.)
- Added ignore rules for patterns intentional in this codebase:
  E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from),
  SIM108/SIM105/SIM117 (readability preferences)
- Added per-file ignores for tests and scripts
- Excluded broken scripts/rename_terminology.py (has curly quotes)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 23:10:42 +01:00

137 lines
3.1 KiB
Python

# 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",
]