Paypal SandBox IPN always returns INVALID(Paypal SandBox IPN 总是返回 INVALID)
问题描述
如以下答案中的一条评论所述,我尝试遵循 本教程.所以现在我有以下内容:
As mentioned in one of the comments in an answer below, I tried following this tutorial. So now I have the following:
ipn.php 文件:
<?php
$ipn_post_data = $_POST;
$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);
if($status == 200 && $response == 'VERIFIED')
{
$subject = "valid";
$message = "good";
}
else
{
$subject = "invalid";
$message = "bad";
}
$to = "oshirowanen@mail.com";
$from = "me@desktop.com";
$header = 'MIME-Version: 1.0' . "
";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$header .= 'To: Oshirowanen <oshirowanen@mail.com>' . "
";
$header .= 'From: Me <me@desktop.com>' . "
";
mail($to,$subject,$message,$header);
?>
<小时>
收到的电子邮件:
Subject "invalid"
Message "bad"
推荐答案
使用基本示例代码 4b 使其正常工作,
Got it working using the basic sample code 4b,
从基本示例代码中清除了 $ipnNotificationUrl = "";,因为我在其中添加了自己的值,
Cleared $ipnNotificationUrl = ""; from the basic sample code as I had a value in there which I added myself,
在沙盒中创建了卖家帐户而不是商业专业帐户,
Created a seller account instead of a business pro account in sandbox,
设置卖家账号启用ipn url,
Set the seller account to enable the ipn url,
使用了以下 PHP 5.2 示例代码 用于 ipn 侦听器
Used the following PHP 5.2 sample code for the ipn listener
将 2 行添加到监听器中,如这里,可以看到下面的两行:
Added the 2 lines into the listener, as described here, the 2 lines can be seen below:
从 下载了 cacert.pem 证书到我的服务器这里并把它和ipn监听器放在同一个目录下:
Downloaded the cacert.pem certificate to my server from here and put it in the same directory as the ipn listener:
第 6 点中提到的 2 行:
The 2 lines mentioned in point 6:
CURLOPT_SSL_VERIFYPEER => TRUE,
CURLOPT_CAINFO => 'cacert.pem',
我不知道为什么 Sandbox business pro 帐户不让我设置 ipn url,但卖家帐户可以.
I have no idea why the sandbox business pro account does not let me set an ipn url, but the seller account does.
这篇关于Paypal SandBox IPN 总是返回 INVALID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Paypal SandBox IPN 总是返回 INVALID
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
