par
finipe » 09 févr. 2016, 03:56
J'avais essayé entre temps, et cette ligne là permet au script de passer le fsockopen (en contradiction avec tout ce que j'ai pu lire sur le Net, et j'en ai lu des kilomètres sur le sujet de cette satanée NIP !)
Si le cap du fsockopen passe désormais (même si je ne sais pas pourquoi), la suite n'est pas concluante... Je me permets un peu de code (je sais que le sujet a été traité des milliards de fois sur les différents forums, mais je n'ai trouvé aucune réponse claire, concise, précise, je crois que c'est la première fois que ça m'arrive !) :
Code : Tout sélectionner
<?php
/////////////////////////////////////////////////////
// INCLUDES
/////////////////////////////////////////////////////
require_once("_inc.configuration.php");
require_once("_inc.etatcommande.php");
require_once("_inc.fonctions.php");
$DEBUG = TRUE;
// DEBUG : Ouverture du log
if($DEBUG == TRUE)
{
$log = fopen('lognip.txt', 'r+');
// Vide le fichier et remet le curseur au début
ftruncate($log, 0);
fseek($log, 0);
}
$req = 'cmd=_notify-validate';
foreach($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// Renvoyer au système PayPal pour validation
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
//$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Host: www.sandbox.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://ipnpb.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen("www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
if($fp == FALSE)
{
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "fsockopen = FALSE - Erreur : ".$errstr." (".$errno.")\r\n");
}
else
{
// -------- DEBUG ---------
fputs($log, $header.$req."\r\n\r\n");
fputs($fp, $header.$req);
while(!feof($fp))
{
$res = fgets($fp, 1024);
$res = trim($res);
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "res = ".$res."\r\n");
/////////////////////////////////////////////////////
// TRANSACTION VERIFIEE
/////////////////////////////////////////////////////
if(strcmp($res, "VERIFIED") == 0)
{
// Ici, plein de code pour vérifier l'état de la commande, le stock, envoyer des mails, etc.
// Mais le script ne passe pas cette étape !
}
/////////////////////////////////////////////////////
// TRANSACTION NON VERIFIEE
/////////////////////////////////////////////////////
else
{
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "NON VERIFIE\r\n");
}
/////////////////////////////////////////////////////
// TRANSACTION INVALIDE
/////////////////////////////////////////////////////
if(strcmp($res, "INVALID") == 0)
{
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "INVALIDE\r\n");
}
}
fclose($fp);
}
// Fermeture du fichier log
if($DEBUG == TRUE) fclose($log);
mysql_close();
?>
Je crois avoir essayé toutes les combinaisons possibles dans les lignes de code du début :
Code : Tout sélectionner
<?php
// Pour le header...
$header .= "Host: www.sandbox.paypal.com:443\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";
$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Host: ipnpb.paypal.com\r\n";
// Pour le fsockopen...
$fp = fsockopen("www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
$fp = fsockopen("ssl://www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
$fp = fsockopen("tls://www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
$fp = fsockopen("www.sandbox.paypal.com", 80, $errnum, $errstr, 30);
?>
Et au mieux, je récupère le log suivant :
Code : Tout sélectionner
POST /cgi-bin/webscr HTTP/1.0
Host: www.sandbox.paypal.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 799
cmd=_notify-validate&mc_gross=13.87&protection_eligibility=Ineligible&payer_id=68NNNB7AKU3C2&tax=0.00&payment_date=17%3A53%3A13+Feb+08%2C+2016+PST&payment_status=Completed&charset=windows-1252&first_name=test&mc_fee=0.72¬ify_version=3.8&custom=7&payer_status=verified&business=xxxxxx-facilitator%40free.fr&quantity=1&verify_sign=AoIlwP.cbXyRSnpgjFfIYtfb677IAwuE5Kt20F4B7rXty6vXR1t9uN85&payer_email=xxxxxx-buyer%40free.fr&txn_id=8DF95096V53977023&payment_type=instant&last_name=buyer&receiver_email=xxxxxx-facilitator%40free.fr&payment_fee=&receiver_id=BJBG36JFMA9RJ&txn_type=web_accept&item_name=Commande&mc_currency=EUR&item_number=&residence_country=FR&test_ipn=1&handling_amount=0.00&transaction_subject=7&payment_gross=&shipping=0.00&ipn_track_id=9121b4b352de0
res = HTTP/1.0 302 Found
NON VERIFIE
res = Location: https://www.sandbox.paypal.com
NON VERIFIE
res = Server: BigIP
NON VERIFIE
res = Connection: close
NON VERIFIE
res = Content-Length: 0
NON VERIFIE
res =
NON VERIFIE
Bref, une bonne journée de vacances passée à se prendre la tête devant un écran

J'avais essayé entre temps, et cette ligne là permet au script de passer le fsockopen (en contradiction avec tout ce que j'ai pu lire sur le Net, et j'en ai lu des kilomètres sur le sujet de cette satanée NIP !)
Si le cap du fsockopen passe désormais (même si je ne sais pas pourquoi), la suite n'est pas concluante... Je me permets un peu de code (je sais que le sujet a été traité des milliards de fois sur les différents forums, mais je n'ai trouvé aucune réponse claire, concise, précise, je crois que c'est la première fois que ça m'arrive !) :
[code]<?php
/////////////////////////////////////////////////////
// INCLUDES
/////////////////////////////////////////////////////
require_once("_inc.configuration.php");
require_once("_inc.etatcommande.php");
require_once("_inc.fonctions.php");
$DEBUG = TRUE;
// DEBUG : Ouverture du log
if($DEBUG == TRUE)
{
$log = fopen('lognip.txt', 'r+');
// Vide le fichier et remet le curseur au début
ftruncate($log, 0);
fseek($log, 0);
}
$req = 'cmd=_notify-validate';
foreach($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// Renvoyer au système PayPal pour validation
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
//$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Host: www.sandbox.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://ipnpb.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen("www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
if($fp == FALSE)
{
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "fsockopen = FALSE - Erreur : ".$errstr." (".$errno.")\r\n");
}
else
{
// -------- DEBUG ---------
fputs($log, $header.$req."\r\n\r\n");
fputs($fp, $header.$req);
while(!feof($fp))
{
$res = fgets($fp, 1024);
$res = trim($res);
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "res = ".$res."\r\n");
/////////////////////////////////////////////////////
// TRANSACTION VERIFIEE
/////////////////////////////////////////////////////
if(strcmp($res, "VERIFIED") == 0)
{
// Ici, plein de code pour vérifier l'état de la commande, le stock, envoyer des mails, etc.
// Mais le script ne passe pas cette étape !
}
/////////////////////////////////////////////////////
// TRANSACTION NON VERIFIEE
/////////////////////////////////////////////////////
else
{
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "NON VERIFIE\r\n");
}
/////////////////////////////////////////////////////
// TRANSACTION INVALIDE
/////////////////////////////////////////////////////
if(strcmp($res, "INVALID") == 0)
{
// -------- DEBUG ---------
if($DEBUG == TRUE) fputs($log, "INVALIDE\r\n");
}
}
fclose($fp);
}
// Fermeture du fichier log
if($DEBUG == TRUE) fclose($log);
mysql_close();
?>[/code]
Je crois avoir essayé toutes les combinaisons possibles dans les lignes de code du début :
[code]<?php
// Pour le header...
$header .= "Host: www.sandbox.paypal.com:443\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";
$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Host: ipnpb.paypal.com\r\n";
// Pour le fsockopen...
$fp = fsockopen("www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
$fp = fsockopen("ssl://www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
$fp = fsockopen("tls://www.sandbox.paypal.com", 443, $errnum, $errstr, 30);
$fp = fsockopen("www.sandbox.paypal.com", 80, $errnum, $errstr, 30);
?>[/code]
Et au mieux, je récupère le log suivant :
[code]POST /cgi-bin/webscr HTTP/1.0
Host: www.sandbox.paypal.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 799
cmd=_notify-validate&mc_gross=13.87&protection_eligibility=Ineligible&payer_id=68NNNB7AKU3C2&tax=0.00&payment_date=17%3A53%3A13+Feb+08%2C+2016+PST&payment_status=Completed&charset=windows-1252&first_name=test&mc_fee=0.72¬ify_version=3.8&custom=7&payer_status=verified&business=xxxxxx-facilitator%40free.fr&quantity=1&verify_sign=AoIlwP.cbXyRSnpgjFfIYtfb677IAwuE5Kt20F4B7rXty6vXR1t9uN85&payer_email=xxxxxx-buyer%40free.fr&txn_id=8DF95096V53977023&payment_type=instant&last_name=buyer&receiver_email=xxxxxx-facilitator%40free.fr&payment_fee=&receiver_id=BJBG36JFMA9RJ&txn_type=web_accept&item_name=Commande&mc_currency=EUR&item_number=&residence_country=FR&test_ipn=1&handling_amount=0.00&transaction_subject=7&payment_gross=&shipping=0.00&ipn_track_id=9121b4b352de0
res = HTTP/1.0 302 Found
NON VERIFIE
res = Location: https://www.sandbox.paypal.com
NON VERIFIE
res = Server: BigIP
NON VERIFIE
res = Connection: close
NON VERIFIE
res = Content-Length: 0
NON VERIFIE
res =
NON VERIFIE[/code]
Bref, une bonne journée de vacances passée à se prendre la tête devant un écran #-o