You are here

function uc_payment_method_2checkout in Ubercart 7.3

Same name and namespace in other branches
  1. 5 payment/uc_2checkout/uc_2checkout.module \uc_payment_method_2checkout()
  2. 6.2 payment/uc_2checkout/uc_2checkout.module \uc_payment_method_2checkout()

Adds 2Checkout settings to the payment method settings form.

See also

uc_2checkout_uc_payment_method()

1 string reference to 'uc_payment_method_2checkout'
uc_2checkout_uc_payment_method in payment/uc_2checkout/uc_2checkout.module
Implements hook_uc_payment_method().

File

payment/uc_2checkout/uc_2checkout.module, line 94
Integrates 2Checkout.com's redirected payment service.

Code

function uc_payment_method_2checkout($op, &$order, $form = NULL, &$form_state = NULL) {
  switch ($op) {
    case 'cart-details':
      $build = array();
      if (variable_get('uc_2checkout_check', FALSE)) {
        $build['pay_method'] = array(
          '#type' => 'select',
          '#title' => t('Select your payment type:'),
          '#default_value' => $_SESSION['pay_method'] == 'CK' ? 'CK' : 'CC',
          '#options' => array(
            'CC' => t('Credit card'),
            'CK' => t('Online check'),
          ),
        );
        unset($_SESSION['pay_method']);
      }
      return $build;
    case 'cart-process':
      if (isset($form_state['values']['panes']['payment']['details']['pay_method'])) {
        $_SESSION['pay_method'] = $form_state['values']['panes']['payment']['details']['pay_method'];
      }
      return;
    case 'settings':
      $form['uc_2checkout_sid'] = array(
        '#type' => 'textfield',
        '#title' => t('Vendor account number'),
        '#description' => t('Your 2Checkout vendor account number.'),
        '#default_value' => variable_get('uc_2checkout_sid', ''),
        '#size' => 16,
      );
      $form['uc_2checkout_secret_word'] = array(
        '#type' => 'textfield',
        '#title' => t('Secret word for order verification'),
        '#description' => t('The secret word entered in your 2Checkout account Look and Feel settings.'),
        '#default_value' => variable_get('uc_2checkout_secret_word', 'tango'),
        '#size' => 16,
      );
      $form['uc_2checkout_demo'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable demo mode, allowing you to process fake orders for testing purposes.'),
        '#default_value' => variable_get('uc_2checkout_demo', TRUE),
      );
      $form['uc_2checkout_language'] = array(
        '#type' => 'select',
        '#title' => t('Language preference'),
        '#description' => t('Adjust language on 2Checkout pages.'),
        '#options' => array(
          'en' => t('English'),
          'sp' => t('Spanish'),
        ),
        '#default_value' => variable_get('uc_2checkout_language', 'en'),
      );
      $form['uc_2checkout_currency_code'] = array(
        '#type' => 'select',
        '#title' => t('Currency for the sale'),
        '#options' => array(
          '' => t('Auto detected by 2CO'),
          'USD',
          'EUR',
          'ARS',
          'AUD',
          'BRL',
          'GBP',
          'CAD',
          'DKK',
          'HKD',
          'INR',
          'ILS',
          'JPY',
          'LTL',
          'MYR',
          'MXN',
          'NZD',
          'NOK',
          'PHP',
          'RON',
          'RUB',
          'SGD',
          'ZAR',
          'SEK',
          'CHF',
          'TRY',
          'AED',
        ),
        '#default_value' => variable_get('uc_2checkout_currency_code', ''),
      );
      $form['uc_2checkout_check'] = array(
        '#type' => 'checkbox',
        '#title' => t('Allow customers to choose to pay by credit card or online check.'),
        '#default_value' => variable_get('uc_2checkout_check', FALSE),
      );
      $form['uc_2checkout_method_title'] = array(
        '#type' => 'textfield',
        '#title' => t('Payment method title'),
        '#default_value' => variable_get('uc_2checkout_method_title', t('Credit card on a secure server:')),
      );
      $form['uc_2checkout_checkout_type'] = array(
        '#type' => 'radios',
        '#title' => t('Checkout type'),
        '#options' => array(
          'dynamic' => t('Dynamic checkout (user is redirected to 2CO)'),
          'direct' => t('Direct checkout (payment page opens in iframe popup)'),
        ),
        '#default_value' => variable_get('uc_2checkout_checkout_type', 'dynamic'),
      );
      $form['uc_2checkout_notification_url'] = array(
        '#type' => 'textfield',
        '#title' => t('Instant notification settings URL'),
        '#description' => t('Pass this URL to the <a href="@help_url">instant notification settings</a> parameter in your 2Checkout account. This way, any refunds or failed fraud reviews will automatically cancel the Ubercart order.', array(
          '@help_url' => 'https://www.2checkout.com/static/va/documentation/INS/index.html',
        )),
        '#default_value' => url('cart/2checkout/notification', array(
          'absolute' => TRUE,
        )),
        '#attributes' => array(
          'readonly' => 'readonly',
        ),
      );
      return $form;
  }
}