ADR-00031 — Razorpay-Hosted Checkout UI for Card Capture vs. In-House Card Entry + pci-service Integration Now
- Status: Approved / Implemented
- Date: 2026-10-06
- Authors: Engineering Team
Context
A customer paying online must enter card details somewhere, and those details must be tokenized before any system stores a reference to them. BRD-016’s Out-of-Scope already names “letting a customer save a payment method for faster reuse on a future order” as not built today. pci-service — a Rust microservice sharing pii-service’s encrypted Entity-Attribute-Value store via rust-lang-core-lib’s domain::encrypt/service::encrypt pattern — already exists in this monorepo as production-ready, generic encrypted-attribute infrastructure, but has zero callers from payment-service today. This ADR settles why: whether card capture should happen inside Razorpay’s own hosted checkout UI (keeping raw card data outside this system’s boundary entirely), or whether ui-application should instead present its own native card-entry screen now, with payment-service (or a new consumer) integrating pci-service immediately to store the resulting token/last4/brand.
Decision Drivers (FRs & NFRs)
- SR-017 NFR-01 —
payment-servicenever receives or persists raw card numbers, CVV, or other card credentials. - SR-016 NFR-05 — no card/PCI data collection by this system; Razorpay’s hosted UI is the sole card-entry surface today.
- BRD-016’s Out-of-Scope — saved-payment-method reuse is explicit future scope, not a current requirement.
- The platform’s coding standards no-over-engineering rule — no feature, abstraction, or integration beyond what the current requirement needs.
Options Evaluated
Option 1 — Razorpay’s hosted checkout UI handles all card entry and tokenization; pci-service integration deferred (CHOSEN)
As implemented: the Flutter client never renders its own card-input form. It opens Razorpay’s own hosted checkout UI (the same screen CreatePaymentOrderActivity’s returned razorpay_order_id/razorpay_key_id are used to launch), and Razorpay performs card entry, validation, and tokenization entirely on its own infrastructure. No raw card field — number, expiry, CVV — is ever received, parsed, logged, or transmitted by ui-application, order-service, or payment-service at any point. pci-service’s encrypted card-attribute store exists and is callable, but has no integration wired to it from this flow.
- Pros:
- This system never enters PCI DSS scope for card data at all. Razorpay is itself a PCI DSS Level 1 certified provider; its hosted checkout fields and end-to-end encryption absorb the compliance burden (secure card entry, encryption in transit, tokenization) that would otherwise require this monorepo’s own services and
ui-application’s own mobile code to be independently scoped, audited, and maintained under PCI DSS (network segmentation, restricted logging, SAQ/ROC, etc.) — a materially larger and ongoing security commitment than a card-storage feature on its own would justify today. - Minimizes the attack surface on the mobile client specifically. With no native card-entry form in
ui-application, there is no local-storage, memory, clipboard, or log-leak surface for raw card data to be secured against on the client side either — the data simply never exists there. - Matches the actual, current business requirement. Nothing in BRD-015 or BRD-016 asks for saved-card reuse yet; wiring
pci-serviceinto this flow now would be building for a requirement that doesn’t exist today, which the platform’s coding standards no-over-engineering rule applies against even at the architecture-decision level, not just at the code level. - Leaves a ready, already-built integration point for later.
pci-service’s EAV store is shared, generic infrastructure (the same patternpii-servicealready uses in production) — adopting it when a save-card feature is actually scoped is calling an existing, tested capability, not building one from scratch.
- This system never enters PCI DSS scope for card data at all. Razorpay is itself a PCI DSS Level 1 certified provider; its hosted checkout fields and end-to-end encryption absorb the compliance burden (secure card entry, encryption in transit, tokenization) that would otherwise require this monorepo’s own services and
- Cons & Accepted Trade-offs:
- No “pay with a saved card” option exists today — every checkout re-enters card details on Razorpay’s own UI. Building that later needs its own new integration work: a Razorpay-issued card token (and last4/brand metadata) delivered via a future webhook,
payment-service(or a new consumer) becomingpci-service’s first caller, and a UI flow for managing saved cards — none of which exists yet. This is tracked as named future scope in BRD-016’s Out-of-Scope, not as technical debt, since nothing currently required is unmet.
- No “pay with a saved card” option exists today — every checkout re-enters card details on Razorpay’s own UI. Building that later needs its own new integration work: a Razorpay-issued card token (and last4/brand metadata) delivered via a future webhook,
Option 2 — Build a native card-entry UI in ui-application now, and integrate pci-service today to store the token/last4/brand at capture time
- Pros: Would let a customer save a card for faster reuse immediately, without waiting on a separate future initiative.
- Cons (Why Rejected):
- Pulls this system directly into PCI DSS scope the moment any raw card field passes through code this monorepo owns — even transiently, before tokenizing — requiring this system to independently re-implement and maintain the end-to-end encryption and secure-handling guidance Razorpay’s own hosted fields already provide for free today.
- No current business requirement justifies the cost. Neither BRD-015 nor BRD-016 asks for saved-card reuse today; building the capture-and-storage path now would be speculative scope against the platform’s coding standards no-over-engineering rule.
- Works against the payment provider’s own stated guidance. Razorpay’s merchant-integration documentation recommends hosted checkout/tokenization specifically so merchants keep card data off their own infrastructure; a custom capture path increases both compliance and security risk for a capability nothing today actually needs.
Final Decision
Option 1 is selected and implemented. All card entry and tokenization happens inside Razorpay’s own hosted checkout UI; payment-service, order-service, and ui-application never receive or persist raw card data (SR-017 NFR-01). pci-service’s encrypted card-attribute store is intentionally left uncalled — it is the reserved integration point for a future save-card-for-reuse capability (storing the Razorpay-issued card token plus last4/brand metadata obtained via a future webhook), not a gap with no path forward.
Related Documents
- BRD-015 — Payment Capture & Confirmation
- BRD-016 — Payment Transaction Ledger, Refund Guarantee & Data Security
- SR-016 — Payment Capture & Confirmation System Requirements
- SR-017 — Payment Transaction Ledger & Security System Requirements
- Architecture — Payment Transaction Ledger, Refund Compensation & Gateway Audit Trail
- Microservices: payment-service, pci-service