// 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 .= “Host: www.paypal.com:443\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)
{
// HTTP ERROR
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, “VERIFIED”) == 0)
{
// 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
$mail_From = “From: Payments :: Googlelance”;
$mail_To = “xxxxxx@xxxxxxx.com”;
$mail_Subject = “VERIFIED IPN”;
$mail_Body = $req;
foreach ($_POST as $key => $value){
$emailtext .= $key . ” = ” .$value .”\n\n”;
}
mail($mail_To, $mail_Subject, $emailtext . “\n\n” . $mail_Body, $mail_From);
}
else if (strcmp ($res, “INVALID”) == 0)
{
// log for manual investigation
$mail_From = “From: Payments@xxxxxxxx.com”;
$mail_To = “xxxxxxx@xxxxxxx.com”;
$mail_Subject = “INVALID IPN”;
$mail_Body = $req;
foreach ($_POST as $key => $value)
{
$emailtext .= $key . ” = ” .$value .”\n\n”;
}
mail($mail_To, $mail_Subject, $emailtext . “\n\n” . $mail_Body, $mail_From);
}
}
fclose ($fp);
}
?>
this is my script which i am using to get a IPN but its not sending any email to given address as well as i dont think so that IPN even comming to my web.
I have already created a bsiness account with paypal and set the desired settings for ipn system into my account even also i am sending notify_url also with my form but still no IPN is comming to my web
Please help me out if its possible.
http://googlelance.com
Post your projects and get 100′s of proposals within 24 hours
A Userfriendly Freelance Portal
You show how you treat the RETURN from PP. I do believe you did not set your message to PP correctly in the first place!
where PPpass is YOUR url for a good transaction and PPfail for these that fail.UNLESS a payment has been completed, PP does not return anything…
You can use 2 return addresses in your sending form:
I aslo suggest you use: to get a POST reply (the default is a GET reply (visible on the address bar!)
Personnaly, I prefer to use the same address for the return, and just check a pass-through variable: if that variable is set, I have a successful transaction, else, the transaction failed, or the client cancelled.
On a successful return, you get:
[mc_gross] => 0.01
[invoice] => 4ea15a95f902394110bad3276ed12942 (This is the Session number)
[protection_eligibility] => None
[address_status] => unconfirmed
[payer_id] => something
[tax] => 0.00
[address_street] => something
[payment_date] => 01:22:09 Sep 17, 2008 PDT
[payment_status] => Completed // success!
[charset] => windows-1252
[address_zip] => something
[first_name] => something
[mc_fee] => 0.01
[address_country_code] => something
[address_name] => something
[notify_version] => 2.5
[custom] =>
[payer_status] => unverified
[business] => your paypal account
[address_country] => something
[address_city] => something
[quantity] => 1 // single item transaction (total value only)
[payer_email] => something
[verify_sign] => AgzGrMUR6U2ibE3cX2Rf97rm6Am-A4SJmG.BD.3PUeec-4-E05coW8BN
[txn_id] => 9RK972211U493415V
[payment_type] => instant
[payer_business_name] => something
[last_name] => something
[address_state] => something
[receiver_email] => something
[payment_fee] =>
[receiver_id] => H9D66WUFE8FSS
[txn_type] => web_accept
[item_name] => Global Purchase/Payment
[mc_currency] => EUR
[item_number] =>
[residence_country] => xx
[payment_gross] =>
[shipping] => 0.00
[merchant_return_link] => xxx