You are here

public function PaymentMethodBase::refundPayment in Payment 8.2

Refunds the payment.

Implementations must dispatch the \Drupal\payment\Event\PaymentEvents::PAYMENT_PRE_REFUND Symfony event before refunding the payment.

Return value

\Drupal\payment\OperationResultInterface

Overrides PaymentMethodRefundPaymentInterface::refundPayment

See also

self::refundPaymentAccess

File

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

Class

PaymentMethodBase
A base payment method plugin.

Namespace

Drupal\payment\Plugin\Payment\Method

Code

public function refundPayment() {
  if (!$this
    ->getPayment()) {
    throw new \LogicException('Trying to refund a non-existing payment. A payment must be set trough self::setPayment() first.');
  }
  $this->eventDispatcher
    ->preRefundPayment($this
    ->getPayment());
  $this
    ->doRefundPayment();
  return $this
    ->getPaymentRefundResult();
}