You are here

function pay_method_direct::form in Pay 7

Same name and namespace in other branches
  1. 6 includes/handlers/pay_method_direct.inc \pay_method_direct::form()

Overrides pay::form

File

includes/handlers/pay_method_direct.inc, line 111
The base class for 'direct' payment activities, where payments are collected on third-party sites such as PayPal, and the responses are returned to Drupal on a URL callback.

Class

pay_method_direct
@file The base class for 'direct' payment activities, where payments are collected on third-party sites such as PayPal, and the responses are returned to Drupal on a URL callback.

Code

function form(&$form, &$form_state) {
  global $user;
  parent::form($form, $form_state);
  if (isset($this->gateway_testmode) && $this->gateway_testmode) {
    drupal_set_message(t('The @name payment method is in test mode. This transaction will not be fully processed.', array(
      '@name' => $this
        ->title(),
    )), 'warning');
  }
  $method_form = array();
  $method_form['first_name'] = array(
    '#type' => 'textfield',
    '#title' => t('First name'),
    '#required' => TRUE,
  );
  $method_form['last_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Last name'),
    '#required' => TRUE,
  );
  if ($user->uid) {
    $method_form['mail'] = array(
      '#type' => 'value',
      '#value' => $user->mail,
    );
  }
  else {
    $method_form['mail'] = array(
      '#type' => 'textfield',
      '#title' => t('E-mail'),
      '#required' => TRUE,
    );
  }
  $method_form['billto'] = array(
    '#type' => 'postal',
    '#postal_user' => $user,
    '#title' => t('Billing address'),
    '#required' => TRUE,
  );

  // Add this method_form to the expected place on the parent form.
  $form[$this->pay_form
    ->handler()]['pay_method'][$this->pmid] = $method_form;
}