我的Paypal IPN脚本是否正确?

时间:2014-06-12 16:18:07

标签: paypal paypal-ipn

我不断收到paypals IPN的“重试”错误。我没有编写这个脚本,我的开发人员做了,我们都无法理解。这是脚本:

if(isset($ _ POST ['item_name'],$ _POST ['item_number'])){

$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'];

$req = 'cmd=_notify-validate';

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

$header  = "POST /cgi-bin/webscr HTTP/1.1\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);

fputs($fp, $header, $req);

while(!feof($fp)) {

    $res=fgets($fp,1024);

    if(strcmp($res, "VERIFIED") == 0) {

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'http://www.dollarboot.com/paypal/ipn_success.php');
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, 'item_name=' . $item_name . '&item_number=' . $item_number);
        curl_exec($curl);
        curl_close($curl);

    }

}

}

0 个答案:

没有答案