Payment System (Stripe + Django)

Built a production-grade payment system focusing on reliability, consistency, and failure recovery.

Architecture

Client → Django Backend → Stripe ↓ Webhook Handler → DB

Flow

intent = stripe.PaymentIntent.create( amount=amount, currency='usd' )
Payment confirmation happens through webhook, not API response.

Webhook

if event['type']=='payment_intent.succeeded': update_payment_status()

Challenges

Duplicate events Network failures Partial transactions

Solutions

Idempotency keys Retry with backoff Reconciliation jobs

Impact

Reliable payments Consistency guaranteed Failure-safe system