Technical Debt — Checkout Completion Payment Flow Gaps
By Engineering Team•October 5, 2026•5 min read
| Metadata | Details |
|---|---|
| System | Checkout Completion — Payment Capture & Fulfillment Handoff |
| Document ID | TD-2026-OPF-001 |
| Author | Engineering Team |
| Status | Tracked |
SR-014 and ADR-00027 link here rather than restating these gaps inline; this is the one place they’re tracked.
TD-01 — A definitively failed payment resolves no faster than a payment that never resolves at all
- Status: Open
- Severity: Medium
- Affected component:
payment-service’s webhook strategy dispatch;order-service’s checkout saga payment-wait step - Evidence:
razorpaywebhook_strategies.rs’sPaymentFailedStrategy/RefundProcessedStrategyuse the shared trait’s default no-opafter_commit— onlyPaymentCapturedStrategyoverrides it to callPaymentSignalService.SignalPaymentCaptured. The saga’swaitForPaymentCapturedstep therefore has no signal to react to on a failure webhook and sits on its fullpaymentWaitTimeout = 15 * time.Minute(checkout_saga_workflow.go:19,76-84,108-124) before compensating. - Impact: The saga already knows, from the webhook, that payment failed — but takes up to 15 minutes to act on it regardless. This exceeds the UI’s own ~90-second post-checkout wait window (see Razorpay Payment Flow), so the client will locally time out and show an ambiguous state to the customer well before the saga itself gives up and the order is actually compensated.
- Remediation direction: Add a
PaymentFailedStrategy.after_commitoverride that signals the saga via a newSignalPaymentFailed-equivalent RPC (mirroringSignalPaymentCaptured’s shape), so theworkflow.SelectorinwaitForPaymentCapturedcan react to a definitive failure immediately instead of only a capture or a timeout. - Related requirement: SR-016 FR-03
TD-02 — A retried CreatePaymentOrderActivity can create a duplicate real Razorpay order
- Status: Open
- Severity: High
- Affected component:
payment-service’screate_payment_orderservice method;payment_gateway_orderstable schema - Evidence: Temporal’s
defaultActivityOptions(checkout_saga_workflow.go:30-35) retriesCreatePaymentOrderActivityup to 3 times on any transient failure (e.g. a timed-out response whose Razorpay call actually succeeded).paymentorder_svc_impl.rs:33-108’screate_payment_orderunconditionally calls Razorpay (:56-66) then inserts (:68-84) with no pre-check keyed byorder_id. The table’s only unique index is onrazorpay_order_id(m20260826_000005_create_payment_gateway_orders_table.rs:18-35), which does not help — a retry produces a newrazorpay_order_idfor the same e-commerce order, so the unique index never fires.paymentorder_rep_impl.rs:34-56’screateis a plain insert, not an upsert. - Impact: A single order can end up with two real, separately chargeable Razorpay orders if a retry occurs after the first call actually succeeded but its response was lost (e.g. a network blip between
payment-serviceand Razorpay, or betweenorder-serviceandpayment-service) — a genuine financial-correctness risk, not just a data-hygiene one. - Remediation direction: Add a lookup-before-create (or a DB-level upsert) keyed by
(tenant_id, order_id)increate_payment_order— if apayment_gateway_ordersrow already exists for this order, return it instead of calling Razorpay again. This mirrors the idempotency-key deduporder-servicealready applies to order creation itself (SR-012 FR-13). - Related requirement: SR-016 FR-01, SR-016 NFR-01
TD-03 — No circuit breaker or gateway-aware retry/backoff around the Razorpay HTTP call
- Status: Open
- Severity: Low
- Affected component:
payment-service’srepository/razorpayimplementation - Evidence:
razorpay_rep_impl.rs:22-34builds a barereqwest::Clientwith only a 10-second timeout;create_order(:69-79) andrefund_payment(:150-160) have no retry/backoff wrapper of their own, and noretry/backoff/circuitcrate appears inpayment-service’sCargo.tomlfor this path. The only resilience this call gets is Temporal’s generic 3-attempt activity retry, which has no awareness of Razorpay-specific error semantics (e.g. distinguishing a genuinely transient 5xx from a request that already partially succeeded). - Impact: A sustained Razorpay outage retries the same way a single transient blip does — no backoff, no fail-fast — potentially amplifying load against a degraded third party across every in-flight checkout simultaneously.
- Remediation direction: No action needed immediately; Rust has no circuit-breaker capability in
rust-lang-core-libtoday (confirmed — the platform’s cross-cutting principles capability table lists it “Not present” for both Go and Rust, present only in Node). If Razorpay outages become a recurring operational issue, this is the first place to add gateway-aware backoff. - Related requirement: SR-016 FR-01
TD-04 — No scheduled sweep recovers a captured payment whose webhook is never (re)delivered
- Status: Open
- Severity: Medium
- Affected component:
order-service’s reconciliation service (reconciliation_imp_svc.go) - Evidence:
Reconcile(:41-113) is only ever invoked fromSignalPaymentCaptured’s own*serviceerror.NotFoundfallback path (checkoutsaga_imp_svc.go:73-93) — i.e. only when a webhook actually arrives, late or not. No cron job or polling loop exists anywhere inorder-serviceorpayment-servicethat would independently ask Razorpay whether a payment was captured if its webhook is lost outright and never redelivered. - Impact: In the edge case where Razorpay’s webhook delivery permanently fails for one event (not just delayed, but genuinely never redelivered), the order remains stuck in its compensated/failed state indefinitely even though the customer was actually charged — contradicting BRD-015’s BR-02 guarantee of eventual, definite resolution in the general case.
- Remediation direction: Add a periodic reconciliation sweep (e.g. a scheduled job querying Razorpay’s own payment-status API for any
order_orchestrationsrow stuck in a failed/compensated state with no matching capture event) as a backstop independent of webhook delivery. - Related requirement: BRD-015 BR-02, SR-016 FR-03
TD-05 — Post-shipment inventory consumption can silently fail with no saga-visible failure state
- Status: Open
- Severity: Low
- Affected component:
order-service’sConsumeInventoryActivity - Evidence: The activity always returns
nilregardless of its actual outcome (checkout_saga_workflow.go:100,189-195), by explicit design per its own doc-comment (:185-188) — it is intentionally best-effort so a transient failure here never fails an otherwise-successful, already-shipped order.order-service’s own module documentation acknowledges the consequence directly: a reservation can be left “phantom-inflated” (counted as reserved stock that was never actually converted to a permanent deduction), recoverable only through manual inventory-service tooling. - Impact: Low-frequency, low-severity stock-accounting drift — not a customer-facing failure, since the order has already shipped by this point. Recovery today is manual.
- Remediation direction: No change needed unless this becomes observable as recurring drift in practice — then add a logged/alerted (but still non-saga-failing) path so the drift is visible without re-introducing a false saga failure on an already-shipped order.
- Related requirement: SR-014 FR-07
Related Documents
- BRD-015 — Payment Capture & Confirmation
- SR-016 — Payment Capture & Confirmation System Requirements
- BRD-013 — Checkout Completion: Real Payment Capture and Reliable Fulfillment Handoff
- SR-014 — Checkout Completion: Payment Capture & Fulfillment Handoff System Requirements
- ADR-00027 — Asynchronous Saga + Webhook Relay vs. Synchronous Payment Capture for Checkout Completion
- Architecture — Checkout Completion: Payment Capture and Fulfillment Handoff
- Microservices: order-service, payment-service