I'd like to ask about the technique to optimize the update for multiple VirtualCurrency, Inventory at the same time; and handle the rollback in case there is any issues happening.
The case is: An user opens a loot box with 10 gem (virtual currency). He gets 100 gold (another virtual currency) and 1 item in the inventory.
The custom server checks the logic and verify the transaction then call 3 API to update:
- AddUserVirtualCurrency (Add gold)
- SubtractUserVirtualCurrency (Decrease gem)
- GrantItemsToUser (Add item)
My questions are:
- Is there any way to use 1 API to handle all these requests?
- If there is any issue when calling these API, is there any way to rollback the process (ex: revoke the item, add back gem and reduce gold)?