Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php PayPal IPN已停止工作_Php_Curl_Paypal_Paypal Ipn - Fatal编程技术网

Php PayPal IPN已停止工作

Php PayPal IPN已停止工作,php,curl,paypal,paypal-ipn,Php,Curl,Paypal,Paypal Ipn,下面的脚本运行了好几个小时,突然停止了工作 我没有改变任何事情 下面是否有任何看起来不正确的东西会妨碍它正常工作 <?php // STEP 1: read POST data // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. // Instead, read raw POST data from the input stream. $

下面的脚本运行了好几个小时,突然停止了工作

我没有改变任何事情

下面是否有任何看起来不正确的东西会妨碍它正常工作

<?php

// STEP 1: read POST data

// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
    $keyval = explode ('=', $keyval);
    if (count($keyval) == 2)
        $myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
    $get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
    if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
        $value = urlencode(stripslashes($value));
    } else {
        $value = urlencode($value);
    }
    $req .= "&$key=$value";
}


// Step 2: POST IPN data back to PayPal to validate

$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));

// In wamp-like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set
// the directory path of the certificate as shown below:
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
    // error_log("Got " . curl_error($ch) . " when processing IPN data");
    curl_close($ch);
    exit;
}
curl_close($ch);
if (strcmp ($res, "VERIFIED") == 0) {
    // The IPN is verified, process it:
    // check whether the payment_status is Completed
    // check that txn_id has not been previously processed
    // check that receiver_email is your Primary PayPal email
    // check that payment_amount/payment_currency are correct
    // process the notification

    // assign posted variables to local variables
    $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'];


    // process payment
        // Added pp_trans_id which is the unique Transaction ID provided by PayPal
        // Added reg_date which is in UNIX_TIME()
        // Set WHERE to be equal to $id for perfect match
    mysql_connect('localhost', 'wgaxzhpl_registe', '****');
    mysql_select_db('wgaxzhpl_register');
    $id = $_POST['custom'];
   $insert      = mysql_query("INSERT INTO `log` (txn_id, active) VALUES ('".$txn_id."', 1);");

}
 else if (strcmp ($res, "INVALID") == 0) {
    // IPN invalid, log for manual investigation
}
?>

检查您的PayPal帐户中的IPN历史记录,查看IPN是否实际被发送,以及返回的响应。如果它显示它们正在被发送,并且包含200个响应,那么这意味着您的脚本正在被命中并成功完成。在这种情况下,您需要检查脚本的逻辑,看看为什么它没有按照您的想法执行

如果它根本不发送,您需要仔细检查PayPal帐户中的IPN配置或付款请求中使用的通知URL

如果它显示它正在发送但得到的响应不是200,则意味着您的IPN脚本失败。您可以查看web服务器日志,了解错误的具体内容并解决问题。

请参阅

它似乎在发送无关的数据

我记录了paypal对验证的响应,它会在我记录的重要位置周围发送一些信息


内容类型:text/html;字符集=UTF-8 -空行- 8. 已证实的 0



您是否收到任何错误消息?你有网络或mysql访问权限吗?没有错误,托管和mysql工作得很好!我检查了我的IPN历史记录,一切都很好,ai有Http 200响应和IPN消息OK,然后正如我提到的,这意味着脚本被PayPal的服务器命中,它返回一个响应,说它成功完成了。如果在运行的脚本中看不到应该发生的事情,则需要仔细检查逻辑。