You are here

public function PaymentMethodBase::executePaymentAccess in Payment 8.2

Checks if the payment can be executed.

Parameters

\Drupal\Core\Session\AccountInterface $account:

Return value

\Drupal\Core\Access\AccessResultInterface

Overrides PaymentMethodInterface::executePaymentAccess

See also

self::executePayment

File

src/Plugin/Payment/Method/PaymentMethodBase.php, line 201

Class

PaymentMethodBase
A base payment method plugin.

Namespace

Drupal\payment\Plugin\Payment\Method

Code

public function executePaymentAccess(AccountInterface $account) {
  if (!$this
    ->getPayment()) {
    throw new \LogicException('Trying to check access for a non-existing payment. A payment must be set trough self::setPayment() first.');
  }
  return AccessResult::allowedIf($this->pluginDefinition['active'])
    ->andIf($this
    ->executePaymentAccessCurrency($account))
    ->andIf($this->eventDispatcher
    ->executePaymentAccess($this
    ->getPayment(), $this, $account))
    ->andIf($this
    ->doExecutePaymentAccess($account))
    ->addCacheableDependency($this
    ->getPayment())
    ->addCacheTags([
    'payment_method',
  ]);
}