使用Paypal的IPN的php的cURL错误:[60]
可能重复:使用Paypal的IPN的php的cURL错误:[60],php,curl,certificate,paypal-ipn,Php,Curl,Certificate,Paypal Ipn,可能重复: 我正在使用cpanel管理一个网站。我已经设置了一个ipn.php文件和一个ipnlistener.php文件,以便从我的网站上收听来自Paypal的ipn。我还设置了一个ipn_errors.log文件来记录错误。错误日志显示以下错误:cURL error:[60]设置证书验证位置时出错: CAfile:/home/wwwplrma/public\u html/cert/api\u cert\u chain.crt 卡帕斯:没有 我在public\u html目录中没有看到任何这
我正在使用cpanel管理一个网站。我已经设置了一个ipn.php文件和一个ipnlistener.php文件,以便从我的网站上收听来自Paypal的ipn。我还设置了一个ipn_errors.log文件来记录错误。错误日志显示以下错误:cURL error:[60]设置证书验证位置时出错: CAfile:/home/wwwplrma/public\u html/cert/api\u cert\u chain.crt 卡帕斯:没有 我在public\u html目录中没有看到任何这样的证书。文件的权限是否有问题,或者此错误是否与其他内容有关?ipn.php和ipnlistener.php的权限设置为644,ipn_errors.log的权限设置为775,提前感谢 我的代码如下: ipn_errors.log: [2012年10月22日] 00:32:49]卷曲错误:[60]设置证书验证位置时出错: CAfile:/home/wwwplrma/public\u html/cert/api\u cert\u chain.crt CApath: 没有 [22-Oct-2012 00:42:57]卷曲错误:[60]错误设置证书 验证位置:CAfile: /home/wwwplrma/public_html/cert/api_cert_chain.crt CApath:无 ipn.php:
<?php
/*
ipn.php - example code used for the tutorial:
PayPal IPN with PHP
How To Implement an Instant Payment Notification listener script in PHP
http://www.micahcarrick.com/paypal-ipn-with-php.html
(c) 2011 - Micah Carrick
*/
// tell PHP to log errors to ipn_errors.log in this directory
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
// intantiate the IPN listener
include('ipnlistener.php');
$listener = new IpnListener();
// tell the IPN listener to use the PayPal test sandbox
$listener->use_sandbox = true;
// try to process the IPN POST
try {
$listener->requirePostMethod();
$verified = $listener->processIpn();
} catch (Exception $e) {
error_log($e->getMessage());
exit(0);
}
if ($verified) {
$errmsg = ''; // stores errors from fraud checks
//Check if received verified. Delete later.
error_log("Post Method Verified");
// 1. Make sure the payment status is "Completed"
if ($_POST['payment_status'] != 'Completed') {
// simply ignore any IPN that is not completed
exit(0);
}
// 2. Make sure seller email matches your primary account email.
if ($_POST['receiver_email'] != 'support@****.com') {
$errmsg .= "'receiver_email' does not match: ";
$errmsg .= $_POST['receiver_email']."\n";
}
// 3. Make sure the amount(s) paid match
if ($_POST['mc_gross'] != '7.00') {
$errmsg .= "'mc_gross' does not match: ";
$errmsg .= $_POST['mc_gross']."\n";
}
// 4. Make sure the currency code matches
if ($_POST['mc_currency'] != 'USD') {
$errmsg .= "'mc_currency' does not match: ";
$errmsg .= $_POST['mc_currency']."\n";
}
// 5. Ensure the transaction is not a duplicate.
/*
mysql_connect('localhost', 'DB_USER', 'DB_PW') or exit(0);
mysql_select_db('DB_NAME') or exit(0);
$txn_id = mysql_real_escape_string($_POST['txn_id']);
$sql = "SELECT COUNT(*) FROM orders WHERE txn_id = '$txn_id'";
$r = mysql_query($sql);
if (!$r) {
error_log(mysql_error());
exit(0);
}
$exists = mysql_result($r, 0);
mysql_free_result($r);
if ($exists) {
$errmsg .= "'txn_id' has already been processed: ".$_POST['txn_id']."\n";
}
*/
if (!empty($errmsg)) {
// manually investigate errors from the fraud checking
$body = "IPN failed fraud checks: \n$errmsg\n\n";
$body .= $listener->getTextReport();
mail('****@gmail.com', 'IPN Fraud Warning', $body);
} else {
//Test email for successful transaction IPN
mail('****@gmail.com', 'Valid IPN with successful transaction', $listener->getTextReport());
//error_log($listener->getTextReport());
/*
// add this order to a table of completed orders
$payer_email = mysql_real_escape_string($_POST['payer_email']);
$mc_gross = mysql_real_escape_string($_POST['mc_gross']);
$sql = "INSERT INTO orders VALUES
(NULL, '$txn_id', '$payer_email', $mc_gross)";
if (!mysql_query($sql)) {
error_log(mysql_error());
exit(0);
}
// send user an email with a link to their digital download
$to = filter_var($_POST['payer_email'], FILTER_SANITIZE_EMAIL);
$subject = "Your digital download is ready";
mail($to, "Thank you for your order", "Download URL: ...");
*/
}
} else {
//Check if received. Delete later
error_log("Post Method Unverified");
// manually investigate the invalid IPN
mail('****@gmail.com', 'Invalid IPN', $listener->getTextReport());
}
?>
既然这有助于您,我将添加它作为答案;希望它也能帮助其他人,但不知何故我对此表示怀疑:)
ipnlistener.php
中的代码使用CURLOPT_CAINFO
指定证书链的路径,因此必须存在于服务器上:
/home/wwwplrma/public_html/cert/api_cert_chain.crt
@谢谢你的回复!我已编辑了我的问题以区分它。:)类“IpnListener”未找到-证书不是您的主要问题(是否?)。事实上,该错误是昨天出现的,因为IpnListener.php文件有编码错误。这个问题昨天就解决了,现在已经不存在了。您可以使用时间戳查看较新的错误。最新的错误就在最下面。那就从你的问题中消除噪音吧,因为这与你的具体问题无关了。此外,我建议您将错误消息(现在算在内的)放在示例代码上方。完成编辑,感谢您帮助我将问题发布好。我是新来的。:)
/home/wwwplrma/public_html/cert/api_cert_chain.crt