Php 贝宝ipn脚本赢得';行不通

Php 贝宝ipn脚本赢得';行不通,php,paypal,paypal-ipn,Php,Paypal,Paypal Ipn,不太清楚是什么问题,但我希望有人能帮我。我去了,并使用他们的工具创建了一个php脚本,用于写入db(MySQL)。下面是它还给我的确切脚本(显然,除了凭证): 丰富的。。。或者die()消息有点令人担忧,因为没有使用任何类型的日志文件来捕获和记录代码投入生产后可能发生的错误(只回显错误消息是不明智的,尤其是如果此脚本的调用方不是您) 我抛出了一些error\u log()调用,并简化了一些错误消息,这些消息现在将显示给调用者,请尝试以下操作: <?php // Revision Note

不太清楚是什么问题,但我希望有人能帮我。我去了,并使用他们的工具创建了一个php脚本,用于写入db(MySQL)。下面是它还给我的确切脚本(显然,除了凭证):


丰富的
。。。或者die()
消息有点令人担忧,因为没有使用任何类型的日志文件来捕获和记录代码投入生产后可能发生的错误(只回显错误消息是不明智的,尤其是如果此脚本的调用方不是您)

我抛出了一些
error\u log()
调用,并简化了一些错误消息,这些消息现在将显示给调用者,请尝试以下操作:

<?php

// Revision Notes
// 11/04/11 - changed post back url from https://www.paypal.com/cgi-bin/webscr to https://ipnpb.paypal.com/cgi-bin/webscr
// For more info see below:
// https://www.x.com/content/bulletin-ip-address-expansion-paypal-services
// "ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following: 
// To continue posting back to https://www.paypal.com  to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script
// OR Alternatively, you will need to modify  your IPN script to post back IPNs to the newly created URL https://ipnpb.paypal.com using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)."

$productionMode = false;
$errorLog = 'ipn_errorlog.txt';

/////////////////////////////////////////////////
/////////////Begin Script below./////////////////
/////////////////////////////////////////////////

// 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";
}
// 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";

