Minimal but production-shaped REST API for online payments. Built to demonstrate clean software engineering practices: explicit state machines, unit + integration tests, CI/CD, and automated deploys.
🇬🇧 English below · 🇪🇸 Versión en español primero.
🌐 Live demo: https://testing-examen-soft-eng.onrender.com/docs (Swagger UI)
Una API REST mínima para procesar pagos en línea, con dos métodos: PayPal y tarjeta de crédito. Cada uno tiene su propio set de reglas de negocio y validaciones. El objetivo del proyecto no es el dominio (pagos) sino mostrar buenas prácticas de software engineering:
- ✅ State machine explícita para los estados del pago (
REGISTRADO → PAGADO / FALLIDO → REGISTRADO) - ✅ Tests unitarios e integración con
unittest(sin dependencias extra) - ✅ CI con GitHub Actions — corre tests en cada PR
- ✅ CD a Render automático al merge en
production - ✅ Documentación API auto-generada (Swagger + ReDoc)
- ✅ Trade-offs documentados (almacenamiento, concurrencia, validaciones)
FastAPI · Pydantic · unittest · GitHub Actions · Render · Python 3.11
- Tarjeta de crédito: monto < $10.000 y máximo 1 pago en
REGISTRADOa la vez. - PayPal: monto < $5.000.
pip install -r requirements.txt
fastapi dev main.py
# Swagger: http://127.0.0.1:8000/docs# Opción 1: script
python3 test_local.py
# Opción 2: unittest directo
python3 -m unittest test_main -v| Método | Path | Acción |
|---|---|---|
| GET | /payments |
Listar todos los pagos |
| POST | /payments/{id} |
Registrar un nuevo pago |
| POST | /payments/{id}/update |
Actualizar (solo si está REGISTRADO) |
| POST | /payments/{id}/pay |
Procesar pago (corre validaciones) |
| POST | /payments/{id}/revert |
Revertir pago FALLIDO a REGISTRADO |
Sebastián Mesch Henriques — @SMESCH1
A minimal REST API for online payments supporting two methods: PayPal and credit card. Each has its own business rules and validations. The goal is not the payments domain itself — it's to showcase clean software engineering practices:
- ✅ Explicit state machine for payment status (
REGISTRADO → PAGADO / FALLIDO → REGISTRADO) - ✅ Unit + integration tests with stdlib
unittest - ✅ CI via GitHub Actions — runs tests on every PR
- ✅ CD to Render on merge to
production - ✅ Auto-generated API docs (Swagger + ReDoc)
- ✅ Documented trade-offs (storage, concurrency, validations)
FastAPI · Pydantic · unittest · GitHub Actions · Render · Python 3.11
- Credit card: amount < $10.000 and a maximum of 1 payment in
REGISTRADOstatus at any time. - PayPal: amount < $5.000.
┌─────────────┐ process ┌──────────┐
│ REGISTRADO │ ──────────────►│ PAGADO │
└─────────────┘ └──────────┘
▲
│ revert
│
│ ┌─────────────┐
└────│ FALLIDO │ ◄─── validation failed
└─────────────┘
pip install -r requirements.txt
fastapi dev main.py
# Swagger: http://127.0.0.1:8000/docspython3 -m unittest test_main -v- Deployed automatically to Render on merge to
productionbranch - Live: https://testing-examen-soft-eng.onrender.com/docs
Sebastián Mesch Henriques — @SMESCH1
MIT — see LICENSE.