Last post May 18, 2020 07:30 PM by mgebhard
May 17, 2020 09:30 PM|georgeakpan233|LINK
I am trying to find out how a payment can be attached to a user profile, and the payment also will be displayed along with the user profile ID on a web form. For instance, if a user tries to buy goods from a commercial site, and the user is required to fund
or credit his or her account before using this credit to buy the goods; the user will click on a payment gateway button that will be redirected to the payment portal for payment authorization. After payment has been made, the user's account will be automatically
credited and it will be displayed on the navigation bar attached to the displayed user profile ID.
Lets say, user A wants to make a payment of 100 into his or her user account. After making payment through an embedded payment gateway, the user's account will be credited with exactly 100 and it should be shown or displayed on any web page the user
navigates to, under the user's login account.
The next thing I will like to know is, when a user makes a purchase the user's account will be debited and there will a deduction in the user's profile account. For example if a user has about 100 in whatever currency, and the user makes a purchase
for 40, the user will be left with 60;
1. How will the deduction be done with regards to coding?
2. Will the credited amount be saved in the database so that after the purchase the database table will be updated in the appropriate column where the amount will be saved ?
I will please need some guidance and if possible a brief coding on this. I will be totally grateful too if I get assistance and I thank you in anticipation. Thank you,
May 18, 2020 10:52 AM|mgebhard|LINK
Honestly, this is pretty basic stuff and if you have a checking or saving account then you already understand how it works. Create a table that has the user's Id, a decimal type, and a date. From there is is just debits and credit; positive and negative
decimals. Just SUM the decimal column to find the user's balance between two dates. You'll need want a period where financials are closed and you start over by moving the user's balance from the preceding period to the next.. It could be monthly, yearly,
never.... it is up to you.
May 18, 2020 07:16 PM|georgeakpan233|LINK
I thought of something similar to what you have stated with a bit difference though; a database table with user ID, email, password and a numerical data type column. I even thought of using my already created table that has email, username and password columns
by adding a new column titled "Account" that will accept numeric data type. That way, when a user makes payment the monetary figures will be stored in the "Account" column in the table, and when the user uses part of the funds to make a purchase, the "Account"
column of that user will be updated to the remaining balance. Assuming the user deposited 100 via payment gateway and later makes a transaction with 50, the "account" column in the database table will be automatically updated from 100 to 50...showing that
the user has used 50 out of 100 of the deposited funds.
May 18, 2020 07:30 PM|mgebhard|LINK
Do NOT store a calculated value from financial transactions! Store the actual debit and credit and calculate the value on depends. If a customer every refutes charges you will not have any history of the transactions in your DB and you might not be able
to figure out if the customer is correct or not.
Login to your bank account and take a look at your checking or saving ledger. Use the ledger as a template for your application.