OK I have a script on my site which uses PayPal for members to sign up. When the user has paid PayPal is suposed to use IPN to send the user information to this file named "paypal.php" and for some reason unknown to me it is not working. Could it be that PayPal has upgraded and the file is no longer compatable anymore, if so can this file be updated to work once again?
The code is as follows:
PHP Code:
<?PHP
// 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);
// 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'];
$payment_date = date("Y-m-d");
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
}else{
$esubject = "Membership Payment ERROR";
$emessage = "Another Membership Payment has been processed, but there was an error inserting the info into the database.
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($business, $esubject, $emessage, "From: $emailfrom\nX-Mailer: PHP/" . phpversion());
}
}
else if (strcmp ($res, "INVALID") == 0) {
$subject = "Membership Payment INVALID";
$message = "A payment attempt was made but the status was marked INVALID.
there's so called pointer. i've pointed out the cause for the script malfunction. maybe you're new to php, but believe me, you only need some hours/days to read the manual and solve this problem (if you want to solve it yourself).
__________________
just an ignorant noob with moronic solution...
Ive been trying to use the above code also, I have absolutly no idea about PHP etc, so would be very usefull if you could post up the code that you tihnk is correct
This looks like a pretty good IPN script. I can understand most of it but would like if someone correct the problem as I cannot see what the errors are.