Я протестировал все нормально в песочнице, прослушиватель IPN работал, как и ожидалось, и я также получил ожидаемые ответы в своей почте.
Я начал работу сейчас, но хотя клиент может оформить покупку в порядке, и PayPal даже дает идентификатор транзакции покупки, похоже, что прослушиватель IPN перестал работать, он никогда не слышит IPN от PayPal, и поэтому никакая бизнес-логика обработка, которая должна происходить, срабатывает всякий раз, когда совершается покупка. Что случилось?
В моем коде прослушивателя IPN нет ничего плохого, потому что он отлично работал в среде песочницы. Я использовал этот код IPN: https://github.com/Quixotix/PHP-PayPal-IPN а>
Просто вообще не бьют. Вот как я использую запрос NVP:
$return_url = urlencode("http://www.zeej.com.sa/printshop/checkout4_confirm.php");
$cancel_url = urlencode("http://www.zeej.com.sa/printshop/cancel.php");
$notify_url = urlencode("http://www.zeej.com.sa/printshop/ipn.php");
$nvpStr ="&BUTTONCODE=HOSTED&BUTTONTYPE=BUYNOW&L_BUTTONVAR1=amount=".$usd_total."&L_BUTTONVAR2=return=".$return_url."&L_BUTTONVAR3=cancel_return=".$cancel_url."&L_BUTTONVAR4=no_shipping=1&L_BUTTONVAR5=notify_url=".$notify_url."&L_BUTTONVAR6=custom=".$custom_qs;
$httpParsedResponseAr = PPHttpPost('BMCreateButton', $nvpStr);
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
$hostedbuttonid = $httpParsedResponseAr["HOSTEDBUTTONID"];
} else {
die('Please refresh the page and try again. <br />Error: Create Payment Button Failed: ' . print_r($httpParsedResponseAr, true));
}
А это мой код PPHttpPost, который я тоже взял откуда-то из интернета и отлично работал во время тестирования в песочнице:
function PPHttpPost($methodName_, $nvpStr_) {
global $environment;
$environment = "";
// Set up your API credentials, PayPal end point, and API version.
$API_UserName = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
$API_Password = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
$API_Signature = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxx');
$API_Endpoint = "https://api-3t.paypal.com/nvp"; //
if("sandbox" === $environment || "beta-sandbox" === $environment) {
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
}
$version = urlencode('98.0');
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature".$nvpStr_;
//echo($nvpreq);
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// Get response from the server.
$httpResponse = curl_exec($ch);
if(!$httpResponse) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
// Extract the response details.
$httpResponseAr = explode("&", $httpResponse);
$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value) {
$tmpAr = explode("=", $value);
if(sizeof($tmpAr) > 1) {
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
}
}
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
}
return $httpParsedResponseAr;
}
?>