为什么sandbox paypal没有给我发送IPN?

时间:2010-08-24 23:43:16

标签: paypal

我的处理程序和paypal几天前已经沟通,然后发生了一些事情,导致后者停止发送IPN了。我尝试通过我自己的脚本模拟IPN发送而没有使用cURL进行验证的回发功能。我的处理程序非常好用。我还在发回PayPal的行之前放置了一行简单的代码(已经通过cURL测试过),所以我可以查看paypal的回复。该行代码只是将IPN记录到数据库中。它也没有记录。应该对吗?因为paypal发送IPN两次。我确保在我的商家帐户中启用了IPN,并且链接指向我的处理程序。现在我开始怀疑贝宝不给我任何东西。这是我的处理程序:

<?php

require_once 'classes/Mysql.php';
require_once 'classes/Email.php';

$mysql = new Mysql();
$myemail = new Email();

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$payment_status = $_POST['txn_type'];
$payment_amount = $_POST['mc_amount3'];
$payment_currency = $_POST['mc_currency'];
$subscr_id = $_POST['subscr_id'];
$receiver_email = urldecode($_POST['receiver_email']);
$payer_email = $_POST['payer_email'];
$subscr_type = $_POST['option_selection1'];
$username = $_POST['custom'];

//Save a copy of $req to the database. If paypal sends IPN, this should at least grab the first one before validation. 
$memberID = $mysql->get_member_id($username);
$mysql->test_message($req.$payment_amount.$payment_currency, $memberID, $username, $payment_amount, $payment_currency);

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

//This if block does the payment processing. If I place this before the validation/post back occurs, it doesn't work either. But it works when testing using my cURL script--- before the validation.
if($memberID)
{
    if($payment_status=='subscr_signup' && $payment_currency=='USD' && !$mysql->check_if_transactionID_exists($subscr_id)) 
    {
        $mysql->activate_subscription($memberID, $subscr_id, $subscr_type, $payment_amount);
    }

}

}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}

我听到这么多故事贝宝是如此令人沮丧的设定。可能是paypal只是没有发送IPN或者我的处理程序有问题吗?

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题 - 如果您从行$res转储变量$res = fgets ($fp, 1024);,您会看到HTTP/1.1 200 OK,而不是VERIFIED / { {1}}你正在寻找。

请尝试查看此答案以获取更多信息:Paypal IPN returning HTTP/1.1 200 OK