Beispiel #1
0
 function _getPDTresults($orderAmount, $my_currency, $pdtTX)
 {
     global $db;
     $ipnData = ipn_postback('PDT', $pdtTX);
     $respdata = $ipnData['info'];
     // parse the data
     $lines = explode("\n", $respdata);
     $this->pdtData = array();
     for ($i = 1; $i < count($lines); $i++) {
         if (!strstr($lines[$i], "=")) {
             continue;
         }
         list($key, $val) = explode("=", $lines[$i]);
         $this->pdtData[urldecode($key)] = urldecode($val);
     }
     if ($this->pdtData['txn_id'] == '' || $this->pdtData['payment_status'] == '') {
         ipn_debug_email('PDT Returned INVALID Data. Must wait for IPN to process instead. ' . "\n" . print_r($this->pdtData, true));
         return FALSE;
     } else {
         ipn_debug_email('PDT Returned Data ' . print_r($this->pdtData, true));
     }
     $_POST['mc_gross'] = $this->pdtData['mc_gross'];
     $_POST['mc_currency'] = $this->pdtData['mc_currency'];
     $_POST['business'] = $this->pdtData['business'];
     $_POST['receiver_email'] = $this->pdtData['receiver_email'];
     $PDTstatus = ipn_validate_transaction($respdata, $this->pdtData, 'PDT') && valid_payment($orderAmount, $my_currency, 'PDT') && $this->pdtData['payment_status'] == 'Completed';
     if ($this->pdtData['payment_status'] != '' && $this->pdtData['payment_status'] != 'Completed') {
         ipn_debug_email('PDT WARNING :: Order not marked as "Completed".  Check for Pending reasons or wait for IPN to complete.' . "\n" . '[payment_status] => ' . $this->pdtData['payment_status'] . "\n" . '[pending_reason] => ' . $this->pdtData['pending_reason']);
     }
     $sql = "SELECT order_id, paypal_ipn_id, payment_status, txn_type, pending_reason\n                FROM " . TABLE_PAYPAL . "\n                WHERE txn_id = :transactionID OR parent_txn_id = :transactionID\n                ORDER BY order_id DESC  ";
     $sql = $db->bindVars($sql, ':transactionID', $this->pdtData['txn_id'], 'string');
     $ipn_id = $db->Execute($sql);
     if ($ipn_id->RecordCount() != 0) {
         ipn_debug_email('PDT WARNING :: Transaction already exists. Perhaps IPN already added it.  PDT processing ended.');
         $pdtTXN_is_unique = false;
     } else {
         $pdtTXN_is_unique = true;
     }
     $PDTstatus = $pdtTXN_is_unique && $PDTstatus;
     if ($PDTstatus == TRUE) {
         $this->transaction_id = $this->pdtData['txn_id'];
     }
     return $PDTstatus;
 }
     $debug_logfile_path = ipn_debug_email('Breakpoint: 0 - Initializing debugging.');
     if ($debug_logfile_path == '') {
         $debug_logfile_path = 'includes/modules/payment/paypal/logs/ipn_debug_php_errors-' . time() . '.log';
     }
     @ini_set('log_errors', 1);
     @ini_set('log_errors_max_len', 0);
     @ini_set('display_errors', 0);
     // do not output errors to screen/browser/client (only to log file)
     @ini_set('error_log', DIR_FS_CATALOG . $debug_logfile_path);
     error_reporting(version_compare(PHP_VERSION, 5.3, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE : version_compare(PHP_VERSION, 6.0, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT : E_ALL & ~E_NOTICE);
 }
 ipn_debug_email('Breakpoint: Flag Status:' . "\nisECtransaction = " . (int) $isECtransaction . "\nisDPtransaction = " . (int) $isDPtransaction);
 /**
  * do confirmation post-back to PayPal and extract the results for subsequent use
  */
 $info = ipn_postback();
 $new_status = 1;
 ipn_debug_email('Breakpoint: 1 - Collected data from PayPal notification');
 /**
  * validate transaction -- email address, matching txn record, etc
  */
 if (!ipn_validate_transaction($info, $_POST, 'IPN') === true) {
     if (!$isECtransaction && $_POST['txn_type'] != '') {
         ipn_debug_email('IPN FATAL ERROR :: Transaction did not validate. ABORTED.');
         die;
     }
 }
 if ($isDPtransaction) {
     ipn_debug_email('IPN NOTICE :: This is a Website Payments Pro transaction.  The rest of this log file is INFORMATION ONLY, and is not used for real processing.');
 }
 ipn_debug_email('Breakpoint: 2 - Validated transaction components');
  * Include custom application_top.php
  */
 $show_all_errors = false;
 $current_page_base = 'paypalipn';
 $loaderPrefix = 'paypal_ipn';
 require 'includes/application_top.php';
 $extraDebug = defined('IPN_EXTRA_DEBUG_DETAILS') && IPN_EXTRA_DEBUG_DETAILS == 'All';
 if (defined('MODULE_PAYMENT_PAYPALWPP_DEBUGGING') && strstr(MODULE_PAYMENT_PAYPALWPP_DEBUGGING, 'Log') || defined('MODULE_PAYMENT_PAYPAL_IPN_DEBUG') && strstr(MODULE_PAYMENT_PAYPAL_IPN_DEBUG, 'Log') || $_POST['ppdebug'] == 'on' && strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) {
     @ini_set('display_errors', E_ALL ^ E_NOTICE);
     error_reporting(E_ALL ^ E_NOTICE);
     $show_all_errors = true;
 }
 /**
  * do confirmation post-back to PayPal and extract the results for subsequent use
  */
 $ipnData = ipn_postback();
 $postdata = $ipnData['postdata'];
 $info = $ipnData['info'];
 $new_status = 1;
 ipn_debug_email('Breakpoint: 1 - Collected data from PayPal notification');
 /**
  * validate transaction -- email address, matching txn record, etc
  */
 if (!ipn_validate_transaction($info, $_POST) === true) {
     if (!$isECtransaction && $_POST['txn_type'] != '') {
         ipn_debug_email('IPN FATAL ERROR :: Transaction did not validate');
         die;
     }
 }
 ipn_debug_email('Breakpoint: 2 - Validated transaction components');
 /**