public function VisaCheckout::validateConfigurationForm in Commerce Authorize.Net 8
Form validation 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 PaymentGatewayBase::validateConfigurationForm
File
- src/
Plugin/ Commerce/ PaymentGateway/ VisaCheckout.php, line 165
Class
- VisaCheckout
- Provides the Authorize.net payment gateway.
Namespace
Drupal\commerce_authnet\Plugin\Commerce\PaymentGatewayCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
$values = $form_state
->getValue($form['#parents']);
if (!empty($values['api_login']) && !empty($values['transaction_key'])) {
$request = new XmlRequest(new Configuration([
'sandbox' => $values['mode'] == 'test',
'api_login' => $values['api_login'],
'transaction_key' => $values['transaction_key'],
]), $this->httpClient, 'authenticateTestRequest');
$request
->addDataType(new MerchantAuthentication([
'name' => $values['api_login'],
'transactionKey' => $values['transaction_key'],
]));
$response = $request
->sendRequest();
if ($response
->getResultCode() != 'Ok') {
$this
->logResponse($response);
$this->messenger
->addError($this
->describeResponse($response));
}
}
}