Not sure what you mean when you say "restricted URL." It is the IPN URL that I was describing. It's basically just a way to get the information into the database. PayPal offers sample codes and they even have a way for you to post received inforamtion back to them to verify the authenticity of IPN transactions (I skip this step because it's not an issue for me).
Here is the code I use:
<?
require_once("userfunctions.php");
// Change the three variables below to reflect your own database connection information.
$database = "dbname";
$user = "user";
$pass = "pass";
$db = mysql_connect("localhost", $user, $pass);
mysql_select_db($database,$db);
$result = mysql_query("INSERT INTO paypal_transactions (receiver_email, item_name, item_number, quantity, invoice, custom, payment_status, pending_reason, payment_date, payment_gross, payment_fee, txn_id, txn_type, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, address_status, payer_email, payer_status, payment_type, notify_version, verify_sign, response, subscr_date, period1, period2, period3, amount1, amount2, amount3, recurring, reattempt, retry_at, recur_times, username, password, subscr_id) VALUES ('$receiver_email', '$item_name', '$item_number', '$quantity', '$invoice', '$custom', '$payment_status', '$pending_reason', '$payment_date', '$payment_gross', '$payment_fee', '$txn_id', '$txn_type', '$first_name', '$last_name', '$address_street', '$address_city', '$address_state', '$address_zip', '$address_country', '$address_status', '$payer_email', '$payer_status', '$payment_type', '$notify_version', '$verify_sign', 'NONE', '$subscr_date', '$period1', '$period2', '$period3', '$amount1', '$amount2', '$amount3', '$recurring', '$reattempt', '$retry_at', '$recur_times', '$username', '$password', '$subscr_id')",$db);
if ($txn_type == "subscr_signup")
{
$result = mysql_query("INSERT INTO users (username, password, first_name, last_name, payer_email, subscr_id) VALUES ('$payer_email', password('$subscr_id'), '$first_name', '$last_name', '$payer_email', '$subscr_id')",$db);
$email = $payer_email;
$from = "From: support@fflschedules.com\r\n"
."Bcc: bschaaf@bschaaf.com";
$mesg = "Thank you for subscribing to fflschedules.com. This message is being sent to inform you of your login credentials for the site.\r\n\r\nPlease use the following values to access your subscription for the first time:\r\n\r\n"
."Username: ".$payer_email."\r\n"
."Password: ".$subscr_id."\r\n\r\n"
."You may change either (or both) of these values after you login for the first time to something that is easier to remember. For directions on how to use the site and answers to the most common questions, please visit the fflschedules.com help page. Also, check out http://www.fflforums.com if you need a (FREE!) place to host a league messageboard and http://www.ffllinks.com for hundreds of fantasy football links.\r\n\r\nBest of luck with your league this season and thank you for using fflschedules.com!\r\n"
."\r\n"
."Brenden Schaaf\r\n"
."fflschedules.com \r\n";
mail($email, "fflschedules.com login information", $mesg, $from);
}
if ($txn_type == "subscr_payment")
{
$result = mysql_query("INSERT INTO subscriptionmoney (payment_date, payment_gross, payment_fee, txn_type, first_name, last_name, payer_email, subscr_id) VALUES ('$payment_date', '$payment_gross', '$payment_fee', '$txn_type', '$first_name', '$last_name', '$payer_email', '$subscr_id')",$db);
}
if ($txn_type == "subscr_eot")
{
// get a random dictionary word between 4 and 7 characters long (includes 2 characters for trailing \n)
$couponcode = get_random_word(6,9);
// add a number between 0 and 999 to it
srand ((double) microtime() * 1000000);
$rand_number = rand(0, 999);
$couponcode .= $rand_number;
$timeadjust = (24 * 6 * 60 * 60);
$expirydate = date("Y-m-d",time() + $timeadjust);
$result=mysql_query("INSERT INTO subscriptionplans
(sortorder, name, displayname, initialcost, termlengthqty, termlengthdesc, renews, renewalcost, renewlengthqty, renewlengthdesc, arrowname, display, descriptivetext, percentchoosing, couponcode, active, expires)
VALUES
('999', '$couponcode', 'Repeat Customer', '7.49', '1', 'Year', 'N', '0.00', '0', '', '', 'N', 'This personalized coupon code is valid for only 5 days from the time your subscription expired. This plan is exactly the same as our \"One Year\" renewing plan, except it is significantly discounted. You can view the regular prices and plan details at <A HREF=\"http://www.fflschedules.com/subscriptionrates.php\">http://www.fflschedules.com/subscriptionrates.php</A>, but make sure you sign up from this page to get the discounted rates!', '0', '$couponcode', 'Y', '$expirydate')
");
$result = mysql_query("DELETE FROM users WHERE subscr_id = '$subscr_id'",$db);
$result = mysql_query("DELETE FROM leaguenames WHERE subscr_id = '$subscr_id'",$db);
//$result = mysql_query("DELETE FROM teamnames WHERE subscr_id = '$subscr_id'",$db);
$result = mysql_query("DELETE FROM divisionnames WHERE subscr_id = '$subscr_id'",$db);
$result = mysql_query("DELETE FROM conferencenames WHERE subscr_id = '$subscr_id'",$db);
$email = $payer_email;
// $email = 'webmaster@fflschedules.com';
$from = "From: support@fflschedules.com\r\n"
."Bcc: bschaaf@bschaaf.com";
$mesg = "$first_name $last_name\r\n$payer_email\r\n\r\nThis message is just to let you know that your fflschedules.com subscription term has ended. "
."Thanks again for choosing fflschedules.com for your scheduling needs. If you would like to sign up for a new subscription, we offer you the following coupon code, which is valid for the next 5 days. It entitles you to 25% off the normal one year subscription price.\r\n\r\nCOUPON CODE: $couponcode\r\n\r\nDIRECT LINK: http://www.fflschedules.com/subscriptiondetails.php?couponcode=$couponcode\r\n\r\n"
."You may visit the link above or enter the coupon code in the designated spot on the fflSchedules.com main page and follow the instructions to activate your new subscription. You will need to reenter your league information as this subscription will be considered entirley separate from your former plan.\r\n\r\n"
."Even if you choose not to use the special coupon code shown above, we look forward to having the opportunity to serve you again in the future. "
."Best of luck with your league this season and thank you for using fflschedules.com!\r\n"
."\r\n"
."Brenden Schaaf\r\n"
."fflSchedules.com \r\n";
mail($email, "your fflschedules.com term has ended", $mesg, $from);
}
?>