php - 即使购买成功,PayPal IPN 页面也不会被点击

标签 php paypal live paypal-ipn

我在 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;
}

?>

最佳答案

好的,我发现了问题。 paypal 没有任何问题。 我访问了我的 IPN 页面 www.mydomain.com/printshop/ipn.php,PHP 显示我在该页面上有一个语法错误... 所以这就是它不接受任何 IPN 命中的原因,因为它甚至没有运行!修复了语法错误,现在我收到了 IPN 匹配。

关于php - 即使购买成功,PayPal IPN 页面也不会被点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16277525/

相关文章:

php - 如何修复 'Adding An element to array rather than replacing it'?

PayPal Advanced 用户定义字段的最大长度

JQuery jquery-1.7.1.min.js live() 不推荐使用 on()

javascript - jQuery 实时确认

youtube 实时聊天节目仅在桌面上 - 在移动设备上什么都看不到

php - 尝试包含导航栏页面时文件解析错误

javascript - ajax post 整数和字符串数组

php - 在编辑页面中显示选定的单选按钮

grails - Paypal Sandbox IPN 总是失败

php - 在 Paypal 中存储客户数据