public function process()
 {
     $order = Order::getInstance();
     $cart_order_id = $_POST['orderRef'];
     $order_summary = $order->getSummary($cart_order_id);
     if (isset($_POST['signature'])) {
         $check = $_POST;
         unset($check['signature']);
         ksort($check);
         $build_query = http_build_query($check, '', '&');
         $build_query = preg_replace('/%0D%0A|%0A%0D|%0A|%0D/i', '%0A', $build_query);
         $sig_check = $_POST['signature'] == hash("SHA512", $build_query . $this->_module['merchant_passphrase']);
     } else {
         $sig_check = true;
     }
     if ($_POST['responseCode'] == '0' && $sig_check) {
         $order->orderStatus(Order::ORDER_PROCESS, $cart_order_id);
         $order->paymentStatus(Order::PAYMENT_SUCCESS, $cart_order_id);
     }
     $transData['notes'] = $sig_check == true ? 'response signature check verified' : 'response signature check failed';
     $transData['gateway'] = 'CharityClear';
     $transData['order_id'] = $_POST['orderRef'];
     $transData['trans_id'] = $_POST['xref'];
     $transData['amount'] = $_POST['amountReceived'] > 0 ? $_POST['amountReceived'] / 100 : '';
     $transData['status'] = $_POST['responseMessage'];
     $transData['customer_id'] = $order_summary['customer_id'];
     $transData['extra'] = '';
     $order->logTransaction($transData);
     $url = explode('/modules/gateway/CharityClear', $GLOBALS['storeURL']);
     httpredir($url[0] . '/index.php?_a=complete');
     // ccNow doesn't send back any data at all right now so we have to leave it pending
     //httpredir(currentPage(array('_g', 'type', 'cmd', 'module'), array('_a' => 'complete')));
     return false;
 }
Esempio n. 2
0
 public function extendedCheckout(PaymentObjectInterface $paymentObj, $getUrlOnly = false)
 {
     $obj = new \stdClass();
     \Order\Order::getInstance()->validateOrder($paymentObj);
     // Must be in specific order for checksum ---------
     $obj->MerchantID = $this->getMerchantID();
     $obj->Timestamp = $this->getTimeStamp();
     $obj->Amount = $paymentObj->getAmount();
     $obj->Country = $paymentObj->getCountry();
     $obj->Currency = $paymentObj->getCurrency();
     $obj->Description = $paymentObj->getDescription();
     $obj->EndUserIP = $this->getIP();
     $obj->Issuer = $paymentObj->getIssuer();
     $obj->Language = $paymentObj->getLanguage();
     $obj->OrderID = $paymentObj->getOrderID();
     $obj->PaymentMethod = $paymentObj->getPaymentMethod();
     $obj->Reference = $paymentObj->getReference();
     $obj->URLCompleted = $this->getSuccessURL();
     $obj->URLError = $this->getErrorURL();
     $obj->XML = Order::getInstance()->createXML();
     // ------------------------------------------------
     $obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
     $result = $this->client->CheckoutExtended(array('request' => $obj));
     /* store the checksum momentarily */
     $checksum = $result->CheckoutExtendedResult->Checksum;
     /* Replace the checksum in the data with secretCode to generate a new checksum */
     $result->CheckoutExtendedResult->Checksum = $this->getSecretCode();
     /* Verify response data */
     if ($checksum != $this->generateChecksum($result->CheckoutExtendedResult)) {
         throw new \Exception("Data could not be verified");
     }
     /* Return mister checksum */
     $result->CheckoutExtendedResult->Checksum = $checksum;
     /* Return just the payment URL if required */
     if ($getUrlOnly) {
         return $result->CheckoutExtendedResult->PaymentScreenURL;
     }
     $transactionObj = new TransactionObject();
     $transactionObj->setData($result->CheckoutExtendedResult);
     /* Default return all data */
     return $transactionObj;
 }
 public function process()
 {
     $coinbase_order = $this->coinbase->call("orders/" . $_GET["order"]["uuid"])->data;
     $order = Order::getInstance();
     if ($coinbase_order->status == "mispaid") {
         $order->orderStatus(Order::ORDER_PENDING, $this->order_number);
         $order->paymentStatus(Order::PAYMENT_PENDING, $this->order_number);
         $transData['notes'] = "Bitcoin payment mispaid";
         $order->logTransaction($transData);
         $GLOBALS['gui']->setError("Your Bitcoin payment was the incorrect amount. Please contact support to resolve your order.");
     } elseif ($coinbase_order->status == "expired") {
         $order->orderStatus(Order::ORDER_PENDING, $this->order_number);
         $order->paymentStatus(Order::PAYMENT_PENDING, $this->order_number);
         $transData['notes'] = "Bitcoin payment expired";
         $order->logTransaction($transData);
         $GLOBALS['gui']->setError("Your Bitcoin payment has expired before you could make your payment. Please contact support to resolve your order.");
     } else {
         $order->orderStatus(Order::ORDER_PROCESS, $this->order_number);
         $order->paymentStatus(Order::PAYMENT_SUCCESS, $this->order_number);
         $transData['notes'] = "Bitcoin payment successful";
         $order->logTransaction($transData);
     }
     httpredir(currentPage(array('_g', 'type', 'cmd', 'module'), array('_a' => 'complete')));
 }
