You are here

public function AcceptJs::buildPaymentOperations in Commerce Authorize.Net 8

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 PaymentGatewayBase::buildPaymentOperations

File

src/Plugin/Commerce/PaymentGateway/AcceptJs.php, line 839

Class

AcceptJs
Provides the Accept.js payment gateway.

Namespace

Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway

Code

public function buildPaymentOperations(PaymentInterface $payment) {
  $payment_state = $payment
    ->getState()
    ->getId();
  $operations = parent::buildPaymentOperations($payment);
  $operations['approve'] = [
    'title' => $this
      ->t('Approve'),
    'page_title' => $this
      ->t('Approve payment'),
    'plugin_form' => 'approve-payment',
    'access' => in_array($payment_state, [
      'unauthorized_review',
      'authorization_review',
    ]),
  ];
  $operations['decline'] = [
    'title' => $this
      ->t('Decline'),
    'page_title' => $this
      ->t('Decline payment'),
    'plugin_form' => 'decline-payment',
    'access' => in_array($payment_state, [
      'unauthorized_review',
      'authorization_review',
    ]),
  ];
  return $operations;
}