Esempio n. 1
0
 /**
  * Function used to process free orders
  *
  * @return  void
  *
  * @since  1.0.0
  */
 public function processFreeOrder()
 {
     $jinput = JFactory::getApplication()->input;
     $comquick2cartHelper = new comquick2cartHelper();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $post = $jinput->post;
     $orderid = $post->get('orderid', '', 'STRING');
     $guest_email = '';
     if (!empty($orderid)) {
         $query = "SELECT `amount`,`email` FROM `#__kart_orders` where `id`=" . $orderid;
         $db->setQuery($query);
         $orderDetail = $db->loadAssoc();
         $orderPrice = (int) $orderDetail['amount'];
         if (empty($orderPrice)) {
             if (empty($user->id) && $orderDetail['email']) {
                 $guest_email = "&email=" . md5($orderDetail['email']);
             }
             // CONFORM ONLY 0 PRICE ORDER
             $comquick2cartHelper->updatestatus($orderid, 'C', $comment = '', $send_mail = 1, $store_id = 0);
         }
     }
     global $mainframe;
     $mainframe = JFactory::getApplication();
     $orderItemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=orders');
     $orderLink = 'index.php?option=com_quick2cart&view=orders&layout=order&orderid=' . $orderid . '&Itemid=' . $orderItemid . $guest_email;
     $link = JUri::base() . substr(JRoute::_($orderLink, false), strlen(JUri::base(true)) + 1);
     $mainframe->redirect($link);
 }
Esempio n. 2
0
 function processpayment($post, $pg_plugin, $order_id)
 {
     $comquick2cartHelper = new comquick2cartHelper();
     $jinput = JFactory::getApplication()->input;
     $jinput->set('remote', 1);
     $sacontroller = new quick2cartController();
     $sacontroller->execute('clearcart');
     $orderItemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=orders');
     $chkoutItemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=cartcheckout');
     $return_resp = array();
     //Authorise Post Data
     if (!empty($post['plugin_payment_method']) && $post['plugin_payment_method'] == 'onsite') {
         $plugin_payment_method = $post['plugin_payment_method'];
     }
     $order_id = $this->extract_prefix($order_id);
     $vars = $this->getPaymentVars($pg_plugin, $order_id);
     // Payment trigger
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('payment', $pg_plugin);
     $data = $dispatcher->trigger('onTP_Processpayment', array($post, $vars));
     //$vars added by aniket
     $data = $data[0];
     $res = @$this->storelog($pg_plugin, $data);
     //get order id
     if (empty($order_id)) {
         $order_id = $data['order_id'];
     }
     $order_id = $this->extract_prefix($order_id);
     /*start for guest checkout*/
     $query = "SELECT ou.user_id,ou.user_email\n\t\t\tFROM #__kart_users as ou\n\t\t\tWHERE ou.address_type='BT' AND ou.order_id = " . $order_id;
     $this->_db->setQuery($query);
     $user_detail = $this->_db->loadObject();
     $params = JComponentHelper::getParams('com_quick2cart');
     $guest_email = "";
     if (!$user_detail->user_id && $params->get('guest')) {
         $guest_email = "&email=" . md5($user_detail->user_email);
     }
     /*end for guest checkout*/
     $data['processor'] = $pg_plugin;
     $data['status'] = trim($data['status']);
     $query = "SELECT o.amount\n\t\t\t\tFROM #__kart_orders  as o\n\t\t\t\twhere o.id=" . $order_id;
     $this->_db->setQuery($query);
     $order_amount = $this->_db->loadResult();
     $return_resp['status'] = '0';
     $epsilon = 0.0;
     $epsilon2 = 0.01;
     $return_resp['msg'] = JText::_('COM_QUICK2CART_ORDER_THNX');
     if ($data['status'] == 'C' && $data['total_paid_amt'] - $order_amount >= $epsilon) {
         // received amount is greater or equal to order amount
         $data['status'] = 'C';
         $return_resp['status'] = '1';
         $return_resp['msg'] = JText::_('COM_QUICK2CART_ORDER_THNX_CONFIRM');
     } else {
         if ($order_amount - $data['total_paid_amt'] > $epsilon2) {
             // received amount les
             $data['status'] = 'E';
             $return_resp['status'] = '0';
             $comp_pay = "&paybuttonstatus=1";
             $return_resp['msg'] = JText::_('COM_QUICK2CART_ORDER_THNX_ERROR');
         } else {
             if (empty($data['status'])) {
                 $data['status'] = 'P';
                 $return_resp['status'] = '0';
                 $comp_pay = "&paybuttonstatus=1";
                 $return_resp['msg'] = JText::_('COM_QUICK2CART_ORDER_THNX');
             }
         }
     }
     if ($data['status'] != 'C' && !empty($data['error'])) {
         $return_resp['msg'] = $data['error']['code'] . " " . $data['error']['desc'];
         $comp_pay = "&paybuttonstatus=1";
         $link = '<a href="#complete-order">' . JText::_('COM_QUICK2CART_ORDER_PROCESS_AGAIN_TEXT') . '</a>';
         $comp_pay_msg = '</br>' . JText::sprintf('COM_QUICK2CART_ORDER_PROCESS_AGAIN', $link);
         $return_resp['msg'] .= $comp_pay_msg;
     }
     $this->updateOrder($data, $pg_plugin);
     $comquick2cartHelper->updatestatus($order_id, $data['status']);
     $return_resp['return'] = JUri::root() . substr(JRoute::_("index.php?option=com_quick2cart&view=orders&layout=order" . $guest_email . "&orderid=" . $order_id . "&processor={$pg_plugin}" . $comp_pay . "&Itemid=" . $orderItemid, false), strlen(JUri::base(true)) + 1);
     return $return_resp;
 }
Esempio n. 3
0
 /**
  * This function update the order status with note.
  *
  * If escaping mechanism is either htmlspecialchars or htmlentities, uses
  * {@link $_encoding} setting.
  *
  * @param   integer  $store_id  if we are updating store product status
  *
  * @return  integer  if 1 = success 	2= error 	3 = refund order
  *
  * @since   2.2
  */
 public function store($store_id = 0)
 {
     $comquick2cartHelper = new comquick2cartHelper();
     $lang = JFactory::getLanguage();
     $lang->load('com_quick2cart', JPATH_SITE);
     $returnvaule = 1;
     $jinput = JFactory::getApplication()->input;
     $layout = $jinput->get("layout");
     $status = $jinput->get('status');
     $data = $jinput->post;
     $orderId = $data->get('id');
     $notify_chk = $data->get('notify_chk' . '|' . $orderId, '');
     if (isset($notify_chk) && $notify_chk != null) {
         $notify_chk = 1;
     } else {
         $notify_chk = 0;
     }
     // $comment = $data->get('comment', '', 'STRING');
     // Save order history
     $add_note_chk = $data->get('add_note_chk' . '|' . $orderId, '');
     $note = $data->get('order_note' . '|' . $orderId, '', "STRING");
     $comquick2cartHelper->updatestatus($orderId, $status, $note, $notify_chk, $store_id);
     if ($status == 'RF') {
         $returnvaule = 3;
     }
     // Get order item
     if ($layout == "order") {
         $orderItemsStr = $data->get("orderItemsStr", '', "STRING");
         $orderItems = explode("||", $orderItemsStr);
     } else {
         $orderItems = $this->getOrderItems($orderId);
     }
     // Save order history
     foreach ($orderItems as $oitemId) {
         // Save order item status history
         $this->comquick2cartHelper->saveOrderStatusHistory($orderId, $oitemId, $jinput->get('status'), $note, $notify_chk);
     }
     return $returnvaule;
 }