Esempio n. 4
0
         $cleanup = '<?php unlink(__FILE__); ?>';
         $filename = 'print.' . $print_hash . '.php';
         if (file_put_contents(CC_FILES_DIR . $filename, $template . $cleanup)) {
             httpredir($GLOBALS['storeURL'] . '/files/' . $filename);
         } else {
             $GLOBALS['main']->setACPWarning($lang['orders']['error_print_generate']);
             httpredir(currentPage(array('print')));
         }
     } else {
         $GLOBALS['main']->setACPWarning($lang['orders']['order_not_found']);
         httpredir(currentPage(array('print')));
     }
 } else {
     if (isset($_POST['multi-order']) && !empty($_POST['multi-order'])) {
         // Update selected orders to given status
         $order = Order::getInstance();
         // An admin is working on this so lets NOT send out email notifications
         //$order->disableAdminEmail();
         $updated = false;
         $deleted = false;
         $add_array = array();
         foreach ($_POST['multi-order'] as $order_id) {
             // If multi action variable is numeric we need to update the order status
             if (!empty($_POST['multi-status'])) {
                 if ($order->orderStatus((int) $_POST['multi-status'], $order_id)) {
                     $updated = true;
                 }
             }
             switch ($_POST['multi-action']) {
                 case 'print':
                     $add_array['print'][] = $order_id;
Esempio n. 5
0
 public static function UserViewInvoice($invid)
 {
     $xtpl = self::$xtpl;
     $invoice = Invoice::getInstance();
     $xtpl->assign('FINCURR', 'current');
     $xtpl->assign('INVSCURR', 'current');
     if (!is_numeric($invid)) {
         $xtpl->parse('main.viewinvoice.inverror');
     } else {
         $invdata = $invoice->FetchData($invid);
         if ($invdata['accountid'] != self::$userid) {
             $xtpl->parse('main.viewinvoice.invrights');
         } else {
             $order = Order::getInstance();
             $pkg = Package::getInstance();
             $orderdata = $order->FetchData($invdata['orderid']);
             $pkgdata = $pkg->FetchData($orderdata['productid']);
             $xtpl->assign('INV', $invdata);
             $xtpl->assign('PKG', $pkgdata);
             $xtpl->assign('ORDER', $orderdata);
             if ($invdata['status'] == 'Paid') {
                 $xtpl->parse('main.viewinvoice.invoice.paid');
             }
             $xtpl->parse('main.viewinvoice.invoice');
         }
     }
     $xtpl->parse('main.viewinvoice');
     $xtpl->parse('main');
     $xtpl->out('main');
 }
Esempio n. 6
0
 public function Unsuspend($orderid)
 {
     $order = Order::getInstance();
     $sm = ServerModule::getInstance();
     $order->orderid = $orderid;
     $order->Update('', 'status', 'Terminated');
     $orderdata = $order->FetchData();
     $server = Server::getInstance();
     $sm->id = $order->FindModuleID();
     $serverdata = $server->FetchData($orderdata['serverid']);
     return $sm->UnsuspendService(unserialize($serverdata['accessdata']), unserialize($orderdata['accessdata']));
 }
Esempio n. 7
0
 /**
  * Orders
  */
 private function _orders()
 {
     // Order history
     $template = 'templates/content.orders.php';
     if ($GLOBALS['user']->is()) {
         $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['your_account'], 'index.php?_a=account');
         $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['your_orders'], currentPage(array('cart_order_id'), null, false));
         if (isset($_GET['cart_order_id']) && Order::validOrderId(trim($_GET['cart_order_id']))) {
             if (($orders = $GLOBALS['db']->select('CubeCart_order_summary', false, array('customer_id' => $GLOBALS['user']->get('customer_id'), 'cart_order_id' => $_GET['cart_order_id']))) !== false) {
                 $template = 'templates/content.receipt.php';
                 $order = $orders[0];
                 $GLOBALS['gui']->addBreadcrumb($order['cart_order_id'], currentPage());
                 if (($items = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     foreach ($items as $item) {
                         // Do price formatting
                         $item['price_total'] = $GLOBALS['tax']->priceFormat($item['price'] * $item['quantity'], true);
                         $item['price'] = $GLOBALS['tax']->priceFormat($item['price']);
                         $item['options'] = unserialize($item['product_options']);
                         $vars['items'][] = $item;
                     }
                     $GLOBALS['smarty']->assign('ITEMS', $vars['items']);
                 }
                 // Taxes
                 if (($taxes = $GLOBALS['db']->select('CubeCart_order_tax', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     $GLOBALS['tax']->loadTaxes($GLOBALS['config']->get('config', 'basket_tax_by_delivery') ? $order['country'] : $order['country_d']);
                     foreach ($taxes as $vat) {
                         $detail = $GLOBALS['tax']->fetchTaxDetails($vat['tax_id']);
                         $vars['taxes'][] = array('name' => $detail['name'], 'value' => $GLOBALS['tax']->priceFormat($vat['amount'], true));
                     }
                 } else {
                     $vars['taxes'][] = array('name' => $GLOBALS['language']->basket['total_tax'], 'value' => $GLOBALS['tax']->priceFormat($order['total_tax']));
                 }
                 $GLOBALS['smarty']->assign('TAXES', $vars['taxes']);
                 $order['state'] = getStateFormat($order['state']);
                 $order['country'] = getCountryFormat($order['country']);
                 $order['state_d'] = is_numeric($order['state_d']) ? getStateFormat($order['state_d']) : $order['state_d'];
                 $order['country_d'] = getCountryFormat($order['country_d']);
                 if ($order['discount'] > 0) {
                     $GLOBALS['smarty']->assign('DISCOUNT', true);
                 }
                 // Loop through price values, and do the formatting
                 foreach (array('discount', 'shipping', 'subtotal', 'total', 'total_tax') as $key) {
                     $order[$key] = $GLOBALS['tax']->priceFormat($order[$key], true);
                 }
                 $order['order_status'] = $GLOBALS['language']->order_state['name_' . $order['status']];
                 $order['order_date_formatted'] = formatTime($order['order_date'], false, true);
                 foreach ($GLOBALS['hooks']->load('class.cubecart.order_summary') as $hook) {
                     include $hook;
                 }
                 $GLOBALS['smarty']->assign('SUM', $order);
                 $GLOBALS['smarty']->assign('ORDER', $order);
                 $GLOBALS['session']->delete('ghost_customer_id');
                 // Courier Tracking URLs
                 if (!empty($order['ship_method'])) {
                     // Load the module
                     $method = str_replace(' ', '_', $order['ship_method']);
                     $ship_class = CC_ROOT_DIR . '/modules/shipping/' . $method . '/' . 'shipping.class.php';
                     if (file_exists($ship_class)) {
                         include $ship_class;
                         if (class_exists($method) && method_exists((string) $method, 'tracking')) {
                             $shipping = new $method(false);
                             $url = $shipping->tracking($order['ship_tracking']);
                             $url = empty($url) && filter_var($order['ship_tracking'], FILTER_VALIDATE_URL) ? $order['ship_tracking'] : $url;
                             $delivery = array('url' => $url, 'method' => $order['ship_method'], 'date' => !empty($order['ship_date']) ? $order['ship_date'] : '', 'tracking' => $order['ship_tracking']);
                         }
                         unset($ship_class);
                     } else {
                         $delivery = array('url' => filter_var($order['ship_tracking'], FILTER_VALIDATE_URL) ? $order['ship_tracking'] : '', 'method' => $order['ship_method'], 'product' => $order['ship_product'], 'tracking' => $order['ship_tracking'], 'date' => !empty($order['ship_date']) ? $order['ship_date'] : '');
                     }
                     if (empty($delivery['date']) && empty($delivery['url']) && empty($delivery['tracking'])) {
                         $delivery = false;
                     }
                 } else {
                     $delivery = false;
                 }
                 $GLOBALS['smarty']->assign('DELIVERY', $delivery);
             } else {
                 httpredir(currentPage(array('cart_order_id')));
             }
         } else {
             if (isset($_GET['cancel']) && Order::validOrderId(trim($_GET['cancel']))) {
                 $order = Order::getInstance();
                 if ($order->orderStatus(Order::ORDER_CANCELLED, $_GET['cancel'])) {
                     // Specify order was cancelled by customer
                     $note = array('admin_id' => 0, 'cart_order_id' => $_GET['cancel'], 'content' => $GLOBALS['language']->orders['cancel_by_customer']);
                     $GLOBALS['db']->insert('CubeCart_order_notes', $note);
                     $GLOBALS['gui']->setError($GLOBALS['language']->orders['notify_order_cancelled']);
                 }
                 httpredir(currentPage(array('cancel')));
             } else {
                 if (isset($_GET['reorder']) && Order::validOrderId(trim($_GET['reorder']))) {
                     $basket = $GLOBALS['db']->select('CubeCart_order_summary', array('basket'), array('cart_order_id' => $_GET['reorder'], 'customer_id' => $GLOBALS['user']->get('customer_id')));
                     $past_data = unserialize($basket[0]['basket']);
                     $GLOBALS['cart']->basket['contents'] = $past_data['contents'];
                     $GLOBALS['cart']->save();
                     httpredir('?_a=basket');
                 }
             }
             $per_page = 15;
             $page = isset($_GET['page']) ? $_GET['page'] : 1;
             if (($orders = $GLOBALS['db']->select('CubeCart_order_summary', array('cart_order_id', 'ship_tracking', 'order_date', 'status', 'total', 'basket'), array('customer_id' => $GLOBALS['user']->get('customer_id')), array('cart_order_id' => 'DESC'), $per_page, $page)) !== false) {
                 foreach ($orders as $i => $order) {
                     $order['time'] = formatTime($order['order_date']);
                     $status = $order['status'];
                     switch ((int) $order['status']) {
                         case 1:
                             # Pending
                             $icon = 'basket.png';
                             break;
                         case 2:
                             # Processing
                             $icon = 'clock.png';
                             break;
                         case 3:
                             # Complete & dispatched
                             $icon = 'lorry.png';
                             break;
                         case 4:
                             # Declined
                         # Declined
                         case 5:
                             # Fraud
                             $icon = 'error.png';
                             break;
                         case 6:
                             # Cancelled
                             $icon = 'bin.png';
                             break;
                     }
                     $order['total'] = $GLOBALS['tax']->priceFormat($order['total'], true);
                     $order['make_payment'] = $order['status'] == 1 && !empty($order['basket']) ? true : false;
                     $order['cancel'] = in_array($order['status'], array(1, 2)) ? true : false;
                     $order['status'] = array('icon' => $icon, 'text' => $GLOBALS['language']->order_state['name_' . (int) $order['status']]);
                     $vars['orders'][] = $order;
                 }
                 foreach ($GLOBALS['hooks']->load('class.cubecart.order_list') as $hook) {
                     include $hook;
                 }
                 $GLOBALS['smarty']->assign('ORDERS', $vars['orders']);
                 $GLOBALS['smarty']->assign('PAGINATION', $GLOBALS['db']->pagination(count($orders), $per_page, $page));
             }
         }
     } else {
         // Order lookup for unregistered users
         if (isset($_POST['cart_order_id']) && isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) && Order::validOrderId(trim($_POST['cart_order_id']))) {
             $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->orders['my_order'], currentPage());
             if (($orders = $GLOBALS['db']->select('CubeCart_order_summary', false, array('email' => $_POST['email'], 'cart_order_id' => $_POST['cart_order_id']))) !== false) {
                 $template = 'templates/content.receipt.php';
                 $order = $orders[0];
                 $GLOBALS['user']->setGhostId($order['customer_id']);
                 if (($items = $GLOBALS['db']->select('CubeCart_order_inventory', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     foreach ($items as $item) {
                         // Do price formatting
                         $item['price_total'] = $GLOBALS['tax']->priceFormat($item['price'] * $item['quantity'], true);
                         $item['price'] = $GLOBALS['tax']->priceFormat($item['price']);
                         $item['options'] = unserialize($item['product_options']);
                         $vars['items'][] = $item;
                     }
                     $GLOBALS['smarty']->assign('ITEMS', $vars['items']);
                 }
                 if (($taxes = $GLOBALS['db']->select('CubeCart_order_tax', false, array('cart_order_id' => $order['cart_order_id']))) !== false) {
                     $GLOBALS['tax']->loadTaxes($GLOBALS['config']->get('config', 'basket_tax_by_delivery') ? $order['country'] : $order['country_d']);
                     foreach ($taxes as $vat) {
                         $detail = $GLOBALS['tax']->fetchTaxDetails($vat['tax_id']);
                         $vars['taxes'][] = array('name' => $detail['name'], 'value' => $GLOBALS['tax']->priceFormat($vat['amount'], true));
                     }
                 } else {
                     $vars['taxes'][] = array('name' => $GLOBALS['language']->basket['total_tax'], 'value' => $GLOBALS['tax']->priceFormat($order['total_tax']));
                 }
                 $GLOBALS['smarty']->assign('TAXES', $vars['taxes']);
                 $order['country'] = getCountryFormat($order['country']);
                 $order['country_d'] = getCountryFormat($order['country_d']);
                 $order['state'] = is_numeric($order['state']) ? getStateFormat($order['state']) : $order['state'];
                 $order['state_d'] = is_numeric($order['state_d']) ? getStateFormat($order['state_d']) : $order['state_d'];
                 // Loop through price values, and do the formatting
                 foreach (array('discount', 'shipping', 'subtotal', 'total', 'total_tax') as $key) {
                     $order[$key] = $GLOBALS['tax']->priceFormat($order[$key], true);
                 }
                 $order['order_status'] = $GLOBALS['language']->order_state['name_' . $order['status']];
                 $order['order_date_formatted'] = formatTime($order['order_date'], false, true);
                 foreach ($GLOBALS['hooks']->load('class.cubecart.order_summary') as $hook) {
                     include $hook;
                 }
                 $GLOBALS['smarty']->assign('SUM', $order);
                 $GLOBALS['smarty']->assign('ORDER', $order);
             }
         } else {
             // Display a search page
             $cart_oder_id = Order::validOrderId(trim($_GET['cart_order_id'])) ? trim($_GET['cart_order_id']) : '';
             $GLOBALS['smarty']->assign('ORDER_NUMBER', $cart_oder_id);
             $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->orders['search'], currentPage());
         }
     }
     $content = $GLOBALS['smarty']->fetch($template);
     $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
 }