MISE À JOUR 1:vraiment confus au sujet des paiements paypal
écriture $res
à un fichier texte renvoie juste le mot VERIFIED
:
<?php
/*
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("PayPal") or die(mysql_error());
*/
// 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 ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$ourFileName = "payment_successful.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle, $res);
fclose($ourFileHandle);
}
else if (strcmp ($res, "INVALID") == 0) {
$ourFileName = "payment_failed.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle, $res);
fclose($ourFileHandle);
}
}
fclose ($fp);
}
?>
QUESTION ORIGINAL:
je l'IPN suivante (Script Instant Payment), qui fonctionne, c'est-à-dire qu'il crée un fichier réussi en cas de succès et un fichier en échec en cas d'échec. Est-ce que paypal renvoie des valeurs de poste au fichier IPN pour que je puisse déterminer quel paiement a été effectué ou quel paiement a échoué?
Si oui, comment accéder à ces valeurs? Si non, comment puis-je savoir quel paiement a été accepté ou refusé?
C'est le script dans le fichier IPN J'ai actuellement:
<?php
// 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 ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$ourFileName = "payment_successful.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
}
else if (strcmp ($res, "INVALID") == 0) {
$ourFileName = "payment_failed.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
}
}
fclose ($fp);
}
?>
de Nevermind, je compris ce que paypal est de retour. – oshirowanen