Khawer Zeshan
Khawer Zeshan

Reputation: 9646

How to deduct customer balance when has more than one call connected at a time

we do allow him to call based on his current balance, the call is scheduled for 10 min, next call comes in it is also scheduled for 10 min because the customer balance was not updated as his first call is still in process. we only update the balance when a call is disconnected. in this way balance will go negative. but is there is any solution to this problem so that balance do not go negative ?

Upvotes: 1

Views: 344

Answers (1)

jefflunt
jefflunt

Reputation: 33954

Banks solves this problem by placing a "hold" on the funds, and tracking two separate balances: the current balance (all money in the account) and the available balance (which is the current balance, minus the total of all the "holds" on all funds outstanding).

Let's say you have a balance of $10, and the calls cost $1/minute.

The idea is that your first 10 minute call wouldn't actually deduct the funds before it was done, but it would say, "Hey, I'm going to need $10 out of the current balance." The money, as you said, is only actually taken away when the call is disconnected.

However, because the "hold" on that $10 is already in place, when the second call is setup, it checks the balance and says, "Hey I'm going to need $10," but the algorithm would take the total balance ($10) and subtract the total of all the "hold" amounts ($10), and return $0.

So, basically the second call wouldn't get setup, because you balance algorithm would say, "Yes you've got $10 in your account, but you've currently reserved $10 of that, leaving you with $0 'available balance'. Therefore, I can't reserve the time for your call unless you either cancel your first call, or add more money to your balance."

Upvotes: 2

Related Questions