You are here

public function PaymentMethodBase::capturePayment in Payment 8.2

Captures the payment.

Implementations must dispatch the \Drupal\payment\Event\PaymentEvents::PAYMENT_PRE_CAPTURE Symfony event before capture.

Return value

\Drupal\payment\OperationResultInterface

Overrides PaymentMethodCapturePaymentInterface::capturePayment

See also

self::capturePaymentAccess

File

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

Class

PaymentMethodBase
A base payment method plugin.

Namespace

Drupal\payment\Plugin\Payment\Method

Code

public function capturePayment() {
  if (!$this
    ->getPayment()) {
    throw new \LogicException('Trying to capture a non-existing payment. A payment must be set trough self::setPayment() first.');
  }
  $this->eventDispatcher
    ->preCapturePayment($this
    ->getPayment());
  $this
    ->doCapturePayment();
  return $this
    ->getPaymentCaptureResult();
}