Exemplo n.º 1
0
 static function TempTokenFromPlan($plan)
 {
     $temptoken = new aecTempToken();
     $temptoken->getComposite();
     if (empty($temptoken->content)) {
         $content = array();
         $content['usage'] = $plan['id'];
         $content['processor'] = $plan['gw'][0]->processor_name;
         if (isset($plan['gw'][0]->recurring)) {
             $content['recurring'] = $plan['gw'][0]->recurring;
         }
         $temptoken->create($content);
     } elseif (empty($temptoken->content['usage']) || $temptoken->content['usage'] !== $plan['id']) {
         $temptoken->content['usage'] = $plan['id'];
         $temptoken->content['processor'] = $plan['gw'][0]->processor_name;
         if (isset($plan['gw'][0]->recurring)) {
             $temptoken->content['recurring'] = $plan['gw'][0]->recurring;
         }
         $temptoken->storeload();
     }
 }
Exemplo n.º 2
0
 public function checkout($repeat = 0, $error = null, $coupon = null)
 {
     global $aecConfig;
     if (!$this->checkAuth()) {
         return false;
     }
     $this->puffer();
     $this->touchInvoice(false, true);
     if ($this->invoice->method != $this->processor) {
         $this->invoice->method = $this->processor;
         $this->invoice->storeload();
     }
     // Delete TempToken - the data is now safe with the invoice
     $temptoken = new aecTempToken();
     $temptoken->getComposite();
     if ($temptoken->id) {
         $temptoken->delete();
     }
     if (!empty($coupon)) {
         $this->InvoiceAddCoupon($coupon);
     }
     $user_ident = aecGetParam('user_ident', 0, true, array('string', 'clear_nonemail'));
     if (!empty($user_ident) && !empty($this->invoice->id)) {
         if ($this->invoice->addTargetUser(strtolower($user_ident))) {
             $this->invoice->storeload();
         }
     }
     $repeat = empty($repeat) ? 0 : $repeat;
     $exceptproc = array('none', 'free');
     $recurring = false;
     if (!in_array(strtolower($this->processor), $exceptproc)) {
         if (is_object($this->pp)) {
             if (isset($this->invoice->params['userselect_recurring'])) {
                 $recurring_choice = $this->invoice->params['userselect_recurring'];
             } else {
                 $recurring_choice = null;
             }
             $recurring = $this->pp->is_recurring($recurring_choice);
         }
     }
     // If this is marked as supposedly free
     if (in_array(strtolower($this->processor), $exceptproc) && !empty($this->plan)) {
         // Double Check Amount for made_free
         $this->invoice->computeAmount($this);
         if (!empty($this->invoice->made_free) || $this->plan->params['full_free'] && empty($this->invoice->counter) && empty($this->plan->params['trial_period']) || $this->plan->params['full_free'] && $this->invoice->counter || $this->plan->params['trial_free'] && empty($this->invoice->counter)) {
             // Only allow clearing while recurring if everything is free
             if (!($recurring && (empty($this->plan->params['full_free']) || empty($this->plan->params['trial_free'])))) {
                 // mark paid
                 if ($this->invoice->pay() !== false) {
                     return $this->thanks(false, true);
                 }
             }
         }
         return getView('access_denied');
     } elseif (in_array(strtolower($this->processor), $exceptproc)) {
         if (!empty($this->invoice->made_free)) {
             // mark paid
             if ($this->invoice->pay() !== false) {
                 return $this->thanks(false, true);
             }
         }
         return getView('access_denied');
     } elseif (strcmp(strtolower($this->processor), 'error') === 0) {
         // Nope, won't work buddy
         return getView('access_denied');
     }
     if (!empty($this->pp)) {
         if ($this->pp->requireSSLcheckout() && empty($_SERVER['HTTPS']) && !$aecConfig->cfg['override_reqssl']) {
             aecRedirect(AECToolbox::deadsureURL("index.php?option=com_acctexp&task=repeatPayment&invoice=" . $this->invoice->invoice_number . "&first=" . ($repeat ? 0 : 1) . '&' . xJ::token() . '=1', true, true));
             exit;
         }
     }
     $this->loadItems();
     $this->loadItemTotal();
     $exchange = $silent = null;
     $this->triggerMIs('invoice_items_checkout', $exchange, $this->items, $silent);
     // Either this is fully free, or the next term is free and this is non recurring
     if (!empty($this->items->grand_total) && !$recurring) {
         if ($this->items->grand_total->isFree() && !$recurring) {
             $this->invoice->pay();
             return $this->thanks(false, true);
         }
     }
     return $this->InvoiceToCheckout($repeat, $error);
 }
Exemplo n.º 3
0
 public function saveToToken($vars)
 {
     $temptoken = new aecTempToken();
     $temptoken->getComposite();
     $existing = false;
     if (!empty($temptoken->content['usage'])) {
         $existing = true;
     }
     $content = array();
     $content['usage'] = $vars['usage'];
     $content['processor'] = $vars['processor'];
     $content['recurring'] = $vars['recurring'];
     if (empty($temptoken->id)) {
         $temptoken->create($content);
     } else {
         if (is_array($temptoken->content)) {
             $temptoken->content = array_merge($temptoken->content, $content);
         } else {
             $temptoken->content = $content;
         }
     }
     $temptoken->storeload();
     return $existing;
 }
