Hi, I know this may overwhelm some of you by just seeing the title and how many time this has been address and the preexisting literature on the paypal website.

I don't know if going through the manual again can really help me. I feel like I'm almost there but I'm so tired of looking at the same code over and over again that I think I'm going to go for a walk and see if maybe seeing the outdoors can help me find the issue.

<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
$myfile=fopen('test.php',"w+");
$textwrite="PUT ERROR HERE ";
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
$textwrite.=$key . " " .$value. "\r\n";
}

// 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 ('ssl://www.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'];

if (!$fp) {
	$textwrite.="!fp error \r\n";
// HTTP ERROR
} else {
	$textwrite.="else to !fp";
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
	$textwrite.="strcmp res VERIFIED";
// check the payment_status is Completed
// 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
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
$textwrite.="else if (strcmp ($res, ";
}
}
fclose ($fp);
}
fwrite($myfile, $textwrite);
fclose($myfile);
?>

Once I send the IPN from the paypal sandbox I get this information created on the test.php file.

PUT ERROR HERE test_ipn 1

payment_type instant

payment_date 14%3A21%3A41+Feb+23%2C+2011+PST

payment_status Completed

payer_status verified

first_name John

last_name Smith

payer_email buyer%40paypalsandbox.com

payer_id TESTBUYERID01

business seller%40paypalsandbox.com

receiver_email seller%40paypalsandbox.com

receiver_id TESTSELLERID1

residence_country US

item_name1 something

item_number1 AK-1234

quantity1 1

tax 2.02

mc_currency USD

mc_fee 0.44

mc_gross 15.34

mc_gross_1 12.34

mc_handling 2.06

mc_handling1 1.67

mc_shipping 3.02

mc_shipping1 1.02

txn_type cart

txn_id 412232221

notify_version 2.4

custom xyz123

invoice abc1234

charset windows-1252

verify_sign A4E-vGUIfDi7KCLjHNlRLb1m8op9AyZHHlPZfTAJig2uRqRlneFfF2yi

else to !fpelse if (strcmp (INVALID,

My question is why isn't the code approving the if (strcmp ($res, "VERIFIED") == 0) { line?

    My walk did help me.

    I just had to change the line
    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

    to
    $fp = fsockopen ('ssl://www.sandox.paypal.com', 443, $errno, $errstr, 30);

      note that the paypal sandbox is buggy
      using it the other day it wouldn't return an ipn response on a payment - only the specific ipn notifier tool did that properly
      use it for basics, then put through real payments of a few pence (cents)

        Write a Reply...