I try to create an MFS(mobile financial service/p2p money transfer, bank with limited work) for learning. The transaction looks difficult. The user can do 3 things with his account.
- Deposit money to an e-wallet
- Withdraw money from an e-wallet
- Send money to another user's e-wallet.
Deposit money: Users can do it 3 way
- bank to e-wallet
- credit card to e-wallet
- Agent e-wallet account to my e-wallet account.
Withdraw money from:
- Nearest e-wallet agent(maybe a shopkeeper. He gives the cash and the person transfers money to his e-wallet. For this work, he gets a commission.)
- Helping banks ATM booths (not implemented right now)
- Transfer money to a linked bank account.
Now the way I was thinking and stuck is.
Here I have a transaction-type table that has charges and tries to make a single transaction table. Questions arise.
- Cash out charges are distributed between company and agent. 1% for the company and 1% goes to the agent account.
- Send money from one e-wallet to another e-wallet we have to adjust 2 account's current balances. But suppose we add money from a bank account to my MFS at that time I do not have the access to edit the bank account's current balance. So what type of data or trigger methods I should insert then?
- Add money through an agent, has both sides of account access. We can debit from the agent account and credit it to my e-wallet account.
So, what should my optimized schema look like? Any resource specific to this is appreciatable.
N.B: Still do not understand? just think about
- One bank tries to transfer money from one account to another account.
- One person from X bank wants to transfer money to a person whose bank account is in Y bank. How do you design those transfers? Also, share some resources on backup plans and security for those transactions.