Bonjour a tous,
je suis charge de mettre en place un système de payement par Paypal sur le site de notre entreprise.
Actuellement, j'ai créer un bouton sur paypal.com, hoster sur mon serveur, configurer l'ipn, test sandbox.
Je reçois bien les notifications de paypal, le payement sur mon compte est bien valider.
je n'arrive par contre pas a récupérer les valeurs de l'ipn que je souhaiterais pusher dans ma DB.
Je cherche en vain, mais IPN me renvois constamment un résultat INVALID.
$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: [email protected]";
$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 == "[email protected]") && ($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 = "[email protected]";
$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 = "[email protected]";
$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);
}
pour infos le header correspond a :
Code : Tout sélectionner
cmd=_notify-validate&test_ipn=1&payment_type=instant&payment_date=23%3A10%3A24+Feb+20%2C+2011+PST&payment_status=Completed&address_status=confirmed&payer_status=unverified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=France&address_country_code=FR&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123%2C+any+street&receiver_email=seller%40paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=FR&item_name1=something&item_number1=AK-1234&quantity1=1&tax=2.02&mc_currency=EUR&mc_fee=0.44&mc_gross_1=9.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=24221710¬ify_version=2.4&custom=xyz123&invoice=abc1234&charset=windows-1252&verify_sign=Aupij1oYOKQskMQ5jMuGmlbvJaEGAmLs-P69iqQd.rAuwAJAJJ6Byjpm
Merci a ceux qui m'apporterons une aide précieuse ^^
Bonjour a tous,
je suis charge de mettre en place un système de payement par Paypal sur le site de notre entreprise.
Actuellement, j'ai créer un bouton sur paypal.com, hoster sur mon serveur, configurer l'ipn, test sandbox.
Je reçois bien les notifications de paypal, le payement sur mon compte est bien valider.
je n'arrive par contre pas a récupérer les valeurs de l'ipn que je souhaiterais pusher dans ma DB.
Je cherche en vain, mais IPN me renvois constamment un résultat INVALID.
[php]
$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:
[email protected]";
$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 == "
[email protected]") && ($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 = "
[email protected]";
$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 = "
[email protected]";
$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);
}
[/php]
pour infos le header correspond a :
[code]
cmd=_notify-validate&test_ipn=1&payment_type=instant&payment_date=23%3A10%3A24+Feb+20%2C+2011+PST&payment_status=Completed&address_status=confirmed&payer_status=unverified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=France&address_country_code=FR&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123%2C+any+street&receiver_email=seller%40paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=FR&item_name1=something&item_number1=AK-1234&quantity1=1&tax=2.02&mc_currency=EUR&mc_fee=0.44&mc_gross_1=9.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=24221710¬ify_version=2.4&custom=xyz123&invoice=abc1234&charset=windows-1252&verify_sign=Aupij1oYOKQskMQ5jMuGmlbvJaEGAmLs-P69iqQd.rAuwAJAJJ6Byjpm
[/code]
Merci a ceux qui m'apporterons une aide précieuse ^^