PayPal IPN notification receiving multiple notification for the same payment

我们两清 提交于 2019-12-24 11:29:35

问题


I would like to know why I'm receiving multiple IPN notification for one payment, and how I can stop this. I would like keep only one notification.

// 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
}

回答1:


Two posibilities came to my mind:

  1. PayPal retries notification, if your handling script returns HTTP error.
  2. For certain transations PayPal sends multiple notifications. Like for cheques. Or when transaction is later cancelled/refunded/reversed. You need to check payment status field for that.



回答2:


It looks like a very old post but i find this same issue on 2019 and you can simply fix this by adding

    header("HTTP/1.1 200 OK");

adding http header 200 ok in first line of your code.



来源:https://stackoverflow.com/questions/16014245/paypal-ipn-notification-receiving-multiple-notification-for-the-same-payment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!