You are here

public function PaymentMethodAddForm::submitCreditCardForm in Commerce Authorize.Net 8

Handles the submission of the credit card form.

Parameters

array $element: The credit card form element.

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

Overrides PaymentMethodAddForm::submitCreditCardForm

File

src/PluginForm/AcceptJs/PaymentMethodAddForm.php, line 257

Class

PaymentMethodAddForm

Namespace

Drupal\commerce_authnet\PluginForm\AcceptJs

Code

public function submitCreditCardForm(array $element, FormStateInterface $form_state) {

  // The payment gateway plugin will process the submitted payment details.
  $values = $form_state
    ->getValues();
  if (!empty($values['contact_information']['email'])) {

    // Then we are dealing with anonymous user. Adding a customer email.
    $payment_details = $values['payment_information']['add_payment_method']['payment_details'];
    $payment_details['customer_email'] = $values['contact_information']['email'];
    $form_state
      ->setValue([
      'payment_information',
      'add_payment_method',
      'payment_details',
    ], $payment_details);
  }
}