Company: Stripe_1nov
Difficulty: medium
Payment Intent System Problem Description A payment processor tracks every payment with a small state machine called a Payment Intent . An intent remembers the merchant it pays, the amount, and its state, which is one of: REQUIRES_ACTION -- the state an intent is created in. It may move to PROCESSING. PROCESSING -- the customer has tried to pay but the attempt has not resolved yet. COMPLETED -- the payment succeeded and its amount has been added to the merchant's balance. You are given a chronologically ordered list of commands and must report every merchant's final balance. Commands INIT <merchant_id> <starting_balance> -- create a merchant with that balance. If a merchant with this id already exists, do nothing (the existing balance is not replaced). CREATE <payment_intent_id> <merchant_id> <amount> -- create an intent in state REQUIRES_ACTION. Do nothing if an intent with this id already exists, if the merchant does not exist, or if the amount is negati