You are here

public function PaymentMethodPane::process in Ubercart 8.4

Processes a checkout pane.

Parameters

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

array $form: The checkout form array.

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

Return value

bool TRUE if the pane is valid, FALSE otherwise.

Overrides CheckoutPanePluginBase::process

File

payment/uc_payment/src/Plugin/Ubercart/CheckoutPane/PaymentMethodPane.php, line 154

Class

PaymentMethodPane
Allows the user to select a payment method and preview the line items.

Namespace

Drupal\uc_payment\Plugin\Ubercart\CheckoutPane

Code

public function process(OrderInterface $order, array $form, FormStateInterface $form_state) {
  if (!$form_state
    ->getValue([
    'panes',
    'payment',
    'payment_method',
  ])) {
    $form_state
      ->setErrorByName('panes][payment][payment_method', $this
      ->t('You cannot check out without selecting a payment method.'));
    return FALSE;
  }
  $order
    ->setPaymentMethodId($form_state
    ->getValue([
    'panes',
    'payment',
    'payment_method',
  ]));
  $result = $this->paymentMethodManager
    ->createFromOrder($order)
    ->cartProcess($order, $form, $form_state);
  return $result !== FALSE;
}