You are here

public function PaymentGatewayBase::buildPaymentOperations in Commerce Core 8.2

Builds the available operations for the given payment.

Parameters

\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment.

Return value

array The operations. Keyed by operation ID, each value is an array with the following keys:

  • title: The operation title.
  • page_title: The operation page title.
  • plugin_form: The plugin form ID.
  • access: Whether the operation is allowed for the given payment.

Overrides PaymentGatewayInterface::buildPaymentOperations

1 method overrides PaymentGatewayBase::buildPaymentOperations()
Manual::buildPaymentOperations in modules/payment/src/Plugin/Commerce/PaymentGateway/Manual.php
Builds the available operations for the given payment.

File

modules/payment/src/Plugin/Commerce/PaymentGateway/PaymentGatewayBase.php, line 405

Class

PaymentGatewayBase
Provides the base class for payment gateways.

Namespace

Drupal\commerce_payment\Plugin\Commerce\PaymentGateway

Code

public function buildPaymentOperations(PaymentInterface $payment) {
  $operations = [];
  if ($this instanceof SupportsAuthorizationsInterface) {
    $operations['capture'] = [
      'title' => $this
        ->t('Capture'),
      'page_title' => $this
        ->t('Capture payment'),
      'plugin_form' => 'capture-payment',
      'access' => $this
        ->canCapturePayment($payment),
    ];
  }
  if ($this instanceof SupportsVoidsInterface) {
    $operations['void'] = [
      'title' => $this
        ->t('Void'),
      'page_title' => $this
        ->t('Void payment'),
      'plugin_form' => 'void-payment',
      'access' => $this
        ->canVoidPayment($payment),
    ];
  }
  if ($this instanceof SupportsRefundsInterface) {
    $operations['refund'] = [
      'title' => $this
        ->t('Refund'),
      'page_title' => $this
        ->t('Refund payment'),
      'plugin_form' => 'refund-payment',
      'access' => $this
        ->canRefundPayment($payment),
    ];
  }
  return $operations;
}