You are here

public function PayPalPaymentMethodPluginBase::buildConfigurationForm in Ubercart 8.4

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\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().

Return value

array The form structure.

Overrides PaymentMethodPluginBase::buildConfigurationForm

1 call to PayPalPaymentMethodPluginBase::buildConfigurationForm()
PayPalExpressCheckout::buildConfigurationForm in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php
Form constructor.
2 methods override PayPalPaymentMethodPluginBase::buildConfigurationForm()
PayPalExpressCheckout::buildConfigurationForm in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php
Form constructor.
PayPalPaymentsStandard::buildConfigurationForm in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalPaymentsStandard.php
Form constructor.

File

payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalPaymentMethodPluginBase.php, line 33

Class

PayPalPaymentMethodPluginBase
Defines the PayPal Express Checkout payment method.

Namespace

Drupal\uc_paypal\Plugin\Ubercart\PaymentMethod

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form['wps_email'] = [
    '#type' => 'email',
    '#title' => $this
      ->t('PayPal e-mail address'),
    '#description' => $this
      ->t('The e-mail address you use for the PayPal account you want to receive payments.'),
    '#default_value' => $this->configuration['wps_email'],
  ];
  $form['wpp_server'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('API server'),
    '#description' => $this
      ->t('Sign up for and use a Sandbox account for testing.'),
    '#options' => [
      'https://api-3t.sandbox.paypal.com/nvp' => $this
        ->t('Sandbox'),
      'https://api-3t.paypal.com/nvp' => $this
        ->t('Live'),
    ],
    '#default_value' => $this->configuration['wpp_server'],
  ];
  $form['api'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('API credentials'),
    '#description' => $this
      ->t('@link for information on obtaining credentials. You need to acquire an API Signature. If you have already requested API credentials, you can review your settings under the API Access section of your PayPal profile.', [
      '@link' => Link::fromTextAndUrl($this
        ->t('Click here'), Url::fromUri('https://developer.paypal.com/docs/classic/api/apiCredentials/'))
        ->toString(),
    ]),
    '#open' => TRUE,
  ];
  $form['api']['api_username'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('API username'),
    '#default_value' => $this->configuration['api']['api_username'],
  ];
  $form['api']['api_password'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('API password'),
    '#default_value' => $this->configuration['api']['api_password'],
  ];
  $form['api']['api_signature'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Signature'),
    '#default_value' => $this->configuration['api']['api_signature'],
  ];
  return $form;
}