Chaim Brodetsky

Case study / Commerce integration

E-commerce checkout integration on AWS

I built a storefront gateway that coordinates a shopper’s cart, payment, and order across separate services. The hardest part of checkout comes just after a charge succeeds, when the warehouse can still decline the order.

A brass path connects a checkout counter to warehouse shelves in an illustrated scale model.

One checkout request

  1. StorefrontSubmit the cart
  2. GatewayCheck branch and minimum
  3. Payment providerProcess the charge
  4. Order serviceConfirm stock and create order

Why the order can still fail

Payment and stock reservations belong to different systems. A successful charge tells the storefront that money has moved. It still needs an order number before it can tell the customer that the purchase is complete. I put that coordination in the gateway so each checkout client can use the same workflow.

Watch the payment recovery workflow · 16 seconds
Video description

The gateway checks the branch cart. Payment succeeds, but order creation fails. The gateway uses the payment reference to attempt cancellation. A shared request ID helps support investigate the outcome.

Before the charge

The gateway looks up the signed-in shopper’s cart for the selected branch. It checks the minimum checkout amount and opens a payment transaction. Once payment succeeds, it passes the provider’s transaction reference and any applied coupon discount to the order service.

When payment and stock disagree

The order service checks the cart again and asks the warehouse to confirm its reservation. It then writes the order and its lines and closes the cart in one DynamoDB transaction. A failure at that boundary can leave a successful charge with no corresponding order.

After the payment succeeds
Gateway requests an order
Stock confirmed

The order service records the order and closes the cart.

Order creation fails

Attempt cancellation using the payment reference.

How support can follow a failed checkout

If order placement fails after payment, the gateway attempts to cancel the charge using the provider’s transaction reference. Cancellation can fail too. The gateway records the failure, carries a shared request ID through the calls, and can direct a customer who sees a charge to contact support before trying again. That gives support a specific transaction to investigate.