How ACID Protects a Stripe Payment
Concept. One payment updates several records that must agree. Atomicity commits those records together. Consistency keeps the ledger balanced. Isolation prevents concurrent payments from losing a balance update. Durability preserves a confirmed payment after a crash.
Intuition. Mickey clicks "Pay $9.99." The payment system authorizes the card, then records the payment, updates the ledger and merchant balance, and queues a webhook. ACID protects the internal database writes from partial failure, concurrent updates, and crashes.
What one payment touches
Stripe processes roughly $1T of payments a year. Every "Pay" click triggers several internal writes:
Figure: One transaction commits four internal payment writesAfter card authorization, a payment service records a payment, writes balanced ledger entries, updates the merchant balance, and queues a webhook in one illustrative database transaction. Commit all four internal writes or roll them all back.
Figure 1. After card authorization, the database records the payment, writes two balancing ledger rows, updates the merchant balance, and queues a webhook. One transaction commits those four internal writes together.
If one internal write fails, the database rolls them all back. Isolation prevents an unsafe interleaving from losing a balance update. Durability preserves the committed records after the server returns 200 OK. Together, the four ACID properties protect the payment's internal state.
What each property prevents
Figure: Four ACID properties prevent four payment failuresA two-by-two grid of failures. Atomicity prevents a payment record from committing without its webhook entry. Consistency prevents ledger rows from falling out of balance. Isolation prevents concurrent payments from losing a balance update. Durability prevents a confirmed payment from vanishing after a crash. Color key: the red bar marks each failure, and the coloured letter marks the ACID property that prevents it.
Figure 2. Four failures map to four guarantees: atomicity prevents partial internal writes, consistency keeps the ledger balanced, isolation prevents concurrent payments from losing a balance update, and durability preserves a confirmed payment after a crash.
ACID gives the payment system a precise contract for failures, concurrency, and recovery.
The external card authorization cannot join the database transaction. The payment system coordinates that boundary with payment state, idempotency keys, retries, and refunds.
Takeaway: ACID protects the payment system's internal records, while idempotency and explicit payment state coordinate retries across the external card network.