【问题标题】:PayPal IPN page not being hit even though purchase goes through即使购买通过,PayPal IPN 页面也不会被点击
【发布时间】:2013-04-23 01:16:25
【问题描述】:

我在沙盒中测试了一切正常,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 消息,它应该会为您提供一个状态代码,如果正在返回,则该状态代码正在返回。
  • 我刚刚查看了IPN历史,交易确实存在!其状态为“已发送”。我还访问了 developer.paypal.com 并使用了 IPN 模拟器,但我的程序再次无法听到 IPN 命中。问题出在哪里?在沙盒环境中运行时,我没有任何问题。这是一个错误的网址吗? “zeej.com.sa/printshop/ipn.php”……不应该有这么长的路吗?

标签: php paypal live paypal-ipn


【解决方案1】:

您是否检查过您的服务器访问日志和错误日志以确保脚本没有出错?现在有一些 IPN 问题正在发生,这可能会导致您看到的 yoru 问题。我建议用PayPal's Merchant Technical Support 开一张票,以便调查这个问题。这样,一旦问题得到解决,您也会收到通知。

【讨论】:

    【解决方案2】:

    好的,我找到了问题。用paypal没问题。 我去了我的 IPN 页面www.mydomain.com/printshop/ipn.php,PHP 告诉我页面上有语法错误... 所以这就是为什么它不接受任何 IPN 点击,因为它甚至没有运行!修复了语法错误,现在我收到了 IPN 命中。

    【讨论】:

      猜你喜欢
      • 2011-11-20
      • 1970-01-01
      • 2015-03-10
      • 2020-12-03
      • 2014-04-22
      • 2019-05-30
      • 2015-04-09
      • 2015-02-28
      • 2013-03-14
      相关资源
      最近更新 更多