Exemplo n.º 1
0
 public function parseNotification($post)
 {
     $response = array();
     $response['amount_paid'] = number_format($post['OutSum'], 2);
     $response['invoice'] = aecInvoiceHelper::InvoiceNumberfromId($post['InvId']);
     return $response;
 }
Exemplo n.º 2
0
 public function parseNotification($post)
 {
     $response = array();
     $response['invoice'] = aecInvoiceHelper::InvoiceNumberfromId($post['INVOICE']);
     $response['amount_paid'] = $post['AMOUNT'];
     return $response;
 }
Exemplo n.º 3
0
    // Make sure this really is expired
    if (!$metaUser->objSubscription->isExpired()) {
        return getView('access_denied');
    }
    $expired = strtotime($metaUser->objSubscription->expiration);
    $trial = strcmp($metaUser->objSubscription->status, 'Trial') === 0;
    if (!$trial) {
        $params = $metaUser->objSubscription->params;
        if (isset($params['trialflag'])) {
            $trial = 1;
        }
    }
}
$invoices = aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid);
if ($invoices) {
    $invoice = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($metaUser->userid);
} else {
    $invoice = null;
}
$expiration = AECToolbox::formatDate($expired);
$tmpl->setTitle(JText::_('EXPIRED_TITLE'));
$continue = false;
if ($tmpl->cfg['continue_button'] && $metaUser->hasSubscription) {
    $status = SubscriptionPlanHandler::PlanStatus($metaUser->focusSubscription->plan);
    if (!empty($status)) {
        $continue = true;
    }
}
$intro = 0;
if ($metaUser->hasSubscription) {
    if ($metaUser->objSubscription->status == "Expired") {
Exemplo n.º 4
0
 public function Settings()
 {
     $db = JFactory::getDBO();
     $settings = array();
     if (!empty($_POST['type']) && !empty($_POST['id']) && empty($_POST['edit'])) {
         $db = JFactory::getDBO();
         $settings['edit'] = array('hidden', 1);
         $settings['type'] = array('hidden', $_POST['type']);
         $fixed = array();
         switch ($_POST['type']) {
             case 'metauser':
                 $fixed = array('userid');
                 $object = new metaUserDB();
                 $s = AECToolbox::searchUser($_POST['id']);
                 if (!empty($s)) {
                     $_POST['id'] = $object->getIDbyUserid($s[0]);
                 } else {
                     $_POST['id'] = $object->getIDbyUserid((int) $_POST['id']);
                 }
                 break;
             case 'processor':
                 if (!is_numeric($_POST['id'])) {
                     $query = 'SELECT `id`' . ' FROM #__acctexp_config_processors' . ' WHERE `name` = \'' . (int) $_POST['id'] . '\'';
                     $db->setQuery($query);
                     $_POST['id'] = $db->loadResult();
                 }
                 $object = new processor();
                 break;
             case 'invoice':
                 if (!is_numeric($_POST['id'])) {
                     $_POST['id'] = aecInvoiceHelper::InvoiceIDfromNumber($_POST['id']);
                 }
                 $object = new Invoice();
                 break;
         }
         $object->load($_POST['id']);
         $vars = get_object_vars($object);
         $encoded = $object->declareParamFields();
         foreach ($vars as $k => $v) {
             if (is_null($k)) {
                 $k = "";
             }
             if ($k == 'id') {
                 $settings['id'] = array('hidden', $v);
             } elseif (in_array($k, $fixed)) {
                 $settings[$k] = array('p', $k, $k, $v);
             } elseif (in_array($k, $encoded)) {
                 $v = jsoonHandler::encode($v);
                 if ($v === "null") {
                     $v = "";
                 }
                 $settings[$k] = array('inputD', $k, $k, $v);
             } elseif (strpos($k, '_') !== 0) {
                 $settings[$k] = array('inputD', $k, $k, $v);
             }
         }
     } else {
         $settings['type'] = array('list', 'Item Type', 'The type of Item you want to edit');
         $settings['id'] = array('inputC', 'Item ID', 'Identification for your Item');
         $types = array('metauser' => 'MetaUser Information', 'processor' => 'Payment Processor', 'invoice' => 'Invoice');
         $typelist = array();
         foreach ($types as $type => $typename) {
             $typelist[] = JHTML::_('select.option', $type, $typename);
         }
         $settings['lists']['type'] = JHTML::_('select.genericlist', $typelist, 'type', 'size="3"', 'value', 'text', array());
     }
     return $settings;
 }
Exemplo n.º 5
0
 public function cancelEntity($invoice_number, $task)
 {
     $invoiceid = aecInvoiceHelper::InvoiceIDfromNumber($invoice_number, 0, true);
     $userid = '';
     if ($invoiceid) {
         $objInvoice = new Invoice();
         $objInvoice->load($invoiceid);
         $objInvoice->delete();
         if (strcmp($task, 'editMembership') == 0) {
             $userid = '&userid=' . $objInvoice->userid;
         }
     }
     aecRedirect('index.php?option=com_acctexp&task=' . $task . $userid, JText::_('REMOVED'));
 }
Exemplo n.º 6
0
        }
        $subscriptions[$usid] = $subscription;
        $subscriptions[$usid]->objPlan = new SubscriptionPlan();
        $subscriptions[$usid]->objPlan->load($subscription->plan);
        if (!empty($subscription->type)) {
            if (!in_array($subscription->type, $pplist)) {
                $pplist[] = $subscription->type;
            }
        }
    }
}
$pagesize = 15;
if (empty($page)) {
    $page = 0;
}
$invoiceList = aecInvoiceHelper::InvoiceIdList($metaUser->userid, $page * $pagesize, $pagesize);
$properties['invoice_pages'] = (int) ($invoiceno / $pagesize);
$properties['invoice_page'] = $page;
$invoices = array();
foreach ($invoiceList as $invoiceid) {
    $invoices[$invoiceid] = array();
    $invoice = new Invoice();
    $invoice->load($invoiceid);
    $rowstyle = '';
    $actionsarray = array();
    if (!in_array($invoice->method, $excludedprocs)) {
        $actionsarray[] = array('task' => 'invoicePrint', 'add' => 'invoice=' . $invoice->invoice_number . '&tmpl=component', 'text' => JText::_('HISTORY_ACTION_PRINT'), 'insert' => ' target="_blank" ', 'class' => 'btn');
        $actionsarray[] = array('task' => 'invoicePDF', 'add' => 'invoice=' . $invoice->invoice_number, 'text' => 'PDF', 'insert' => '', 'class' => 'btn');
    }
    if ($invoice->transaction_date == '0000-00-00 00:00:00' || $invoice->subscr_id) {
        if ($invoice->transaction_date == '0000-00-00 00:00:00') {
Exemplo n.º 7
0
 public function loadLatest($userid, $plan, $subscr = null)
 {
     if (!empty($subscr)) {
         $this->loadbySubscriptionId($subscr, $userid);
     }
     if (empty($this->id)) {
         $this->load(aecInvoiceHelper::lastClearedInvoiceIDbyUserID($userid, $plan));
     }
     if (empty($this->id)) {
         $this->load(aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($userid, $plan));
     }
 }
Exemplo n.º 8
0
 static function VerifyMetaUser($metaUser)
 {
     global $aecConfig;
     if (!$aecConfig->cfg['require_subscription']) {
         return true;
     }
     if ($metaUser->hasSubscription) {
         $result = $metaUser->objSubscription->verify($metaUser);
         if ($result == 'expired' || $result == 'pending') {
             $metaUser->setTempAuth();
         }
         return $result;
     }
     if (!empty($aecConfig->cfg['entry_plan'])) {
         $payment_plan = new SubscriptionPlan();
         $payment_plan->load($aecConfig->cfg['entry_plan']);
         $metaUser->establishFocus($payment_plan, 'free', false);
         $metaUser->focusSubscription->applyUsage($payment_plan->id, 'free', 1, 0);
         return AECToolbox::VerifyUser($metaUser->cmsUser->username);
     } else {
         $invoices = aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid);
         $metaUser->setTempAuth();
         if ($invoices) {
             $invoice = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($metaUser->userid);
             if ($invoice) {
                 return 'open_invoice';
             }
         }
         return 'subscribe';
     }
 }
Exemplo n.º 9
0
 public function exportMembers()
 {
     $db = JFactory::getDBO();
     foreach ($this->filter as $k => $v) {
         if (empty($v)) {
             $this->filter[$k] = array();
         }
     }
     // Assemble Database call
     if (!in_array('notconfig', $this->filter['status'])) {
         $where = array();
         if (!empty($this->filter['planid'])) {
             $where[] = '`plan` IN (' . implode(',', $this->filter['planid']) . ')';
         }
         $query = 'SELECT a.id, a.userid' . ' FROM #__acctexp_subscr AS a' . ' INNER JOIN #__users AS b ON a.userid = b.id';
         if (!empty($where)) {
             $query .= ' WHERE ( ' . implode(' OR ', $where) . ' )';
         }
         if (!empty($this->filter['status'])) {
             $stati = array();
             foreach ($this->filter['status'] as $status) {
                 $stati[] = 'LOWER( `status` ) = \'' . strtolower($status) . '\'';
             }
             if (!empty($where)) {
                 $query .= ' AND (' . implode(' OR ', $stati) . ')';
             } else {
                 $query .= ' WHERE (' . implode(' OR ', $stati) . ')';
             }
         }
         if (!empty($this->filter['orderby'])) {
             $query .= ' ORDER BY ' . $this->filter['orderby'] . '';
         }
     } else {
         $query = 'SELECT DISTINCT b.id AS `userid`' . ' FROM #__users as b' . ' WHERE b.id NOT IN (' . ' SELECT a.userid' . ' FROM #__acctexp_subscr as a);';
     }
     $db->setQuery($query);
     $descriptions = AECToolbox::rewriteEngineExplain($this->options['rewrite_rule']);
     $descarray = explode(';', $descriptions);
     $this->exphandler->putDescription($descarray);
     // Fetch Userlist
     $userlist = $db->loadObjectList();
     // Plans Array
     $plans = array();
     // Iterate through userlist
     if (!empty($userlist)) {
         foreach ($userlist as $entry) {
             $metaUser = new metaUser($entry->userid);
             if (!empty($entry->id)) {
                 $metaUser->moveFocus($entry->id);
             }
             if ($metaUser->hasSubscription) {
                 $planid = $metaUser->focusSubscription->plan;
                 if (!isset($plans[$planid])) {
                     $plans[$planid] = new SubscriptionPlan();
                     $plans[$planid]->load($planid);
                 }
                 $invoiceid = aecInvoiceHelper::lastClearedInvoiceIDbyUserID($metaUser->userid, $planid);
                 if ($invoiceid) {
                     $invoice = new Invoice();
                     $invoice->load($invoiceid);
                     $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser, $plans[$planid], $invoice);
                 } else {
                     $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser, $plans[$planid]);
                 }
             } else {
                 $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser);
             }
             $larray = explode(';', $line);
             // Remove whitespaces and newlines
             foreach ($larray as $larrid => $larrval) {
                 $larray[$descarray[$larrid]] = trim($larrval);
                 unset($larray[$larrid]);
             }
             $this->exphandler->putln($larray);
         }
     }
 }
