/**
  * Called on cart checkout.
  * @since 1.0.0
  *
  * @param Cart $cart Cart.
  */
 public function onCheckout($cart)
 {
     if (!isset($this->omnipay)) {
         throw new ShopException('Omnipay gateway not set.', 0);
     }
     if ($this->isCreditCard && !isset($this->creditCard)) {
         throw new GatewayException('Credit Card not set.', 1);
     }
     try {
         $response = $this->omnipay->authorize(array_merge(['amount' => $cart->total, 'currency' => Config::get('shop.currency'), 'card' => $this->isCreditCard ? $this->creditCard : [], 'returnUrl' => $this->callbackSuccess], $this->options))->send();
         if (!$response->isSuccessful()) {
             throw new CheckoutException($response->getMessage(), 1);
         }
     } catch (Exception $e) {
         throw new CheckoutException('Exception caught while attempting authorize.' . "\n" . $e->getMessage(), 1);
     }
 }
示例#2
0
 /**
  * Access check
  *
  * @param   string  $action  The action to check
  * @param   string  $item    The item to check the action against
  * @return  boolean
  */
 public function access($action = 'view', $item = 'tickets')
 {
     if (!$this->get('_access-check-done', false)) {
         $this->_acl = ACL::getACL();
         if ($this->isSubmitter() || $this->isOwner()) {
             if (!$this->_acl->check('read', 'tickets')) {
                 $this->_acl->setAccess('read', 'tickets', 1);
             }
             if (!$this->_acl->check('update', 'tickets')) {
                 $this->_acl->setAccess('update', 'tickets', -1);
             }
             if (!$this->_acl->check('create', 'comments')) {
                 $this->_acl->setAccess('create', 'comments', -1);
             }
             if (!$this->_acl->check('read', 'comments')) {
                 $this->_acl->setAccess('read', 'comments', 1);
             }
         }
         if ($this->_acl->authorize($this->get('group'))) {
             $this->_acl->setAccess('read', 'tickets', 1);
             $this->_acl->setAccess('update', 'tickets', 1);
             $this->_acl->setAccess('delete', 'tickets', 1);
             $this->_acl->setAccess('create', 'comments', 1);
             $this->_acl->setAccess('read', 'comments', 1);
             $this->_acl->setAccess('create', 'private_comments', 1);
             $this->_acl->setAccess('read', 'private_comments', 1);
             $this->set('_cc-check-done', true);
         }
         $this->set('_access-check-done', true);
     }
     if ($action == 'read' && $item == 'tickets' && !$this->_acl->check('read', 'tickets') && !$this->get('_cc-check-done')) {
         if (!User::get('guest') && $this->comments()->total() > 0) {
             $last = $this->comments('list')->last();
             //, array('access' => 1), true)->last();
             $cc = $last->changelog()->get('cc');
             if (in_array(User::get('username'), $cc) || in_array(User::get('email'), $cc)) {
                 $this->_acl->setAccess('read', 'tickets', 1);
                 $this->_acl->setAccess('create', 'comments', -1);
                 $this->_acl->setAccess('read', 'comments', 1);
             }
         }
         $this->set('_cc-check-done', true);
     }
     return $this->_acl->check($action, $item);
 }