Exemplo n.º 4
0
function subscribe($option)
{
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    if (defined('JPATH_MANIFESTS') && !empty($_REQUEST['jform'])) {
        foreach ($_REQUEST['jform'] as $k => $v) {
            $map = array('password1' => 'password', 'email1' => 'email');
            if (isset($map[$k])) {
                $_POST[$map[$k]] = $v;
            } else {
                $_POST[$k] = $v;
            }
        }
    }
    $intro = aecGetParam('intro', 0, true, array('word', 'int'));
    $usage = aecGetParam('usage', 0, true, array('word', 'string', 'clear_nonalnum'));
    $group = aecGetParam('group', 0, true, array('word', 'int'));
    $processor = aecGetParam('processor', '', true, array('word', 'string', 'clear_nonalnum'));
    $userid = aecGetParam('userid', 0, true, array('word', 'int'));
    $username = aecGetParam('username', '', true, array('string', 'clear_nonalnumwhitespace'));
    $email = aecGetParam('email', '', true, array('string', 'clear_nonemail'));
    $token = aecGetParam('aectoken', 0, true, array('string'));
    $forget = aecGetParam('forget', '', true, array('string'));
    $k2mode = false;
    if ($token) {
        $temptoken = new aecTempToken();
        $temptoken->getComposite();
        if (!empty($temptoken->content['handler'])) {
            if ($temptoken->content['handler'] == 'k2') {
                $k2mode = true;
            }
        }
        if (!empty($temptoken->content)) {
            $password = null;
            $details = array();
            if ($forget == 'usage') {
                $details[] = 'usage';
                $details[] = 'processor';
                $details[] = 'recurring';
            }
            if ($forget == 'userdetails') {
                $details[] = 'username';
                $details[] = 'email';
                $details[] = 'password';
                $details[] = 'password2';
            }
            foreach ($temptoken->content as $k => $v) {
                if (!in_array($k, $details)) {
                    ${$k} = $v;
                    $_POST[$k] = $v;
                }
            }
            if (!empty($username)) {
                $query = 'SELECT id' . ' FROM #__users' . ' WHERE username = \'' . $username . '\'';
                $db->setQuery($query);
                $id = $db->loadResult();
                if (!empty($id)) {
                    $userid = $id;
                    $metaUser = new metaUser($id);
                    $metaUser->setTempAuth($password);
                }
            }
        }
    }
    if (!empty($username) && $usage) {
        $CB = aecComponentHelper::detect_component('anyCB');
        $AL = aecComponentHelper::detect_component('ALPHA');
        $JS = aecComponentHelper::detect_component('JOMSOCIAL');
        if (!$AL && !$CB && !$JS && !$k2mode) {
            // Joomla 1.6+ Sanity Check
            if (isset($_POST['email2']) && isset($_POST['email'])) {
                if ($_POST['email2'] !== $_POST['email']) {
                    aecErrorAlert(JText::_('AEC_WARNREG_EMAIL_NOMATCH'));
                    return JText::_('AEC_WARNREG_EMAIL_NOMATCH');
                }
            }
            if (isset($_POST['password2']) && isset($_POST['password'])) {
                if ($_POST['password2'] !== $_POST['password']) {
                    aecErrorAlert(JText::_('AEC_WARNREG_PASSWORD_NOMATCH'));
                    return JText::_('AEC_WARNREG_PASSWORD_NOMATCH');
                }
            }
            // Joomla 1.5 Sanity Check
            // Get required system objects
            $user = clone JFactory::getUser();
            $duplicationcheck = checkUsernameEmail($username, $email);
            $usertype = JRequest::get('post');
            // Bind the post array to the user object
            if (!$user->bind($usertype, 'usertype') || $duplicationcheck !== true) {
                $binderror = $user->getError();
                if (!empty($binderror)) {
                    JError::raiseError(500, $user->getError());
                } else {
                    JError::raiseError(500, $duplicationcheck);
                }
                unset($_POST);
                subscribe($option);
                return false;
            }
            JRequest::checkToken() or die('Invalid Token');
        } elseif (empty($token)) {
            if (isset($_POST['username']) && isset($_POST['email'])) {
                $check = checkUsernameEmail($username, $email);
                if ($check !== true) {
                    return $check;
                }
            }
        }
        $iFactory = new InvoiceFactory($userid, $usage, $group, $processor);
        $iFactory->confirm();
    } else {
        if ($user->id) {
            $userid = $user->id;
            $passthrough = array();
        } elseif (!empty($userid) && !isset($_POST['username'])) {
            $passthrough = array();
        } elseif (empty($userid)) {
            if (!empty($_POST['username']) && !empty($_POST['email'])) {
                $check = checkUsernameEmail($username, $email);
                if ($check !== true) {
                    return $check;
                }
            }
            $nopass = array('option', 'task', 'intro', 'usage', 'group', 'processor', 'recurring', 'Itemid', 'submit_x', 'submit_y', 'userid', 'id', 'gid');
            $passthrough = array();
            foreach ($_POST as $k => $v) {
                if (in_array($k, $nopass)) {
                    unset($_POST[$k]);
                } else {
                    $passthrough[$k] = $v;
                }
            }
        }
        if (!empty($userid)) {
            $passthrough['userid'] = $userid;
            $password = aecGetParam('password', '', true, array('string'));
            if (!empty($password)) {
                $passthrough['password'] = $password;
            }
        }
        $iFactory = new InvoiceFactory($userid, $usage, $group, $processor, null, $passthrough, false);
        if (!$iFactory->authed) {
            if (!$iFactory->checkAuth()) {
                return false;
            }
        }
        if (!empty($iFactory->passthrough['invoice'])) {
            repeatInvoice($option, $iFactory->passthrough['invoice'], null, $userid);
        } else {
            $iFactory->create($intro, $usage, $group, $processor, 0);
        }
    }
}