// Switch between Testing and Production Server
if( !$productionMode ){
  $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
}else{
  $fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);
}

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$business = $_POST['business'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$mc_gross = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$receiver_id = $_POST['receiver_id'];
$quantity = $_POST['quantity'];
$num_cart_items = $_POST['num_cart_items'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$payment_type = $_POST['payment_type'];
$payment_status = $_POST['payment_status'];
$payment_gross = $_POST['payment_gross'];
$payment_fee = $_POST['payment_fee'];
$settle_amount = $_POST['settle_amount'];
$memo = $_POST['memo'];
$payer_email = $_POST['payer_email'];
$txn_type = $_POST['txn_type'];
$payer_status = $_POST['payer_status'];
$address_street = $_POST['address_street'];
$address_city = $_POST['address_city'];
$address_state = $_POST['address_state'];
$address_zip = $_POST['address_zip'];
$address_country = $_POST['address_country'];
$address_status = $_POST['address_status'];
$item_number = $_POST['item_number'];
$tax = $_POST['tax'];
$option_name1 = $_POST['option_name1'];
$option_selection1 = $_POST['option_selection1'];
$option_name2 = $_POST['option_name2'];
$option_selection2 = $_POST['option_selection2'];
$for_auction = $_POST['for_auction'];
$invoice = $_POST['invoice'];
$custom = $_POST['custom'];
$notify_version = $_POST['notify_version'];
$verify_sign = $_POST['verify_sign'];
$payer_business_name = $_POST['payer_business_name'];
$payer_id =$_POST['payer_id'];
$mc_currency = $_POST['mc_currency'];
$mc_fee = $_POST['mc_fee'];
$exchange_rate = $_POST['exchange_rate'];
$settle_currency  = $_POST['settle_currency'];
$parent_txn_id  = $_POST['parent_txn_id'];
$pending_reason = $_POST['pending_reason'];
$reason_code = $_POST['reason_code'];


// subscription specific vars

$subscr_id = $_POST['subscr_id'];
$subscr_date = $_POST['subscr_date'];
$subscr_effective  = $_POST['subscr_effective'];
$period1 = $_POST['period1'];
$period2 = $_POST['period2'];
$period3 = $_POST['period3'];
$amount1 = $_POST['amount1'];
$amount2 = $_POST['amount2'];
$amount3 = $_POST['amount3'];
$mc_amount1 = $_POST['mc_amount1'];
$mc_amount2 = $_POST['mc_amount2'];
$mc_amount3 = $_POST['mcamount3'];
$recurring = $_POST['recurring'];
$reattempt = $_POST['reattempt'];
$retry_at = $_POST['retry_at'];
$recur_times = $_POST['recur_times'];
$username = $_POST['username'];
$password = $_POST['password'];

//auction specific vars

$for_auction = $_POST['for_auction'];
$auction_closing_date  = $_POST['auction_closing_date'];
$auction_multi_item  = $_POST['auction_multi_item'];
$auction_buyer_id  = $_POST['auction_buyer_id'];



//DB connect creds and email 
$notify_email =  "hidden_for_StackOverflow";         //email address to which debug emails are sent to
$DB_Server = "hidden_for_StackOverflow"; //your MySQL Server
$DB_Username = "hidden_for_StackOverflow"; //your MySQL User Name
$DB_Password = "hidden_for_StackOverflow"; //your MySQL Password
$DB_DBName = "hidden_for_StackOverflow"; //your MySQL Database Name


if (!$fp) {
  // HTTP ERROR
  error_log( "Failed to connect to PayPal through HTTP\n" , 3 , $errorLog );
} else {
  fputs ($fp, $header . $req);
  while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {

      //create MySQL connection
      if( !( $Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) ) ){
        error_log( "Failed to connect to MySQL Server - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
        die( 'Database connection failure' );
      }

      //select database
      if( !( $Db = @mysql_select_db($DB_DBName, $Connect) ) ){
        error_log( "Failed to connect to MySQL Database - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
        die( 'Database connection failure' );
      }

      // What is the point of this?!
      #$fecha = date("m")."/".date("d")."/".date("Y");
      #$fecha = date("Y").date("m").date("d");
      $fecha = date("Ymd");

      //check if transaction ID has been processed before
      $checkquery = "select txnid from paypal_payment_info where txnid='".(int) $txn_id."'";
      if( !( $sihay = mysql_query($checkquery) ) ){
        error_log( "Duplicate Check - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
        die( 'Your order experienced an error' );
      }
      if (mysql_num_rows($sihay)== 0){
        //execute query

        if ($txn_type == "cart"){
          $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";

          if( !( $result = mysql_query($strQuery) ) ){
            error_log( "Adding Payment - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
            die( 'Your order experienced an error' );
          }
          for ($i = 1; $i <= $num_cart_items; $i++) {
            $struery = "insert into paypal_cart_info(txnid,itemnumber,itemname,os0,on0,os1,on1,quantity,invoice,custom) values ('".$txn_id."','".$_POST["item_number".$i]."','".$_POST["item_name".$i]."','".$_POST["option_name1_".$i]."','".$_POST["option_selection1_".$i]."','".$_POST["option_name2_".$i]."','".$_POST["option_selection2_".$i]."','".$_POST["quantity".$i]."','".$invoice."','".$custom."')";
            if( !( $result = mysql_query($struery) ) ){
              error_log( "Adding Item #$i - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
              die( 'There was a problem processing your purchase' );
            }
          }
        }
        else{
          $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
          if( !( $result = mysql_query($strQuery) ){
            error_log( "Adding Non-Cart Item - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
            die( 'There was a problem processing your purchase' );
          }
        }


        // send an email in any case
        echo "Verified";
        # There is no $strQuery2
        mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
      }
      else {
        // send an email
        # There is no $strQuery2
        error_log( "Duplicate Transaction\n" , 3 , $errorLog );
        mail($notify_email, "VERIFIED DUPLICATED TRANSACTION", "$res\n $req \n $strQuery\n $struery\n  $strQuery2");
      }

      //subscription handling branch
      if ( $txn_type == "subscr_signup"  ||  $txn_type == "subscr_payment"  ) {

        // insert subscriber payment info into paypal_payment_info table
        $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
        if( !( $result = mysql_query($strQuery) ) ){
          error_log( "Adding Subscription - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
          die( 'There was a problem processing your Subscription' );
        }

         // insert subscriber info into paypal_subscription_info table
        $strQuery2 = "insert into paypal_subscription_info(subscr_id , sub_event, subscr_date ,subscr_effective,period1,period2, period3, amount1 ,amount2 ,amount3,  mc_amount1,  mc_amount2,  mc_amount3, recurring, reattempt,retry_at, recur_times, username ,password, payment_txn_id, subscriber_emailaddress, datecreation) values ('".$subscr_id."', '".$txn_type."','".$subscr_date."','".$subscr_effective."','".$period1."','".$period2."','".$period3."','".$amount1."','".$amount2."','".$amount3."','".$mc_amount1."','".$mc_amount2."','".$mc_amount3."','".$recurring."','".$reattempt."','".$retry_at."','".$recur_times."','".$username."','".$password."', '".$txn_id."','".$payer_email."','".$fecha."')";
        if( !( $result = mysql_query($strQuery2) ) ){
          error_log( "Adding Subscription - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
          die( 'There was a problem processing your Subscription' );
        }

        mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
      }
    }

    // if the IPN POST was 'INVALID'...do this
    else if (strcmp ($res, "INVALID") == 0) {
      // log for manual investigation
      error_log( "Invalid IPN - $res\n $req\n" , 3 , $errorLog );
      mail($notify_email, "INVALID IPN", "$res\n $req");
    }
    else{
      error_log( "Unformed & Invalid IPN - $res\n $req\n" , 3 , $errorLog );
    }
  }
  fclose ($fp);
}

丰富的
。。。或者die()
消息有点令人担忧,因为没有使用任何类型的日志文件来捕获和记录代码投入生产后可能发生的错误(只回显错误消息是不明智的,尤其是如果此脚本的调用方不是您)

我抛出了一些
error\u log()
调用,并简化了一些错误消息,这些消息现在将显示给调用者,请尝试以下操作:

<?php

// Revision Notes
// 11/04/11 - changed post back url from https://www.paypal.com/cgi-bin/webscr to https://ipnpb.paypal.com/cgi-bin/webscr
// For more info see below:
// https://www.x.com/content/bulletin-ip-address-expansion-paypal-services
// "ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following: 
// To continue posting back to https://www.paypal.com  to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script
// OR Alternatively, you will need to modify  your IPN script to post back IPNs to the newly created URL https://ipnpb.paypal.com using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)."

$productionMode = false;
$errorLog = 'ipn_errorlog.txt';

/////////////////////////////////////////////////
/////////////Begin Script below./////////////////
/////////////////////////////////////////////////

// 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";
}
// 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";

// Switch between Testing and Production Server
if( !$productionMode ){
  $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
}else{
  $fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);
}

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$business = $_POST['business'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$mc_gross = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$receiver_id = $_POST['receiver_id'];
$quantity = $_POST['quantity'];
$num_cart_items = $_POST['num_cart_items'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$payment_type = $_POST['payment_type'];
$payment_status = $_POST['payment_status'];
$payment_gross = $_POST['payment_gross'];
$payment_fee = $_POST['payment_fee'];
$settle_amount = $_POST['settle_amount'];
$memo = $_POST['memo'];
$payer_email = $_POST['payer_email'];
$txn_type = $_POST['txn_type'];
$payer_status = $_POST['payer_status'];
$address_street = $_POST['address_street'];
$address_city = $_POST['address_city'];
$address_state = $_POST['address_state'];
$address_zip = $_POST['address_zip'];
$address_country = $_POST['address_country'];
$address_status = $_POST['address_status'];
$item_number = $_POST['item_number'];
$tax = $_POST['tax'];
$option_name1 = $_POST['option_name1'];
$option_selection1 = $_POST['option_selection1'];
$option_name2 = $_POST['option_name2'];
$option_selection2 = $_POST['option_selection2'];
$for_auction = $_POST['for_auction'];
$invoice = $_POST['invoice'];
$custom = $_POST['custom'];
$notify_version = $_POST['notify_version'];
$verify_sign = $_POST['verify_sign'];
$payer_business_name = $_POST['payer_business_name'];
$payer_id =$_POST['payer_id'];
$mc_currency = $_POST['mc_currency'];
$mc_fee = $_POST['mc_fee'];
$exchange_rate = $_POST['exchange_rate'];
$settle_currency  = $_POST['settle_currency'];
$parent_txn_id  = $_POST['parent_txn_id'];
$pending_reason = $_POST['pending_reason'];
$reason_code = $_POST['reason_code'];


// subscription specific vars

$subscr_id = $_POST['subscr_id'];
$subscr_date = $_POST['subscr_date'];
$subscr_effective  = $_POST['subscr_effective'];
$period1 = $_POST['period1'];
$period2 = $_POST['period2'];
$period3 = $_POST['period3'];
$amount1 = $_POST['amount1'];
$amount2 = $_POST['amount2'];
$amount3 = $_POST['amount3'];
$mc_amount1 = $_POST['mc_amount1'];
$mc_amount2 = $_POST['mc_amount2'];
$mc_amount3 = $_POST['mcamount3'];
$recurring = $_POST['recurring'];
$reattempt = $_POST['reattempt'];
$retry_at = $_POST['retry_at'];
$recur_times = $_POST['recur_times'];
$username = $_POST['username'];
$password = $_POST['password'];

//auction specific vars

$for_auction = $_POST['for_auction'];
$auction_closing_date  = $_POST['auction_closing_date'];
$auction_multi_item  = $_POST['auction_multi_item'];
$auction_buyer_id  = $_POST['auction_buyer_id'];



//DB connect creds and email 
$notify_email =  "hidden_for_StackOverflow";         //email address to which debug emails are sent to
$DB_Server = "hidden_for_StackOverflow"; //your MySQL Server
$DB_Username = "hidden_for_StackOverflow"; //your MySQL User Name
$DB_Password = "hidden_for_StackOverflow"; //your MySQL Password
$DB_DBName = "hidden_for_StackOverflow"; //your MySQL Database Name


if (!$fp) {
  // HTTP ERROR
  error_log( "Failed to connect to PayPal through HTTP\n" , 3 , $errorLog );
} else {
  fputs ($fp, $header . $req);
  while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {

      //create MySQL connection
      if( !( $Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) ) ){
        error_log( "Failed to connect to MySQL Server - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
        die( 'Database connection failure' );
      }

      //select database
      if( !( $Db = @mysql_select_db($DB_DBName, $Connect) ) ){
        error_log( "Failed to connect to MySQL Database - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
        die( 'Database connection failure' );
      }

      // What is the point of this?!
      #$fecha = date("m")."/".date("d")."/".date("Y");
      #$fecha = date("Y").date("m").date("d");
      $fecha = date("Ymd");

      //check if transaction ID has been processed before
      $checkquery = "select txnid from paypal_payment_info where txnid='".(int) $txn_id."'";
      if( !( $sihay = mysql_query($checkquery) ) ){
        error_log( "Duplicate Check - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
        die( 'Your order experienced an error' );
      }
      if (mysql_num_rows($sihay)== 0){
        //execute query

        if ($txn_type == "cart"){
          $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";

          if( !( $result = mysql_query($strQuery) ) ){
            error_log( "Adding Payment - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
            die( 'Your order experienced an error' );
          }
          for ($i = 1; $i <= $num_cart_items; $i++) {
            $struery = "insert into paypal_cart_info(txnid,itemnumber,itemname,os0,on0,os1,on1,quantity,invoice,custom) values ('".$txn_id."','".$_POST["item_number".$i]."','".$_POST["item_name".$i]."','".$_POST["option_name1_".$i]."','".$_POST["option_selection1_".$i]."','".$_POST["option_name2_".$i]."','".$_POST["option_selection2_".$i]."','".$_POST["quantity".$i]."','".$invoice."','".$custom."')";
            if( !( $result = mysql_query($struery) ) ){
              error_log( "Adding Item #$i - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
              die( 'There was a problem processing your purchase' );
            }
          }
        }
        else{
          $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
          if( !( $result = mysql_query($strQuery) ){
            error_log( "Adding Non-Cart Item - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
            die( 'There was a problem processing your purchase' );
          }
        }


        // send an email in any case
        echo "Verified";
        # There is no $strQuery2
        mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
      }
      else {
        // send an email
        # There is no $strQuery2
        error_log( "Duplicate Transaction\n" , 3 , $errorLog );
        mail($notify_email, "VERIFIED DUPLICATED TRANSACTION", "$res\n $req \n $strQuery\n $struery\n  $strQuery2");
      }

      //subscription handling branch
      if ( $txn_type == "subscr_signup"  ||  $txn_type == "subscr_payment"  ) {

        // insert subscriber payment info into paypal_payment_info table
        $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
        if( !( $result = mysql_query($strQuery) ) ){
          error_log( "Adding Subscription - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
          die( 'There was a problem processing your Subscription' );
        }

         // insert subscriber info into paypal_subscription_info table
        $strQuery2 = "insert into paypal_subscription_info(subscr_id , sub_event, subscr_date ,subscr_effective,period1,period2, period3, amount1 ,amount2 ,amount3,  mc_amount1,  mc_amount2,  mc_amount3, recurring, reattempt,retry_at, recur_times, username ,password, payment_txn_id, subscriber_emailaddress, datecreation) values ('".$subscr_id."', '".$txn_type."','".$subscr_date."','".$subscr_effective."','".$period1."','".$period2."','".$period3."','".$amount1."','".$amount2."','".$amount3."','".$mc_amount1."','".$mc_amount2."','".$mc_amount3."','".$recurring."','".$reattempt."','".$retry_at."','".$recur_times."','".$username."','".$password."', '".$txn_id."','".$payer_email."','".$fecha."')";
        if( !( $result = mysql_query($strQuery2) ) ){
          error_log( "Adding Subscription - MySQL Query Failed - #".mysql_errno()." - ".mysql_error()."\n" , 3 , $errorLog );
          die( 'There was a problem processing your Subscription' );
        }

        mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
      }
    }

    // if the IPN POST was 'INVALID'...do this
    else if (strcmp ($res, "INVALID") == 0) {
      // log for manual investigation
      error_log( "Invalid IPN - $res\n $req\n" , 3 , $errorLog );
      mail($notify_email, "INVALID IPN", "$res\n $req");
    }
    else{
      error_log( "Unformed & Invalid IPN - $res\n $req\n" , 3 , $errorLog );
    }
  }
  fclose ($fp);
}

您的脚本似乎会针对各种情况发送通知电子邮件。你收到过这些邮件吗?如果有,你能提供他们的相关内容吗?到目前为止,我还没有收到任何电子邮件。如果我真的收到了,我会发布他们的内容。看来你的脚本会针对各种情况发送通知电子邮件。你收到过这些邮件吗?如果有,你能提供他们的相关内容吗?到目前为止,我还没有收到任何电子邮件。如果我得到任何,我会发布他们的内容。好的。我刚试过,但仍然没有任何信息发送到我或我的数据库。你是直接呼叫它,还是通过PayPal工具?你两个都试过了吗?您是否尝试过使用包含具有预期字段值的POST表单的测试页面来调用它?如果你什么也没看到,那可能是因为它根本没有被触发。(一个过于简单的想法/错误,但是,奥卡姆剃刀。)好的。我试过一些不同的东西。我在生产模式关闭的情况下使用了贝宝的工具,但一无所获。我试着在生产模式打开的情况下使用他们的工具(显然造成了无效的情况),并得到了预期的响应(一封包含IPN内容的电子邮件)。我试着用网络浏览器直接访问IPN侦听器,也收到了关于这一点的电子邮件(但是,由于没有发送IPN请求,所以没有包含IPN请求)。是的。。。刚刚检查了php错误日志。结果表明,脚本试图写入错误日志,但有文件权限错误。我使用新访问的错误日志发现这就是错误:“添加付款-MySQL查询失败”。原来是“zipcode”的数据库字段输入错误。它被输入为“zipode”。我是否应该因为一次打字错误而浪费了8个小时的时间而感到愚蠢?同样,非常感谢你的帮助。欢迎来到程序员的世界——每小时都在浪费时间,对代码进行剧烈的重新开发,只找到一个丢失的“。”,或者类似的东西是这个过程的标准。但是,我们学会了,我们不再犯简单的错误(开始犯复杂的错误,然后停止犯复杂的错误,再开始犯简单的错误)——这是一个不断增长的过程。很高兴能帮上忙。我刚试过,但仍然没有任何信息发送到我或我的数据库。你是直接呼叫它,还是通过PayPal工具?你两个都试过了吗?您是否尝试过使用包含具有预期字段值的POST表单的测试页面来调用它?如果你什么也没看到,那可能是因为它根本没有被触发。(一个过于简单的想法/错误,但是,奥卡姆剃刀。)好的。我试过一些不同的东西。我在生产模式关闭的情况下使用了贝宝的工具,但一无所获。我试着在生产模式打开的情况下使用他们的工具(显然造成了无效的情况),并得到了预期的响应(一封包含IPN内容的电子邮件)。我试着用网络浏览器直接访问IPN侦听器,也收到了关于这一点的电子邮件(但是,由于没有发送IPN请求,所以没有包含IPN请求)。是的。。。刚刚检查了php错误日志。结果表明,脚本试图写入错误日志,但有文件权限错误。我使用新访问的错误日志发现这就是错误:“添加付款-MySQL查询失败”。原来是“zipcode”的数据库字段输入错误。它被输入为“zipode”。我是否应该因为一次打字错误而浪费了8个小时的时间而感到愚蠢?同样,非常感谢你的帮助。欢迎来到程序员的世界——每小时都在浪费时间,对代码进行剧烈的重新开发,只找到一个丢失的“。”,或者类似的东西是这个过程的标准。但是,我们学会了,我们不再犯简单的错误(开始犯复杂的错误,然后停止犯复杂的错误,再开始犯简单的错误)——这是一个不断增长的过程。很高兴能帮忙。