All work
Production

Checkout Platform

An 11-state, checkpoint-resumable checkout across 5 microservices — retries resume, they never re-charge.

Role
SDE 1 – Backend (Java)
Company
Standard Chartered Research and Technology (SOLV)
Period
Jan 2024 – Present
Stack
Java 8 · Spring Boot · Dropwizard · MySQL · DynamoDB · REST
~25K
orders / month
99.57%
payment-to-order completion
~50K
checkout sessions / month
~32K
split-payment sessions / month (99.1% success)

Production metrics · 30-day window · Sep 2026

Context

Checkout is the moment a B2B retailer’s cart becomes a paid, fulfillable order. On our platform, one checkout touches five services: an API gateway that the mobile app talks to, a checkout service that orchestrates the flow, a payment service that owns payment sessions and expectations, a payment-gateway service that talks to PayU and Razorpay, and an order-processing service that reserves inventory and creates the order. Customers can pay fully upfront, pay a configurable advance, or pay on delivery, and can apply their wallet (JumboCash) balance on top.

The problem

A checkout is a long, multi-step, cross-service transaction with real money in the middle. Any step can fail or time out: payment-session creation, the gateway round-trip, order placement, or the post-order bookkeeping. Two different actors can also try to finish the same checkout at once — the app returning from the payment screen, and the gateway’s server-to-server webhook. Without care, that gives you the two worst outcomes in commerce: a customer charged twice, or charged with no order created.

Constraints

  • Every step must be safely retryable. Mobile networks drop, and users tap again.
  • The flow has to support full payment, partial advance, zero advance (pay on delivery), and wallet + UPI split payments in one model.
  • Business teams change prepayment policy often (by category, customer segment, cart value) and should not need a deploy to do it.
  • The design must be debuggable after the fact: “what happened to this checkout?” needs a precise answer.

Design

  • Explicit state machine. A cart checkout moves through 11 states: initiated → payment session created → payment session successful → order placed → pending payment expectations created → completed. Each has failure and abort branches. An order-payment checkout (paying dues on an existing order) uses a smaller 7-state variant. Allowed transitions are table-driven, and every transition is appended to an append-only transition log, so a checkout’s full history is always reconstructable.
  • Checkpointed snapshots. Each significant step writes a JSON snapshot: cart details, payment options, the customer’s payment selection, the payment-session initiation and completion responses, the order-placement response, post-advance payment expectations, and failure details. That is 9 checkpoint types. When a request retries, the step reads its snapshot and resumes instead of redoing work. That is what makes retries safe.
  • Idempotent order creation. Order placement writes a DynamoDB conditional record keyed on the cart id with a 900-second TTL before creating anything. A concurrent or repeated attempt sees the record and either replays the existing order or backs off. This collapses the app-callback vs webhook race into exactly one order.
  • Config-driven prepayment rules. A rules table targets marketplace × customer segment × category × cart value, and resolves to an advance percentage. Conflicts resolve deterministically: a 0% rule wins, otherwise the highest percentage wins, and ties go to the newest rule. Policy changes are rows, not releases.
  • Split payments with per-item attribution. A payment session holds one leg per instrument (UPI through the gateway, and the wallet). Payment expectations are created per cart item. An advance is allocated pro rata across items by what each still owes, so after the order is placed, every order item carries an exact balance due at delivery.
  • Zero-advance fast path. When nothing is due upfront, checkout skips the gateway entirely and places the order directly.
Cart checkout · state machine
CHECKOUT_INITIATED: Cart validated, payment options computedINITIATEDPAYMENT_SESSION_CREATED: Payment session and gateway order createdPS_CREATEDPAYMENT_SESSION_CREATION_FAILED: Session could not be created; retryablePS_CREATE_FAILPAYMENT_SESSION_SUCCESSFUL: Payment confirmed with the gatewayPS_SUCCESSFULPAYMENT_SESSION_COMPLETION_FAILED: Completion failed; retryablePS_COMPLETE_FAILORDER_PLACEMENT_SUCCESSFUL: Order created (idempotent on cart)ORDER_OKORDER_PLACEMENT_FAILED: Order creation failed; retry or re-payORDER_FAILPENDING_PAYMENT_EXPECTATION_CREATED: Balance due at delivery recorded per order itemPPE_CREATEDPENDING_PAYMENT_EXPECTATION_CREATION_FAILED: Balance-due records failed; flagged for follow-upPPE_FAILCHECKOUT_COMPLETED: DoneCOMPLETEDCHECKOUT_ABORTED: Abandoned or superseded by a newer checkoutABORTED
  • start
  • happy path
  • failure (dashed)
  • terminal (double)

