J'ai mis en place URL de notification de compte Paypal pour aller à ce script:Paypal IPN échec
// Read the notification from PayPal which comes in the form of a POST array and create the acknowledgement response
$req = 'cmd=_notify-validate'; // add 'cmd' to beginning of the acknowledgement you send back to PayPal
foreach ($_POST as $key => $value)
{ // Loop through the notification NV pairs
$value = urlencode(stripslashes($value)); // Encode the values
$req .= "&$key=$value"; // Add the NV pairs to the acknowledgement
}
// Assign the paypal payment notification values to local variables
if($_POST){
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];}
//Set up the acknowledgement request headers (this is the updated version for http 1.1)
$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.paypal.com\r\n";
$header .= "Connection: close\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
//Open a socket for the acknowledgement request
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
if(!$fp){
echo "HTTP ERROR";
}
else
{//start 1
// Post request back to PayPal for validation
fputs ($fp, $header . $req);
//once paypal receives the acknowledgement response, another message will be send containing the single word VERIFIED or INVALID
while (!feof($fp))
{ //start 2, while not EndOfFile
$res = fgets ($fp, 1024); // Get the acknowledgement response
$res = trim($res);
if (strcmp ($res, "VERIFIED") == 0)
{// start 3, Response is OK
if ($payment_status == "Completed")
{//start 4
//send email announcing success
$from = "Rupert Heath Literary Agency";
$to = $payer_email;
$subject = "Ebook";
$body = "It works";
mail($to, $subject, $body, $from);
}//end 4
}//end 3
else if(strcmp ($res, "INVALID") == 0)
{//start 5
//send email announcing failure
//$error_log .= 'Line 57'
$from = "Guide Test Page";
$to = $payer_email;
$subject = "INVALID IPN";
$body = "Doesn't work";
mail($to, $subject, $body, $from);
}//end 5
} //end 2
fclose ($fp); //close file pointer
} //end 1
qui repose sur un certain nombre d'exemples hébergé sur le Web et adresse pour la mise à niveau HTTP 1.1
Le script, en tant que test, envoie un e-mail de réussite ou d'échec en fonction d'une réponse VERIFIED ou INVALID de Paypal. Le problème est que je reçois toujours un email INVALID et ne peux pas comprendre pourquoi. J'ai regardé l'histoire IPN de Paypal et le code de réponse de HTTP est 200 qui semble indiquer que l'échange d'IPN a fonctionné correctement ainsi peut-être que Paypal répond VERIFIED mais mon manuscrit a une erreur.
Les détails de l'histoire IPN sont:
Notification instantanée de paiement (IPN) détails
message ID69025489S2598613V
Date/heure created18/07/2013 23:22 PDT
Original/Resent Original
Dernier délai de livraison date/heure 18/07/2013 23:22 PDT
notification URL http://www.rupertheath.com/ipn/ipn_script
code de réponse HTTP 200
état de livraison Sent
Nombre de relances 0
Transaction ID4D0877596N038120Y
IPN typeTransaction fait
IPN message mc_gross = 0,01 & protection_eligibility = admissible & address_status = confirmé & payer_id = C3USV8A4Q2QDW & taxe = 0.00 & address_street = Ramsey Maison 34 Fowlers route & payment_date = 23: 22: 44 18 juillet 2013 PDT & payment_status = Terminé & charset = Windows- 1252 & address_zip = SP1 2QU & prenom = Michael & mc_fee = 0,01 & address_country_code = GB & address_name = Michael Heath & notify_version = 3,7 & sur mesure = & payer_status = vérifié & [email protected] & address_country = Royaume-Uni & address_city = Salisbury & quantité = 1 & verify_sign = AhKyCHsfiy2frgZNNoQmGHQ3LhKMAboweJqZzYCdqp30Hb7b99tF.04a & [email protected] & txn_id = 4D0877596N038120Y & payment_type = instant & last_name = Heath & address_state = Wiltshire & receiver_email = emailagency @ rupertheath.com & payment_fee = & receiver_id = BRM2TYMP4ACZ8 & txn_type = web_accept & item_name = Ebook & mc_currency = GBP & item_number = & residence_country = GB & handling_amount = 0.00 & transaction_subject = Ebook & payment_gross = & expédition = 0.00 & ipn_track_id = b0a3b4ae3c51c
Quelqu'un peut-il m'aider à déboguer ce problème?
D'où avez-vous obtenu ce code de vérification? –
Paypal avoir une page historique IPN et si vous cliquez sur un événement IPN particulier, vous obtenez toutes ces données. Il semble d'après les données que Paypal pense que tout s'est bien passé donc je me méfie de mon script, même si je l'ai déjà dépassé cent fois! – Perkin5