Php 贝宝IPN没有';t发送到服务器

Php 贝宝IPN没有';t发送到服务器,php,paypal,paypal-ipn,Php,Paypal,Paypal Ipn,我已经尝试了很多解决这个问题的方法,但真的找不到一个。我复制了这么多的例子,但没有一个成功。我知道这在这里是有效的,因为我的朋友在他的网站上毫无错误地使用它 我知道我这里的IPN有效,正如一位朋友给我的,并且已经收到了他的IPN消息 我检查了我的HTTP访问日志,PayPal从未接触过我的服务器来发布数据。在PayPal IPN历史页面上,显示“重试”付款 我的IPN和按钮代码如下 <?php include("inc/er.php"); include("inc/database.php

我已经尝试了很多解决这个问题的方法,但真的找不到一个。我复制了这么多的例子,但没有一个成功。我知道这在这里是有效的,因为我的朋友在他的网站上毫无错误地使用它

我知道我这里的IPN有效,正如一位朋友给我的,并且已经收到了他的IPN消息

我检查了我的HTTP访问日志,PayPal从未接触过我的服务器来发布数据。在PayPal IPN历史页面上,显示“重试”付款

我的IPN和按钮代码如下

<?php
include("inc/er.php");
include("inc/database.php");
include("inc/functions.php");


require("inc/ipn.config.php");
$req = 'cmd=_notify-validate';


// 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.sandbox.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {

    //email
    $mail_From = "From: IPN@tester.com";
    $mail_To = $email;
    $mail_Subject = "HTTP ERROR";
    $mail_Body = $errstr;

    mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
}
else
{
    $ids = explode("|", $_POST['custom']);
    $item_username = $ids[0];
    $item_userid = $ids[1];
    $item_email = $ids[2];
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txnId = $_POST['txn_id'];
    $receiverEmail = $_POST['receiver_email'];
    $payerEmail = $_POST['payer_email'];
    $price = 4;
    $payment_amount = str_replace('.00', '', $payment_amount);

    fputs ($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets ($fp, 1024);
        $res = trim($res);
        if (strcmp($res, "VERIFIED")==0) {
            addPaypalPayment($item_name, $item_number, $item_username, $item_userid, $item_email, $payment_status, $payment_amount, $payment_currency, $txnId, $receiver_email, $payer_email, '1');
            serviceAdd($item_userid, $item_number, getNumServices($item_userid));
            setServiceActive($item_userid, $item_packageid);
            sendEmailWithUsername("Carwash", "PayPal IPN", "Success!");

            sendEmailWithUsername($_SESSION["username"], "Your new VPN purchase", "You can gain access to your new VPN account by visiting <a href='https://bvpn.biz/manage.php?do=activate'>this</a> link.");
        }
        else if (strcmp($res, "INVALID")==0) {
            $mail_To = $email;
            $mail_Subject = "PayPal - Invalid IPN ";
            $mail_Body = "We have had an INVALID response. \n\nThe transaction ID number is: $txn_id \n\n username = $username";
            mail($mail_To, $mail_Subject, $mail_Body);
        }
    } //end of while
    fclose ($fp);
}
?>

钮扣

<form action="https://<?php echo $url; ?>/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick"/>
    <input type="hidden" name="business" value="<?php echo $email; ?>"/>
    <input type="hidden" name="item_name" value="<?php echo $pname; ?>"/>
    <input type="hidden" name="item_number" value="<?php echo $id; ?>"/>
    <input type="hidden" name="amount" value="<?php echo $prices[$id - 1] . ".00"; ?>"/>
    <input type="hidden" name="quantity" value="1"/>
    <input type="hidden" name="no_note" value="1"/>
    <input type="hidden" name="currency_code" value="USD"/>
    <input type="hidden" name="lc" value="US"/>
    <input type="hidden" name="bn" value="PP-BuyNowBF"/>
    <input type="hidden" name="return"
           value="https://bvpn.biz/success.php?id=<?php echo $id; ?>&met=<?php echo $met; ?>"/>
    <input type="hidden" name="cancel_return"
           value="https://bvpn.biz/success.php?id=<?php echo $id; ?>&met=<?php echo $met; ?>&do=2"/>
    <input type="hidden" name="notify_url" value="https://bvpn.biz/ipn.php"/>
    <input type="hidden" name="custom" value="<?php echo $_SESSION['username'].'|'.getUserId($_SESSION["username"]).'|'.getUserEmail($_SESSION["username"]); ?>"/>
    <div style="padding-top:100px; padding-right: 40%; padding-left: 40%;">
        <center><input type="submit" name="submit" class="btn" value="Checkout with PayPal"></center>
    </div>
</form>

一个可能的原因是回发邮件标题已过期

$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";
现在应改为:

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host:www.sandbox.paypal.com\r\n";
$header .= "Connection:close\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
贝宝已经停止支持HTTP1.0


希望这有助于快速提问。。。此代码是否位于实时服务器(即非本地主机)上?如果Paypal从未接触过服务器,则问题中的代码完全无关。关注网络问题(防火墙、IP连接),并仔细检查您提供的PayPal的IPN URL。