Hi there. I want to ask about account balance. Usually they will top up their balance, and use the balance to purchase in my app.
How should I maintain these logic in Adalo? The balance will be use as validation if they want to purchase products in my app. (if the balance is not sufficient, they can’t purchase and should top up first)
Can I have balance in the Users’ Database? And every time there are success top up, I’ll add the balance. Or every time there are success transaction I’ll deduct the balance.
I should create calculate the “Remaining Balance” every time they want to purchase with the syntax
Total Top Up Balance - Total Used Balance = Remaining Balance? If yes, in the future after I have a lot of transaction, will the app become slow?
Need your advice because I want to ensure the best way. Thank you.
You might want to have current balance on the user DB, and a DB for the transactions… When the user Tops Up, you create a transaction when successful. and add it to there balance, if the user is using an in app purchase from their in-app balance… subtract the balance.
Have a condition on that calculation that states transaction is only successful if the purchase cost - current balance is greater or equal to 0.
If its successful, simply create a db where you store all in-app transactions. have a relationship that links the transactions to the user (a user can have multiple transactions but a transactions belongs to one user).
To maintain a consistent balance, never load all the transactions at once, i would have last 20 or 30 transactions and on a custom list that loads as user scrolls. with a tab to see full history of transactions… which you can then expect the user to wait while you load them up (load as he scrolls as well).
Have a modal that pops up if the balance is less than 0… and send the user to make a top-up if this is the case.
Like the dyslexic vodafone .
You can, when making a transaction get the “total current balance - current purchase”.
I assume you also have a collection to keep every single transaction (top up and purchse)?
This will help then to match Accounts Payable with Accounts Receivable and make sure that your total - also the sum of the single transactions, correspond to the total balance.
So I would say:
User collection with field Current balance, where they top up and sums to previous current balance.
Collection Transactions. here you track single transactions from all users (Also good for future analytics)
Top up Transactions: Here you track the single top up transactions from all users.
When there is a purchase:
New balance = User collection current balance - current purchase
Add single record to Collection Transactions.
Then you can use a Sum of All transactions and compare to all top ups to see
You top up 100$
Get a purchase of 40$
Current Balance = 60$ (Previous current balance 100$ - Purchase 40$)
You top up 200$
Get a purchase of 50$
Current Balance = 210$ (Previous current balance 260$ - Purchase 50$)
Sum of single top ups is 300$
Sum of single transactions is 90$
That gives you the current balance = 210$
So you can use both methods to guarantee that the Balances and top-ups and purchases match the total with the single transactions (top up, purchases).
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.