You are here

public function Payment::submitForm in Ubercart 8.4

Form submission handler.

Parameters

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

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides EditableOrderPanePluginInterface::submitForm

File

payment/uc_payment/src/Plugin/Ubercart/OrderPane/Payment.php, line 129

Class

Payment
Specify and collect payment for an order.

Namespace

Drupal\uc_payment\Plugin\Ubercart\OrderPane

Code

public function submitForm(OrderInterface $order, array &$form, FormStateInterface $form_state) {
  $changes['payment_method'] = $form_state
    ->getValue('payment_method');
  $changes['payment_details'] = $form_state
    ->getValue('payment_details') ?: [];
  $order
    ->setPaymentMethodId($changes['payment_method']);
  $method = \Drupal::service('plugin.manager.uc_payment.method')
    ->createFromOrder($order);
  $return = $method
    ->orderEditProcess($order, $form, $form_state);
  if (is_array($return)) {
    $changes['payment_details'] = array_merge($changes['payment_details'], $return);
  }
  $order->payment_details = $changes['payment_details'];
}