Back to Interactive Flows
Credit Purchase & Top-Up Flow
End-to-end flow for purchasing credits in a SaaS application, from checkout initiation to credit balance update.
Flow Steps
User Initiates Purchase
Frontend
Create Stripe Checkout Session
Payment API
Redirect to Stripe Checkout
Stripe Checkout
Payment Success
Stripe
Webhook Received
Webhook Handler
Process Webhook
Webhook Processor
Update Credit Balance
Credit Service
Confirmation
Frontend + Email Service
Additional Edge Cases
- Webhook arrives before user returns to app
- Payment succeeds but webhook never arrives (polling fallback)
- Partial refunds after credit usage
- Chargeback handling
Failure Recovery
Webhook is source of truth. If webhook delayed, poll Stripe API for session status. All operations are idempotent. Failed payments don't affect credit balance. Support can manually adjust if needed.