💼 Hiring Quest – Java Tech Lead @ ExeQut
Challenge-based hiring quest with structured evaluation and real project outcomes.
Top performers get hired with a paid contract and the opportunity to work on real-world projects.
Cart Checkout + Mock Payment System
Single Service | Java / Spring Boot
🧠 Business Context
You are designing the backend for a small e-commerce product.
The system allows users to:
Create a cart
Add items
Checkout
Pay for their order
This system is not expected to scale
However:
It handles real money
Order state must always be correct
No double payments
No invalid state transitions
Webhooks may arrive twice
You are the Tech Lead responsible for:
Defining the domain model and designing clear boundaries inside a single service
Designing the order state machine and protecting business invariants
Ensuring data consistency and correctness in all state transitions
Handling payment safely, including webhook processing and idempotency
Defining a safe payment handling strategy that prevents double charges
Designing failure handling for duplicates, retries, and race conditions
Making conscious architectural trade-offs (simplicity vs robustness)
Enabling future extensibility (refunds, partial payments, cancellations) without breaking core invariants
👥 User Flows
✅ Flow 1 — Happy Path
Create cart
Add items
Checkout → Order created
Start payment
Mock provider confirms payment (webhook)
Order becomes PAID
✅ Flow 2 — Payment Failure + Retry
Start payment
Provider sends FAILED
Order becomes PAYMENT_FAILED
Start payment again
Provider confirms → Order becomes PAID
✅ Flow 3 — Duplicate Event Handling
Provider may send the same webhook twice
System must remain correct
No duplicate transitions
No corrupted state
📌 Functional Requirements
1️⃣ Cart
Endpoints:
POST /carts → create cart
POST /carts/{cartId}/items → add item (productId, quantity, price)
Cart rules:
Items can be modified before checkout
Checkout locks the cart
2️⃣ Checkout / Order
Endpoint:
POST /carts/{cartId}/checkout
Behavior:
Creates an Order from cart
Locks cart
Initializes order state
Required Order States
You must define and implement a state machine.
Minimum states:
CREATED
PENDING_PAYMENT
PAYMENT_FAILED
PAID
(Optional: CANCELLED if you can support it cleanly.)
You must enforce valid transitions.
3️⃣ Payment
Endpoints:
POST /orders/{orderId}/payment/start
POST /payments/webhook
Required Behavior
When starting payment:
Create a payment intent / attempt
Order moves to PENDING_PAYMENT
Must prevent duplicate active payments
When webhook is received:
Update order state safely
Handle duplicate webhook calls idempotently
🔌 Mock Payment Provider (Simple Requirement)
You must implement a minimal mock provider inside the same project that:
Simulates payment start
Allows triggering a payment result (CONFIRMED / FAILED)
Calls your /payments/webhook endpoint
No need for complex simulation.
Just enough to demonstrate full flow.
🧪 Testing Requirements
Minimum:
1 unit test validating domain state transition
Optional but strong:
1 integration test covering happy path
Test for duplicate webhook
📦 Deliverables
Your submission must include:
Complete Java / Spring Boot codebase
Clear domain model & order state machine
Payment handling (including idempotency & webhook logic)
Mock payment provider
Required endpoints implemented
At least 1 unit test for state transitions
README (setup + assumptions + key decisions)
🎥 10–15 min Video (Required)
Cover:
Architecture & key decisions
State machine & payment flow
Webhook handling & idempotency
Edge cases (failures, retries, duplicates)
Trade-offs & improvements
👉 The technical review session will focus on your submitted solution, so make sure you fully understand and can clearly walk us through your implementation.
📊 Evaluation Criteria
Area & Weight
State machine & invariants: 25%
Idempotency & payment safety: 25%
Code clarity & structure: 25%
Testing: 20%
Documentation clarity: 5%