soomla/ios-store — pull request #22 by gkrishna1 (2014-04-19 18:04:23+00:00)
Title: takeAmount() sets balance to zero if balance goes negative

If balance is going in negative (below zero value) then takeAmount() should not change the current available balance value. Before these code changes takeAmount() sets the current available balance to zero if the balance goes negative.

Added a new event "EVENT_INSUFFICIENT_VIRTUAL_CURRENCY" in the event
handler.

Test case:
Suppose there is 80 coins balance and an game power-up is of worth 100 coins. If takeAmount() is called at this time to buy the item then takeAmount() sets the balance to zero by removing the balance. This should not happen.

The takeAmount() and giveAmount() methods now returns a BOOL which will give more control and confirmation to developer about the success or failure of the transaction. And also no need to check repeated getBalance() calls.