The code processes the _POST variable and since Zikula has changed how the variables are processed I am not sure this is why the problem has appeared. The IPN function is the following http://agilityjot.com/index.php?module=UpgradeUser&func=paypalIPN and the function in the following:
Code
function UpgradeUser_user_paypalIPN()
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
// This is for checking PDT (payment data transfer)
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$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);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$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'];
$payer_name = $_POST['first_name'] . ' ' . $_POST['last_name'];
switch ($item_number) {
case 1:
case 2:
$uid = $_POST['custom'];
$gname = "Standard";
break;
case 3:
$uid = $_POST['custom'];
$gname = "Premium";
break;
case 4:
list($giftname, $giftemail) = explode(':', $_POST['custom']);
$gname = "Standard";
break;
}
if (!$fp) {
// HTTP ERROR
$stop = _HTTPERRORIPN;
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
if ($_POST['payment_status'] != 'Completed') {
$stop = _PENDINGFUNDS;
}
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
foreach ($_POST as $key => $value){
$emailtext .= $key . " = " .$value ."\n\n";
}
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
$stop = _INVALIDIPN;
}
}
fclose ($fp);
}
if (!$stop) {
$diskAllow = explode('|', pnModGetVar('UpgradeUser', 'diskAllow'));
list($ds, $amt) = explode(':', current($diskAllow));
$adminmail = pnConfigGetVar('adminmail');
$sitename = pnConfigGetVar('sitename');
$siteurl = pnGetBaseURL();
switch ($item_number) {
case 4:
$subject = _UPGRADEUSERPURCHASESUB;
$message = _UPGRADEUSERHEADER . _UPGRADEUSERPURCHASE1 . " $giftname ($giftemail) " . _UPGRADEUSERPURCHASE2;
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $payer_email, 'subject' => $subject, 'body' => $message, 'html' => 1));
pnModAPIFunc('UpgradeUser', 'user', 'addGift', array('email' => $giftemail, 'fromemail' => $payer_email));
$message = _UPGRADEUSERHEADER . _UPGRADEUSERCONGRATS1 . " $sitename. " . _UPGRADEUSERCONGRATS2 . " ${payer_name}" . _UPGRADEUSERCONGRATS3 . "<br /><br />";
if (pnUserGetIDFromEmail($giftemail) === false) {
$accturl = $siteurl . '/index.php?module=Users&func=register';
$message .= _UPGRADEUSERHASNOACCT1 . $accturl . _UPGRADEUSERHASNOACCT2;
} else {
$message .= _UPGRADEUSERHASACCT;
}
$email = $giftemail;
$subject = "$sitename " . _ASREG . " " . _ASREGCONFIRM;
break;
default:
pnModAPIFunc('UpgradeUser', 'user', 'updateReg', array('uid' => $uid, 'regtype' => $gname, 'diskspace' => $ds));
$uname = pnUserGetVar('uname', $uid);
$email = pnUserGetVar('email', $uid);
$item = pnModAPIFunc('UpgradeUser',
'user',
'get',
array('uid' => $uid));
$message = _UPGRADEUSERHEADER . _WELCOMETO . " $sitename ($siteurl)!<br /><br />" . _THANKYOU . " ${sitename}!<br /><br />" . _YOUEXPIREDATE . strftime('%d %B %Y', strtotime($item['expire'])) . ".<br /><br />";
$subject = "$sitename " . _ASREG . " " . _ASREGCONFIRM;
break;
}
// send the e-mail
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $email, 'subject' => $subject, 'body' => $message, 'html' => 1));
if (pnConfigGetVar('reg_notifyemail') != "") {
$email2 = pnConfigGetVar('reg_notifyemail');
$subject2 = _NOTIFYEMAILSUB;
$message2 = _NOTIFYEMAILCONT1 . "$uname" . _NOTIFYEMAILCONT2;
// send the e-mail
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $email2, 'subject' => $subject2, 'body' => $message2));
}
} else {
$email2 = $adminmail;
$subject2 = _PROBLEMIPN;
$message2 = pnVarPrepForDisplay($stop) . " the uid= $uid \nreq= $req" ;
// send the e-mail
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $email2, 'subject' => $subject2, 'body' => $message2));
}
}
{
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
// This is for checking PDT (payment data transfer)
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$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);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$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'];
$payer_name = $_POST['first_name'] . ' ' . $_POST['last_name'];
switch ($item_number) {
case 1:
case 2:
$uid = $_POST['custom'];
$gname = "Standard";
break;
case 3:
$uid = $_POST['custom'];
$gname = "Premium";
break;
case 4:
list($giftname, $giftemail) = explode(':', $_POST['custom']);
$gname = "Standard";
break;
}
if (!$fp) {
// HTTP ERROR
$stop = _HTTPERRORIPN;
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
if ($_POST['payment_status'] != 'Completed') {
$stop = _PENDINGFUNDS;
}
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
foreach ($_POST as $key => $value){
$emailtext .= $key . " = " .$value ."\n\n";
}
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
$stop = _INVALIDIPN;
}
}
fclose ($fp);
}
if (!$stop) {
$diskAllow = explode('|', pnModGetVar('UpgradeUser', 'diskAllow'));
list($ds, $amt) = explode(':', current($diskAllow));
$adminmail = pnConfigGetVar('adminmail');
$sitename = pnConfigGetVar('sitename');
$siteurl = pnGetBaseURL();
switch ($item_number) {
case 4:
$subject = _UPGRADEUSERPURCHASESUB;
$message = _UPGRADEUSERHEADER . _UPGRADEUSERPURCHASE1 . " $giftname ($giftemail) " . _UPGRADEUSERPURCHASE2;
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $payer_email, 'subject' => $subject, 'body' => $message, 'html' => 1));
pnModAPIFunc('UpgradeUser', 'user', 'addGift', array('email' => $giftemail, 'fromemail' => $payer_email));
$message = _UPGRADEUSERHEADER . _UPGRADEUSERCONGRATS1 . " $sitename. " . _UPGRADEUSERCONGRATS2 . " ${payer_name}" . _UPGRADEUSERCONGRATS3 . "<br /><br />";
if (pnUserGetIDFromEmail($giftemail) === false) {
$accturl = $siteurl . '/index.php?module=Users&func=register';
$message .= _UPGRADEUSERHASNOACCT1 . $accturl . _UPGRADEUSERHASNOACCT2;
} else {
$message .= _UPGRADEUSERHASACCT;
}
$email = $giftemail;
$subject = "$sitename " . _ASREG . " " . _ASREGCONFIRM;
break;
default:
pnModAPIFunc('UpgradeUser', 'user', 'updateReg', array('uid' => $uid, 'regtype' => $gname, 'diskspace' => $ds));
$uname = pnUserGetVar('uname', $uid);
$email = pnUserGetVar('email', $uid);
$item = pnModAPIFunc('UpgradeUser',
'user',
'get',
array('uid' => $uid));
$message = _UPGRADEUSERHEADER . _WELCOMETO . " $sitename ($siteurl)!<br /><br />" . _THANKYOU . " ${sitename}!<br /><br />" . _YOUEXPIREDATE . strftime('%d %B %Y', strtotime($item['expire'])) . ".<br /><br />";
$subject = "$sitename " . _ASREG . " " . _ASREGCONFIRM;
break;
}
// send the e-mail
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $email, 'subject' => $subject, 'body' => $message, 'html' => 1));
if (pnConfigGetVar('reg_notifyemail') != "") {
$email2 = pnConfigGetVar('reg_notifyemail');
$subject2 = _NOTIFYEMAILSUB;
$message2 = _NOTIFYEMAILCONT1 . "$uname" . _NOTIFYEMAILCONT2;
// send the e-mail
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $email2, 'subject' => $subject2, 'body' => $message2));
}
} else {
$email2 = $adminmail;
$subject2 = _PROBLEMIPN;
$message2 = pnVarPrepForDisplay($stop) . " the uid= $uid \nreq= $req" ;
// send the e-mail
pnModAPIFunc('Mailer', 'user', 'sendmessage', array('toaddress' => $email2, 'subject' => $subject2, 'body' => $message2));
}
}
Because I am reading the _POST from within this function I am not sure this is what is causing the problem or if it is something from Paypal but since this problem has only occurred since I have upgraded it does seem suspect. The payment is accepted but it continues to send the function and send the confirmation email but it does not continue to take payment (unfortunately
