Esempio n. 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;
 }
 $payment_modules = new payment($_SESSION['payment']);
 $shipping_modules = new shipping($_SESSION['shipping']);
 /**
  * require order class
  */
 require DIR_WS_CLASSES . 'order.php';
 $order = new order();
 /**
  * require order_total class
  */
 require DIR_WS_CLASSES . 'order_total.php';
 $order_total_modules = new order_total();
 $zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PROCESS');
 $order_totals = $order_total_modules->process();
 $zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_TOTALS_PROCESS');
 if (valid_payment($order->info['total'], $_SESSION['currency']) === false && !$isECtransaction && !$isDPtransaction) {
     ipn_debug_email('IPN NOTICE :: Failed because of currency mismatch.');
     die;
 }
 if ($ipnFoundSession === false && !$isECtransaction && !$isDPtransaction) {
     ipn_debug_email('IPN NOTICE :: Unique but no session - Assumed to be a personal payment, rather than a new Website Payments Standard transaction. Ignoring.');
     die;
 }
 if (!strstr($txn_type, 'denied') && !strstr($txn_type, 'failed') && !strstr($txn_type, 'voided')) {
     $insert_id = $order->create($order_totals);
     $zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE');
     ipn_debug_email('Breakpoint: 5a - built order -- OID: ' . $insert_id);
     $sql_data_array = ipn_create_order_array($insert_id, $txn_type);
     ipn_debug_email('Breakpoint: 5b - PP table OID: ' . print_r($sql_data_array, true));
     zen_db_perform(TABLE_PAYPAL, $sql_data_array);
     ipn_debug_email('Breakpoint: 5c - PP table OID saved');
  */
 require DIR_WS_CLASSES . 'payment.php';
 $payment_modules = new payment($_SESSION['payment']);
 $shipping_modules = new shipping($_SESSION['shipping']);
 /**
  * require order class
  */
 require DIR_WS_CLASSES . 'order.php';
 $order = new order();
 /**
  * require order_total class
  */
 require DIR_WS_CLASSES . 'order_total.php';
 $order_total_modules = new order_total();
 $order_totals = $order_total_modules->process();
 if (valid_payment($order->info['total'], $_SESSION['currency']) === false) {
     die;
 }
 if ($ipnFoundSession === false) {
     ipn_debug_email('IPN NOTICE :: Unique but no session - Assumed to be a personal payment, rather than an IPN transaction. Ignoring.');
     die;
 }
 $insert_id = $order->create($order_totals);
 if ($extraDebug) {
     ipn_debug_email('Breakpoint: 5a - built order -- OID:' . $insert_id);
 }
 $sql_data_array = ipn_create_order_array($insert_id, $txn_type);
 if ($extraDebug) {
     ipn_debug_email('Breakpoint: 5b - PP table OID:' . print_r($sql_data_array, true));
 }
 zen_db_perform(TABLE_PAYPAL, $sql_data_array);