You are here

public function TwoCheckout::cartDetails in Ubercart 8.4

Returns the form or render array to be displayed at checkout.

Parameters

\Drupal\uc_order\OrderInterface $order: The order which is being processed.

array $form: The checkout form array.

\Drupal\Core\Form\FormStateInterface $form_state: The checkout form state array.

Return value

array A form or render array.

Overrides PaymentMethodPluginBase::cartDetails

File

payment/uc_2checkout/src/Plugin/Ubercart/PaymentMethod/TwoCheckout.php, line 131

Class

TwoCheckout
Defines the 2Checkout payment method.

Namespace

Drupal\uc_2checkout\Plugin\Ubercart\PaymentMethod

Code

public function cartDetails(OrderInterface $order, array $form, FormStateInterface $form_state) {
  $build = [];
  $session = \Drupal::service('session');
  if ($this->configuration['check']) {
    $build['pay_method'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Select your payment type:'),
      '#default_value' => $session
        ->get('pay_method') == 'CK' ? 'CK' : 'CC',
      '#options' => [
        'CC' => $this
          ->t('Credit card'),
        'CK' => $this
          ->t('Online check'),
      ],
    ];
    $session
      ->remove('pay_method');
  }
  return $build;
}