Paypal没有与IPN通信

时间:2014-09-14 21:05:25

标签: php paypal paypal-ipn

使用Paypal IPN时遇到了很大问题。当我使用沙盒时,IPN正常工作并与我的数据库对话(并向我发送电子邮件以检查呼叫)。但是,当我想使用我的真实账户来验证它是否有效时,IPN是未知的..

这是我的代码:

    <?php
$email_account = "*****@****.fr";
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: www.paypal.com\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);
$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'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
parse_str($_POST['custom'],$custom);


$body = 'Appel avec l\'IPN \n   
Appel réussi';
mail('****@gmail.com','test IPN', $body);


if (!fp) {
}
else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets ($fp, 1024);
        if (strcmp ($res, "VERIFIED") == 0) {
            if ($payment_status == "Completed") {
                if ($email_account == $receiver_email) {
                           // Mysql query
                           mail('****@gmail.com','test IPN', 'Transaction réussi');
                } //end if ($email_account == $receiver_email)
                else {
                       mail('****@gmail.com','test IPN', 'Erreur transaction');
                } // end else ($email_account == $receiver_email)
                exit();
            } // end if ($payment_status == "Completed")
        } // end if(strcmp ($res, "VERIFIED") == 0)
        else if (strcmp ($res, "INVALID") == 0) {
        } // end else if (strcmp ($res, "INVALID") == 0)
    } // end while
    fclose ($fp);
} // end else of (!$fp)

您知道为什么Paypal无法联系IPN吗?

提前感谢您的回答

1 个答案:

答案 0 :(得分:0)

问题解决了!我没有在帐户设置中激活IPN。

全部谢谢:)