我在Sandbox中测试了一切,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;
}
?>
答案 0 :(得分:1)
好的,我发现了这个问题。这与paypal没有任何问题。
我去了我的IPN页面www.mydomain.com/printshop/ipn.php
,PHP显示我在页面上有语法错误...
这就是为什么它不接受任何IPN命中,因为它甚至没有运行!修复了语法错误,现在我收到了IPN命中。
答案 1 :(得分:0)
您是否检查过服务器访问日志和错误日志以确保脚本没有错误输出?现在正在发生一些IPN问题,可能会导致你看到的yoru问题。我建议用PayPal's Merchant Technical Support打开一张票,这样可以查看这个问题。这样,一旦问题得到解决,您也会收到通知。