A Simple Fix to A Major Banking Blunder

hephzy

Hephzy

Posted on June 29, 2024

A Simple Fix to A Major Banking Blunder

As a developer, I've come to understand that even minor oversights can lead to significant outcomes. I recently discovered a flaw in an API used for banking operations that might have let users take out more money than they had in their accounts. Upon finding the defect, I promptly set out to work on a remedy to block any unauthorized withdrawals.

Overview of the Banking Blunder

Upon examining the API code, it was evident that the withdrawal function lacked a critical validation step. In the absence of this check, users could potentially withdraw amounts exceeding their account balances, leading to overdrafts and severe financial implications. Such a vulnerability poses a considerable risk to the banking sector, eroding the trust and security customers anticipate in financial dealings. Banks must swiftly rectify these issues to preserve their credibility and safeguard client assets.

The Simple Fix

To tackle this problem, I implemented a straightforward validation check that compares the withdrawal amount to the account balance. If the withdrawal amount is greater than the balance, the system issues an error message for insufficient funds. This measure helps to prevent customers from overdrawing their accounts and incurring hefty fees.

By instituting this validation check, banks can markedly decrease the incidence of overdrafts and the fees customers accrue. This enhancement not only boosts customer satisfaction but also economizes bank resources by reducing the necessity to reverse transactions or manage overdrafts.

Steps to Implement the Fix

In tackling the problem, I devised an asynchronous function tasked with verifying the user's current balance.

async function checkBalance(accountNumber) {
  const query = `
    SELECT Balance
    FROM Accounts
    WHERE Account_No = ?
  `;
  const values = [accountNumber];
  const result = (await dB).query(query, values);
  console.log(result);
  return result; // You have to extract the balance from the result
}
Enter fullscreen mode Exit fullscreen mode

Then, I compare that with the amount the user wishes to withdraw.

const hasAmount = await checkBalance(Source_account)
      console.log(hasAmount[0][0].Balance);

      if (hasAmount[0][0].Balance <= Amount) {
        throw Error (`Not Enough Balance`);
      }
Enter fullscreen mode Exit fullscreen mode

Conclusion

In software development, attention to detail is crucial. By catching this defect and implementing a simple validation check, I prevented a potential banking blunder. This experience serves as a reminder that even the smallest fixes can have a significant impact on the reliability and security of our systems.

Banks need to emphasize the potential risks and consequences of overlooking such issues. It is imperative for banks to prioritize implementing these simple fixes to maintain trust and credibility with their customers.

NOTE
This article serves as Assignment - Task 0 for the HNG Internship programme, a rapid programme designed to provide beginners in technology with fundamental training in various fields. It offers the opportunity to gain experience by working as interns, collaborating with peers to accomplish tasks, or submitting projects before deadlines. Additionally, there is a HNG premium space where tech enthusiasts can connect, participate in mock interviews, have their CVs reviewed, and explore opportunities.

💖 💪 🙅 🚩
hephzy
Hephzy

Posted on June 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related