class VisaCheckoutForm 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\PaymentOffsiteForm
- class \Drupal\commerce_authnet\PluginForm\VisaCheckoutForm
- class \Drupal\commerce_payment\PluginForm\PaymentOffsiteForm
- class \Drupal\commerce_payment\PluginForm\PaymentGatewayFormBase implements PaymentGatewayFormInterface uses DependencySerializationTrait, StringTranslationTrait
Expanded class hierarchy of VisaCheckoutForm
File
- src/
PluginForm/ VisaCheckoutForm.php, line 8
Namespace
Drupal\commerce_authnet\PluginFormView source
class VisaCheckoutForm extends PaymentOffsiteForm {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
/** @var \Drupal\commerce_payment\Entity\PaymentInterface $payment */
$payment = $this->entity;
$form['authnet_visa']['#type'] = 'container';
$form['authnet_visa']['#attributes']['class'][] = 'authorize-net-accept-js-form';
/** @var \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\PaymentGatewayBase $plugin */
$plugin = $this->plugin;
$form['authnet_visa']['#attached']['library'][] = 'commerce_authnet/form-visa-checkout';
if ($plugin
->getMode() == 'test') {
$form['authnet_visa']['#attached']['library'][] = 'commerce_authnet/form-visa-checkout-sandbox';
$image_src = 'https://sandbox.secure.checkout.visa.com/wallet-services-web/xo/button.png';
}
else {
$form['authnet_visa']['#attached']['library'][] = 'commerce_authnet/form-visa-checkout-production';
$image_src = 'https://secure.checkout.visa.com/wallet-services-web/xo/button.png';
}
$order = $payment
->getOrder();
$current_checkout_step = $order
->get('checkout_step')
->getValue()[0]['value'];
/** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */
$checkout_flow = $order
->get('checkout_flow')->entity;
$next_step = $checkout_flow
->getPlugin()
->getNextStepId($current_checkout_step);
$form['authnet_visa']['#attached']['drupalSettings']['commerceAuthorizeNet'] = [
'visaApiKey' => $plugin
->getConfiguration()['visa_checkout_api_key'],
'paymentMethodType' => 'authnet_visa',
'currencyCode' => $payment
->getAmount()
->getCurrencyCode(),
'number' => $payment
->getAmount()
->getNumber(),
'successUrl' => $form['#return_url'],
'errorUrl' => $form['#return_url'],
'cancelUrl' => $form['#cancel_url'],
'nextCheckoutStepUrl' => '/checkout/' . $order
->id() . '/' . $next_step,
];
$form['authnet_visa']['visa_button'] = [
'#type' => 'html_tag',
'#tag' => 'img',
'#attributes' => [
'alt' => 'Visa Checkout',
'role' => 'button',
'class' => [
'v-button',
],
'src' => $image_src,
],
];
return $form;
}
}
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 | |
PaymentGatewayFormBase:: |
protected | property | The form entity. | |
PaymentGatewayFormBase:: |
public | function |
Gets the form entity. Overrides PaymentGatewayFormInterface:: |
|
PaymentGatewayFormBase:: |
public | function |
Gets the form element to which errors should be assigned. Overrides PaymentGatewayFormInterface:: |
1 |
PaymentGatewayFormBase:: |
public | function |
Sets the form entity. Overrides PaymentGatewayFormInterface:: |
|
PaymentOffsiteForm:: |
protected | function | Builds the redirect form. | |
PaymentOffsiteForm:: |
public static | function | Prepares the complete form for a POST redirect. | |
PaymentOffsiteForm:: |
constant | |||
PaymentOffsiteForm:: |
constant | |||
PaymentOffsiteForm:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
PluginFormBase:: |
protected | property | The plugin this form is for. | 3 |
PluginFormBase:: |
public | function |
Sets the plugin for this object. Overrides PluginAwareInterface:: |
1 |
PluginFormBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
2 |
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. | |
VisaCheckoutForm:: |
public | function |
Form constructor. Overrides PaymentOffsiteForm:: |