function getItem() { $result = array(); $post = JRequest::get('post'); $post = oseMscAddon::getPost('licseat_', $post); if (!isset($post['contact_send'])) { $post['contact_send'] = 0; } if (!isset($post['internal_contact_send'])) { $post['internal_contact_send'] = 0; } $db = oseDB::instance(); $msc_id = JRequest::getInt('msc_id', 0); $member_id = JRequest::getInt('member_id', 0); $mscLicInfo = oseRegistry::call('msc')->getExtInfo($msc_id, 'lic', 'obj'); $mscLicInfoParams = oseObject::getParams($mscLicInfo); $where = array(); $where[] = "license_user_id = '{$member_id}'"; if (empty($mscLicInfoParams->id)) { $where[] = "license_id = '{$mscLicInfoParams->id}'"; } $where = oseDB::implodeWhere(); $query = " SELECT * FROM `#__oselic_license_seat`" . $where . " ORDER BY id DESC"; $db->setQuery($query); $item = oseDB::loadItem('obj'); $result['success'] = empty($item) ? false : true; $result['total'] = empty($item) ? 0 : 1; $result['result'] = empty($item) ? array() : $item; //$result = oseJson::encode($result); return $result; }
function generateOrderParams($msc_id, $price, $payment_mode, $msc_option) { $params = array(); $params['msc_id'] = $msc_id; if ($payment_mode == 'a') { $payment = oseMscAddon::getExtInfo($msc_id, 'payment', 'array'); $payment = $payment[$msc_option]; if (oseObject::getValue($payment, 'has_trial')) { $params['has_trial'] = 1; $params['a1'] = $price; $params['p1'] = oseObject::getValue($payment, 'p1'); $params['t1'] = oseObject::getValue($payment, 't1'); $params['a3'] = oseObject::getValue($payment, 'a3'); $params['p3'] = oseObject::getValue($payment, 'p3'); $params['t3'] = oseObject::getValue($payment, 't3'); } else { $params['has_trial'] = 0; $params['a3'] = $price; $params['p3'] = oseObject::getValue($payment, 'p3'); $params['t3'] = oseObject::getValue($payment, 't3'); } } if ($payment_mode == 'm') { $payment = oseMscAddon::getExtInfo($msc_id, 'payment', 'array'); $payment = $payment[$msc_option]; $params['recurrence_mode'] = 'period'; $params['a3'] = $price; $params['p3'] = oseObject::getValue($payment, 'p3'); $params['t3'] = oseObject::getValue($payment, 't3'); $params['eternal'] = oseObject::getValue($payment, 'eternal'); } $params['msc_option'] = $msc_option; return $params; }
public function createOrder($payment_mode, $payment_method, $msc_id, $msc_option, $user_id) { $nItem = array('entry_id' => $msc_id, 'entry_type' => 'msc', 'msc_option' => $msc_option); $cart = $this->getCart($payment_mode, $nItem); $result = oseMscAddon::runAction('register.payment.save', array('member_id' => $user_id, 'payment_method' => $payment_method), true, false); return $result['order_id']; }
public static function activate($params) { $result = array(); $result['success'] = true; if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Renew.Order'); return $result; } //unset($params['allow_work']); return oseMscAddon::runAction('join.order.save', $params); }
public static function save($params = array()) { $result = array(); $post = JRequest::get('post'); if (oseMscAddon::quickSavePanel('jgroup_', $post)) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVE_SUCCESSFULLY'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR_IN_SAVING_JOOMLA_USER_GROUP_PARAMETERS'); } return $result; }
public static function save($params = array()) { $result = array(); $post = JRequest::get('post'); if (oseMscAddon::quickSavePanel('mailchimp_', $post)) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVE_SUCCESSFULLY'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); } return $result; }
public static function save($params = array()) { $post = JRequest::get('post'); $post['msc_restrict'] = JRequest::getVar('msc_restrict', null, 'post', 'string', JREQUEST_ALLOWHTML); if (oseMscAddon::quickSavePanel('msc_', $post)) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVE_SUCCESSFULLY'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR_IN_SAVING_MSC_PARAMETERS'); } return $result; }
public static function save($params = array()) { $result = array(); $post = JRequest::get('post'); $post['jcontent_view_control'] = empty($post['jcontent_view_control']) ? 0 : 1; $post['jcontent_create_control'] = empty($post['jcontent_create_control']) ? 0 : 1; $post['jcontent_edit_control'] = empty($post['jcontent_edit_control']) ? 0 : 1; if (oseMscAddon::quickSavePanel('jcontent_', $post)) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVE_SUCCESSFULLY'); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); } return $result; }
function drawSubLeaf($node) { $item = self::generateSubMsc($node); $array = array(); $payment = oseMscAddon::getExtInfo(oseObject::getValue($node, 'id'), 'payment', 'obj'); $price = oseObject::getValue($item, 'standard_price') . ' for every ' . oseObject::getValue($item, 'standard_recurrence'); if ($payment->has_trial) { $price .= ' (' . oseObject::getValue($item, 'trial_price') . ' in the first ' . oseObject::getValue($item, 'trial_recurrence') . ')'; } if (strtolower($payment->payment_mode) == 'm') { $array['button'] = $this->drawButton($node, 'm', JText::_('Manual Renewal')); } elseif (strtolower($payment->payment_mode) == 'a') { $array['button'] = $this->drawButton($node, 'a', JText::_('Automatic Renewal')); } else { $array['button'] = $this->drawButton($node, 'm', JText::_('Manual Renewal')); $array['button'] .= $this->drawButton($node, 'a', JText::_('Automatic Renewal')); } $array['title'] = $this->drawSubTitle('<p>|__' . oseObject::getValue($item, 'title') . "</p>"); $array['price'] = $this->drawPrice(oseObject::getValue($item, 'price')); $array['period'] = $this->drawPeriod(oseObject::getValue($item, 'period')); $array = implode("\r\n", $array); return $array; }
public static function save($params = array()) { $post = JRequest::get('post'); if (!isset($post['licseat_contact_send'])) { $post['licseat_contact_send'] = 0; } if (!isset($post['licseat_internal_contact_send'])) { $post['licseat_internal_contact_send'] = 0; } if (!isset($post['licseat_enabled'])) { $post['licseat_enabled'] = 0; } if (oseMscAddon::quickSavePanel('licseat_', $post)) { $result['success'] = true; $result['title'] = JText::_('Finished'); $result['content'] = JText::_('Save Successfully!'); } else { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Error in Saving License Parameters'); } return $result; }
function remove($addon_id) { return oseMscAddon::remove($addon_id); }
JRequest::setVar('tmpl', 'component'); } $list = $this->get('Items'); $this->assignRef('list', $list);
function getAddons() { return oseMscAddon::getAddonList('config', true, null, 'obj'); }
function addVmOrder($msc_id, $member_id, $params, $order_number) { if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } // Get the IP Address if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = 'unknown'; } $post = JRequest::get('post'); $payment_mode = $params['payment_mode']; $payment_method = $params['payment_method']; //Insert the vm order table(#__vm_orders) $order = array(); //get membership price $payment = oseRegistry::call('payment'); $paymentInfo = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj'); if ($payment_mode == 'm') { $order_subtotal = $paymentInfo->price; } else { $order_subtotal = empty($paymentInfo->has_trial) ? $paymentInfo->a3 : $paymentInfo->a1; } $order['order_subtotal'] = $params['payment_price']; $order_total = $params['payment_price']; $order['order_total'] = $order_total; $db = oseDB::instance(); //$order['order_tax'] = '0.00'; $query = "SELECT user_info_id FROM `#__vm_user_info` WHERE `user_id` = '" . (int) $member_id . "' AND (`address_type` = 'BT' OR `address_type` IS NULL)"; $db->setQuery($query); $result = $db->loadResult(); $hash_secret = "VirtueMartIsCool"; $user_info_id = empty($result) ? md5(uniqid($hash_secret)) : $result; $vendor_id = '1'; $order['user_id'] = $member_id; $order['vendor_id'] = $vendor_id; $order['user_info_id'] = $user_info_id; $order['order_number'] = $order_number; $order['order_currency'] = !empty($payment->currency) ? $payment->currency : "USD"; $order['order_status'] = 'C'; $order['cdate'] = time(); $order['ip_address'] = $ip; $keys = array_keys($order); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($order as $key => $value) { $order[$key] = $db->Quote($value); } $values = implode(',', $order); $query = "INSERT INTO `#__vm_orders` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } //Insert the #__vm_order_history table $order_id = $db->insertid(); $history = array(); $history['order_id'] = $order_id; $history['order_status_code'] = 'C'; $history['date_added'] = date("Y-m-d G:i:s", time()); $history['customer_notified'] = '1'; $keys = array_keys($history); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($history as $key => $value) { $history[$key] = $db->Quote($value); } $values = implode(',', $history); $query = "INSERT INTO `#__vm_order_history` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } //Insert the Order payment info $payment = array(); $payment['order_id'] = $order_id; $payment['payment_method_id'] = $payment_method; if ($payment_method == 'authorize') { } //Insert the User Bill $bill = array(); $query = " SELECT * FROM `#__osemsc_billinginfo`" . " WHERE user_id = {$member_id}"; $db->setQuery($query); $billInfo = oseDB::loadItem(); if (isset($billInfo)) { $bill['company'] = $billInfo['company']; $bill['address_1'] = $billInfo['addr1']; $bill['address_2'] = $billInfo['addr2']; $bill['city'] = $billInfo['city']; $bill['state'] = $billInfo['state']; $bill['country'] = $billInfo['country']; //get vm country code $query = " SELECT country_3_code FROM `#__vm_country` WHERE `country_2_code` = '{$bill['country']}' "; $db->setQuery($query); $country_code = $db->loadResult(); $bill['country'] = empty($country_code) ? $bill['country'] : $country_code; //get vm state code $query = " SELECT state_2_code FROM `#__vm_state` WHERE `state_name` = '{$bill['state']}' "; $db->setQuery($query); $state_code = $db->loadResult(); $bill['state'] = empty($state_code) ? $bill['state'] : $state_code; $bill['zip'] = $billInfo['postcode']; $bill['phone_1'] = $billInfo['telephone']; } $query = " SELECT * FROM `#__osemsc_userinfo_view`" . " WHERE user_id = {$member_id}"; $db->setQuery($query); $userInfo = oseDB::loadItem(); $bill['order_id'] = $order_id; $bill['user_id'] = $member_id; $bill['address_type'] = 'BT'; $bill['address_type_name'] = '-default-'; $bill['last_name'] = $userInfo['lastname']; $bill['first_name'] = $userInfo['firstname']; $bill['user_email'] = $userInfo['email']; $keys = array_keys($bill); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($bill as $key => $value) { $bill[$key] = $db->Quote($value); } $values = implode(',', $bill); $query = "INSERT INTO `#__vm_order_user_info` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } //Insert the itme table(#__vm_order_item) $item = array(); $item['order_id'] = $order_id; $item['user_info_id'] = $user_info_id; $item['vendor_id'] = $vendor_id; //get the product info $vm = oseMscAddon::getExtInfo($msc_id, 'vm', 'obj'); $query = " SELECT * FROM `#__vm_product` WHERE `product_id` = '{$vm->product_id}' "; $db->setQuery($query); $product = $db->loadObject(); $item['product_id'] = $vm->product_id; $item['order_item_sku'] = $product->product_sku; $item['order_item_name'] = $product->product_name; $item['product_quantity'] = '1'; $item['product_item_price'] = $order_subtotal; $item['product_final_price'] = $order_total; $item['order_item_currency'] = !empty($payment->currency) ? $payment->currency : "USD"; $item['order_status'] = 'C'; $item['cdate'] = time(); $keys = array_keys($item); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($item as $key => $value) { $item[$key] = $db->Quote($value); } $values = implode(',', $item); $query = "INSERT INTO `#__vm_order_item` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Done'); return $result; }
function getAddons() { $result = array(); $type = JRequest::getCmd('addon_type', null); if (empty($type)) { oseExit(); } $items = oseMscAddon::getAddonList($type, true, null); if (count($items) < 1) { $result['total'] = 0; $result['results'] = array(); } else { $result['total'] = count($items); $result['results'] = $items; } $result = oseJson::encode($result); oseExit($result); }
private static function saveOS( $params ) { $result = array(); $post = JRequest::get('post'); $member_id = $params['member_id']; $payment_method = $params['payment_method']; //oseExit($params); JRequest::setVar('member_id',$member_id); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } $params = array(); $paymentCart = oseMscPublic::getCart(); $subtotal = $paymentCart->getSubtotal(); $items = $paymentCart->get('items'); $osePaymentCurrency = $paymentCart->get('currency'); $payment = oseRegistry::call('payment'); $keys = array_keys($items); $payment_mode = $paymentCart->getParams('payment_mode'); $order_number = $payment->generateOrderNumber( $member_id ); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $subtotal; $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $params['payment_serial_number'] = substr($order_number,0,20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; //$paymentOrder->__construct('#__osemsc_order_item'); $params['params'] = array(); foreach($items as $item) { $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); $paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $price = $paymentInfo->a3; if($payment_mode == 'a') { if($paymentInfo->has_trial) { $price = $paymentInfo->a1; } } $price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $params['params'] = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); } //oseExit($params['params']); $params['params']['total'] = $paymentCart->get('total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['next_subtotal'] = $paymentCart->get('next_subtotal'); $params['params'] = oseJSON::encode($params['params']); //$config = oseRegistry::call('msc')->getConfig('payment','obj'); //$params['payment_from'] = $config->payment_system; $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if($updated) { $order_id = $updated; JRequest::setVar('order_id',$order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } //$paymentOrder->__construct('#__osemsc_order_item'); foreach($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); $paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $price = $paymentInfo->a3; if($payment_mode == 'a') { if($paymentInfo->has_trial) { $price = $paymentInfo->a1; } } $price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $itemParams['entry_type'] = oseObject::getValue($item,'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); //$itemParams['msc_id'] = $msc_id; $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); if ( $paymentInfo->payment_mode == $payment_mode || $paymentInfo->payment_mode == 'b') { $itemParams['payment_mode'] = $payment_mode; } else { $itemParams['payment_mode'] = $paymentInfo->payment_mode; } $updated = $paymentOrder->generateOrderItem($order_id,oseObject::getValue($item,'entry_id'), $itemParams); } //$paymentOrder->__construct('#__osemsc_order'); if($updated) { /* $vmorder=self::AddVmOrder($msc_id,$params,$order_number,$paymentInfo); if(!$vmorder['success']) { return $vmorder; } */ $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Order Generate Error'); } return $result; }
function createOrder() { $result = array(); $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('DONE'); $post = JRequest::get('post'); $msc_id = $post['msc_id']; $msc_option = $post['msc_option']; $user_id = $post['user_id']; $cart = oseMscPublic::getCart(); // get current item $cCart = $cart->cart; $cart->init(); $cart->__construct(); $cart->updateParams('payment_mode', 'm'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id, $cart->get('currency'), 0); $nItem = array('entry_id' => $msc_id, 'entry_type' => 'msc', 'msc_option' => $msc_option); $cart->addItem($nItem['entry_id'], $nItem['entry_type'], $nItem); $cart->update(); oseMscAddon::runAction('register.payment.save', array('member_id' => $user_id, 'payment_method' => 'none'), true, false); return $result; }
private static function saveOS($params) { $result = array(); $member_id = $params['member_id']; $payment_method = $params['payment_method']; JRequest::setVar('member_id', $member_id); if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error1'); return $result; } $params = array(); $paymentCart = $cart = oseRegistry::call('payment')->getInstance('Cart'); $paymentCart->refreshCartItems($paymentCart->get('items'), $paymentCart->get('currency')); $osePaymentCurrency = $paymentCart->get('currency'); $payment_mode = $paymentCart->getParams('payment_mode'); $subtotal = $paymentCart->getSubtotal(); if (empty($payment_mode)) { $payment_mode = oseMscPublic::savePaymentMode(); } $items = $paymentCart->get('items'); $oneItem = $items[0]; $payment = oseRegistry::call('payment'); $keys = array_keys($items); $order_number = $payment->generateOrderNumber($member_id); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $paymentCart->get('total'); $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime(); $params['payment_serial_number'] = substr($order_number, 0, 20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; $params['payment_from'] = 'system_reg'; $params['params'] = array(); $params['params']['start_date'] = oseObject::getValue($oneItem, 'start_date', null); $params['params']['expired_date'] = oseObject::getValue($oneItem, 'expired_date', null); $params['params']['total'] = $paymentCart->get('total'); $params['params']['next_total'] = $paymentCart->get('next_total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['coupon_user_id'] = $paymentCart->getParams('coupon_user_id'); $params['params']['gross_tax'] = $paymentCart->getTaxParams('amount'); $params['params']['next_gross_tax'] = $paymentCart->getTaxParams('next_amount'); $params['params']['vat_number'] = $paymentCart->getTaxParams('vat_number'); $params['params']['timestamp'] = uniqid("{$member_id}_", true); $params['params']['returnUrl'] = $paymentCart->getParams('returnUrl'); if ($payment_mode == 'a') { $params['params']['has_trial'] = oseObject::getValue($oneItem, 'has_trial', 0); } else { $params['params']['has_trial'] = 0; } $sisow_issuerid = JRequest::getVar('sisow_issuerid'); if ($sisow_issuerid) { $params['params']['sisow_issuerid'] = $sisow_issuerid; } $sisow_payment = JRequest::getVar('sisow_payment'); if ($sisow_payment) { $params['params']['sisow_payment'] = $sisow_payment; } $params['params']['a1'] = $paymentCart->get('total'); $params['params']['p1'] = oseObject::getValue($oneItem, 'p1', 0); $params['params']['t1'] = oseObject::getValue($oneItem, 't1'); $params['params']['a3'] = $paymentCart->get('next_total'); $params['params']['p3'] = oseObject::getValue($oneItem, 'p3', 0); $params['params']['t3'] = oseObject::getValue($oneItem, 't3'); $params['params'] = oseJSON::encode($params['params']); $list = oseMscAddon::getAddonList('register_order', false, 1, 'obj'); foreach ($list as $addon) { $action_name = 'register_order.' . $addon->name . '.add'; $params = oseMscAddon::runAction($action_name, $params); } $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if ($updated) { $order_id = $updated; $result['order_id'] = $order_id; JRequest::setVar('order_id', $order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error2'); return $result; } foreach ($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item, 'entry_type'); switch ($entry_type) { case ('license'): $license_id = oseObject::getValue($item, 'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id, 'obj'); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case ('msc'): $msc_id = oseObject::getValue($item, 'entry_id'); break; } $msc_option = oseObject::getValue($item, 'msc_option'); if (oseObject::getValue($item, 'eternal')) { $itemParams['payment_mode'] = 'm'; } else { $itemParams['payment_mode'] = $payment_mode; } $price = oseObject::getValue($item, 'a3'); if ($payment_mode == 'a') { if (oseObject::getValue($item, 'has_trial')) { $price = oseObject::getValue($item, 'a1'); } } $itemParams['entry_type'] = oseObject::getValue($item, 'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item, 'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime(); $price_params = $payment->generateOrderParams($msc_id, $price, $payment_mode, $msc_option); $price_params['start_date'] = oseObject::getValue($item, 'start_date', null); $price_params['expired_date'] = oseObject::getValue($item, 'expired_date', null); $price_params['recurrence_mode'] = oseObject::getValue($item, 'recurrence_mode', 'period'); $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj'); $paymentInfo = oseObject::getValue($paymentInfos, $msc_option); $updated = $paymentOrder->generateOrderItem($order_id, oseObject::getValue($item, 'entry_id'), $itemParams); } if ($updated) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Order Generate Error'); } $emailConfig = oseMscConfig::getConfig('email', 'obj'); if (!empty($emailConfig->order_notification)) { $db = oseDB::instance(); $where = array(); $where[] = '`order_id` = ' . $db->Quote($order_id); $orderInfo = $paymentOrder->getOrder($where, 'obj'); $memEmail = oseRegistry::call('member')->getInstance('Email'); $receipt = $memEmail->getOrderNotification($orderInfo);//print_r($receipt);exit; $memEmail->sendToAdminGroup($receipt, $emailConfig->admin_group); } return $result; }
protected function generateMscIdOptionJS() { $list = oseMscPublic::getList(); $cart = oseMscPublic::getCart(); $selectedMsc = oseMscAddon::runAction('register.msc.getSelectedMsc', array()); $options = array(); $msc = oseRegistry::call('msc'); foreach ($list as $key => $entry) { $msc_id = oseObject::getValue($entry, 'id'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array_merge($options, $option); } $currency = oseMscPublic::getCurrency(); $mscList = array('total' => count($list), 'results' => $list); $mscOptions = array('total' => count($options), 'results' => $options); $currency = array('total' => count($currency), 'results' => $currency); $output = "var getMscList = function() {return " . oseJson::encode($mscList) . "};"; $output .= "\r\n"; $output .= "var getMscOption = function() {return " . oseJson::encode($mscOptions) . "};"; return $output; }
private static function saveOS( $params ) { $result = array(); //$post = JRequest::get('post'); $member_id = $params['member_id']; $payment_method = $params['payment_method']; //oseExit($params); JRequest::setVar('member_id',$member_id); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error1'); return $result; } $params = array(); //$paymentCart = oseMscPublic::getCart(); $paymentCart = $cart = oseRegistry::call('payment')->getInstance('Cart'); $paymentCart->refreshCartItems($paymentCart->get('items'),$paymentCart->get('currency')); $osePaymentCurrency = $paymentCart->get('currency'); $payment_mode = $paymentCart->getParams('payment_mode'); $subtotal = $paymentCart->getSubtotal(); if(empty($payment_mode)) { $payment_mode = oseMscPublic::savePaymentMode(); } $items = $paymentCart->get('items'); $oneItem = $items[0]; $payment = oseRegistry::call('payment'); $keys = array_keys($items); //$payment_mode = $paymentCart->getParams('payment_mode'); $order_number = $payment->generateOrderNumber( $member_id ); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $paymentCart->get('total'); $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $params['payment_serial_number'] = substr($order_number,0,20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; $params['payment_from'] = 'system_reg'; $params['params'] = array(); $params['params']['start_date'] = oseObject::getValue($oneItem,'start_date',null); $params['params']['expired_date'] = oseObject::getValue($oneItem,'expired_date',null); $params['params']['total'] = $paymentCart->get('total'); if($paymentCart->getParams('coupon_range2') == 'all') { $params['params']['next_total'] = $params['params']['total']; } else { $params['params']['next_total'] = $paymentCart->get('next_total'); // } //$params['params']['next_total'] = $params['params']['total'];//$paymentCart->get('next_total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['coupon_user_id'] = $paymentCart->getParams('coupon_user_id'); $params['params']['gross_tax'] = $paymentCart->getTaxParams('amount'); $params['params']['next_gross_tax'] = $paymentCart->getTaxParams('next_amount'); $params['params']['vat_number'] = $paymentCart->getTaxParams('vat_number'); $params['params']['timestamp'] = uniqid("{$member_id}_",true); $params['params']['returnUrl'] = $paymentCart->getParams('returnUrl'); if($payment_mode == 'a') { $params['params']['has_trial'] = oseObject::getValue($oneItem,'has_trial',0); } else { $params['params']['has_trial'] = 0; } $params['params']['a1'] = $paymentCart->get('total'); $params['params']['p1'] = oseObject::getValue($oneItem,'p1',0); $params['params']['t1'] = oseObject::getValue($oneItem,'t1'); $params['params']['a3'] = $paymentCart->get('next_total'); $params['params']['p3'] = oseObject::getValue($oneItem,'p3',0); $params['params']['t3'] = oseObject::getValue($oneItem,'t3'); $params['params'] = oseJSON::encode($params['params']); $list = oseMscAddon :: getAddonList('register_order', false, 1, 'obj'); foreach($list as $addon) { $action_name= 'register_order.'.$addon->name.'.add'; //echo $action_name; $params = oseMscAddon :: runAction($action_name, $params); } $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if($updated) { $order_id = $updated; $result['order_id'] = $order_id; JRequest::setVar('order_id',$order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error2'); return $result; } //$paymentOrder->__construct('#__osemsc_order_item'); foreach($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); //$paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); //$paymentInfo = oseObject::getValue($paymentInfos,$msc_option); if ( oseObject::getValue($item,'eternal')) { $itemParams['payment_mode'] = 'm'; } else { $itemParams['payment_mode'] = $payment_mode; } $price = oseObject::getValue($item,'a3'); if($payment_mode == 'a') { if(oseObject::getValue($item,'has_trial')) { $price = oseObject::getValue($item,'a1'); } } //$price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $itemParams['entry_type'] = oseObject::getValue($item,'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); $price_params['start_date'] = oseObject::getValue($item,'start_date',null); $price_params['expired_date'] = oseObject::getValue($item,'expired_date',null); $price_params['recurrence_mode'] = oseObject::getValue($item,'recurrence_mode','period'); $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $updated = $paymentOrder->generateOrderItem($order_id,oseObject::getValue($item,'entry_id'), $itemParams); } //$paymentOrder->__construct('#__osemsc_order'); if($updated) { /* $vmorder=self::AddVmOrder($msc_id,$params,$order_number,$paymentInfo); if(!$vmorder['success']) { return $vmorder; } */ $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Order Generate Error'); } return $result; }
public static function save() { $post = JRequest :: get('post'); $result = array (); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText :: _('Member Information Updated'); $user = JFactory :: getUser(); $member_id = $user->id; $array = array (); $array['username'] = $post['username']; $array['name'] = $post['firstname'] . ' ' . $post['lastname']; $array['password'] = $post['password']; $array['password2'] = $post['password2']; $array['email'] = $post['email']; if ($user->guest) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('You are not a member!'); $isNew = true; return $result; } else { $isNew = false; $member_id = $user->id; } $exists = $this->checkEmail($array['email'], $member_id); if ($exists == true) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Email already exists.'); $isNew = true; return $result; } $user_id = $member_id; $username = $post['username']; $updated = oseMscPublic :: uniqueUserName($username, $user_id); oseRegistry :: call('msc')->runAddonAction('member.billinginfo.save'); if (!$updated['success']) { return $updated; } $uid = self :: jvsave($member_id, $array); if ($isNew) { $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText :: _('Member Information Updated'); $result['member_id'] = $uid; return $result; } else { $member = oseRegistry :: call('member'); $member->instance($member_id); $updated = $member->updateUserInfo($post); if (!$updated) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Failed Updating Member Information'); $result['member_id'] = ''; } else { $list = oseMscAddon :: getAddonList('usersync', false, null, 'obj'); $params = array (); $params['member_id'] = $member_id; $params['allow_work'] = true; foreach ($list as $addon) { $action_name = 'usersync.' . $addon->name . '.juserSave'; $result = oseMscAddon :: runAction($action_name, $params); if (!$result['success']) { return $result; } } } return $result; } }
protected function activateMsc($params = array()) { if (empty($params)) { return array('success' => false); } $member_id = $params['member_id']; if (empty($member_id)) { return false; } $db = oseDB::instance(); $msc = oseRegistry::call('msc'); $member_id = $params['member_id']; $msc_id = $params['msc_id']; $order_id = $params['order_id']; $result = array(); $member = oseRegistry::call('member'); $member->instance($member_id); $updated = $member->joinMsc($msc_id); if ($updated) { $list = oseMscAddon::getAddonList('renew', false, 1, 'obj'); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'activate', 'renew'); $result = oseMscAddon::runAction($action_name, $params, true, false); if (!$result['success']) { self::cancelMsc($params); return $result; } } $userInfo = $member->getBasicInfo('obj'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); if ($ext->wel_email && !$this->isLicensee) { $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->wel_email, 'obj'); $variables = $email->getEmailVariablesWelcome($order_id, $msc_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendWel2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } $result = array(); $result['success'] = true; $result['title'] = $result['status'] = 'Done'; $result['content'] = $result['result'] = JText::_('MEMBERSHIP_JOIN_SUCCEED'); } else { $result['success'] = false; $result['title'] = $result['status'] = 'Error'; $result['content'] = $result['result'] = JText::_('MEMBERSHIP_JOIN_FAILED'); } return $result; }
function saveCart($post) { $result = array(); $result['success'] = true; $result['reload'] = false; $result['script'] = false; $result['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $result['content'] = JText::_('MEMBERSHIP_ACTIVATED_CONTINUE'); $juser = oseMscAddon::getPost('juser_', $post); $password1 = JRequest::getString('juser_password1', '', 'post', JREQUEST_ALLOWRAW); $password2 = JRequest::getString('juser_password2', '', 'post', JREQUEST_ALLOWRAW); if (oseObject::getValue($juser, 'firstname', false) && oseObject::getValue($juser, 'lastname', false)) { $juser['name'] = oseObject::getValue($juser, 'firstname', '') . ' ' . oseObject::getValue($juser, 'lastname', ''); } else { $juser['name'] = oseObject::getValue($juser, 'username', false); } $juser['password'] = $juser['password1'] = $password1; $juser['password2'] = $password2; $juser['email1'] = $juser['email']; $juser['email2'] = $juser['email']; // check unique username $list = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj'); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'formValidate', 'register'); $updated = oseMscAddon::runAction($action_name, array('inner' => true)); if (!$updated['success']) { return $updated; } } if (!$updated['success']) { return $updated; } // check empty password if (empty($juser['password'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('MUST_SUPPLY_PASSWORD'); return $result; } $register = oseMscPublic::juserRegister($juser); if (!oseObject::getValue($register, 'success', false)) { return $register; } else { $memConfig = oseMscConfig::getConfig('register', 'obj'); if ($memConfig->auto_login) { $result['reload'] = true; } $list1 = oseMscAddon::getAddonList('registerOS_header', false, 1, 'obj'); $list2 = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj'); $list3 = oseMscAddon::getAddonList('registerOS_footer', false, 1, 'obj'); $list = array_merge($list1, $list2, $list3); $user = oseObject::getValue($register, 'user'); $cart = oseMscPublic::getCart(); $items = $cart->get('items'); $item = $items[0]; $params = array(); $params['msc_id'] = oseMscPublic::getEntryMscId($item); $params['msc_option'] = oseObject::getValue($item, 'msc_option'); $params['payment_mode'] = $post['payment_payment_mode']; $params['member_id'] = $user->id; $params['payment_method'] = $post['payment_method']; foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'save', 'register'); $updated = oseMscAddon::runAction($action_name, $params); if (!$updated['success']) { return $updated; } } $emailConfig = oseMscConfig::getConfig('email', 'obj'); if (!empty($emailConfig->default_reg_email)) { $member = oseRegistry::call('member'); $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($emailConfig->default_reg_email, 'obj'); if (!empty($emailTempDetail)) { $variables = $email->getEmailVariablesRegistration($user->id); $variables['user'] = oseObject::setValue($variables['user'], 'password', $juser['password1']); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $user->email); if ($emailConfig->sendReg2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } } if ($memConfig->auto_login) { $isLogin = $this->login($juser['username'], $juser['password']); if (!$isLogin['success']) { $session = JFactory::getSession(); $return = $session->get('oseReturnUrl', base64_encode('index.php?option=com_osemsc&view=login')); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = $isLogin['content']; $result['returnUrl'] = $return; return $result; } } return $result; } }
public function joinMsc($msc_id) { $db = oseDB::instance(); $query = " SELECT COUNT(*) FROM `#__osemsc_member`" . " WHERE msc_id !={$msc_id} AND member_id = {$this->member_id}" . " AND status = 1"; $db->setQuery($query); $hasMsc = $db->loadResult(); if ($hasMsc > 0) { //return false; } $query = " SELECT * FROM `#__osemsc_member`" . " WHERE msc_id = {$msc_id} AND member_id = {$this->member_id}"; $db->setQuery($query); $item = oseDB::loadItem('obj'); if (!empty($item)) { $query = " UPDATE `#__osemsc_member`" . " SET `status` = 1, `notified` = '0', `notified2` = '0', `notified3` = '0' " . " WHERE msc_id = {$msc_id} AND member_id = {$this->member_id}"; $db->setQuery($query); if (!$db->query()) { return false; } return $msc_id; } else { $exts = oseMscAddon::getExtInfo($msc_id, 'payment'); foreach ($exts as $ext) { $eternal = $db->Quote(oseObject::getValue($ext, 'eternal')); break; } $eternal = empty($eternal) ? 0 : $eternal; $query = " INSERT INTO `#__osemsc_member` ( msc_id, member_id, eternal ) VALUES " . " ( {$msc_id},{$this->member_id}," . (int) $eternal . " ) "; $db->setQuery($query); if (!$db->query()) { return false; } return $db->insertid(); } }
public static function renew($params) { $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } unset($params['allow_work']); $db = oseDB::instance(); $post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = oseObject::getValue($params,'order_item_id'); if(empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Renew Msc: No Msc ID"); return $result; } $where = array(); $where[] = "order_item_id = {$order_item_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrderItem($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $msc = oseRegistry::call('msc'); $exts = $msc->getExtInfo($msc_id,'payment','obj'); $ext = $exts->{$curOrderParams->msc_option}; if(empty($ext)) { $result['success'] = false; $result['title'] = 'Done'; $result['content'] = JText::_('Fail Renewing Membership.'); return $result; } $config = $msc->getConfig('global','obj'); $manual_renew_mode = empty($ext->manual_renew_mode)?$config->manual_renew_mode:$ext->manual_renew_mode; $manual_to_automatic_mode = empty($ext->manual_to_automatic_mode)?$config->manual_to_automatic_mode:$ext->manual_to_automatic_mode; //oseExit($manual_renew_mode.'&'.$manual_to_automatic_mode); //oseExit($curOrder); //echo $manual_renew_mode."<br>"; //oseExit($ext); if($curOrder->payment_mode == 'm') { $updated = self::renewInManualMode($msc_id,$member_id,$manual_renew_mode,$curOrder,$ext); } else // current order payment mode is a! { $member = oseRegistry::call('member'); $member->instance($member_id); $memInfo = $member->getRenewMscInfo($msc_id,'obj'); //oseExit(oseDB::instance()->_sql); $memParams = oseJson::decode($memInfo->params); if(empty($memParams->order_items_id)) { $params['allow_work'] = true; oseMscAddon::runAction('join.order.save',$params,true,false); } $where = array(); $where[] = "order_item_id = {$memParams->order_item_id}"; $lastOrder = $payment->getOrderItem($where,'obj'); if($lastOrder->payment_mode == 'm') // m 2 a { $updated = self::renewInAutoMaticMode($msc_id,$member_id,$manual_to_automatic_mode,$curOrder,$ext); } else // a 2 a extend { $updated = self::renewInAutoMaticMode($msc_id,$member_id,'extend',$curOrder,$ext); } } return $updated; }
function cancelOrder() { $result = array(); $result['success']= false; $result['title']= 'Error'; $result['content']= 'Error'; $db = oseDB::instance(); $msc= oseRegistry :: call('msc'); $member = oseRegistry::call('member'); $email = oseRegistry::call('member')->getInstance('Email'); $payment= oseRegistry :: call('payment'); $paymentOrder= $payment->getInstance('Order'); $my = JFactory::getUser(); $user_id = $my->id; $member->instance($user_id); $order_id = JRequest::getInt('order_id',0); $member->instance($user_id); $memberships = $member->getMemberOwnedMscInfo(false,1,'obj'); $query = " SELECT * FROM `#__osemsc_order`" ." WHERE `user_id` = '{$user_id}' AND `order_status` = 'confirmed' AND `payment_mode`='a'" ; $db->setQuery($query); $list = oseDB::loadList('obj'); $order_ids = array(); foreach($list as $oItem) { //$memParams = oseJson::decode($membership->params); $order_ids[$oItem->order_id] = $oItem->order_id; } if( !in_array( $order_id,$order_ids ) ) { $result['success']= false; $result['title']= 'Error'; $result['content']= JText :: _('Error No this authority: ').$order_id; } $where= array(); $where[]= "`order_id` = ".$db->Quote($order_id); $order = $payment->getOrder($where, 'obj'); //$result['success']= true; $result['payment_mode']= $order->payment_mode; $result['payment_method'] = $order->payment_method; //$msc_id = $order->entry_id; switch($order->payment_method) { case('paypal_cc') : if($order->payment_mode == 'a') { $config= oseMscConfig :: getConfig('payment', 'obj'); $updated = $paymentOrder->PaypalAPIDeleteProfile($order->payment_serial_number, substr($order->order_number, 0, 20), $user_id); if ($updated['success']==true) { $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; $result['content']= JText :: _('ERROR_CANCELLING_SUB_PLAN').' '.urldecode($order->payment_serial_number). "<br />".JText::_(' Error response from server: '). urldecode($updated['text']); } } break; case('paypal') : if($order->payment_mode == 'a') { $config= oseMscConfig :: getConfig('payment', 'obj'); if($config->paypal_mode == 'paypal_express') { $test_mode= $config->paypal_testmode; $paypal_email = $config->paypal_email; if($test_mode == true) { $url= "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $url= "https://www.paypal.com/cgi-bin/webscr"; } $url = $url.'?cmd=_subscr-find&alias='.$paypal_email; $result['success']= true; $result['payment_method'] = 'paypal'; $result['paypal']= 'ipn'; $result['url']= $url; return $result; } else { //$result['payment_method'] = 'paypal_pro'; $updated= $paymentOrder->PaypalAPIDeleteProfile($order->payment_serial_number, substr($order->order_number, 0, 20), $user_id); if ($updated['success']==true) { $paymentOrder->updateOrder($order->order_id,'cancelled'); $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; $result['content']= JText :: _('ERROR_CANCELLING_SUB_PLAN').' '.urldecode($order->payment_serial_number). "<br />".JText::_(' Error response from server: '). urldecode($updated['text']); } } } break; case('authorize') : if($order->payment_mode == 'a') { $updated= $paymentOrder->AuthorizeARBDeleteProfile($order->payment_serial_number, substr($order->order_number, 0, 20), $user_id); if ($updated['success']==true) { $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; if (strpos($order->payment_serial_number, "_")>0) { $tmpUID = explode("_", $order->payment_serial_number); if ($tmpUID[0] == $order->user_id) { $result['content']= JText :: _('CREDIT_CARD_EXPIRE_BEFORE_SUB_ENDS'); } else { $result['content']= JText :: _('ERROR_CANCELLING_SUB_PLAN').' '.urldecode($order->payment_serial_number); } } else { $result['content']= $updated['text']; } } } break; case('eway'): if($order->payment_mode == 'a') { $updated= $paymentOrder->eWayDeleteProfile($order); if ($updated['success']==true) { $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; $result['content']= $updated['text'];//JText :: _('Error cancelling subscription plan! Please contact the web administrator and quote this profile ID: ').urldecode($order->payment_serial_number); } } break; case('beanstream') : if($order->payment_mode == 'a') { $updated= $paymentOrder->BeanStreamDeleteProfile($order); if ($updated['success']==true) { $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; $result['content']= $updated['text'];//JText :: _('Error cancelling subscription plan! Please contact the web administrator and quote this profile ID: ').urldecode($order->payment_serial_number); } } break; case('epay') : if($order->payment_mode == 'a') { require_once(OSEMSC_B_PATH.DS.'libraries'.DS.'epaysoap.php'); $epay = new EpaySoap(); $config = oseMscConfig::getConfig('payment','obj'); $merchantnumber = $config->epay_merchantnumber; $subscriptionid = $order->payment_serial_number; $updated= $epay->deleteSubscription($merchantnumber, $subscriptionid); if($updated['deletesubscriptionResult'] == true && $result['epayresponse'] == '-1') //$updated= $paymentOrder->BeanStreamDeleteProfile($order); //if ($updated['success']==true) { $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; $result['content']= $updated['text'];//JText :: _('Error cancelling subscription plan! Please contact the web administrator and quote this profile ID: ').urldecode($order->payment_serial_number); } } break; case('2co') : if($order->payment_mode == 'a') { $updated= $paymentOrder->twoCheckoutDeleteProfile($order); if ($updated['success']==true) { $email->sendCancelOrderEmail(array('orderInfo'=>$order)); $result['success']= true; $result['title']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY_TITLE'); $result['content']= JText :: _('SUB_PLAN_CANCEL_SUCCESSFULLY'); } else { $result['success']= false; $result['title']= 'Error'; $result['content']= $updated['text'];//JText :: _('Error cancelling subscription plan! Please contact the web administrator and quote this profile ID: ').urldecode($order->payment_serial_number); } } break; default : $orderItems = $paymentOrder->getOrderItems($order->order_id,'obj'); foreach($orderItems as $key=>$orderItem) { if($orderItem->entry_type == 'msc') { $msc_id = $orderItem->entry_id; $params= oseRegistry :: call('member')->getAddonParams($msc_id, $user_id, $order_id); $updated= $msc->runAddonAction('member.msc.cancelMsc', $params); if(!$updated['success']) { return $updated; } } } break; } if ($result['success']==true) { $orderItems = $paymentOrder->getOrderItems($order->order_id,'obj'); foreach($orderItems as $key=>$orderItem) { if($orderItem->entry_type == 'msc') { $msc_id = $orderItem->entry_id; $arr = array('allow_work'=>true,'msc_id'=>$msc_id,'member_id'=>$user_id,'master'=>true); oseMscAddon::runAction('join.history.manualCancelOrder', $arr); } } $paymentOrder->updateOrder($order_id, 'cancelled', $params= array('payment_mode'=>'a')); //$paymentOrder->updateMembership($msc_id, $user_id, $order_id, 'm'); } return $result; }
function getEmailVariablesReceipt($order_id, $user_id = null) { $db = oseDB::instance(); $content = array(); // get Order Info $payment = oseRegistry::call('payment'); $where = array(); $where[] = "order_id = {$order_id}"; $orderInfo = $payment->getOrder($where, 'obj'); $orderInfoParams = oseJson::decode($orderInfo->params); $paymentInfo = oseMscAddon::getExtInfo($orderInfo->entry_id, 'payment', 'obj'); $member = oseRegistry::call('member'); $member->instance($orderInfo->user_id); $userInfo = $member->getBillingInfo('obj'); $userInfo->email = $userInfo->user_email; $orderInfo->subtotal = $orderInfoParams->subtotal; $orderInfo->total = $orderInfoParams->recurrence_times > 1 ? $orderInfoParams->next_total : $orderInfoParams->total; $orderInfo->discount = isset($orderInfoParams->discount) ? $orderInfoParams->discount : 0; $gw = $payment->getInstance('GateWay'); $gwInfo = $gw->getGWInfo($orderInfo->payment_method); if (!empty($gwInfo)) { if ($gwInfo->is_cc) { $orderInfo->payment_method = 'Credit Card'; } } $orderInfo->itemlist = $this->generateOrderTable($order_id, $orderInfo->user_id); if ($orderInfo->payment_mode == 'm') { $orderInfo->payment_mode = JText::_('Manual Billing'); $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'gross_tax', '0.00'); if ($orderInfo->gross_tax > 0) { $orderInfo->vat_number = oseObject::getValue($orderInfoParams, 'vat_number'); } } else { $orderInfo->payment_mode = JText::_('Automatic Billing'); $params = oseJson::decode($orderInfo->params); $price = null; if (oseObject::getValue($orderInfoParams, 'has_trial', 0)) { if (oseObject::getValue($orderInfoParams, 'recurrence_times', 0) <= 1) { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'gross_tax', '0.00'); } else { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'next_gross_tax', '0.00'); } } else { if (oseObject::getValue($orderInfoParams, 'recurrence_times', 0) <= 2) { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'gross_tax', '0.00'); } else { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'next_gross_tax', '0.00'); } } $orderInfo->vat_number = oseObject::getValue($orderInfoParams, 'vat_number'); $orderInfo->recurring_price = $orderInfo->payment_currency . ' ' . $orderInfoParams->next_total; $orderInfo->recurring_frequency = $orderInfoParams->p3 . ' ' . $orderInfoParams->t3; } $query = "SELECT entry_id FROM `#__osemsc_order_item` WHERE `order_id` = " . $order_id; $db->setQuery($query); $msc_id = $db->loadResult(); $query = " SELECT *,DATE_SUB(`expired_date`,INTERVAL 1 DAY) AS `real_expired_date` " . " FROM `#__osemsc_member`" . " WHERE member_id = {$orderInfo->user_id} AND msc_id={$msc_id}"; $db->setQuery($query); $memberInfo = oseDB::loadItem('obj'); $query = "SELECT * FROM `#__osemsc_acl` WHERE `id` = {$msc_id}"; $db->setQuery($query); $mscInfo = oseDB::loadItem('obj'); $memberInfo->msc_title = $mscInfo->title; $memberInfo->msc_des = $mscInfo->description; $orderInfo->current_date = oseHTML::getDateTime(); $globalConfig = oseRegistry::call('msc')->getConfig('global', 'obj'); if (!empty($globalConfig->DateFormat)) { $memberInfo->start_date = date($globalConfig->DateFormat, strtotime($memberInfo->start_date)); $orderInfo->create_date = date($globalConfig->DateFormat, strtotime($orderInfo->create_date)); $orderInfo->current_date = date($globalConfig->DateFormat, strtotime($orderInfo->current_date)); } $content['user'] = $userInfo; $content['order'] = $orderInfo; $content['profile'] = $member->getProfile(); $content['member'] = $memberInfo; return $content; }
function generateOrder($member_id, $payment_method, $orderPaymentInfo) { return oseRegistry::call('msc')->runAddonAction('register.payment.save', array('member_id' => $member_id, 'payment_method' => $payment_method), true, false); $result = array(); if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } $paymentOrder = oseRegistry::call('payment')->getInstance('Order'); $params = array(); $items = $orderPaymentInfo['items']; unset($orderPaymentInfo['items']); $order_number = $paymentOrder->generateOrderNumber($member_id); $orderPaymentInfo['order_number'] = $order_number; $orderPaymentInfo['entry_type'] = 'msc_list'; $orderPaymentInfo['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $orderPaymentInfo['payment_serial_number'] = substr($orderPaymentInfo['order_number'], 0, 20); $orderPaymentInfo['payment_method'] = 'system'; $orderPaymentInfo['payment_from'] = 'system_admin'; $orderPaymentInfo['payment_mode'] = 'm'; oseObject::setParams($orderPaymentInfo, array('time_stamp' => uniqid("{$member_id}_", true))); // Extra Order Params Updating Function $list = oseMscAddon::getAddonList('register_order', true, 1, 'obj'); foreach ($list as $addon) { $action_name = 'register_order.' . $addon->name . '.add'; //echo $action_name; $params = oseMscAddon::runAction($action_name, $orderPaymentInfo['params'], true, false); } // generate Order $updated = $paymentOrder->generateOrder('', $member_id, $orderPaymentInfo); if (!$updated) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } // generate orer item // in the backend, only manual payment $order_id = $result['order_id'] = $updated; $payment_mode = 'm'; foreach ($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item, 'entry_type'); switch ($entry_type) { case ('license'): $license_id = oseObject::getValue($item, 'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id, 'obj'); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case ('msc'): $msc_id = oseObject::getValue($item, 'entry_id'); break; } $msc_option = oseObject::getValue($item, 'msc_option'); if (oseObject::getValue($item, 'eternal')) { $itemParams['payment_mode'] = 'm'; } else { $itemParams['payment_mode'] = 'm'; } $price = oseObject::getValue($item, 'a3'); if ($payment_mode == 'a') { if (oseObject::getValue($item, 'has_trial')) { $price = oseObject::getValue($item, 'a1'); } } $itemParams['entry_type'] = oseObject::getValue($item, 'entry_type'); $itemParams['payment_price'] = 0;//oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $orderPaymentInfo['payment_currency']; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $paymentOrder->generateOrderParams($msc_id, $price, $payment_mode, $msc_option); $price_params['start_date'] = oseObject::getValue($item, 'start_date', null); $price_params['expired_date'] = oseObject::getValue($item, 'expired_date', null); $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj'); $paymentInfo = oseObject::getValue($paymentInfos, $msc_option); $updated = $paymentOrder->generateOrderItem($order_id, oseObject::getValue($item, 'entry_id'), $itemParams); } if ($updated) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Order Generate Error'); } return $result; }
function updateAddon() { oseMscAddon::updateAddonSimple(); }
* it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * @Copyright Copyright (C) 2010- Open Source Excellence (R) */ defined('_JEXEC') or die("Direct Access Not Allowed"); $headerObjs= oseMscAddon :: getAddonList('paymentOS', false, null, 'obj'); oseMscAddon::loadAddons($headerObjs); oseHTML::script(OSEMSCFOLDER."/views/payment/js/js.payment.js",'1.6'); ?> <script type="text/javascript"> Ext.onReady(function(){ var headerObjs = <?php echo oseJson::encode($headerObjs);?>; var oseViewPaymentfp = oseMsc.payment.buildForm(); oseMsc.payment.fp = new oseMsc.payment.form(oseViewPaymentfp); //alert(oseMsc.payment.fp.fp.toSource(0)) oseMsc.payment.fp.onLoadAddons(headerObjs,'payment',false); oseMsc.payment.fp.setClickBtnAction('submitBtnOk'); oseMsc.payment.fp.render('ose-payment'); oseMsc.payment.fp.loadRegInfo();