Bonjour,
J'ai suivi le tuto Paypal. Cependant, je rencontre des problèmes avec mon IPN.
<?php
$email_account = 'toto@toto.toto';
// 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 .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number']; // id commande
$payment_status = $_POST['payment_status']; // Completed,
$payment_amount = $_POST['mc_gross']; //0.01
$payment_currency = $_POST['mc_currency']; //CAD
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
parse_str($_POST['custom'], $custom);
if (!$fp)
{
// HTTP ERROR
file_put_contents('log', "Erreur HTTP.");
}
else
{
fputs ($fp, $header . $req);
$listeRessources = '';
while (!feof($fp))
{
$res = fgets ($fp, 1024);
$listeRessources .= ' (+) '.$res;
if (strcmp ($res, "VERIFIED") == 0) {
if ($payment_status == "Completed")
{
// Check le mail crédité
if ($email_account != $receiver_email) {
file_put_contents('log', "Mauvais mail.");
die();
}
// Check la cohérence du montant
// ....
if ($payment_amount != $invoice->getPrice() ) {
file_put_contents('log', "Mauvais prix.");
die();
}
// Modification du statut de la facture
// ....
}
} // End verified
else if (strcmp ($res, "INVALID") == 0) {
exit("Paiement invalide !");
}
} // End while
fclose ($fp);
}
file_put_contents('log', "Ressources parcourues : ".$listeRessources);
?>
Cependant, en observant le log, je m'apperçois que JAMAIS le script valide la condition if (strcmp ($res, "VERIFIED") == 0) {
.
Mon log, qui contient la liste des ressources traitées (sauf en cas d'erreur), contient :
Liste des ressources
(+) HTTP/1.0 302 Found
(+) Location: https://www.sandbox.paypal.com
(+) Server: BigIP
(+) Connection: close
(+) Content-Length: 0
(+)
Une idée du problème ? Merci !