← Questions
Payment intents: create, update, confirm, fail and refund
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A payment intent tracks one payment from creation to completion as a small state machine: it waits for action, moves to processing when a payment is attempted, and becomes completed when it succeeds. Process a list of commands and print every merchant's final balance. Commands that don't fit an intent's current state, or that name unknown merchants or intents, do nothing.
- Initialize merchants with a starting balance, create intents for a merchant and amount, attempt them and mark them succeeded; success credits the merchant.
- Allow updating an intent's amount while it still waits for action.
- Add failure (a processing intent goes back to waiting for action) and refunds of completed intents, which debit the merchant.
- Commands now carry timestamps, and a merchant may set a refund window: refunds later than that after the payment succeeded are refused.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
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
