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);
 }
Exemple #2
0
 public function deleteToken()
 {
     $temptoken = new aecTempToken();
     $temptoken->getComposite();
     if ($temptoken->id) {
         $temptoken->delete();
     }
 }