Stored-value wallet with promo expiry

DesignMedium35 minPayPal style

Your task

Design a stored-value wallet that mixes real money and promo/credit balances with different spend rules: promo credits expire, can only be used on certain order types, and must be consumed before real balance; meanwhile concurrent operations (a checkout placing a hold, a refund adding credit, a nightly expiry job) all race on the same wallet. ~60M wallets, peak ~8,000 spends/sec. How do you keep the balance correct, apply the consume-promo-first rule, and ensure an expiry job never voids credit that's already reserved by an in-flight checkout?

It covers

  • Holds
  • Promo credits
  • Expiry