mardi 12 janvier 2021

Design fail safe ATM transaction

This is a Design Question I came across in a Mock Interview.
How can we design ATM transactions Fail Safe(considering Network/Power failure)? Consider below scenario:

  • a. User inserts card into ATM and enters PIN
  • b. Authentication Success
  • c. User Click on money debit option and enters amount to be debited
  • d. confirms and hit Submit.

Assume that ATM(s) and Bank server(s) are connected through Wireless Network

In this case:

  1. Shall we debit the amount from customer's account first and then money withdraw should happen? OR
  2. Money withdraw should happen first and then customer's account should be debited with that amount?

Usually in real life, I have seen that first money gets withdraw from ATM and then we get a confirmation(Success/Failure) text message of withdrawal.

Most of you will say that 1st approach is correct with some modification like maintaining Transaction State(InProgress, Done, On-Hold) But How should we handle(recover/rollback) the below Fail scenarios:

  1. Money Withdrawal Requested by Customer -> Customer's Bank Account debited(On-Hold until physical money debited) -> Physical Money withdraw happens -> Network Failure between Bank Server and ATM happens(may be due to catastrophic situation and ATM machine is not recoverable).

  2. Money Withdrawal Requested by Customer -> Customer's Bank Account debited(On-Hold until physical money debited) -> money withdraw is yet to happen -> Power Failure and ATM is shutdown or Network Failure between Bank Server and ATM(may be due to catastrophic situation and ATM machine is not recoverable).

Aucun commentaire:

Enregistrer un commentaire