ADR-00030 — Webhook-Verified Payment Outcome vs. Client-Reported Checkout Success as Source of Truth

By Engineering Team•October 6, 2026•4 min read
  • Status: Approved / Implemented
  • Date: 2026-10-06
  • Authors: Engineering Team

Context

Once a customer completes payment on Razorpay’s own hosted checkout UI, the ui-application Flutter client receives an immediate client-side success/failure callback from Razorpay’s SDK — well before payment-service’s own webhook has necessarily arrived. ADR-00027 already settled how the saga is sequenced around that gap (schedule and resume asynchronously, rather than block). This ADR settles a separate, narrower question that decision didn’t address: once the saga is waiting, which signal is actually trusted to say the payment succeeded — the server-to-server, signature-verified Razorpay webhook, or the client’s own reported outcome?

Decision Drivers (FRs & NFRs)

  • BRD-015 BR-01 — an order is only ever treated as paid on the strength of a real, verified charge.
  • SR-016 FR-02 — every webhook is HMAC-verified before any action is taken on it.
  • SR-016 FR-03 — only a verified “payment captured” event is relayed into the saga.
  • SR-016 FR-04 — webhook events are persisted idempotently, keyed by the provider’s own event id.
  • SR-016 NFR-04 — the webhook is the sole source of payment-outcome truth.

Options Evaluated

Option 1 — Only the signature-verified webhook is ever trusted to mark a payment captured (CHOSEN)

As implemented: PaymentSignalService.SignalPaymentCaptured is called from exactly one place — PaymentCapturedStrategy::after_commit, reached only after payment-service’s webhook handler has HMAC-verified the inbound Razorpay payload and committed its razorpay_events/payment_ledger rows. There is no RPC or endpoint anywhere in this system that the Flutter client can call to mark a payment captured. The client’s own Razorpay SDK success callback is used only as a UI cue — it transitions the screen to a waiting/confirming state — and the actual order-level outcome the customer eventually sees still comes from the saga’s own SSE stream, which only advances once the webhook-driven signal (or the saga’s timeout) resolves it.

  • Pros:
    • Removes an entire class of forgeable “payment succeeded” claims. A compromised, modified, or simply buggy client has no path to cause an order to be marked paid without Razorpay itself having actually confirmed the charge server-to-server — directly serving BR-01’s “genuinely collected, not just recorded” guarantee.
    • Matches how the payment provider itself settles. Razorpay’s own capture can be delayed, retried, or delivered more than once; a signed webhook, verified and deduplicated by event id (FR-04), is the only signal that reflects what actually happened at the provider, consistent with the same webhook-anchored-truth posture ADR-00028 already applies to the ledger itself.
    • Keeps exactly one writer of “this payment was captured.” If the client also had a path to assert that fact, the system would have two independent sources of truth for the same event that could disagree — the ledger (webhook-driven) and the saga-signal path (client-driven) — with no principled way to reconcile a conflict between them.
  • Cons & Accepted Trade-offs:
    • The customer sees a brief “confirming” state between finishing Razorpay’s checkout and the webhook actually arriving and being relayed — a latency window already accepted by ADR-00027’s async design, not a new cost introduced here.
    • If the webhook is lost outright and never redelivered, there is no independently faster path than the saga’s own 15-minute timeout/reconciliation flow — the same residual gap already tracked as TD-01/TD-04.

Option 2 — Trust the client’s own reported checkout outcome to mark the payment captured

  • Pros: The order could be marked paid the instant the client reports success, with no wait on webhook delivery latency.
  • Cons (Why Rejected):
    • The single largest hole this design could introduce. Any client — including a tampered one, or one hitting the relevant endpoint directly without ever opening Razorpay’s checkout at all — could claim success for a charge that never happened, letting the business mark an order “paid” with no real payment behind it. This is the exact failure BR-01 exists to prevent.
    • Contradicts Razorpay’s own integration guidance, which explicitly warns against treating a client-side handler as payment confirmation and documents server-side webhook verification as the safe pattern.
    • Has no natural idempotency story. A client callback carries no equivalent to a webhook’s signed event id — nothing to dedupe a client that calls the same “I paid” signal twice, the way FR-04’s razorpay_events uniqueness already handles a redelivered webhook for free.

Final Decision

Option 1 is selected and implemented. PaymentSignalService.SignalPaymentCaptured is reachable only from the signature-verified webhook handler; no client-facing path exists, or should ever be added, that can mark a payment captured on the strength of the client’s own reported outcome alone.