Select a state (click, or Tab then Enter) to see its description and allowed transitions, or play the happy path.

Snapshot checkpoints
  • Cart details (not written)
  • Order payment (not written)
  • Payment options (not written)
  • Payment selection (not written)
  • Session initiation response (not written)
  • Session completion response (not written)
  • Order placement response (not written)
  • Post-advance payment expectations (not written)
  • Failure details (not written)
All states as a list
  • CHECKOUT_INITIATED (start) — Cart validated, payment options computed. Next: PAYMENT_SESSION_CREATED, PAYMENT_SESSION_CREATION_FAILED, ORDER_PLACEMENT_SUCCESSFUL, ORDER_PLACEMENT_FAILED, CHECKOUT_ABORTED
  • PAYMENT_SESSION_CREATED (happy) — Payment session and gateway order created. Next: PAYMENT_SESSION_SUCCESSFUL, PAYMENT_SESSION_COMPLETION_FAILED, PAYMENT_SESSION_CREATED, ORDER_PLACEMENT_SUCCESSFUL, CHECKOUT_ABORTED
  • PAYMENT_SESSION_CREATION_FAILED (failure) — Session could not be created; retryable. Next: PAYMENT_SESSION_CREATED, PAYMENT_SESSION_CREATION_FAILED, CHECKOUT_ABORTED
  • PAYMENT_SESSION_SUCCESSFUL (happy) — Payment confirmed with the gateway. Next: ORDER_PLACEMENT_SUCCESSFUL, ORDER_PLACEMENT_FAILED
  • PAYMENT_SESSION_COMPLETION_FAILED (failure) — Completion failed; retryable. Next: PAYMENT_SESSION_SUCCESSFUL, PAYMENT_SESSION_COMPLETION_FAILED, CHECKOUT_ABORTED
  • ORDER_PLACEMENT_SUCCESSFUL (happy) — Order created (idempotent on cart). Next: PENDING_PAYMENT_EXPECTATION_CREATED, PENDING_PAYMENT_EXPECTATION_CREATION_FAILED, CHECKOUT_COMPLETED
  • ORDER_PLACEMENT_FAILED (failure) — Order creation failed; retry or re-pay. Next: PAYMENT_SESSION_CREATED, ORDER_PLACEMENT_FAILED, ORDER_PLACEMENT_SUCCESSFUL, CHECKOUT_ABORTED
  • PENDING_PAYMENT_EXPECTATION_CREATED (happy) — Balance due at delivery recorded per order item. Next: CHECKOUT_COMPLETED, PENDING_PAYMENT_EXPECTATION_CREATION_FAILED
  • PENDING_PAYMENT_EXPECTATION_CREATION_FAILED (failure) — Balance-due records failed; flagged for follow-up. Next: none
  • CHECKOUT_COMPLETED (terminal) — Done. Next: none
  • CHECKOUT_ABORTED (terminal) — Abandoned or superseded by a newer checkout. Next: none
Cart checkout: 11 states. Click a state to see where it can go next.
Checkout architecture The app calls the API gateway, which routes to the checkout service. Checkout fans out to the payment service, which calls the payment-gateway service and then PayU or Razorpay, and to the order-processing service, which writes an idempotency record in DynamoDB before the order store. The gateway's webhook returns to the payment-gateway service, which calls the checkout completion endpoint; this payment path is the highlighted happy path. App API gateway Checkout service Payment service Order store Idempotency record (DynamoDB) Order- processing svc Payment- gateway svc PayU / Razorpay Checkout completion endpoint webhook happy path
Checkout request flow across 5 services

Key decisions & trade-offs

Results

  • ~25K orders/month through checkout at 99.57% payment-to-order completion (payment-session completions that end in a placed order).
  • ~50K checkout sessions/month initiated at 98.4% success.
  • ~32K split-payment sessions/month at 99.1% success.
  • Zero double-charges on retry by design: every step either resumes from its checkpoint or is blocked by the idempotency record.

Tech used

  • Java 8
  • Spring Boot
  • Dropwizard
  • MySQL
  • DynamoDB
  • REST
  • Datadog

Back to all work