Jump to content

Credit system


slj90

Recommended Posts

What is the best practise for websites that use a credit system? For example a website that allows a user to purcahse credits and spend them on the website. Is it as simple as increasing/decreasing their user data in the mysql table? How would more security be added to that process to avoid users editing how many credits they have etc.

 

Thanks,

Link to comment
Share on other sites

it as simple as increasing/decreasing their user data in the mysql table?

 

 

no it's not that simple. you would do this like your bank or credit-card company does it, by storing a record for each transaction that lists the date, amount (credits are +amounts, debits are -amounts), and information about the transaction (confirmation number for payments, name/reason for each debit).

 

to avoid users editing how many credits they have etc

 

 

why would you have any code in place that would allow a user to directly affect these amounts? the user should only have 'permission', through your code, to display the amounts and cause events to occur that enter a transaction for that user. for credit (+) transactions, you would verify with the payment gateway that the user made a payment before entering a row in the database table with the amount. for debit (-) transactions, you would only enter those if you know who the user is and if this is dealing in real money, you would re-verify who the user is by having him/her re-enter their username/password.

Link to comment
Share on other sites

Can look into stripe or paypal as a payment gateway.

 

So that is just the part them purchasing credit packages x amounts.

Check request and verify they actually paid, once get that add the credits to their account.

 

As for on site is a matter of doing a -1 for their credits upon usage.

When out of credits a reminder or link to purchase more credits.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.