refactor: migrate schemas to canonical module locations
Migrate remaining legacy schemas to their respective modules: Marketplace module (app/modules/marketplace/schemas/): - letzshop.py: Letzshop credentials, orders, fulfillment, sync - onboarding.py: Vendor onboarding wizard schemas Catalog module (app/modules/catalog/schemas/): - product.py: ProductCreate, ProductUpdate, ProductResponse Payments module (app/modules/payments/schemas/): - payment.py: PaymentConfig, Stripe, transactions, balance Delete legacy files: - models/schema/letzshop.py - models/schema/onboarding.py - models/schema/product.py - models/schema/payment.py - models/schema/marketplace_product.py (re-export) - models/schema/marketplace_import_job.py (re-export) - models/schema/search.py (empty) Update imports across 19 files to use canonical locations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,10 +3,33 @@
|
||||
Payments module Pydantic schemas.
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.modules.payments.schemas.payment import (
|
||||
# Configuration
|
||||
PaymentConfigResponse,
|
||||
PaymentConfigUpdate,
|
||||
PaymentConfigUpdateResponse,
|
||||
# Stripe
|
||||
StripeConnectRequest,
|
||||
StripeConnectResponse,
|
||||
StripeDisconnectResponse,
|
||||
# Methods
|
||||
PaymentMethodInfo,
|
||||
PaymentMethodsResponse,
|
||||
# Transactions
|
||||
TransactionInfo,
|
||||
TransactionsResponse,
|
||||
# Balance
|
||||
PaymentBalanceResponse,
|
||||
# Refunds (config version)
|
||||
PaymentRefundRequest,
|
||||
PaymentRefundResponse,
|
||||
)
|
||||
|
||||
|
||||
class PaymentRequest(BaseModel):
|
||||
"""Request to process a payment."""
|
||||
@@ -83,6 +106,7 @@ class GatewayResponse(BaseModel):
|
||||
|
||||
|
||||
__all__ = [
|
||||
# Core payment schemas
|
||||
"PaymentRequest",
|
||||
"PaymentResponse",
|
||||
"RefundRequest",
|
||||
@@ -90,4 +114,23 @@ __all__ = [
|
||||
"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",
|
||||
]
|
||||
|
||||
167
app/modules/payments/schemas/payment.py
Normal file
167
app/modules/payments/schemas/payment.py
Normal file
@@ -0,0 +1,167 @@
|
||||
# app/modules/payments/schemas/payment.py
|
||||
"""
|
||||
Payment Pydantic schemas for API validation and responses.
|
||||
|
||||
This module provides schemas for:
|
||||
- Payment configuration
|
||||
- Stripe integration
|
||||
- Payment methods
|
||||
- Transactions and balance
|
||||
- Refunds
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
# ============================================================================
|
||||
# PAYMENT CONFIGURATION SCHEMAS
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class PaymentConfigResponse(BaseModel):
|
||||
"""Response for payment configuration."""
|
||||
|
||||
payment_gateway: str | None = None
|
||||
accepted_methods: list[str] = []
|
||||
currency: str = "EUR"
|
||||
stripe_connected: bool = False
|
||||
stripe_account_id: str | None = None
|
||||
paypal_connected: bool = False
|
||||
message: str | None = None
|
||||
|
||||
|
||||
class PaymentConfigUpdate(BaseModel):
|
||||
"""Request model for updating payment configuration."""
|
||||
|
||||
payment_gateway: str | None = Field(None, max_length=50)
|
||||
accepted_methods: list[str] | None = None
|
||||
currency: str | None = Field(None, max_length=3)
|
||||
|
||||
|
||||
class PaymentConfigUpdateResponse(BaseModel):
|
||||
"""Response for payment configuration update."""
|
||||
|
||||
success: bool = False
|
||||
message: str | None = None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# STRIPE INTEGRATION SCHEMAS
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class StripeConnectRequest(BaseModel):
|
||||
"""Request model for connecting Stripe account."""
|
||||
|
||||
authorization_code: str | None = None
|
||||
state: str | None = None
|
||||
|
||||
|
||||
class StripeConnectResponse(BaseModel):
|
||||
"""Response for Stripe connection."""
|
||||
|
||||
connected: bool = False
|
||||
stripe_account_id: str | None = None
|
||||
message: str | None = None
|
||||
|
||||
|
||||
class StripeDisconnectResponse(BaseModel):
|
||||
"""Response for Stripe disconnection."""
|
||||
|
||||
disconnected: bool = False
|
||||
message: str | None = None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# PAYMENT METHODS SCHEMAS
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class PaymentMethodInfo(BaseModel):
|
||||
"""Information about a payment method."""
|
||||
|
||||
id: str
|
||||
name: str
|
||||
type: str # credit_card, paypal, bank_transfer, etc.
|
||||
enabled: bool = True
|
||||
icon: str | None = None
|
||||
|
||||
|
||||
class PaymentMethodsResponse(BaseModel):
|
||||
"""Response for payment methods listing."""
|
||||
|
||||
methods: list[PaymentMethodInfo] = []
|
||||
message: str | None = None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# TRANSACTION SCHEMAS
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TransactionInfo(BaseModel):
|
||||
"""Information about a payment transaction."""
|
||||
|
||||
id: int
|
||||
order_id: int | None = None
|
||||
amount: float
|
||||
currency: str = "EUR"
|
||||
status: str # pending, completed, failed, refunded
|
||||
payment_method: str | None = None
|
||||
customer_email: str | None = None
|
||||
created_at: datetime
|
||||
completed_at: datetime | None = None
|
||||
metadata: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class TransactionsResponse(BaseModel):
|
||||
"""Response for payment transactions listing."""
|
||||
|
||||
transactions: list[TransactionInfo] = []
|
||||
total: int = 0
|
||||
skip: int = 0
|
||||
limit: int = 50
|
||||
message: str | None = None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# BALANCE SCHEMAS
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class PaymentBalanceResponse(BaseModel):
|
||||
"""Response for payment balance information."""
|
||||
|
||||
available_balance: float = 0.0
|
||||
pending_balance: float = 0.0
|
||||
currency: str = "EUR"
|
||||
next_payout_date: datetime | None = None
|
||||
last_payout_date: datetime | None = None
|
||||
last_payout_amount: float | None = None
|
||||
message: str | None = None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# REFUND SCHEMAS (for payment config endpoints)
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class PaymentRefundRequest(BaseModel):
|
||||
"""Request model for processing a refund (payment module version)."""
|
||||
|
||||
amount: float | None = Field(
|
||||
None, gt=0, description="Partial refund amount, or None for full refund"
|
||||
)
|
||||
reason: str | None = Field(None, max_length=500)
|
||||
|
||||
|
||||
class PaymentRefundResponse(BaseModel):
|
||||
"""Response for refund operation (payment module version)."""
|
||||
|
||||
refund_id: int | None = None
|
||||
payment_id: int | None = None
|
||||
amount: float | None = None
|
||||
status: str | None = None # pending, completed, failed
|
||||
message: str | None = None
|
||||
Reference in New Issue
Block a user