Payment and Transaction Processing Systems Questions
Designing systems that move money correctly: idempotent payment flows, exactly-once semantics, reconciliation, ledgers, double-entry accounting, and fraud-detection architecture. Covers handling retries and partial failures without double-charging, and the consistency guarantees payments demand. Also covers protecting cardholder data through tokenization and PCI scope reduction, reconciling processor webhooks, and merchant and partner payouts. A high-stakes specialization of distributed transactions.
A merchant wants your recommendation on how to capture card data while keeping PCI scope down: route it through a PSP-hosted redirect, embed an iframe/hosted-field widget, or capture via direct API-level tokenization inside their own page. Walk through the PCI-scope, UX, and integration-complexity trade-offs of each, note the typical failure modes, and make a recommendation.
Sample Answer
Direct answer
For most merchants, and specifically for a medium-sized SaaS company that wants customers to adopt its product quickly, recommend embedded hosted fields (the payment service provider's, or PSP's, card inputs rendered in iframes inside the merchant's own checkout page): they keep the merchant in the smallest PCI self-assessment (SAQ A) like a redirect does, while keeping the checkout on-brand and in-page. Use a full redirect when speed of integration matters above everything else, and direct API tokenization in the merchant's own page only when there is a feature need that hosted fields cannot meet, because it moves the merchant into a much larger compliance scope.
The terms
- PCI DSS (Payment Card Industry Data Security Standard): the card networks' security rules for anyone who stores, processes or transmits card data. Smaller merchants prove compliance with a SAQ (self-assessment questionnaire); which SAQ applies depends on how card data touches their systems. The tiers differ hugely in size: SAQ A is a short questionnaire of a few dozen questions, SAQ A-EP runs to roughly 150 to 190 questions covering nearly the full standard, and SAQ D covers all 12 PCI DSS requirements (commonly cited as 300-plus questions across 90-plus pages) plus ongoing obligations SAQ A never asks for, such as quarterly external vulnerability scans.
- PSP (payment service provider): the company that processes cards for the merchant, for example Stripe, Adyen or Braintree.
- Tokenization: exchanging the card number for a token (a random reference) that the merchant can store and charge without ever holding the card number.
- Separate origin: the browser's same-origin security policy, which stops the parent page's JavaScript from reading anything inside an iframe served from a different domain (here, the PSP's). This is why a hosted-fields iframe keeps card data out of the merchant's own code even if that code is compromised.
The three options
| PSP-hosted redirect | Iframe / hosted fields | Direct API tokenization in the merchant's page | |
|---|---|---|---|
| What happens | Shopper leaves to the PSP's payment page, returns afterwards | Merchant page, but card inputs are iframes served by the PSP | Merchant's own form fields; merchant JavaScript sends the card to the PSP's API (or, worse, to the merchant's server) |
| Card data touches merchant | Never | Never (the iframe is a separate origin the page cannot read) | Merchant's page code handles it; server too if posted there |
| Typical SAQ | SAQ A | SAQ A | SAQ A-EP if the browser posts straight to the PSP; SAQ D if it passes through the merchant's servers |
| Branding and UX | PSP's look, limited styling, visible hand-off | Merchant's layout; field styling via PSP options | Complete control |
| Integration effort | Lowest: configure and handle the return and webhook | Low to medium: JavaScript SDK (software development kit: the PSP's browser library), styling, error states | Highest: own form, validation, security controls, audits |
About SAQ A: since 31 March 2025 the SAQ A version in force no longer lists the payment-page script requirements 6.4.3 (keeping and justifying an inventory of every script that runs on the payment page) and 11.6.1 (a mechanism that detects and alerts on unauthorized changes to that page); instead the merchant must confirm, as an eligibility condition, that its site is not susceptible to attacks from scripts that could affect its e-commerce systems. That means even an iframe merchant still has to keep its own page's scripts under control; it is just assessed through eligibility rather than those two controls. SAQ A-EP merchants must meet those script requirements in full.
Typical failure modes
Redirect
- Return-URL failures: shopper closes the tab after paying, so the merchant never sees the redirect back. Fix: rely on the server-side webhook to confirm the order, and treat the return as a hint.
- Trust drop at the hand-off: shoppers abandon when they land on an unfamiliar domain.
- Session loss across the round trip (cart emptied, logged out) if checkout state lives only in the browser.
Hosted fields
- The iframe script fails to load (ad blockers, strict Content Security Policy headers (a browser header that restricts which domains a page is allowed to load scripts and iframes from) that do not allow the PSP's domain, PSP incident): show a clear error and a redirect fallback.
- Styling and accessibility limits: the iframe controls focus and screen-reader labels, so test with keyboard and screen readers.
- Page-level script compromise: an attacker who injects script into the parent page can overlay a fake form on top of the iframe. This is why the SAQ A eligibility condition about scripts matters.
Direct API tokenization
- Skimming attacks (malicious JavaScript injected into the page reads the card fields directly); the merchant is responsible for detecting script changes.
- Scope creep: a developer adds logging on the checkout page or posts through the backend "for convenience" and the merchant is suddenly in SAQ D scope.
- Higher engineering and audit cost for every change to the checkout.
Worked example: the SaaS recommendation
A SaaS company with about 200 employees sells monthly plans at 49 to 499 USD and wants self-serve signup to convert quickly. Its constraints: a branded, in-app upgrade flow (sending users to another domain during signup hurts trust in a product they are just evaluating), a small security team, and no appetite for a large PCI programme.
- Redirect: fastest to ship (days), SAQ A, but the off-brand hop sits in the middle of the signup funnel.
- Direct API tokenization: full design control, but SAQ A-EP means payment-page script inventory, integrity checks and change detection, more audit questions, and ongoing engineering. Nothing the SaaS needs requires it.
- Hosted fields: recommended. SAQ A, the upgrade form looks native to the product, and the integration is a JavaScript SDK plus the same webhook handling a redirect needs. It fits the "fast adoption" goal because it removes the domain hop from signup without adding compliance work. Plan a redirect fallback for when the SDK fails to load.
What would change the recommendation: if the company needs a fully custom card form experience that the PSP's fields cannot style, or wants to route across several PSPs (in which case a vault or orchestration provider (a PSP-agnostic layer that tokenizes the card once and can route the resulting token to more than one downstream PSP), whose own hosted fields preserve SAQ A); if it sells mostly via invoices, the PSP's hosted invoice page (a redirect) is simpler still.
Trade-offs and pitfalls
- "We use tokens, so we are out of scope" is wrong if the card number passed through your page code or servers before becoming a token.
- Branding differences between hosted fields and native fields are smaller than teams expect; the conversion loss usually comes from the redirect's domain change, not from input styling.
- Whatever the option, confirm orders from server-side webhooks (HTTP callbacks the PSP sends directly to your server when a payment's status changes, bypassing the browser), never from what the browser reports back.
Explain what idempotency means in payment processing. Provide concrete examples of problems that arise without idempotency (for example duplicate charges and duplicate fulfillment) and outline high-level strategies to implement idempotency across stateless, horizontally scaled services.
Sample Answer
Direct answer
An operation is idempotent if doing it twice has the same effect as doing it once. In payments that property has to be engineered, because "charge this card 50 USD" is naturally not idempotent: sending it twice charges twice. Duplicates are unavoidable (networks drop responses, clients retry, users double-click, message queues redeliver), so the system must recognise a repeat of the same intent and return the first result instead of acting again. In a horizontally scaled service that recognition cannot live in any one server's memory; it has to live in shared, durable state, usually a unique idempotency key stored alongside the payment and passed on to the processor.
Where duplicates come from
| Source | What happens | Why it is not a bug you can simply fix |
|---|---|---|
| Lost response | Server charged the card, the response died on a flaky mobile network, the app retries | The client cannot tell "never arrived" from "arrived, answer lost" |
| Impatient user | Double-click on Pay, or refresh on the confirmation page | Humans retry when things look slow |
| Load balancer or gateway retry | A proxy retries a request that timed out upstream | Retries are how distributed systems survive transient faults |
| Message redelivery | A queue delivers "payment succeeded" twice | Most queues are at-least-once (every message arrives, some more than once), because exactly-once delivery across a network is not achievable in general |
| Webhook replay | The PSP (payment service provider) resends an event because your endpoint was slow to acknowledge | Same at-least-once contract |
Problems without idempotency
- Duplicate charges. Two charge requests, two captures, one angry customer, a refund, and quite possibly a dispute.
- Duplicate fulfilment. A "payment succeeded" event processed twice ships two parcels or issues two gift-card codes. This one is often worse than a double charge because the goods are gone.
- Duplicate refunds or payouts. Money leaves the platform twice and must be clawed back.
- Corrupted ledger (the running record of every debit and credit). The same transaction posted twice means balances, revenue reports and reconciliation (matching two independent records of the same money to confirm they agree) are all wrong, and the error is discovered days later.
Strategies for stateless, horizontally scaled services
"Stateless" means any request can land on any of, say, 40 identical instances. So the memory of "I have seen this before" must be in a shared store, and the check-and-act must be atomic.
- Client-generated idempotency key. The client creates a random unique ID (for example a UUID, a universally unique identifier drawn from 122 random bits) once per payment attempt, stores it, and sends the same value on every retry. The server treats the key as the identity of the intent.
- Unique constraint, not check-then-insert. "SELECT to see if the key exists, then INSERT" lets two instances both see "not found" at the same moment. A database unique index on the key (scoped per merchant or per user) makes exactly one insert win.
- Store and replay the result. When the first request finishes, save its status code and body against the key. A retry gets the saved response, byte for byte, instead of a fresh execution.
- Fingerprint the request. Store a hash of the request body with the key. The same key with a different amount is a client bug, and should be rejected rather than silently replayed.
- Propagate the key downstream. When calling the processor, pass a key derived from yours. Then even if your service crashes between calling the processor and recording the result, the re-driven call cannot charge twice.
- Idempotent consumers for events. A service consuming "payment succeeded" records the event ID in a processed-events table in the same database transaction as its side effect. A redelivered event hits the unique constraint and is skipped.
- Make state transitions conditional. "Mark order shipped where status = 'paid'" is naturally idempotent: the second attempt matches zero rows. Modelling a payment as a state machine with legal transitions gets you a lot of idempotency for free.
Worked example
Maya taps Pay for a 50.00 USD order on a train.
Without a key: request 1 reaches the server, the card is charged, the response is lost in a tunnel. The app shows "Something went wrong", Maya taps Pay again, request 2 charges another 50.00. Her statement shows 100.00; support refunds 50.00; she may also have filed a dispute with her bank.
With a key: the app generated key 7f3c... when the order was created. Request 1 inserts the key, charges the card through the processor using the same key, stores 201 {payment_id: pay_881}. The retry with 7f3c... hits the unique constraint, finds the stored response and returns pay_881. One charge, and Maya sees "Paid".
And if the retry arrived while request 1 was still talking to the processor, it would find the key in an "in progress" state and get a "try again shortly" answer rather than starting a second charge.
Trade-offs and pitfalls
- Idempotency is not exactly-once. The request may still arrive and be checked several times; idempotency makes the effect happen once. People call this "effectively once".
- A key generated on each retry is useless. The key must be created once per intent and persisted on the client before the first attempt.
- Keys expire. Stores keep keys for a bounded window (Stripe documents that keys can be pruned once they are at least 24 hours old), so a retry after that window is treated as new.
- Scope matters. A key unique per merchant is fine; a key unique only per server instance is not.
- Do not cache failures you should retry. Decide deliberately whether a stored error is replayed or whether a retry is allowed to try again; validation errors and "conflict, still in progress" are usually not stored.
Describe, step-by-step, the end-to-end flow for a typical online card payment (card-not-present) from customer checkout through authorization, capture, settlement, and reconciliation. Highlight which components commonly run in the merchant, payment gateway, processor, and card network, and where latency, failure, retries, and fraud checks typically occur.
Sample Answer
Direct answer
An online card payment is two separate journeys. The authorization is a real-time question ("will the cardholder's bank stand behind this amount?") that travels merchant → payment gateway → processor/acquirer → card network → issuing bank and back while the customer waits. The money movement happens later and in batches: the merchant captures (confirms the amount it wants), captured transactions are cleared through the network, funds are settled from the issuer to the merchant's bank a day or more later, and the merchant reconciles what arrived against what it expected. Latency and fraud checks concentrate on the synchronous authorization leg; failures that matter most are timeouts where you do not know whether the bank said yes.
The cast (who runs what)
| Party | What it is | What runs there |
|---|---|---|
| Merchant | The shop | Checkout UI, order service, its own fraud rules, the order and payment records, reconciliation |
| Payment gateway | The front door the merchant integrates with (often bundled with the processor as a PSP, payment service provider, e.g. Stripe or Adyen) | Card-field collection and tokenization (swapping the card number for a reference so the merchant never stores it), API, idempotency, routing, often a fraud-scoring product |
| Processor / acquirer | The acquirer is the merchant's bank for card acceptance; the processor is the technical platform that talks to the networks on its behalf | Formatting authorization messages, batching captures for clearing, paying the merchant out |
| Card network | Visa, Mastercard and similar | Routing authorizations to the right issuer, running clearing and settlement between banks, network-level fraud and dispute rules |
| Issuer | The cardholder's bank | Approve/decline decision, available-credit check, its own fraud model, placing the hold, and later the customer's statement |
Card-not-present (CNP) means the card is not physically at a terminal (online, in-app, phone), so there is no chip to prove the card is real. That is why CNP leans on extra checks such as the CVC (the three- or four-digit card verification code), address verification and 3-D Secure (3DS: a step where the issuer authenticates the cardholder, for example with a push to the banking app; completing it successfully also shifts fraud liability from the merchant to the issuer, since the issuer vouched for the cardholder).
sequenceDiagram
participant C as Customer
participant M as Merchant
participant G as Gateway/PSP
participant A as Processor/Acquirer
participant N as Card network
participant I as Issuer
C->>M: Pay 80.00
M->>G: Create payment (token, amount, idempotency key)
G->>A: Authorization request
A->>N: Route by card number range
N->>I: Authorize?
I-->>N: Approved, hold placed
N-->>A: Approved
A-->>G: Approved
G-->>M: Authorized
M-->>C: Order confirmed
M->>G: Capture 80.00 (later)
A->>N: Clearing batch
N->>A: Net settlement funds
A->>M: Payout net of fees
Step by step
- Checkout and tokenization (merchant + gateway). The card number is typed into fields served by the gateway, not the merchant's own form, and comes back as a token. This keeps most of the merchant's systems out of scope for PCI DSS (the Payment Card Industry Data Security Standard that governs anyone storing or handling card numbers).
- Create the payment (merchant → gateway). The merchant sends amount, currency, token and an idempotency key (a unique ID for this attempt so a retried request cannot create a second charge). Merchant-side fraud rules usually run here, before the bank is ever asked.
- Authentication, if needed (issuer). For risky transactions, or where regulation requires strong customer authentication (for example much of Europe), the issuer runs 3DS. This is the step with human-scale latency, because the customer may have to approve in an app.
- Authorization (gateway → processor → network → issuer and back). The issuer checks the account, available funds, CVC/address results and its own fraud score, then approves or declines. An approval places a hold: the customer's available credit drops, but no money has moved yet.
- Capture (merchant → gateway). The merchant confirms the final amount, immediately for digital goods or at shipment for physical goods. Authorizations expire: for online card payments Stripe documents a typical 7-day validity window for customer-initiated transactions (Visa merchant-initiated ones are shorter). An expired authorization cannot be captured.
- Clearing (processor → network → issuer). Captured transactions are sent in batches; the issuer converts the hold into a posted charge on the statement.
- Settlement (issuer → network → acquirer → merchant). Banks settle net positions through the network, and the acquirer pays the merchant the captured amount minus fees (interchange, the per-transaction fee paid to the card-issuing bank, set by the network; network fees; the acquirer/PSP markup), usually one to a few business days later depending on the contract.
- Reconciliation (merchant). The merchant matches the settlement report and the bank deposit against its own ledger: every captured payment should appear once, at the expected net amount, and anything else (missing items, fee differences, chargebacks, meaning a cardholder's bank forcibly reversing a payment after a dispute) becomes a break (an unexplained mismatch between what was expected and what arrived) to investigate.
Where latency, failure, retries and fraud checks sit
| Stage | Latency | Typical failures | Retry rule | Fraud control |
|---|---|---|---|---|
| Tokenize/create | Low | Validation errors | Safe with idempotency key | Merchant rules, velocity checks (limits on how many attempts, or how much value, one card, device or account can push through in a short window) |
| 3DS | Seconds to minutes (human) | Customer abandons | Customer-driven | Issuer authentication |
| Authorization | The bulk of machine latency: several network hops | Timeout (outcome unknown), soft decline (e.g. issuer unavailable), hard decline (e.g. stolen card) | Retry a timeout with the SAME idempotency key or query status first; do not blindly retry hard declines | PSP risk score, issuer model, network checks |
| Capture | Low, not customer-facing | Auth expired, amount above authorized | Retry with idempotency key; re-authorize if expired | Rarely |
| Clearing/settlement | Hours to days, batch | Missing or partial items | Handled by reconciliation, not API retries | n/a |
| Post-settlement | Weeks to months | Refunds, chargebacks | Separate flows | Dispute evidence |
The most important failure in the list is the authorization timeout: the request may have reached the issuer and been approved even though the merchant saw an error. Treating that as a decline and letting the customer click Pay again is how customers get charged twice. The correct handling is to mark the payment as unknown, retry with the same idempotency key (the gateway returns the original result) or query the gateway for the payment's status.
Worked example
A customer buys an 80.00 USD jacket on Monday.
- Monday 10:00: authorization for 80.00 approved; the customer's banking app shows an 80.00 pending item.
- Tuesday: the jacket ships; the merchant captures 80.00.
- Tuesday night: the capture goes out in the processor's clearing batch.
- Thursday: payout arrives. If the merchant's all-in pricing were 2.9% + 0.30 USD (an example rate, not a quote), the fee is 80.00 × 0.029 = 2.32, plus 0.30, so 2.62; the deposit line is 80.00 − 2.62 = 77.38 USD.
- Thursday reconciliation: the merchant's ledger expected 80.00 gross; the report shows 80.00 gross, 2.62 fee, 77.38 net. Matched. Had the merchant reconciled the bank deposit against gross revenue it would have seen a false 2.62 shortfall on every order.
Trade-offs and pitfalls
- Authorization is not payment. An approved authorization can still expire uncaptured, and captured money can still come back as a refund or chargeback months later. Fulfilment logic should key off the state it actually needs.
- Unknown is a real state. Systems that model only success/failure convert timeouts into duplicate charges or into lost sales.
- Soft vs hard declines. Retrying a "do not honour" (the generic issuer decline code that gives no specific reason) or stolen-card decline over and over looks like card testing (an attacker running many small charges to find out which stolen card numbers still work) to issuers and networks; retry only declines that are explicitly transient.
- Gross vs net. Reconciliation must model fees, currency conversion and timing, or it produces noise that ops teams learn to ignore.
- Capture timing is a business decision (capture now vs at shipment), with consequences for refunds, disputes and expiry; it should be chosen deliberately, not left at an SDK default.
Outline the main PCI DSS control areas relevant to a cloud-based payments platform, and describe the practical architecture-level approaches a team can use to reduce PCI scope for a merchant. Explain the trade-offs and the residual compliance responsibilities that remain after scope reduction.
Sample Answer
Direct answer
PCI DSS (Payment Card Industry Data Security Standard, currently v4.0.1) has 12 requirements grouped under six goals: secure networks, protect account data, manage vulnerabilities, control access, monitor and test, and maintain a security policy. The cheapest control is not needing most of them: design the payment flow so card numbers go straight from the customer's browser or device to the payment provider and never touch the merchant's systems. Scope reduction shrinks the audit, but it never removes all responsibility: the merchant still owns the page that loads the payment form, its vendors, its policies and its incident response.
Key terms
- Cardholder data: the PAN (primary account number, the long card number), plus cardholder name, expiry date and service code when stored with it.
- SAD (sensitive authentication data): the CVV security code, full track or chip data, and PINs. It must never be stored after authorization.
- CDE (cardholder data environment): every system that stores, processes or transmits cardholder data, plus systems connected to them. PCI scope is the CDE.
- PSP (payment service provider): the company that processes card payments on the merchant's behalf.
- SAQ (self-assessment questionnaire): the form smaller merchants complete to validate compliance. Different SAQs apply to different payment designs, and the shortest ones apply when the merchant never handles card data.
The main PCI DSS control areas
| Goal | Requirements (v4.0.1) | What it means in a cloud payments platform |
|---|---|---|
| Build and maintain a secure network and systems | 1. Network security controls. 2. Secure configurations | Security groups and network policies (security groups are cloud firewall rules attached to a resource, controlling exactly which network traffic may reach it) isolating the CDE; hardened images (server images with unnecessary services and default accounts stripped out before use, to shrink what an attacker could exploit); no default credentials |
| Protect account data | 3. Protect stored account data. 4. Strong cryptography over open networks | Store as little as possible; encrypt stored PANs with keys held in a KMS (key management service, a system dedicated to creating, storing and controlling access to encryption keys) or HSM (hardware security module); TLS (Transport Layer Security, the encryption protocol behind HTTPS) everywhere |
| Maintain a vulnerability management program | 5. Protect against malicious software. 6. Develop and maintain secure systems and software | Patching, secure coding, code review, managing scripts on payment pages |
| Implement strong access control | 7. Restrict access by business need to know. 8. Identify users and authenticate access. 9. Restrict physical access | Least-privilege IAM (identity and access management) roles, MFA (multi-factor authentication) for all CDE access, physical security inherited from the cloud provider |
| Regularly monitor and test networks | 10. Log and monitor all access. 11. Test security regularly | Centralised, tamper-evident logs; vulnerability scans; penetration tests (authorized, simulated attacks meant to find exploitable weaknesses before a real attacker does); change detection (alerting when a file or configuration that is supposed to stay static gets modified, which can signal a compromise) |
| Maintain an information security policy | 12. Support information security with policies and programs | Risk assessment, vendor management, training, incident response plan |
In a cloud deployment, the provider covers part of this (physical security, hypervisor (the virtualization layer that isolates one customer's virtual machines from another's on the same physical hardware), some managed services) and publishes a responsibility matrix saying which requirements it meets, which you meet, and which are shared. You still own your configuration of everything the provider hands you.
Architecture approaches that reduce scope
Ordered from least to most merchant scope:
- Redirect to a PSP-hosted payment page. The customer leaves the merchant site to pay on the PSP's page, then returns. The merchant never sees card data.
- Embedded iframe or hosted fields. (an iframe, inline frame, is a small embedded webpage inside the merchant's page that is actually served by, and under the control of, a different origin, here the PSP) The card inputs are rendered inside frames served by the PSP, so the PAN goes from the browser to the PSP even though the page looks like the merchant's. The merchant receives a token (a random substitute for the card number).
- PSP JavaScript that posts directly to the PSP from a merchant-served page, or client-side encryption of the card in the browser with the PSP's public key. The merchant's servers never receive a readable PAN, but the merchant's page itself can be tampered with to steal it, so more controls apply than in options 1 and 2.
- Tokenization for storage and recurring billing. After the first payment, the merchant stores only the PSP's token and charges it later, so no PAN is at rest in merchant systems.
- P2PE (point-to-point encryption) for card-present terminals: a validated terminal encrypts the card at swipe or tap and only the provider can decrypt it.
- Network segmentation for anything that must remain in scope: isolate the CDE into its own account and network so the rest of the estate is out of scope, and prove the isolation with testing.
Worked example
An online retailer accepts 400,000 card payments a year on its website. That number matters for what follows: under the card networks' volume-based merchant levels, a merchant processing roughly 20,000 to 1,000,000 e-commerce transactions a year falls in the tier that validates PCI compliance by completing a Self-Assessment Questionnaire (SAQ), not the highest-volume tier (Level 1, over roughly six million transactions a year), which faces a mandatory annual on-site audit by a Qualified Security Assessor (QSA). At 400,000 payments, this retailer is squarely in SAQ territory, which is exactly why the SAQ A eligibility question below is the one that decides its validation path.
- Design A: its checkout page posts the card form to its own API, which calls the PSP. Its web servers, API servers, load balancers, logs and the admins of all of them are in the CDE. It must satisfy essentially all 12 requirements across that estate.
- Design B: it switches to PSP hosted fields and stores only tokens. Its servers never see a PAN. Its validation shrinks to a short questionnaire (for fully outsourced e-commerce this is SAQ A). What remains is protecting the checkout page that embeds the PSP frames, managing the PSP as a vendor, and its policies and incident response.
The SAQ A revision published in January 2025 (effective 31 March 2025) removed three payment-page requirements from SAQ A's own checklist (6.4.3: keep an inventory of every script that runs on the payment page, justify why each one is needed, and verify none has been tampered with; 11.6.1: run a change- and tamper-detection mechanism, checked at least weekly, that alerts on unauthorized changes to the payment page's security-relevant HTTP headers and script contents as the browser actually receives them; and 12.3.1: the targeted risk analysis that had backed how often 6.4.3 and 11.6.1 needed to run, no longer needed on SAQ A once those two are gone) and replaced them with two eligibility criteria: every payment-page element must be sourced only from a PCI DSS-compliant third-party service provider, and the merchant must confirm its site is not susceptible to attacks from scripts that could affect its e-commerce systems. In practice that still means controlling which scripts run on the checkout page and vetting who those scripts come from. The underlying requirements 6.4.3, 11.6.1 and 12.3.1 still exist in PCI DSS itself and still apply to merchants on SAQ D or a full on-site assessment; only SAQ A's own paperwork changed for the merchants eligible for it.
Trade-offs
| Approach | Scope | Cost to the merchant |
|---|---|---|
| Redirect | Smallest | Less control over look and flow; the extra hop can cost conversion |
| Iframe / hosted fields | Very small | Styling limits; tied to that PSP's components |
| Direct post or client-side encryption | Moderate | Merchant owns page integrity and more controls |
| Own vault | Large | Full control and PSP portability; full audit burden |
Tokens also create PSP lock-in: a token from one provider does not work at another, which matters if you want a backup processor.
Residual responsibilities after scope reduction
- The page that hosts the payment form. A compromised checkout page can swap the PSP frame for a fake one. Script control, a content security policy (a browser header listing which script sources may run) and change monitoring on that page stay the merchant's job.
- Vendor management. Keep the PSP's attestation of compliance (a formal document, typically signed by a PCI-approved assessor, stating that the PSP's own systems were found compliant) on file, know which requirements it covers, and review it yearly.
- Policies, training, incident response. A breach plan and staff awareness are required regardless of design.
- Anything that drifts back into scope. A support agent who takes a card number over the phone and types it into a CRM (customer relationship management system, the software used to track customer interactions) pulls that CRM and its users back in. Scans for PAN patterns in logs, tickets and data warehouses catch this.
- Annual validation. Scope reduction lowers the effort; it does not remove the obligation to validate and to keep the evidence.
Design a global payouts system to onboard large partners that handles KYC, local tax reporting, and multiple local payment rails while minimizing per-partner customization. Outline data models, workflow orchestration, and how you would manage regulatory differences between countries.
Sample Answer
Direct answer
Build one payout engine and push every country and partner difference into data: a versioned per-country rule pack (which identity checks, which tax forms, which rails, which limits) and a per-partner configuration that only picks options from those packs. Onboarding, identity verification, tax enrollment and each payout run as durable workflows (long-running state machines whose progress survives crashes and restarts), and every money movement is posted to a double-entry ledger (every transaction records equal and opposite entries, so money can never appear or vanish). Local payment rails sit behind one adapter interface, so adding Brazil means writing a rule pack and a rail adapter, not changing the core.
What we are designing to
- Who: "large partners" are platforms (a marketplace, a gig app) that pay many recipients (sellers, drivers, creators). Partner onboards once; its recipients number in the hundreds of thousands.
- KYC (know your customer: verifying who someone is and screening them against sanctions lists) applies to the partner as a business (KYB, know your business, including its beneficial owners (the real individuals who ultimately own or control the business, even when hidden behind holding companies)) and, depending on country and amount, to each recipient.
- Local tax reporting: collect the right tax identity documents, withhold where a country requires it, and file year-end information returns per jurisdiction.
- Multiple local rails: ACH (the US batch bank-transfer network), SEPA Credit Transfer and SEPA Instant (euro-area bank transfers), UK Faster Payments, Brazil's Pix (the central bank's instant payment system), India's UPI (Unified Payments Interface) and IMPS (Immediate Payment Service), plus card push and wallets where banks are thin.
- Minimal per-partner customization: the success test is that onboarding partner number 50 needs zero code changes.
Architecture
flowchart LR
P[Partner API and dashboard] --> WF[Workflow engine]
WF --> ID[Identity and KYC service]
WF --> TX[Tax profile service]
WF --> PO[Payout orchestrator]
RP[(Country rule packs)] --> WF
PO --> LG[(Double-entry ledger)]
PO --> RA[Rail adapters]
RA --> R1[ACH / SEPA / Faster Payments]
RA --> R2[Pix / UPI / wallets]
RA --> RC[Reconciliation]
RC --> LG
| Component | Job | Why it is separate |
|---|---|---|
| Workflow engine (for example Temporal, a durable-execution framework: if the process crashes mid-workflow, it resumes exactly where it left off, by replaying the sequence of already-completed steps from a saved history, rather than starting over or losing track of what was already done) | Runs onboarding, verification loops, payout batches as resumable steps with timers and retries | KYC can wait days for a document; a payout batch must resume exactly where it stopped after a crash |
| Country rule packs | Versioned data: required fields, KYC tier thresholds, tax form types, withholding rules, allowed rails, cut-off times (the latest time of day a payment instruction can be submitted and still go out same-day on that rail), holiday calendars | Regulatory differences change on regulators' schedules, not deploy schedules |
| Identity and KYC service | Collects documents, calls screening vendors, stores decisions and evidence references | One audit trail for "why was this person allowed to receive money" |
| Tax profile service | Stores tax residency, tax IDs, treaty claims, withholding rate (treaty claims: a recipient's claim to a reduced withholding rate under a tax treaty between their country and the paying country), and generates filings | Tax logic is jurisdictional and date-effective |
| Payout orchestrator | Turns "pay recipient R 120.00 EUR" into a rail choice, an instruction, and ledger postings | Keeps money logic out of the rail adapters |
| Rail adapters | One interface (quote, submit, status, parse_return) per rail or banking partner | New rail = new adapter, nothing else changes |
| Ledger | Source of truth for balances and every movement | Auditors and reconciliation read one place |
Data model
The core tables (simplified, all times in UTC, all amounts in integer minor units such as cents):
partner(partner_id, legal_name, home_country, kyb_status, config_version, created_at)
partner_config(partner_id, version, allowed_countries[], payout_schedule, fee_plan_id,
funding_model, rule_pack_overrides_json) -- options only, never code
recipient(recipient_id, partner_id, country, type{individual,business},
kyc_tier, kyc_status, tax_profile_id, created_at)
kyc_check(check_id, subject_id, check_type, vendor, result, evidence_ref,
rule_pack_version, decided_at) -- append-only
tax_profile(tax_profile_id, residency_country, tax_id_token, form_type,
form_status, withholding_bps, treaty_claim, valid_from, valid_to) -- withholding_bps is the withholding rate in basis points (hundredths of a percent), so 1500 means 15%; treaty_claim records a recipient's claim to a reduced rate under a tax treaty between their country and the paying country
payout_method(method_id, recipient_id, rail, account_token, verified_at)
rule_pack(country, version, effective_from, body_json, approved_by)
payout(payout_id, partner_id, recipient_id, amount_minor, currency, rail,
status, idempotency_key UNIQUE, rule_pack_version, created_at)
ledger_entry(entry_id, txn_id, account, amount_minor, currency, posted_at)
rail_event(event_id, payout_id, rail_ref, event_type, raw_ref, received_at)
Three design decisions carry most of the weight:
- Every decision stamps the rule-pack version it used. Months later, when a regulator asks why a recipient was paid without a tax ID, you can show that the German pack version in force that day did not require one below the threshold.
- Bank details and tax IDs are stored as tokens pointing into an encrypted vault, so most services never see the raw values.
- Payout status is a state machine (
created → screened → funded → submitted → settled | returned | failed), and only the orchestrator moves it, driven by rail events.
Workflow orchestration
Partner onboarding (days to weeks): collect business details → KYB and beneficial-owner screening → contract and funding set-up → sandbox test payouts → go live. Each step is a workflow activity (one durable, retryable unit of work inside the workflow, such as one API call) with its own retry policy; a "waiting for document" step is a durable timer (a wait the workflow engine itself schedules and resumes from, surviving restarts, rather than a separate polling job) that reminds the partner and escalates, not a cron job scanning a table.
Recipient onboarding (minutes, at scale): the partner submits recipients through the API; the workflow looks up the recipient's country pack to decide the KYC tier (for example "name and bank account only" below a volume threshold, "ID document plus liveness check" (a liveness check is a quick photo or video challenge proving the ID is being presented by a live person in front of the camera, not a photo of a photo) above it) and which tax form to collect, then marks the recipient payable only when every check the pack requires has passed.
Payout run:
- Partner submits a batch with an idempotency key per payout (an idempotency key is a client-chosen ID that makes a retried request return the original result instead of paying twice).
- Screening: sanctions re-check, limits from the pack, recipient still payable.
- Funding: debit the partner's prefunded balance in the ledger (or confirm incoming funds).
- Tax: compute withholding from the tax profile and post it to a tax-payable account.
- Rail selection by rules: the recipient's currency and country, speed promised by the partner's plan, cost, and cut-off times.
- Submit through the adapter; post
recipient_payable → rail_in_transit(a balanced ledger transaction that debits the recipient_payable account and credits rail_in_transit by the same amount, moving the money from "owed to the recipient" to "handed to the rail and awaiting confirmation"). - Rail events (settled, returned with reason code) arrive asynchronously and complete the workflow; a return reverses the ledger entries and notifies the partner.
Managing regulatory differences between countries
- Rule packs as reviewed data. A compliance analyst edits a pack; a second person approves it; it gets a version and an effective date. Engineers review only the schema.
- Evaluate, do not branch. Code asks the pack "what KYC tier applies to an individual in BR receiving 3,000 BRL per month?" rather than containing
if country == "BR". - Licensing and entity routing. Payouts in some countries must be made by a licensed local entity or partner bank. The pack names which legal entity and banking partner originates the payout, and the ledger has per-entity accounts.
- Data residency. Where identity data must stay in-country, the vault is regional and the core stores only tokens and decisions.
- Tax reporting differs in kind, not just rate. The US uses W-9/W-8BEN forms for tax identity and 1099-series information returns; the EU's DAC7 directive makes platform operators report seller income to tax authorities. Each is a report generator reading the same ledger and tax profiles, parameterized by the pack. Thresholds change (the US 1099-K threshold has been changed several times recently), which is exactly why they live in the pack with effective dates rather than in code.
Worked example: onboarding one partner into two countries
A delivery platform wants weekly payouts to 40,000 couriers in Germany and 60,000 in Brazil.
| Germany pack (DE) | Brazil pack (BR) | |
|---|---|---|
| Rail | SEPA Credit Transfer (batch), SEPA Instant for express | Pix (instant, runs around the clock) |
| Recipient ID | Name, IBAN (international bank account number), date of birth; document check above the pack's volume tier | Name, CPF (Brazilian individual taxpayer number), Pix key |
| Tax | Income data feeds the DAC7 platform report | Local reporting per the BR pack |
| Originating entity | EU licensed entity | Local partner institution |
Partner work: choose allowed_countries = [DE, BR], payout_schedule = weekly, a fee plan. No code. Load in one run: 100,000 payouts. If the orchestrator processes a batch in chunks of 1,000 with ten parallel workers, that is 100 chunks, 10 rounds of work per run. Ledger postings: each payout writes 3 to 4 ledger transactions: funding and submission always happen, tax withholding only when it applies for that recipient's country, and one more on settlement once the rail confirms. Each transaction posts one debit and one credit (a balanced pair), so 3 to 4 transactions means 6 to 8 ledger entries per payout, not a flat "three pairs plus one" regardless of whether tax applies. For a capacity estimate we take the conservative upper bound, 4 transactions (8 entries) per payout: roughly 100,000 × 4 = 400,000 ledger transactions (800,000 entries) per weekly run, which a single well-indexed relational ledger handles comfortably as a batch.
Trade-offs and pitfalls
- Rules engine versus code. A generic rules language becomes an unreviewable second programming language. Keep packs declarative (thresholds, lists, enums) and put genuinely novel behaviour in a new adapter or activity with code review.
- Prefunding versus paying on receipt. Requiring the partner to prefund removes credit risk (the risk that the partner never repays money the platform already advanced) and simplifies the ledger; paying before funds arrive is a credit product and needs underwriting (assessing the partner's ability to repay before extending that credit).
- Instant rails are irrevocable. Pix and SEPA Instant settle in seconds, so screening must finish before submission; on batch rails you sometimes have time to recall.
- Returns come late. An ACH return can arrive days after (the US bank network rejecting or reversing a transfer after it initially looked successful, for example a closed account or insufficient funds) "success". Treat submission as
in_transit, notpaid, and never let a partner re-pay a recipient until the original is definitively returned. - Common wrong turn: storing per-partner
ifstatements "just for this big customer". Every exception becomes a permanent fork; offer it as a pack option or decline it.
Unlock Full Question Bank
Get access to all 10 Payment and Transaction Processing Systems interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.