
Features: - User registration and authentication with JWT tokens - Multi-level admin access (Admin and Super Admin) - Gym management with membership plans - Subscription management with payment integration - Stripe and Paystack payment gateway support - Role-based access control - SQLite database with Alembic migrations - Comprehensive API endpoints with FastAPI - Database models for users, gyms, memberships, subscriptions, and transactions - Admin endpoints for user management and financial reporting - Health check and documentation endpoints Core Components: - FastAPI application with CORS support - SQLAlchemy ORM with relationship mapping - JWT-based authentication with bcrypt password hashing - Payment service abstraction for multiple gateways - Pydantic schemas for request/response validation - Alembic database migration system - Admin dashboard functionality - Environment variable configuration
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from app.models.transaction import TransactionStatus, PaymentGateway
|
|
|
|
|
|
class TransactionBase(BaseModel):
|
|
amount: float
|
|
currency: str = "USD"
|
|
payment_gateway: PaymentGateway
|
|
description: Optional[str] = None
|
|
|
|
|
|
class TransactionCreate(TransactionBase):
|
|
user_id: int
|
|
subscription_id: Optional[int] = None
|
|
|
|
|
|
class TransactionUpdate(BaseModel):
|
|
status: Optional[TransactionStatus] = None
|
|
gateway_transaction_id: Optional[str] = None
|
|
gateway_reference: Optional[str] = None
|
|
|
|
|
|
class TransactionInDB(TransactionBase):
|
|
id: int
|
|
user_id: int
|
|
subscription_id: Optional[int] = None
|
|
status: TransactionStatus
|
|
gateway_transaction_id: Optional[str] = None
|
|
gateway_reference: Optional[str] = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Transaction(TransactionInDB):
|
|
pass
|
|
|
|
|
|
class PaymentRequest(BaseModel):
|
|
membership_plan_id: int
|
|
payment_gateway: PaymentGateway
|