1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$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 (!$fp)
{
$mail_From = "From: lol@lol.lol";
$mail_To = $email;
$mail_Subject = "HTTP PAYPAL ERROR";
$mail_Body = $errstr;
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if ($res == "VERIFIED")
{
if (($payment_status == 'Completed') && ($receiver_email == "dev_1297996026_biz@lol.lol") && ($payment_amount == $amount_they_should_have_paid ) && ($payment_currency == "EUR") && (!txn_id_used_before($txn_id)))
{
$userid = (empty($_POST['custom'])) ? '42420' : $_POST['custom'];
//REQUETES SQL
}
else
{
$mail_To = "lol@lol.lol";
$mail_Subject = "PayPal IPN status not completed or security check fail";
$mail_Body = "Something wrong. \n\nThe transaction ID number is: $txn_id \n\n Payment status = $payment_status \n\n Payment amount = $payment_amount";
mail($mail_To, $mail_Subject, $mail_Body);
}
}
else if (strcmp ($res, "INVALID") == 0)
{
$res = var_dump($_POST);
$mail_To = "lol@lol.lol";
$mail_Subject = "PayPal - Invalid IPN ";
$mail_Body = "We have had an INVALID response. \n\nThe transaction ID number is: $txn_id \n\n username = $username \n\n res=$req\n\n header=$header";
mail($mail_To, $mail_Subject, $mail_Body);
}
}
fclose ($fp);
} |
Partager