Safe storage of account balances in the database?

So, I have a Django web application, and I need to add a payment module to it.

Basically, the user will pay for a certain amount of service, and this will slowly decrease as the user uses this service. I am wondering what is the best practice for this? I can process payments using Satchmo, but then just storing the USD value in the database and having my code interacting with this value directly seems pretty risky. Of course, I can do this, but I wonder if there is already a proven solution to this problem?

+3
source share
2 answers

I don’t know about the “proven solution”, as you put it, but I would strongly recommend not to store the dollar value in the database and increase or decrease this value in dollars. Instead, I would advise storing transactions that can be verified if something goes wrong. Calculate the amount available from credit and debit transactions in the user account, and not store it directly.

For added security, you want your application to not be able to delete transaction records. If for some reason you cannot ban write permissions in the corresponding tables, try repeating the transactions to the second database (which the application does not touch) as they are created.

+6
source

, , , -, ; , (), . , , , (.. -). , webapp, . , , , , . , webapp - .

+1
source

All Articles