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’s PaymentFailedStrategy/RefundProcessedStrategy use the shared trait’s default no-op after_commit — only PaymentCapturedStrategy overrides it to call PaymentSignalService.SignalPaymentCaptured. The saga’s waitForPaymentCaptured step therefore has no signal to react to on a failure webhook and sits on its full paymentWaitTimeout = 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_commit override that signals the saga via a new SignalPaymentFailed-equivalent RPC (mirroring SignalPaymentCaptured’s shape), so the workflow.Selector in waitForPaymentCaptured can 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’s create_payment_order service method; payment_gateway_orders table schema
  • Evidence: Temporal’s defaultActivityOptions (checkout_saga_workflow.go:30-35) retries CreatePaymentOrderActivity up to 3 times on any transient failure (e.g. a timed-out response whose Razorpay call actually succeeded). paymentorder_svc_impl.rs:33-108’s create_payment_order unconditionally calls Razorpay (:56-66) then inserts (:68-84) with no pre-check keyed by order_id. The table’s only unique index is on razorpay_order_id (m20260826_000005_create_payment_gateway_orders_table.rs:18-35), which does not help — a retry produces a new razorpay_order_id for the same e-commerce order, so the unique index never fires. paymentorder_rep_impl.rs:34-56’s create is 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-service and Razorpay, or between order-service and payment-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) in create_payment_order — if a payment_gateway_orders row already exists for this order, return it instead of calling Razorpay again. This mirrors the idempotency-key dedup order-service already 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’s repository/razorpay implementation
  • Evidence: razorpay_rep_impl.rs:22-34 builds a bare reqwest::Client with only a 10-second timeout; create_order (:69-79) and refund_payment (:150-160) have no retry/backoff wrapper of their own, and no retry/backoff/circuit crate appears in payment-service’s Cargo.toml for 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-lib today (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 from SignalPaymentCaptured’s own *serviceerror.NotFound fallback 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 in order-service or payment-service that 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_orchestrations row 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’s ConsumeInventoryActivity
  • Evidence: The activity always returns nil regardless 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