← Questions

Aggregate payment states from asynchronous events

0
StripeCodingLast asked Oct 2026

Payments are driven by asynchronous events that arrive as CSV lines: an event ID, a timestamp, the payment ID and an action such as create (with its merchant), authorize or capture (with an amount). Process the events in arrival order and report, for each payment in the order it was created, its merchant, its current state, the amounts authorized and captured so far, and the time of its last event.

An event ID that was already processed must be ignored. The question comes in four parts that add event types and rules one at a time (a payment captured for less than was authorized ends up partially captured, for example), so keep the state transitions easy to extend.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding