Well for my site i want my users to be on a monthly membership. so once they buy the membership they will have it for 31 days. how do i make it so when the 31 days run out they lose there membership. also I want to make the monthly membership Recurring. I guess ill just show you guys my ipn for paypal.
<?php
include("session1.php");
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
include('ipnlistener.php');
$listener = new IpnListener();
$listener->use_sandbox = true;
try {
$listener->requirePostMethod();
$verified = $listener->processIpn();
} catch (Exception $e) {
error_log($e->getMessage());
exit(0);
}
if ($verified) {
$errmsg = '';
if ($_POST['payment_status'] != 'Completed') {
exit(0);
}
if ($_POST['mc_currency'] != 'USD') {
$errmsg .= "'mc_currency' does not match: ";
$errmsg .= $_POST['mc_currency']."\n";
}
else
require("include/config.php");
$mailer = "email@email.com";
$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'];
$email = $_POST['payer_email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$custom = $_POST["custom"];
$userid = $custom;
mysql_query("UPDATE users SET plan='$item_name', memberstatus='member', subdays='31' WHERE username='$userid'");
$sql = "INSERT INTO orders VALUES
(NULL, '$userid', '$receiver_email', '$item_name', '$payment_amount')";
echo "Payment accpeted. Redirecting ";
if (!mysql_query($sql)) {
error_log(mysql_error());
exit(0);
}
}
?>