You are here

public function AuthorizeNet::submitConfigurationForm in Ubercart 8.4

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides CreditCardPaymentMethodBase::submitConfigurationForm

File

payment/uc_authorizenet/src/Plugin/Ubercart/PaymentMethod/AuthorizeNet.php, line 200

Class

AuthorizeNet
Defines the Authorize.net payment method.

Namespace

Drupal\uc_authorizenet\Plugin\Ubercart\PaymentMethod

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::submitConfigurationForm($form, $form_state);
  $this->configuration['duplicate_window'] = $form_state
    ->getValue('duplicate_window');
  $this->configuration['api']['login_id'] = trim($form_state
    ->getValue([
    'settings',
    'api',
    'login_id',
  ]));
  $this->configuration['api']['transaction_key'] = trim($form_state
    ->getValue([
    'settings',
    'api',
    'transaction_key',
  ]));
  $this->configuration['api']['test_gateway_url'] = $form_state
    ->getValue([
    'settings',
    'api',
    'test_gateway_url',
  ]);
  $this->configuration['api']['live_gateway_url'] = $form_state
    ->getValue([
    'settings',
    'api',
    'live_gateway_url',
  ]);
  $this->configuration['aim']['txn_mode'] = $form_state
    ->getValue([
    'settings',
    'aim',
    'txn_mode',
  ]);
  $this->configuration['aim']['email_customer'] = $form_state
    ->getValue([
    'settings',
    'aim',
    'email_customer',
  ]);
  $this->configuration['aim']['response_debug'] = $form_state
    ->getValue([
    'settings',
    'aim',
    'response_debug',
  ]);
  $this->configuration['arb']['arb_mode'] = $form_state
    ->getValue([
    'settings',
    'arb',
    'arb_mode',
  ]);
  $this->configuration['arb']['report_arb_post'] = $form_state
    ->getValue([
    'settings',
    'arb',
    'report_arb_post',
  ]);
  $this->configuration['cim']['cim_profile'] = $form_state
    ->getValue([
    'settings',
    'cim',
    'cim_profile',
  ]);
  $this->configuration['cim']['cim_mode'] = $form_state
    ->getValue([
    'settings',
    'cim',
    'cim_mode',
  ]);

  // If CC encryption has been configured properly.
  if ($key = uc_credit_encryption_key()) {

    // Setup our encryption object.
    $crypt = \Drupal::service('uc_store.encryption');

    // Encrypt the Login ID, Transaction key, and MD5 Hash.
    $md5_hash = $form_state
      ->getValue([
      'settings',
      'arb',
      'md5_hash',
    ]);
    if (!empty($md5_hash)) {
      $this->configuration['arb']['md5_hash'] = $crypt
        ->encrypt($key, $md5_hash);
    }

    // Store any errors.
    uc_store_encryption_errors($crypt, 'uc_authorizenet');
  }
}