function makemorepayment() { require JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_socialads" . DS . "config" . DS . "config.php"; $model = $this->getModel('showad'); $buildadsession = JFactory::getSession(); $input = JFactory::getApplication()->input; $data = JRequest::get('post'); $adid = $data['adid']; $buildadsession->set('adid', $data['adid']); $buildadsession->set('ad_totalamount', $data['totalamount']); $buildadsession->set('ad_totaldisplay', $data['totaldisplay']); $buildadsession->set('ad_gateway', $data['gateway']); //interchange amt and cop_amt $cop = $input->get('cop', '', 'STRING') ? $input->get('cop', '', 'STRING') : ''; $arb_flag = $input->get('arb_flag') ? $input->get('arb_flag') : 0; $amt = $data['totalamount']; //interchange amt and cop_amt $cop_dis_opn_hide = $input->get('cop_dis_opn_hide', '', 'INT'); JRequest::setVar('coupon_code', $data['cop']); $model = $this->getModel('showad'); $adcop = ''; if ($cop_dis_opn_hide == 0) { $adcop = $model->getcoupon(); if ($adcop) { if ($adcop[0]->val_type == 1) { //discount rate $val = $adcop[0]->value / 100 * $data['totalamount']; } else { $val = $adcop[0]->value; } } else { $val = 0; } $amt = round($data['totalamount'] - $val, 2); } if ($amt <= 0) { $amt = 0; } $temp = $data['totalamount']; $buildadsession->set('ad_totalamount', $amt); $buildadsession->set('orgi_totalamount', $temp); $ad_chargeoption = $buildadsession->get('ad_chargeoption'); if ($ad_chargeoption >= 2) { if (!isset($data['ad_chargeoption_day']) || !$data['ad_chargeoption_day']) { // code to put start date in ad data table $db = JFactory::getDBO(); $addata = new stdClass(); $addata->ad_id = $adid; $addata->ad_startdate = $data['datefrom']; $db->updateObject('#__ad_data', $addata, 'ad_id'); } $credits = $data['ad_totaldays']; } else { $credits = $data['totaldisplay']; } $user = JFactory::getUser(); $option = $data['gateway']; $success_msg = ''; $totalamt = $buildadsession->get('ad_totalamount'); if ($option == 'jomsocialpoints' or $option == 'alphauserpoints') { $plugin = JPluginHelper::getPlugin('payment', $buildadsession->get('ad_gateway')); $pluginParams = json_decode($plugin->params); $totalamt = $buildadsession->get('ad_totalamount') / $pluginParams->conversion; $success_msg = JText::sprintf('TOTAL_POINTS_DEDUCTED_MESSAGE', $buildadsession->get('ad_totalamount')); } JPluginHelper::importPlugin('payment', $option); $dispatcher = JDispatcher::getInstance(); if ($amt <= 0 && $adcop) { $db = JFactory::getDBO(); //added for date type ads $query = "SELECT ad_payment_type FROM #__ad_data WHERE ad_id =" . $adid; $db->setQuery($query); $ad_payment_type = $db->loadResult(); if ($ad_payment_type != 2) { $query = "UPDATE #__ad_data SET ad_credits = ad_credits + {$result->ad_credits_qty}, ad_credits_balance = ad_credits_balance + {$result->ad_credits_qty} WHERE ad_id=" . $result->ad_id; $db->setQuery($query); $db->execute(); } else { if ($ad_payment_type >= 2) { socialadshelper::adddays($adid, $result->ad_credits_qty); } } $paymentdata = new stdClass(); $paymentdata->id = ''; $paymentdata->ad_id = $adid; $paymentdata->cdate = date('Y-m-d H:i:s'); $paymentdata->processor = $buildadsession->get('ad_gateway'); $paymentdata->ad_credits_qty = $credits; $paymentdata->ad_amount = $buildadsession->get('orgi_totalamount'); $paymentdata->ad_original_amt = $buildadsession->get('orgi_totalamount'); $paymentdata->status = 'C'; $paymentdata->ad_coupon = $data['cop']; $paymentdata->payee_id = $user->id; $paymentdata->ip_address = $_SERVER["REMOTE_ADDR"]; if (!$db->insertObject('#__ad_payment_info', $paymentdata, 'id')) { echo $db->stderr(); return false; } global $mainframe; $mainframe = JFactory::getApplication(); $mainframe->redirect('index.php?option=com_socialads&view=managead&Itemid=' . $input->get('Itemid', 0, 'INT')); } else { $orderdata = array('order_id' => '', 'pg_plugin' => $option, 'user' => $user, 'adid' => $adid, 'amount' => $totalamt, 'original_amount' => $buildadsession->get('orgi_totalamount'), 'coupon' => $cop, 'credits' => $credits, 'success_message' => $success_msg); //Here orderid is id in payment_info table $orderid = $model->createorder($orderdata); if (!$orderid) { echo $msg = JText::_('ERROR_SAVE'); } $orderdata['order_id'] = $orderid; $html = $this->getHTML($orderdata); if (!empty($html)) { echo $html; } } }
function saveOrder($data, $orderid, $pg_nm) { $db = JFactory::getDBO(); $paymentdata = new stdClass(); $paymentdata->id = $orderid; $paymentdata->transaction_id = $data['transaction_id']; if ($data['status'] == 'C') { $paymentdata->status = 'C'; if (!empty($data['payment_type'])) { if ($data['payment_type'] == 'recurring') { $paymentdata->subscription_id = $data['subscription_id']; if (empty($data['payment_number'])) { $paymentdata->status = 'P'; } } } $query = "SELECT subscription_id,ad_credits_qty,ad_id FROM #__ad_payment_info WHERE id =" . $orderid; $db->setQuery($query); $result = $db->loadObject(); if (!$result->ad_credits_qty) { $result->ad_credits_qty = 0; } //added for date type ads $adid = $result->ad_id; $query = "SELECT ad_payment_type FROM #__ad_data WHERE ad_id =" . $adid; $db->setQuery($query); $ad_payment_type = $db->loadResult(); if ($ad_payment_type == 2) { socialadshelper::adddays($adid, $result->ad_credits_qty); } else { $query = "UPDATE #__ad_data SET ad_credits = ad_credits + {$result->ad_credits_qty}, ad_credits_balance = ad_credits_balance + {$result->ad_credits_qty} WHERE ad_id=" . $result->ad_id; $db->setQuery($query); $db->execute(); } } $paymentdata->extras = $data['raw_data']; if (!$db->updateObject('#__ad_payment_info', $paymentdata, 'id')) { echo $db->stderr(); return false; } if ($paymentdata->status == 'C') { // added by VM: $socialadsModelShowad = new socialadsModelShowad(); $sendmail = $socialadsModelShowad->SendOrderMAil($orderid, $pg_nm, 1); // end Vm return true; } else { return false; } }
function store() { $data = JRequest::get('post'); $id = $data['id']; $status = $data['status']; //require_once(JPATH_SITE.DS."components".DS."com_socialads".DS."helper.php"); // require when we call from backend $socialadshelper = new socialadshelper(); if ($status == 'RF') { $query = "UPDATE #__ad_payment_info SET status ='RF' WHERE id =" . $id; $this->_db->setQuery($query); if (!$this->_db->execute()) { return 2; } $socialadshelper->new_pay_mail($id); return 3; } elseif ($status == 'E') { $query = "UPDATE #__ad_payment_info SET status ='E' WHERE id =" . $id; $this->_db->setQuery($query); if (!$this->_db->execute()) { return 2; } $socialadshelper->new_pay_mail($id); return 3; } elseif ($status == 'C') { $query = "SELECT * FROM #__ad_payment_info WHERE id =" . $id; $this->_db->setQuery($query); $result = $this->_db->loadObject(); $query = "UPDATE #__ad_payment_info SET status ='C' WHERE id =" . $id; $this->_db->setQuery($query); if (!$this->_db->execute()) { return 2; } //entry for transaction table $query = "SELECT ad_id FROM #__ad_payment_info WHERE id = " . $id; $this->_db->setQuery($query); $ad = $this->_db->loadresult(); JLoader::import('payment', JPATH_SITE . DS . 'components' . DS . 'com_socialads' . DS . 'models'); $socialadsModelpayment = new socialadsModelpayment(); if (empty($ad)) { // add wallet $comment = 'ADS_PAYMENT'; $transc = $socialadsModelpayment->add_transc($result->ad_original_amt, $id, $comment); $sendmail = $socialadsModelpayment->SendOrderMAil($id, $data['search_gateway'], $payPerAd = 0); } else { // pay per ad $sendmail = $socialadsModelpayment->SendOrderMAil($id, $data['search_gateway'], $payPerAd = 1); } require_once JPATH_SITE . '/components/com_socialads/helper.php'; $adid = $result->ad_id; $qryad = "SELECT ad_payment_type FROM #__ad_data WHERE ad_id =" . $adid; $this->_db->setQuery($qryad); $ad_payment_type = $this->_db->loadResult(); if ($ad_payment_type != 2) { $query = "UPDATE #__ad_data SET ad_credits = ad_credits + {$result->ad_credits_qty}, ad_credits_balance = ad_credits_balance + {$result->ad_credits_qty} WHERE ad_id=" . $result->ad_id; $this->_db->setQuery($query); $this->_db->execute(); } //added by sagar for date type ads if (empty($subscriptiondata[0]->subscription_id) and $ad_payment_type == 2) { socialadshelper::adddays($adid, $result->ad_credits_qty); } //added by sagar for date type ads } else { $query = "UPDATE #__ad_payment_info SET status ='P' WHERE id =" . $id; $this->_db->setQuery($query); if (!$this->_db->execute()) { return 2; } } return 1; }