Skip to main content

System Design Prompt: Build a Payment Processing System

Design a scalable payment processing system: transactions, fraud detection, multi-currency, double-entry ledger, and PCI DSS compliance.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are a senior systems architect. Design a payment processing system for a e-commerce marketplace platform that handles 5,000 transactions per second at peak.

Step 1: Define the functional requirements including payment methods (credit card, debit card, ACH, digital wallets), multi-currency support for 25 currencies, recurring billing, partial refunds, and dispute management. Define non-functional requirements: 99.999% availability, transaction latency under 500ms, and PCI DSS Level 1 compliance.

Step 2: Design the high-level architecture with these core services: Payment Gateway Service (orchestrates payment flow), Transaction Ledger Service (double-entry bookkeeping), Fraud Detection Service (real-time risk scoring), Currency Conversion Service (live exchange rates), and Notification Service (receipts and alerts). Show the interaction diagram between services for a complete payment lifecycle.

Step 3: Design the database schema using PostgreSQL for the transaction ledger with ACID guarantees. Implement event sourcing for the payment state machine (pending, authorized, captured, settled, refunded, disputed). Use Redis Cluster for idempotency key storage to prevent duplicate charges. Design the schema to handle 5,000 writes per second.

Step 4: Implement the fraud detection pipeline that scores each transaction in real-time using velocity checks (transactions per card per hour), geolocation anomalies, device fingerprinting, and amount pattern analysis. Set configurable risk thresholds: auto-approve below 30, manual review between thresholds, and auto-decline above 85.

Step 5: Design the settlement and reconciliation system that batches authorized transactions, calculates merchant payouts with fee deductions, and generates settlement reports. Handle split payments, marketplace disbursements, and multi-party payouts. Build automated reconciliation against Stripe statements.

Step 6: Create a disaster recovery and compliance plan including PCI DSS tokenization of card data, encryption at rest and in transit, audit logging of all access to payment data, automated PII data retention policies, and a failover strategy that ensures zero transaction loss during regional outages.

What this prompt does

This prompt casts the AI as a senior systems architect designing a payment processing system for a [business_type] platform handling [tps] transactions per second at peak. It moves through six steps: functional and non-functional requirements (including [payment_methods], [currency_count] currencies, [availability] SLA, and [max_latency]), a service-level architecture, the database and event-sourcing schema on [primary_database], a real-time fraud pipeline, settlement and reconciliation, and a PCI DSS compliance plus disaster-recovery plan.

The structure works because payment systems fail in specific, expensive ways, and each step targets one. Idempotency keys in [cache_layer] stop duplicate charges when a client retries; a double-entry ledger keeps the books provably balanced and makes discrepancies detectable; event sourcing makes the payment state machine auditable after the fact. The fraud step uses concrete thresholds — auto-approve below [auto_approve_score], auto-decline above [auto_decline_score], manual review in between — so scoring policy is explicit rather than hand-waved. Reconciling against [payment_processor] statements closes the loop between your ledger and the money that actually moved, which is where silent settlement bugs usually hide.

When to use it

  • You're scoping a payment platform and need the full lifecycle before touching a processor integration
  • You want a defensible architecture for idempotency, ledgering, and fraud in one document
  • You need to reason about multi-currency support and recurring billing up front
  • You're preparing for a PCI DSS conversation and need tokenization and audit-logging covered
  • You're sizing infrastructure for a high-[tps] workload with a strict [availability] SLA
  • You want settlement, payouts, and reconciliation designed alongside the happy path
  • You need marketplace disbursements or split payments handled, not just single charges

Example output

Expect an architecture document: a service interaction diagram for a full payment lifecycle across the gateway, ledger, fraud, currency, and notification services, a ledger schema with the pending→authorized→captured→settled→refunded→disputed state machine and event sourcing, the fraud-scoring feature list with the configured [auto_approve_score] and [auto_decline_score] thresholds, a settlement and reconciliation flow against [payment_processor] with fee deductions and payouts, and a compliance section covering tokenization, encryption at rest and in transit, audit logging, and regional failover with zero transaction loss. It's a written design walkthrough, not runnable code.

Pro tips

  • Set [tps] to your real peak; it drives the database, sharding, and cache decisions more than any other variable
  • Keep [auto_approve_score] and [auto_decline_score] apart enough to leave a sensible manual-review band in the middle
  • Treat [availability] honestly — five nines implies multi-region failover that materially raises cost and complexity
  • Match [primary_database] to a system with strong ACID guarantees, since the ledger is the part you can't get wrong
  • Use [cache_layer] strictly for idempotency keys here; conflating it with general caching invites duplicate-charge bugs
  • This is a design aid — any real implementation still needs a security review and the actual [payment_processor] API constraints

Frequently Asked Questions

Does this prompt make my system PCI DSS compliant?
No. It designs an architecture that incorporates PCI DSS practices like tokenization, encryption at rest and in transit, and audit logging, but compliance is achieved through audited implementation and processes. Use the output as a design reference, not as certification or a substitute for a qualified assessor.
Why does it insist on a double-entry ledger and idempotency keys?
A double-entry ledger keeps every credit matched to a debit so the books always balance and discrepancies are detectable. Idempotency keys stored in `[cache_layer]` ensure a retried request doesn't charge a customer twice, which is the most common and costly payment bug at scale.
Can I adapt the fraud thresholds to my own risk tolerance?
Yes. The `[auto_approve_score]` and `[auto_decline_score]` variables define the auto-approve, manual-review, and auto-decline bands. Tightening or widening that middle band changes how many transactions go to human review, so you tune it against your fraud rate and review capacity.
Is this design tied to a specific payment processor?
No, it's processor-agnostic and uses `[payment_processor]` only for the reconciliation step. The architecture orchestrates the payment flow around whichever processor you integrate, so you set that variable to match your provider and adjust the reconciliation logic to its statement format.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in System Design Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support