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.
One checkout request
- StorefrontSubmit the cart
- GatewayCheck branch and minimum
- Payment providerProcess the charge
- 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.
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.
The order service records the order and closes the cart.
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.