Ok so I've got most of the PayPal IPN stuff worked out, but no matter what I do I am getting an "invalid" response from PayPal's system on the validating post.

I first started using cURL and my own script to post

cmd=_notify-validate&receiver_email=$receiver_email&item_name=$item_name&item_number=$item_number&quantity=$quantity&invoice=$invoice&payment_status=$payment_status&pending_reason=$pending_reason&payment_date=$payment_date&payment_gross=$payment_gross&payment_fee=$payment_fee&txn_id=$txn_id&txn_type=$txn_type&first_name=$first_name&last_name=$last_name&address_street=$address_street&address_city=$address_city&address_state=$address_state&address_zip=$address_zip&address_country=$address_country&address_status=$address_status&payer_email=$payer_email&payer_id=$payer_id&payer_status=$payer_status&payment_type=$payment_type¬ify_version=1.3&verify_sign=$verify_sign

to https://www.paypal.com/cgi-bin/webscr

Then since that wasn't working, and I discovered that you have to responde with the vars in the exact order received I tried the PHP code on PayPal's site to do:

$req = 'cmd=_notify-validate';

foreach ($HTTP_POST_VARS 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);

But I still get "INVALID" as the response regardless. I have to automate this because I sell downloadable products. I'm introducing PayPal as an alternative to a standard CC payment.

Has anyone implemented IPN and got it working fully?

    Write a Reply...