Exemplo n.º 10
0
function processNotification($option, $processor)
{
    global $aecConfig;
    // Legacy naming support
    switch ($processor) {
        case 'vklix':
            $processor = 'viaklix';
            break;
        case 'auth':
            $processor = 'authorize';
            break;
        case '2co':
            $processor = '2checkout';
            break;
        case 'eps':
            $processor = 'epsnetpay';
            break;
    }
    if (!empty($aecConfig->cfg['debug_processor_notifications'])) {
        aecDebug("ResponseFunction:processNotification");
        aecDebug($_GET);
        aecDebug($_POST);
        aecDebug($_REQUEST);
        aecDebug(file_get_contents("php://input"));
    }
    $response = array();
    $response['fullresponse'] = aecPostParamClear($_POST);
    // parse processor notification
    $pp = new PaymentProcessor();
    if ($pp->loadName($processor)) {
        $pp->init();
        $response = array_merge($response, $pp->parseNotification($response['fullresponse']));
    } else {
        $eventlog = new eventLog();
        $eventlog->issue('processor loading failure', 'processor,loading,error', 'When receiving payment notification, tried to load processor: ' . $processor, 128);
        return;
    }
    // Get Invoice record
    if (!empty($response['invoice'])) {
        $id = aecInvoiceHelper::InvoiceIDfromNumber($response['invoice']);
    } else {
        $id = false;
        $response['invoice'] = 'empty';
    }
    if (!$id) {
        $short = JText::_('AEC_MSG_PROC_INVOICE_FAILED_SH');
        $event = '';
        $tags = '';
        if (isset($response['null'])) {
            if (isset($response['explanation'])) {
                $short = JText::_('AEC_MSG_PROC_INVOICE_ACTION_SH');
                $event .= $response['explanation'];
            } else {
                $event .= JText::_('AEC_MSG_PROC_INVOICE_ACTION_EV_NULL');
            }
            $tags .= 'invoice,processor,payment,null';
        } else {
            $event = sprintf(JText::_('AEC_MSG_PROC_INVOICE_FAILED_EV'), $processor, $response['invoice']);
            $tags = 'invoice,processor,payment,error';
        }
        $params = array();
        $eventlog = new eventLog();
        if (isset($response['null'])) {
            if (isset($response['error'])) {
                $eventlog->issue($short, $tags, $response['error'], 128, $params);
            } else {
                $eventlog->issue($short, $tags, $event, 8, $params);
            }
        } else {
            $eventlog->issue($short, $tags, $event, 128, $params);
            $error = 'Invoice Number not found. Invoice number provided: "' . $response['invoice'] . '"';
            $pp->notificationError($response, $error);
        }
        return;
    } else {
        $iFactory = new InvoiceFactory(null, null, null, null, $response['invoice']);
        $iFactory->processorResponse($response);
    }
}
Exemplo n.º 11
0
 public function executeCommand($command, $vars, $safe = false)
 {
     $result = '';
     switch ($command) {
         case 'rw_constant':
             if (isset($this->rewrite[$vars])) {
                 $result = $this->rewrite[$vars];
             }
             break;
         case 'data':
             if (empty($this->data)) {
                 return false;
             }
             $result = AECToolbox::getObjectProperty($this->data, $vars);
             break;
         case 'safedata':
             if (empty($this->data)) {
                 return false;
             }
             if (AECToolbox::getObjectProperty($this->data, $vars, true)) {
                 $result = AECToolbox::getObjectProperty($this->data, $vars);
             }
             break;
         case 'checkdata':
             if (empty($this->data)) {
                 return false;
             }
             $result = AECToolbox::getObjectProperty($this->data, $vars, true);
             break;
         case 'checkdata_notempty':
             if (empty($this->data)) {
                 return false;
             }
             $check = AECToolbox::getObjectProperty($this->data, $vars, true);
             if (AECToolbox::getObjectProperty($this->data, $vars, true)) {
                 $check = AECToolbox::getObjectProperty($this->data, $vars);
                 $result = !empty($check);
             }
             break;
         case 'metaUser':
             if (!is_object($this->data['metaUser'])) {
                 return false;
             }
             // We also support dot notation for the vars,
             // so explode if that is what the admin wants here
             if (!is_array($vars) && strpos($vars, '.') !== false) {
                 $temp = explode('.', $vars);
                 $vars = $temp;
             } elseif (!is_array($vars)) {
                 return false;
             }
             $result = $this->data['metaUser']->getProperty($vars);
             break;
         case 'invoice_count':
             if (!is_object($this->data['metaUser'])) {
                 return false;
             }
             return aecInvoiceHelper::InvoiceCountbyUserID($this->data['metaUser']->userid);
             break;
         case 'invoice_count_paid':
             if (!is_object($this->data['metaUser'])) {
                 return false;
             }
             return aecInvoiceHelper::PaidInvoiceCountbyUserID($this->data['metaUser']->userid);
             break;
         case 'invoice_count_unpaid':
             if (!is_object($this->data['metaUser'])) {
                 return false;
             }
             return aecInvoiceHelper::UnpaidInvoiceCountbyUserID($this->data['metaUser']->userid);
             break;
         case 'jtext':
             $result = JText::_($vars);
             break;
         case 'constant':
             if (defined($vars)) {
                 $result = constant($vars);
             } else {
                 $result = JText::_($vars);
             }
             break;
         case 'global':
             if (is_array($vars)) {
                 if (isset($vars[0]) && isset($vars[1])) {
                     $call = strtoupper($vars[0]);
                     $v = $vars[1];
                     $allowed = array('SERVER', 'GET', 'POST', 'FILES', 'COOKIE', 'SESSION', 'REQUEST', 'ENV');
                     if (in_array($call, $allowed)) {
                         switch ($call) {
                             case 'SERVER':
                                 if (isset($_SERVER[$v]) && !$safe) {
                                     $result = $_SERVER[$v];
                                 }
                                 break;
                             case 'GET':
                                 if (isset($_GET[$v])) {
                                     $result = $_GET[$v];
                                 }
                                 break;
                             case 'POST':
                                 if (isset($_POST[$v])) {
                                     $result = $_POST[$v];
                                 }
                                 break;
                             case 'FILES':
                                 if (isset($_FILES[$v]) && !$safe) {
                                     $result = $_FILES[$v];
                                 }
                                 break;
                             case 'COOKIE':
                                 if (isset($_COOKIE[$v])) {
                                     $result = $_COOKIE[$v];
                                 }
                                 break;
                             case 'SESSION':
                                 if (isset($_SESSION[$v])) {
                                     $result = $_SESSION[$v];
                                 }
                                 break;
                             case 'REQUEST':
                                 if (isset($_REQUEST[$v])) {
                                     $result = $_REQUEST[$v];
                                 }
                                 break;
                             case 'ENV':
                                 if (isset($_ENV[$v]) && !$safe) {
                                     $result = $_ENV[$v];
                                 }
                                 break;
                         }
                     }
                 }
             } else {
                 if (isset($GLOBALS[$vars])) {
                     $result = $GLOBALS[$vars];
                 }
             }
             break;
         case 'condition':
             if (empty($vars[0]) || !isset($vars[1])) {
                 if (isset($vars[2])) {
                     $result = $vars[2];
                 } else {
                     $result = '';
                 }
             } elseif (isset($vars[1])) {
                 $result = $vars[1];
             } else {
                 $result = '';
             }
             break;
         case 'hastext':
             $result = strpos($vars[0], $vars[1]) !== false ? 1 : 0;
             break;
         case 'uppercase':
             $result = strtoupper($vars);
             break;
         case 'lowercase':
             $result = strtoupper($vars);
             break;
         case 'concat':
             $result = implode($vars);
             break;
         case 'date':
             $result = date($vars[0], strtotime($vars[1]));
             break;
         case 'date_distance':
             $result = round($vars - (int) gmdate('U'));
             break;
         case 'date_distance_days':
             $result = round(($vars - (int) gmdate('U')) / 86400);
             break;
         case 'crop':
             if (isset($vars[2])) {
                 $result = substr($vars[0], (int) $vars[1], (int) $vars[2]);
             } else {
                 $result = substr($vars[0], (int) $vars[1]);
             }
             break;
         case 'pad':
             if (isset($vars[3])) {
                 $result = str_pad($vars[0], (int) $vars[1], $vars[2], JText::_("STR_PAD_" . strtoupper($vars[3])));
             } elseif (isset($vars[2])) {
                 $result = str_pad($vars[0], (int) $vars[1], $vars[2]);
             } else {
                 $result = str_pad($vars[0], (int) $vars[1]);
             }
             break;
         case 'chunk':
             $chunks = str_split($vars[0], (int) $vars[1]);
             if (isset($vars[2])) {
                 $result = implode($vars[2], $chunks);
             } else {
                 $result = implode(' ', $chunks);
             }
             break;
         case 'compare':
             if (isset($vars[2])) {
                 $result = AECToolbox::compare($vars[1], $vars[0], $vars[2]);
             } else {
                 $result = 0;
             }
             break;
         case 'math':
             if (isset($vars[2])) {
                 $result = AECToolbox::math($vars[1], (double) $vars[0], (double) $vars[2]);
             } else {
                 $result = 0;
             }
             break;
         case 'randomstring':
             $result = AECToolbox::randomstring((int) $vars);
             break;
         case 'randomstring_alphanum':
             $result = AECToolbox::randomstring((int) $vars, true);
             break;
         case 'randomstring_alphanum_large':
             $result = AECToolbox::randomstring((int) $vars, true, true);
             break;
         case 'php_function':
             if (!$safe) {
                 if (isset($vars[1])) {
                     $result = call_user_func_array($vars[0], $vars[1]);
                 } else {
                     $result = call_user_func_array($vars[0], array());
                 }
             }
             break;
         case 'php_method':
             if (!$safe) {
                 $callback = array($vars[0], $vars[1]);
                 if (isset($vars[2])) {
                     $result = call_user_func_array($callback, $vars[2]);
                 } else {
                     $result = call_user_func_array($callback, array());
                 }
             }
             break;
         default:
             $result = $command . ' is no command';
             break;
     }
     return $result;
 }