@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'); if ($_POST['exchange_rate'] == '') { $_POST[exchange_rate] = 1; } if ($_POST['num_cart_items'] == '') { $_POST[num_cart_items] = 1; }
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; }