
- Created FastAPI application with Stripe payment processing - Added payment intent creation, retrieval, and webhook handling - Implemented SQLite database with payments and payment_methods tables - Set up Alembic for database migrations - Added comprehensive API endpoints for payment management - Configured CORS middleware for cross-origin requests - Added health check and service information endpoints - Created complete project documentation with setup instructions - Integrated Ruff for code formatting and linting
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from sqlalchemy import Column, Integer, String, Float, DateTime, Boolean
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
|
|
|
|
class Payment(Base):
|
|
__tablename__ = "payments"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
stripe_payment_intent_id = Column(String, unique=True, index=True)
|
|
amount = Column(Float, nullable=False)
|
|
currency = Column(String, default="usd")
|
|
status = Column(String, nullable=False)
|
|
customer_email = Column(String, index=True)
|
|
customer_name = Column(String)
|
|
description = Column(String)
|
|
metadata = Column(String) # JSON string for additional data
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
is_webhook_processed = Column(Boolean, default=False)
|
|
|
|
|
|
class PaymentMethod(Base):
|
|
__tablename__ = "payment_methods"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
stripe_payment_method_id = Column(String, unique=True, index=True)
|
|
customer_email = Column(String, index=True)
|
|
type = Column(String, nullable=False) # card, bank_account, etc.
|
|
card_brand = Column(String) # visa, mastercard, etc.
|
|
card_last_four = Column(String)
|
|
is_default = Column(Boolean, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|