Paypal SandBox IPN始终返回INVALID [英] Paypal SandBox IPN always returns 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' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header .= 'To: Oshirowanen <oshirowanen@mail.com>' . "\r\n";
$header .= 'From: Me <me@desktop.com>' . "\r\n";
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网址,
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
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行:
CURLOPT_SSL_VERIFYPEER => TRUE,
CURLOPT_CAINFO => 'cacert.pem',
我不知道为什么沙盒商务专业版帐户不允许我设置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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!