You are here

public function StripePaymentMethodController::payment_method_configuration_form_elements in Stripe 7

Builder for the method configuration form elements.

Parameters

array $element: The parent element.

array $form_state: The form states.

TODO: Allow admin to configure a payment method WITHOUT Stripe.js. The card information for the method's Payment will then be be stored in the Payment::method_data. Provide clear and visible warning with information regarding the security risk and PCI compliance. TODO: Add option to (not) collect card holder's name. TODO: Add option to collect card holder's address.

Return value

array The forms elements to configure a payment method.

File

stripe_payment/includes/StripePaymentMethodController.inc, line 514
Stripe Payment controller class and helper code (classes and function).

Class

StripePaymentMethodController

Code

public function payment_method_configuration_form_elements(array $element, array &$form_state) {
  $controller_data = $form_state['payment_method']->controller_data + $this->controller_data_defaults;
  $elements = array();
  $elements['keys'] = array(
    '#type' => 'fieldset',
    '#title' => t('Authentication'),
    '#tree' => TRUE,
    'mode' => array(
      '#type' => 'select',
      '#options' => array(
        0 => t('Use site-wide keys'),
        1 => t('Use specific keys'),
      ),
      '#attributes' => array(
        'class' => array(
          'keys-mode',
        ),
      ),
      '#default_value' => $controller_data['keys']['mode'],
    ),
    'site-wide' => array(
      '#type' => 'item',
      '#markup' => t('Using site-wide %status keys as configured on the <a href="@url">Stripe settings page</a>.', array(
        '%status' => variable_get('stripe_key_status', 'test'),
        '@url' => url('admin/config/stripe/settings'),
      )),
      '#states' => array(
        'visible' => array(
          ':input.keys-mode' => array(
            'value' => 0,
          ),
        ),
      ),
    ),
    'secret' => array(
      '#type' => 'textfield',
      '#title' => t('Secret Key'),
      '#states' => array(
        'visible' => array(
          ':input.keys-mode' => array(
            'value' => 1,
          ),
        ),
        'required' => array(
          ':input.keys-mode' => array(
            'value' => 1,
          ),
        ),
      ),
      '#default_value' => $controller_data['keys']['secret'],
    ),
    'publishable' => array(
      '#type' => 'textfield',
      '#title' => t('Publishable Key'),
      '#states' => array(
        'visible' => array(
          ':input.keys-mode' => array(
            'value' => 1,
          ),
        ),
        'required' => array(
          ':input.keys-mode' => array(
            'value' => 1,
          ),
        ),
      ),
      '#default_value' => $controller_data['keys']['publishable'],
    ),
  );
  return $elements;
}