User account payment RRS feed

  • Question

  • User-1994446809 posted

    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,



    Sunday, May 17, 2020 9:30 PM

All replies

  • User475983607 posted

    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.

    Monday, May 18, 2020 10:52 AM
  • User-1994446809 posted

    Hi mgebhard,

    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.

    Monday, May 18, 2020 7:16 PM
  • User475983607 posted

    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. 

    Monday, May 18, 2020 7:30 PM