Module Classification: - Core (4): core, tenancy, cms, customers - always enabled - Optional (7): payments, billing, inventory, orders, marketplace, analytics, messaging - Internal (2): dev-tools, monitoring - admin-only Key Changes: - Rename platform-admin module to tenancy - Promote CMS and Customers to core modules - Create new payments module (gateway abstractions) - Add billing→payments and orders→payments dependencies - Mark dev-tools and monitoring as internal modules New Infrastructure: - app/modules/events.py: Module event bus (ENABLED, DISABLED, STARTUP, SHUTDOWN) - app/modules/migrations.py: Module-specific migration discovery - app/core/observability.py: Health checks, Prometheus metrics, Sentry integration Enhanced ModuleDefinition: - version, is_internal, permissions - config_schema, default_config - migrations_path - Lifecycle hooks: on_enable, on_disable, on_startup, health_check New Registry Functions: - get_optional_module_codes(), get_internal_module_codes() - is_core_module(), is_internal_module() - get_modules_by_tier(), get_module_tier() Migrations: - zc*: Rename platform-admin to tenancy - zd*: Ensure CMS and Customers enabled for all platforms Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
94 lines
2.1 KiB
Python
94 lines
2.1 KiB
Python
# app/modules/payments/schemas/__init__.py
|
|
"""
|
|
Payments module Pydantic schemas.
|
|
"""
|
|
|
|
from pydantic import BaseModel, Field
|
|
from datetime import datetime
|
|
from typing import Any
|
|
|
|
|
|
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__ = [
|
|
"PaymentRequest",
|
|
"PaymentResponse",
|
|
"RefundRequest",
|
|
"RefundResponse",
|
|
"PaymentMethodCreate",
|
|
"PaymentMethodResponse",
|
|
"GatewayResponse",
|
|
]
|