๐ Hi there! The description you are currently reading is just 4th part of the problem set. It is highly recommended to read ALL THE 4 PARTS before coding as parts may build on top of each other ๐ณ
Last month, we received the new Payment Intent system you built ๐, and merchants have been LOVING how simple it makes accepting payments. Congratulations ๐!
However, numerous merchants have requested that we augment our refund functionality by letting merchants specify a refund timeout policy: the amount of time after a payment succeeds that refunds are permitted. For example, one merchant, LlmaCorp, only wants to accept refunds within 15 days of a payment succeeding. Being able to return a llama afte 15 days would be absurd after all.
Let's add this functionality to our system, which means we will need to change the format of our commands to handle timing ๐ช.
Timestamps
Merchant Refund Timeout Limit
๐ <timestamp> INIT <merchant_id> <starting_balance> <refund_time_out_limit>
๐ทเผยทหCredit to Rachelแฅซแญก.
Example 1:
Input: commands = ["1 INIT m1 0 5", "2 CREATE p1 m1 100", "3 CREATE p2 m1 50", "4 ATTEMPT p1", "5 ATTEMPT p2", "8 SUCCEED p1", "10 SUCCEED p2", "11 REFUND p1", "16 REFUND p2"]
Output: ["m1 50"]
Explanation:In the above example, the reund of Payment Intent p1 succeeded because p1 was succeeded at time 8 and refunded at time 11, which is within merchant m1's refund timeout limit of 5. However, the refund of Payment Intent p2 failed because p2 was succeeded at time 10 and refunded at time 16, and 16 - 10 = 6 > 5, meaning it occured after m1's timeout limit. Because p1 was successfully refunded and p2 was not, the final balance of merchant m1 should be 50 :P
๐ซถ
input:
output: