Turning this membership login into subscription login
Posted: Thu Sep 22, 2011 7:32 pm
Hi there. I am asking for a little help on this project. I've recently purchased a script only to find that it wasn't quite what I wanted. The script I bought creates a one time payment membership login system through paypal. Unfortunately I was looking for a recurring payment membership login system with paypal. I've been told "the script could easily be modified to allow it if you know a bit of php". Well, I don't. At least not enough to know where to start.
I should also add that the script works perfectly one time payment memberships.
Here are the parts of the script that I think are relevant:
The Config:
The 'paypal.php'
If someone could point me in the right direction that would be very much appreciated
I should also add that the script works perfectly one time payment memberships.
Here are the parts of the script that I think are relevant:
The Config:
Code: Select all
<?PHP
//////////CONFIGURATION///////////////
$dbhost = 'localhost'; //your database host
$dbusername = 'db_name'; //your database username
$dbpasswd = 'db_pass'; //your database password
$database_name = 'db_login'; //your database name
$business = 'xxxxxxxxxxx@yahoo.com'; //your paypal email address
$adminmail = 'xxxxxxxxx@yahoo.com'; //admin email address where notifications are sent
$itemcost = '1.00'; //how much your item costs
$itemname = 'xxxxxxxxxx'; //name of your item
$itemnumber = 'xxxxxxx'; //give your item a number or word for identification
$itemcurrency = 'USD'; //the currency used for the payment
$notifyurl = '/members/paypal.php'; //url to this paypal script
$emailfrom = 'xxxxxxxx@yahoo.com'; //who emails to users will be from
$sitename = 'xxxxxxxx.com'; //NAME OF YOUR SITE
$membersurl = '/membersarea.html'; //url to your members area
$webmastername = 'xxxxxxx'; //name of your webmaster or your name
////////////END CONFIGURATION////////////Code: Select all
<?PHP
include 'config.php';
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$payment_date = date("Y-m-d");
if (!$fp) {
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0 && ($payment_status=="Completed" || $payment_status=="Pending")) { //IF PAYMENT IS
$query = "SELECT * FROM members WHERE txn_id='$txn_id'";
$result = mysql_query($query) or die ("Could not execute the query1");
$num_rows = mysql_num_rows($result);
if ($num_rows > 0 ){//IF THERE IS A TXN_ID IN THE DB UPDATE THE PAYMENT STATUS
$updatequery = ("UPDATE members SET payment_status='$payment_status' WHERE txn_id='$txn_id'");
$updateresult = mysql_query($updatequery) or die ("Could not execute query2");
////IF PAYMENT STATUS WAS UPDATED DO THE BELOW
//////////EMAIL ADMIN THAT PAYMENT HAS CLEARED////////
$csubject = "A Membership Payment has Cleared";
$cmessage = "A Membership Payment has Cleared.
PAYMENT INFO:
Item Name:$item_name
Item Num:$item_number
Status:$payment_status
Amount:$payment_amount
Currency:$payment_currency
TXN Id:$txn_id
Buyer:$payer_email
Date:$payment_date
";
mail($adminmail, $csubject, $cmessage, "From: $emailfrom\nX-Mailer: PHP/" . phpversion());
////////END EMAIL ADMIN//////
//////////EMAIL BUYER ////////
$dsubject = "You now have full access to the weight catagory of Ultimate Hypnosis Downloads!";
$dmessage = "Thank you for joining $sitename!
You now have access to our Members area.
ACCESS INFO:
Members Url: $membersurl
Username: $payer_email
Password: $random_password
Thanks for your purchase!
$webmastername
";
mail($payer_email, $dsubject, $dmessage, "From: $emailfrom\nX-Mailer: PHP/" . phpversion());
////////END EMAIL BUYER//////