【问题标题】:PayPal IPN notification receiving multiple notification for the same paymentPayPal IPN 通知收到同一付款的多个通知
【发布时间】:2013-04-07 12:17:37
【问题描述】:

我想知道为什么我会收到一次付款的多个 IPN 通知,以及如何阻止这种情况。我只想保留一个通知。

// STEP 2: Post IPN data back to paypal to validate

//$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));

// In wamp like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path 
// of the certificate as shown below.
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
    // error_log("Got " . curl_error($ch) . " when processing IPN data");
    curl_close($ch);
    exit;
}
curl_close($ch);

// STEP 3: Inspect IPN validation result and act accordingly

if (strcmp ($res, "VERIFIED") == 0) {

    // my stuff goes here

} else if (strcmp ($res, "INVALID") == 0) {
    // log for manual investigation
}

【问题讨论】:

  • 你是怎么打这个电话的?直接从这个脚本中调用还是从另一个脚本调用?
  • 我正在使用 codeigniter ,这个脚本是在控制器中调用的
  • 这很奇怪,每次调用它总是返回一个响应

标签: php codeigniter paypal-ipn


【解决方案1】:

我想到了两种可能性:

  1. 如果您的处理脚本返回 HTTP 错误,PayPal 会重试通知。
  2. 对于某些交易,PayPal 会发送多个通知。就像支票一样。或者当交易后来被取消/退款/撤销时。您需要检查付款状态字段。

【讨论】:

  • 谢谢@martin-prikrly 这是我得到的“状态”:“完成”,
  • 您是否检查过您的脚本是否返回 HTTP 200?例如。检查您的网络服务器日志以获取返回的代码。另见stackoverflow.com/questions/3758521/…
  • 我找到了一个愚蠢的解决方案,IPN 通知的问题是在数据库上为一个事务创建多个记录,我将项目 ID 和客户 ID 修改为唯一的,谢谢
【解决方案2】:

这看起来像是一篇很老的帖子,但我在 2019 年发现了同样的问题 你可以简单地通过添加

来解决这个问题
    header("HTTP/1.1 200 OK");

在代码的第一行添加 http 标头 200 ok。

【讨论】:

    猜你喜欢
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    • 2019-05-04
    • 2011-12-28
    • 1970-01-01
    • 2013-11-10
    • 2012-09-03
    • 2014-08-19
    相关资源
    最近更新 更多