Design an Embedded Pay-by-Bank Checkout
Design an embeddable bank-payment flow that safely coordinates merchant pages, bank authorization, payment state, and retry-safe settlement outcomes.
Problem statement
For this exercise, assume a merchant embeds a hosted checkout widget in an iframe. A shopper selects a bank, completes login and authorization on a bank-owned surface, returns to the widget, and confirms a payment.
The merchant integrates through checkout and payment APIs plus authenticated status notifications, while the iframe communicates only bounded lifecycle events to its parent through postMessage.
Design the product and supporting system so merchant retries cannot create duplicate payments, bank credentials never cross the hosted authorization boundary, and pending or uncertain bank outcomes converge to one durable status.
Refunds, card payments, and the bank's internal authentication implementation are out of scope.
What to build
- A merchant can idempotently create a short-lived checkout session for an amount, currency, order reference, and approved embedding origin.
- A shopper can select a supported bank and complete bank-owned authentication and consent without exposing credentials to the merchant or widget.
- The widget can confirm one payment from an authorized account and receive a durable pending, succeeded, failed, or uncertain outcome across retries.
- The merchant can poll or receive authenticated notifications for payment transitions, while the iframe emits only origin-bound lifecycle events to its parent.
At scale
- For this exercise, assume 20,000 checkout-session creations per second globally with bursts five times higher during major sales.
- For this exercise, target 300 milliseconds p95 for platform-owned API decisions and two seconds p95 for widget bootstrap, excluding bank-controlled authentication latency.
- For this exercise, support hundreds of bank integrations whose timeouts, duplicate callbacks, and delayed final states may last up to 24 hours.
- For this exercise, an acknowledged payment intent and every externally visible state transition must survive a zone failure; retain payment and delivery audit metadata for seven years.