Пример #1
0
 case 'updatestatus':
     if (!empty($_GET['order_id']) && !empty($_GET['newstatus'])) {
         $showlog = $_GET['showlog'] == 1 ? 1 : 0;
         USES_paypal_class_order();
         $log_ts = '';
         $log_user = '';
         $log_msg = '';
         $newstatus = $_GET['newstatus'];
         $order_id = $_GET['order_id'];
         $retstatus = $_GET['oldstatus'];
         $ord = new ppOrder($_GET['order_id']);
         if ($ord->isNew) {
             break;
         }
         // non-existant order
         if ($ord->UpdateStatus($newstatus)) {
             //if (ppOrder::UpdateStatus($newstatus, $order_id)) {
             $sql = "SELECT * FROM {$_TABLES['paypal.order_log']}\n                WHERE order_id = '" . DB_escapeString($order_id) . "'\n                ORDER BY ts DESC\n                LIMIT 1";
             //echo $sql;die;
             $L = DB_fetchArray(DB_query($sql, 1), false);
             if (!empty($L)) {
                 $log_ts = $L['ts'];
                 $log_user = $L['username'];
                 $log_msg = $L['message'];
                 $retstatus = $_GET['newstatus'];
             }
         }
         header('Content-Type: text/xml');
         header("Cache-Control: no-cache, must-revalidate");
         //A date in the past
         header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Пример #2
0
}
//PAYPAL_debug('Admin view: ' . $action);
switch ($view) {
    case 'history':
        $content .= PAYPAL_history(true);
        break;
    case 'orderhist':
        if (isset($_POST['upd_orders']) && is_array($_POST['upd_orders'])) {
            USES_paypal_class_order();
            $i = 0;
            foreach ($_POST['upd_orders'] as $order_id) {
                if (!isset($_POST['newstatus'][$order_id]) || !isset($_POST['oldstatus'][$order_id]) || $_POST['newstatus'][$order_id] == $_POST['oldstatus'][$order_id]) {
                    continue;
                }
                $ord = new ppOrder($order_id);
                $ord->UpdateStatus($_POST['newstatus'][$order_id], $order_id);
                $i++;
            }
            $msg[] = sprintf($LANG_PP['updated_x_orders'], $i);
        }
        $content .= PAYPAL_orders(true);
        break;
    case 'order':
        USES_paypal_class_order();
        $order = new ppOrder($actionval);
        $content .= $order->View(true);
        break;
    case 'ipnlog':
        $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'all';
        $log_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
        $txn_id = isset($_REQUEST['txn_id']) ? COM_applyFilter($_REQUEST['txn_id']) : '';
Пример #3
0
 /**
  *   Process a refund.
  *   If a purchase is completely refunded, then call the plugins to
  *   handle the refund.  Otherwise, do nothing; partial refunds need to
  *   be handled manually.
  *
  *   @todo: handle partial refunds
  */
 protected function handleRefund()
 {
     global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP;
     // Try to get original order information.  Use the "parent transaction"
     // or invoice number, if available from the IPN message
     if (isset($this->pp_data['invoice'])) {
         $order_id = $this->pp_data['invoice'];
     } else {
         $order_id = DB_getItem($_TABLES['paypal.orders'], 'order_id', "pmt_txn_id = '" . DB_escapeString($this->pp_data['parent_txn_id']) . "'");
     }
     $Order = new ppOrder($order_id);
     if ($Order->order_id == '') {
         return false;
     }
     // Figure out if the entire order was refunded
     $refund_amt = abs((double) $this->pp_data['pmt_gross']);
     $item_total = 0;
     foreach ($Order->items as $key => $data) {
         $item_total += $data['quantity'] * $data['price'];
     }
     $item_total += $Order->miscCharges();
     if ($item_total == $refund_amt) {
         // Completely refunded, let the items handle any refund
         // actions.  None for catalog items (since there's no inventory,
         // but plugin items may need to do something.
         foreach ($Order->items as $key => $data) {
             if (PAYPAL_is_plugin_item($data['product_id'])) {
                 // Split the item number into component parts.  It could
                 // be just a single string, depending on the plugin's needs.
                 if (strstr($data['product_id'], ':')) {
                     $pi_info = split(':', $data['product_id']);
                 } else {
                     $pi_info = array($data['product_id']);
                 }
                 $vars = array('item' => $pi_info, 'ipn_data' => $this->pp_data);
                 $status = LGLIB_invokeService($pi_info[0], 'handleRefund', $vars, $output, $svc_msg);
                 // Don't care about the status, really.  May not even be
                 // a plugin function to handle refunds
             }
         }
         // Update the order status to Refunded
         $Order->UpdateStatus($LANG_PP['orderstatus']['refunded']);
     }
 }