
I built a payment processing platform in Mexico with FastAPI — here's what I learned after 10+ production deployments
I've been running FastAPI in production for a payment processing platform in Mexico for the past couple of years. We handle SPEI transfers (Mexico's interbank transfer system), OXXO Pay (cash payments at convenience stores), and crypto on-ramps through multiple PSP integrations. I wanted to share some real lessons from production that I don't see discussed much. The stack FastAPI + async SQLAlchemy 2.0 + asyncpg PostgreSQL + Redis (rate limiting + caching) Docker → AWS ECS Fargate GitHub Actions CI/CD Alembic for migrations Lesson 1: Webhook state machines save your life When you process payments, you receive webhooks from payment providers. The naive approach is to just update the payment status directly. Don't do this. We built a webhook state machine where each payment goes through defined states: pending → processing → completed/failed. Every state transition is logged with timestamps. When a payment provider sends duplicate webhooks (and they will), the state machine just ignores
Continue reading on Dev.to Python
Opens in a new tab


