Paypal IPN 获得空白确认(应为“已验证"或“无效") [英] Paypal IPN Getting blank confirmation ( should be "VERIFIED" or "INVALID" )

查看:29
本文介绍了Paypal IPN 获得空白确认(应为“已验证"或“无效")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在这里测试 Paypal IPN.我已经用 Sandbox 设置好了.我正在向它发送虚假的 IPN 请求,它正在接收 IPN.然后,我让它返回信息以进行验证,并将响应写入文本文件,以便我可以自己检查.IPN 运行良好,响应正在写入文本文件.

I'm just testing the Paypal IPN here. I've got it set up with Sandbox. I'm sending it fake IPN requests, and it's receiving the IPN. Then, I'm getting it to return the information for verification, and I'm writing the response to a text file so I can check it out on my own. The IPN is firing fine, and the response is getting written to the text file.

只有一个问题...回复是空白的.

There's just one problem... The response is blank.

响应应该被接收为已验证"或无效",而这些是仅有的 2 个可能的响应......所以发生了什么 =S.非常感谢任何帮助.

The response is supposed to be received as "VERIFIED" or "INVALID", and these are the only 2 possible responses... so what's going on =S. Any help is greatly appreciated.

完整代码如下:

$ipn_post_data = $_POST;

$response = "";

    // Choose url
    $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

    // Set up request to PayPal
    $request = curl_init();
    curl_setopt_array($request, array
    (
        CURLOPT_URL => $url,
        CURLOPT_POST => TRUE,
        CURLOPT_POSTFIELDS => http_build_query(array('cmd' => '_notify-validate') + $ipn_post_data),
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_HEADER => FALSE,
        CURLOPT_SSL_VERIFYPEER => TRUE,
        CURLOPT_CAINFO => 'cacert.pem',
    ));

    // Execute request and get response and status code
    $response = curl_exec($request);
    $status   = curl_getinfo($request, CURLINFO_HTTP_CODE);

    // Close connection
    curl_close($request);


$fh = fopen( "ipntest.txt", 'a+' );
$date = date( "Y-M-j H:i" );
fwrite( $fh, $date . " Response: " . $response . "
" );
fclose( $fh );

if($status == 200 && $response == 'VERIFIED')
{
    // All good! Proceed...
}
else
{
    // Not good. Ignore, or log for investigation...
}

文本文件输出:

2012-Nov-26 23:24 Response: 
2012-Nov-26 23:25 Response: 

我之前一直在使用这个代码,我一直在努力让它工作一个星期,所以这不仅仅是暂时的失败或其他什么......

I had been using this code previously, I've been trying to get it to work for a week, so it's not just a temporary failure or something...

伙计们干杯.

推荐答案

所以仅供将来参考,对于有同样问题的人:

So just for future reference, for people with this same problem:

这里的问题是没有 CA 文件.

我不确定 CA 文件究竟是做什么的,但我知道它与 Paypal 的 SSL 证书和建立 SSL 连接有关.当我开始查看 cURL 的错误时,我看到了以下内容:

I'm unsure what exactly a CA file does but I know it has something to do with Paypal's SSL certificate and establishing an SSL connection. When I started looking at cURL's errors, I saw the following:

[27-Nov-2012 21:46:11 UTC] cURL error: [77] error setting certificate verify locations:
  CAfile: /etc/ssl/certs/api_cert_chain.crt
  CApath: /etc/ssl/certs

我找到的快速解决方案是下载 IpnListener.php 类.(这是 eldblz 推荐的.它使处理 IPN 变得更容易,并且为我没有 CAFile 提供了解决方案.如果您下载整个 IpnListener.php 包,它包含一个名为 cert 的文件夹,其中包含您需要的 api_cert_chain.crt,并且已经对其进行了配置以供使用.

The quick solution that I found was to download the IpnListener.php class. (This was recommended by eldblz. It made dealing with IPN way easier AND it provided a solution to my not having a CAFile. If you download the entire IpnListener.php package, it includes a folder called cert which includes the api_cert_chain.crt that you need, and already has it configured for use.

这篇关于Paypal IPN 获得空白确认(应为“已验证"或“无效")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