我在沙箱中測試了一切正常,IPN偵聽程序會按預期工作,並且我也會在郵件中預期回覆。PayPal IPN網頁即使通過購買也沒有被擊中
我已經開始生活,但客戶可以將購買罰款,並且PayPal甚至提供購買交易ID,看起來IPN監聽器已停止工作,它從不會聽到來自PayPal的IPN,因此沒有的商業邏輯處理應該在購買時發生火災。怎麼了?
我的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;
}
?>
您是否檢查過您的PayPal賬戶中的IPN歷史記錄,以確認它實際上是從PayPal發出的。另外,如果您在歷史記錄中查看IPN消息,它應該會返回一個返回狀態代碼。 – 2013-04-29 14:23:56
我剛剛查過了IPN的歷史,事實上就在那裏!其狀態是「發送」。我也去了developer.paypal.com並使用了IPN模擬器,但是我的程序再次聽不到IPN命中。哪裏有問題?在沙箱環境中運行時,我沒有任何問題。這是一個錯誤的網址? 「http://www.zeej.com.sa/printshop/ipn.php」......應該沒有這麼長的道路什麼的? – user961627 2013-04-29 16:43:25