Practice assignment

Idempotent payment event-processing take-home

Payment events arrive from a message broker with at-least-once delivery. Balances must never be applied twice. You implement PaymentEventHandler.handle(PaymentEvent) → APPLIED | DUPLICATE | DEAD_LETTERED.

The starter

handle(event) → APPLIED | DUPLICATE | DEAD_LETTERED

CREDIT adds, DEBIT subtracts, balance never negative.
On success: OutboxMessage("balance-changed", …) in the same transaction.

Requirements

Grading rubric

AreaPoints
Correctness (provided tests)30
Idempotency & transactional boundaries20
Concurrency (optimistic locking via @Version)10
Own tests (concurrent duplicates)15
Structure & domain clarity5
NOTES.md: outbox relay, ordering, retries vs DLQ20

Levels: junior ≥ 60, mid ≥ 75, senior ≥ 85 (and a strong NOTES.md).

What reviewers look for

Common mistakes

How to run it

mvn verify. Pair this with the Node webhook task if you want the same ideas at the HTTP edge.

Generate a practice consumer from a payments or platform job ad, or try the Node webhook sample first.

Download the webhook sample Generate one from a job ad

Related practice tasks

Frequently asked questions

How is this different from the webhook take-home?
This one is a broker consumer in Spring Boot (you implement a handler). The webhook task is an HTTP endpoint with a signature check in TypeScript. The idempotency and outbox ideas are the same family.
Should a lost race return DUPLICATE?
Only if you already know the event is stored. If the transaction did not commit, throwing and letting the broker retry is correct; the retry should then see DUPLICATE.
Do I have to build the outbox publisher?
No. Write the row in the same transaction. Explain in NOTES.md how a relay would publish it.

Practice only. This is an original HireCheck practice assignment, not a real employer's take-home, and it is not affiliated with any company mentioned as a role example.