SR-016 — Payment Capture & Confirmation System Requirements
- Status: Approved
- Document ID: SR-2026-PAY-001
- Date: 2026-10-05
- Authors: Engineering Team
Traces back to BRD-015 — Payment Capture & Confirmation.
Real Payment Collection
FR-01: Real Payment-Provider Order Creation.
When the checkout saga reaches the payment step, order-service calls payment-service’s CreatePaymentOrder RPC, which creates a real order against the payment provider (Razorpay) rather than treating the customer’s selected payment method as already-successful. Satisfies BRD-015 BR-01.
FR-02: Signature-Verified Webhook Before Any Action.
payment-service exposes exactly one REST route, POST /payment/webhook/razorpay, in an otherwise gRPC-only service. Every inbound webhook is HMAC-verified against the payment provider’s signing secret before any downstream action — an unverified or incorrectly signed payload is rejected outright. Satisfies BRD-015 BR-01.
FR-03: Captured-Only Saga Relay.
Of the webhook event types handled, only a “payment captured” event is relayed onward to order-service’s PaymentSignalService.SignalPaymentCaptured over gRPC. “Payment failed” and “refund processed” events are persisted (see FR-04) but are explicitly not relayed to the saga today — a scoped gap tracked by Technical Debt TD-01. The saga’s own timeout-driven compensation (see SR-014 FR-01) is what currently resolves these un-relayed outcomes.
FR-04: Idempotent Webhook Event Persistence. Every webhook event is persisted keyed by the payment provider’s own event id — a redelivered webhook for an already-processed event id is recognized and not reprocessed. Satisfies BRD-015 BR-03.
Non-Functional Requirements
Composition & Reuse
NFR-01: Per-Endpoint Repository Split for the Payment Provider.
payment-service’s repository/razorpay/ wraps every outbound Razorpay API call — one repository method per provider endpoint (create_order, refund_payment), never an aggregate method that internally sequences several calls. service/ never holds the raw HTTP client directly.
Audit Trail
NFR-02: Fire-and-Forget Audit Publishing.
Request/response payloads for payment-provider calls are published to the audit-trail topic via a background task (tokio::spawn) — a publish failure is logged but never fails the RPC or webhook response that triggered it. See the audit trail standard for the full envelope/masking contract.
Auth-metadata note: the gRPC auth-metadata requirement covering
PaymentSignalService.SignalPaymentCaptured(the relay called by FR-03) is stated once, as the shared umbrella rule for every saga-signal RPC, in SR-014 NFR-02 — not repeated here.
Security & Trust Boundary
NFR-03: Server-Authoritative Payment-Order Creation.
The Razorpay order — and the amount it will charge — is always constructed by payment-service from the checkout saga’s own already-validated input (FR-01); the ui-application Flutter client never constructs or submits a payment order/amount itself, and never holds a credential capable of doing so. The client only ever receives the razorpay_order_id/razorpay_key_id already scoped to that amount, used solely to open Razorpay’s hosted checkout UI. Satisfies BRD-015 BR-01.
Decision: ADR-00029.
NFR-04: Webhook Is the Sole Source of Payment-Outcome Truth. A payment is only ever treated as captured on the strength of Razorpay’s own signature-verified webhook (FR-02); no RPC or endpoint anywhere in this system allows the client’s own reported checkout outcome to mark a payment captured. The client’s checkout-success callback is used only as a UI cue, never as a trust signal the saga or ledger acts on. Satisfies BRD-015 BR-01. Decision: ADR-00030.
NFR-05: No Card/PCI Data Collected by This System (Razorpay-Hosted Checkout).
Card entry and tokenization happen entirely inside Razorpay’s own hosted checkout UI — payment-service, order-service, and ui-application never receive, parse, or persist raw card/PAN/CVV data. pci-service’s encrypted card-attribute store is deliberately left uncalled from this flow today; it is the reserved integration point for a future saved-payment-method capability (storing only a Razorpay-issued card token plus last4/brand metadata, obtained via a future webhook — never raw card data). Cross-references BRD-016’s Out-of-Scope and SR-017 NFR-01, which state the same no-card-data boundary for payment-service’s own ledger/security scope. Satisfies BRD-015 BR-01.
Decision: ADR-00031.
Related Documents
- BRD-015 — Payment Capture & Confirmation
- BRD-016 — Payment Transaction Ledger, Refund Guarantee & Data Security
- ADR-00027 — Asynchronous Saga + Webhook Relay vs. Synchronous Payment Capture for Checkout Completion
- ADR-00029 — Server-Side Razorpay Order Creation (payment-service) vs. Client-Constructed Payment Order
- ADR-00030 — Webhook-Verified Payment Outcome vs. Client-Reported Checkout Success as Source of Truth
- ADR-00031 — Razorpay-Hosted Checkout UI for Card Capture vs. In-House Card Entry + pci-service Integration Now
- SR-017 — Payment Transaction Ledger & Security System Requirements — NFR-01’s same no-card-data boundary, cross-referenced by NFR-05 above
- Architecture — Checkout Completion: Payment Capture and Fulfillment Handoff
- Technical Debt — Checkout Completion Payment Flow Gaps
- BRD-013 — Checkout Completion Orchestration: Reliable Stock, Payment, and Fulfillment Sequencing
- SR-014 — Checkout Completion: Payment Capture & Fulfillment Handoff System Requirements — the saga scheduling (FR-01, FR-02) this payment flow executes inside of, and the auth-metadata umbrella rule (NFR-02) covering the saga-signal RPC this flow calls
- Microservices: payment-service, order-service