Results 1 to 2 of 2
May 29, 2012, 01:28 #1
- Join Date
- May 2011
- 0 Post(s)
- 0 Thread(s)
What is the best way to build a paying login members account’
I am really looking for guidance and advice here. I have just built a members only community site and now want to make certain areas of the site ‘paying members only’ areas.
I am not sure of the correct way to structure the SQL/MySQL/PHP so that members will only gain access to the restricted areas once payment has been made and that this access will automatically terminate at the end of the payment cycle.
I have put forward my ideas below but I am not sure if this is the best and most efficient way to do it; so, I would love to hear back from everybody with their ideas and guidance on the correct way to build this function.
I will be using Paypal as the preferred method of payment.
First- we need a method to be able to determine a members user level . i.e one level will allow only for general access and the next ‘higher’ level will allow for access to restricted areas.
Below is the column that will be held in the members table and will be used to qualify a members membership level.
user_level TINYINT (1) UNSIGNED NOT NULL DEFAULT 0,
I propose to then have a payments table. This table will have three columns.
- The user ID
- Date of payment
- Date payment expires
I am thinking of storing the dates as Unix time stamp e.g. UNIX_TIMESTAMP(now())
The advantage of using a Unix time stamp, in my view, will be that it will be easier for me to calculate the end date for the access period. I.e for a 30 day access period I will simply MULTIPLY a 24 hour UNIX TIME STAMP BY 30
I.E 86400(24 hours) x 30 = 2592000 ) . I will then ADD THE 2592000 to the current Timestamp ( UNIX_TIMESTAMP (now()) )and this will give me the exact time 30 days, from the moment of payment, when the membership will expire.
I will then have an automated CRON JOB script that uploads every hour to check if a member’s membership has expired.
If CURRENT TIME is greater than the time stamp in the ‘Date payment expires’ column then the script will automatically change the status of USER LEVEL from HIGHER LEVEL TO LESSOR LEVEL
Please let me know what you think. I am still new to all this and this is my first real attempt to work out how to build a script to do something.
May 29, 2012, 11:22 #2
- Join Date
- May 2012
- 1 Post(s)
- 0 Thread(s)
Yes, this will work. You can use PayPal recurring payments to make billing more convenient. https://www.paypal.com/pdn-recurring
I also suggest you create a separate table for a log of transactions where you'll save every successful or failed transaction. PayPal will provide you with a whole bunch of information about each transactions, like fees, dates, statuses and stuff. Save it all: you may need it in case something goes wrong.