You are here

function commerce_amex_hosted_settings_form in Commerce American Express Payment Gateway (Amex) 7

Payment method callback: settings form.

File

./commerce_amex.module, line 306
Implements American Express payment gateway for use in Drupal Commerce.

Code

function commerce_amex_hosted_settings_form($settings = NULL) {
  module_load_include('inc', 'commerce_payment', 'includes/commerce_payment.credit_card');

  // Merge default settings into the stored settings array.
  $settings = (array) $settings + commerce_amex_hosted_default_settings();
  $form = array();
  $form['merchant_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Merchant ID'),
    '#description' => t('Your Merchant ID.'),
    '#default_value' => $settings['merchant_id'],
    '#required' => TRUE,
  );

  // @todo Secure password data
  $form['password'] = array(
    '#type' => 'textfield',
    '#title' => t('Password'),
    '#description' => t('Your Transaction Password.'),
    '#default_value' => $settings['password'],
    '#required' => TRUE,
  );
  $form['txn_type'] = array(
    '#type' => 'radios',
    '#title' => t('Default credit card transaction type'),
    '#description' => t('The default will be used to process transactions during checkout.'),
    '#options' => array(
      AMEX_OP_PAY => t('Payment in Full'),
      AMEX_OP_AUTH => t('Authorisation only (requires manual or automated capture after checkout)'),
      AMEX_OP_VERIFY => t('Verify (US Only) no funds are collected any amount is only used for risk assesment.'),
    ),
    '#default_value' => $settings['txn_type'],
  );
  $form['txn_3d_secure'] = array(
    '#type' => 'radios',
    '#title' => t('Carry out 3D Secure security check'),
    '#default_value' => $settings['txn_3d_secure'],
    '#options' => array(
      '0' => t('Do not perform 3D-Secure checks for this transaction only and always authorise.'),
      '1' => t('If card is enroled attempt authentication (allow if remote server errors)'),
      '2' => t('If card is enroled require authentication'),
      '3' => t('Require card to be enroled and attempt authentication (allow if remote server errors)'),
      '4' => t('Require card to be enroled and require authentication'),
    ),
  );
  $form['txn_mode'] = array(
    '#type' => 'radios',
    '#title' => t('Transaction mode'),
    '#description' => t('Adjust to live transactions when you are ready to start processing real payments.'),
    '#options' => array(
      AMEX_TXN_MODE_LIVE => t('Live transactions'),
      AMEX_TXN_MODE_TEST => t('Test transactions'),
    ),
    '#default_value' => $settings['txn_mode'],
  );
  $form['txn_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Transaction URL'),
    '#description' => t('Enter the transaction URL e.g. https://gateway-emea.americanexpress.com'),
    '#default_value' => $settings['txn_url'],
    '#required' => TRUE,
  );

  // Card on File module support.
  if (module_exists('commerce_cardonfile')) {
    $form['cardonfile'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable Card on File functionality with this payment method.'),
      '#description' => t('Stores tokenised value for card data.'),
      '#default_value' => $settings['cardonfile'],
    );
    $form['continuous'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use continuous authority transactions.'),
      '#description' => t('Card on file strage will be required.'),
      '#default_value' => $settings['continuous'],
    );
  }
  else {
    $form['cardonfile'] = array(
      '#type' => 'markup',
      '#markup' => t('To enable Card on File funcitionality download and install the Card on File module.'),
    );
  }
  return $form;
}