class EcheckAddForm in Commerce Authorize.Net 8
Hierarchy
- class \Drupal\Core\Plugin\PluginFormBase implements PluginAwareInterface, PluginFormInterface
- class \Drupal\commerce_payment\PluginForm\PaymentGatewayFormBase implements PaymentGatewayFormInterface uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\commerce_payment\PluginForm\PaymentMethodFormBase implements ContainerInjectionInterface
- class \Drupal\commerce_payment\PluginForm\PaymentMethodAddForm
- class \Drupal\commerce_authnet\PluginForm\EcheckAddForm
- class \Drupal\commerce_payment\PluginForm\PaymentMethodAddForm
- class \Drupal\commerce_payment\PluginForm\PaymentMethodFormBase implements ContainerInjectionInterface
- class \Drupal\commerce_payment\PluginForm\PaymentGatewayFormBase implements PaymentGatewayFormInterface uses DependencySerializationTrait, StringTranslationTrait
Expanded class hierarchy of EcheckAddForm
File
- src/
PluginForm/ EcheckAddForm.php, line 9
Namespace
Drupal\commerce_authnet\PluginFormView source
class EcheckAddForm extends BasePaymentMethodAddForm {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['payment_details'] = $this
->buildEcheckForm($form['payment_details'], $form_state);
return $form;
}
/**
* Builds the eCheck form.
*/
public function buildEcheckForm(array $element, FormStateInterface $form_state) {
// Alter the form with AuthorizeNet Accept JS specific needs.
$element['#attributes']['class'][] = 'authorize-net-accept-js-form';
/** @var \Drupal\commerce_authnet\Plugin\Commerce\PaymentGateway\AuthorizeNetInterface $plugin */
$plugin = $this->plugin;
if ($plugin
->getMode() == 'test') {
$element['#attached']['library'][] = 'commerce_authnet/accept-js-sandbox';
}
else {
$element['#attached']['library'][] = 'commerce_authnet/accept-js-production';
}
$element['#attached']['library'][] = 'commerce_authnet/form-echeck';
$element['#attached']['drupalSettings']['commerceAuthorizeNet'] = [
'clientKey' => $plugin
->getConfiguration()['client_key'],
'apiLoginID' => $plugin
->getConfiguration()['api_login'],
'paymentMethodType' => 'authnet_echeck',
];
// To display validation errors.
$element['payment_errors'] = [
'#type' => 'markup',
'#markup' => '<div id="payment-errors"></div>',
'#weight' => -200,
];
$element['routing_number'] = [
'#type' => 'textfield',
'#title' => t('Routing number'),
'#description' => t("The bank's routing number."),
'#attributes' => [
'class' => [
'authnet-echeck-routing-number',
],
],
];
$element['account_number'] = [
'#type' => 'textfield',
'#title' => t('Bank account'),
'#description' => t('The bank account number.'),
'#attributes' => [
'class' => [
'authnet-echeck-account-number',
],
],
];
$element['name_on_account'] = [
'#type' => 'textfield',
'#title' => t('Name on account'),
'#description' => t('The name of the person who holds the bank account.'),
'#attributes' => [
'class' => [
'authnet-echeck-name-on-account',
],
],
];
$element['account_type'] = [
'#type' => 'select',
'#title' => t('Account type'),
'#description' => t('The type of bank account. Currently only WEB eCheck ACH transactions are supported.'),
'#options' => AuthorizeNetEcheck::getAccountTypes(),
'#attributes' => [
'class' => [
'authnet-echeck-account-type',
],
],
];
// Populated by the JS library after receiving a response from AuthorizeNet.
$element['data_descriptor'] = [
'#type' => 'hidden',
'#attributes' => [
'class' => [
'accept-js-data-descriptor',
],
],
];
$element['data_value'] = [
'#type' => 'hidden',
'#attributes' => [
'class' => [
'accept-js-data-value',
],
],
];
return $element;
}
/**
* {@inheritdoc}
*/
protected function validateEcheckForm(array &$element, FormStateInterface $form_state) {
// The JS library performs its own validation.
}
/**
* {@inheritdoc}
*/
public function submitEcheckForm(array $element, FormStateInterface $form_state) {
// The payment gateway plugin will process the submitted payment details.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EcheckAddForm:: |
public | function |
Form constructor. Overrides PaymentMethodAddForm:: |
|
EcheckAddForm:: |
public | function | Builds the eCheck form. | |
EcheckAddForm:: |
public | function | ||
EcheckAddForm:: |
protected | function | ||
PaymentGatewayFormBase:: |
protected | property | The form entity. | |
PaymentGatewayFormBase:: |
public | function |
Gets the form entity. Overrides PaymentGatewayFormInterface:: |
|
PaymentGatewayFormBase:: |
public | function |
Sets the form entity. Overrides PaymentGatewayFormInterface:: |
|
PaymentMethodAddForm:: |
protected | function | Builds the credit card form. | 1 |
PaymentMethodAddForm:: |
protected | function | Builds the PayPal form. | |
PaymentMethodAddForm:: |
public | function |
Gets the form element to which errors should be assigned. Overrides PaymentGatewayFormBase:: |
|
PaymentMethodAddForm:: |
public | function |
Form submission handler. Overrides PaymentMethodFormBase:: |
|
PaymentMethodAddForm:: |
protected | function | Handles the submission of the credit card form. | |
PaymentMethodAddForm:: |
protected | function | Handles the submission of the PayPal form. | |
PaymentMethodAddForm:: |
public | function |
Form validation handler. Overrides PaymentMethodFormBase:: |
|
PaymentMethodAddForm:: |
protected | function | Validates the credit card form. | |
PaymentMethodAddForm:: |
protected | function | Validates the PayPal form. | |
PaymentMethodFormBase:: |
protected | property | The current store. | |
PaymentMethodFormBase:: |
protected | property | The entity type manager. | |
PaymentMethodFormBase:: |
protected | property | The inline form manager. | |
PaymentMethodFormBase:: |
protected | property | The logger. | |
PaymentMethodFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
PaymentMethodFormBase:: |
public | function | Constructs a new PaymentMethodFormBase. | |
PluginFormBase:: |
protected | property | The plugin this form is for. | 3 |
PluginFormBase:: |
public | function |
Sets the plugin for this object. Overrides PluginAwareInterface:: |
1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |