2013-04-15 60 views
1

我想知道为什么我收到多个IPN通知一次付款,我怎么能阻止这一切。我想只保留一个通知。贝宝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 
} 
+0

你如何让这个电话?直接从这个脚本或你从另一个脚本调用? – Fabio

+0

我正在使用codeigniter,这个脚本是在控制器 –

+0

中调用的,这很奇怪,它总是返回一个响应,每次调用 – Fabio

回答

3

两个posibilities来到我的脑海:

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

谢谢@ martin-prikrly这就是我得到的“status”:“COMPLETED”, –

+0

你是否检查过你的脚本返回HTTP 200?例如。检查您的网络服务器日志以获取返回的代码。另请参见http://stackoverflow.com/questions/3758521/paypal-ipn-notification-twice –

+0

我发现了一个愚蠢的解决方案, 与IPN通知的问题是,DB创建多个记录一次交易, 我修改了项目ID和客户ID变成唯一的,所有的THX –