Preparing your design workspace

Loading the problem and your saved attempt…

Design a Payment Transaction State Machine

Model idempotent payment transactions, provider outcomes, retries, refunds, and auditable state transitions.

For this exercise, assume a merchant submits a payment in one currency to one external provider. A transaction begins Pending and can finish as Succeeded or Failed after either a synchronous provider response or an authenticated asynchronous outcome.

Repeating the same merchant request must not create a second charge, repeated provider outcomes must not create a second state change, and every accepted transition must remain auditable. A Succeeded transaction may be refunded once for its full amount.

Design the model and interfaces, then implement the bounded behavior that applies a provider outcome. Multi-provider routing, partial refunds, and foreign exchange are out of scope.