
- 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
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.payments import router as payments_router
|
|
from app.db.base import engine, Base
|
|
|
|
# Create database tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Stripe Payment Integration Service",
|
|
description="A FastAPI service for handling Stripe payments",
|
|
version="1.0.0",
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(payments_router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""Base endpoint with service information"""
|
|
return {
|
|
"title": "Stripe Payment Integration Service",
|
|
"description": "A FastAPI service for handling Stripe payments",
|
|
"version": "1.0.0",
|
|
"documentation": "/docs",
|
|
"health_check": "/health",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint"""
|
|
return {
|
|
"status": "healthy",
|
|
"service": "stripe-payment-integration-service",
|
|
"version": "1.0.0",
|
|
}
|