Index: payment/uc_credit/uc_credit.module
===================================================================
--- payment/uc_credit/uc_credit.module	(revision 1641)
+++ payment/uc_credit/uc_credit.module	(working copy)
@@ -372,8 +372,8 @@
 
   $path = base_path() . drupal_get_path('module', 'uc_credit');
   $title = t('Credit card:');
-  $cc_types = array('visa', 'mastercard', 'discover', 'amex');
-  foreach ($cc_types as $type) {
+  $cc_types = uc_credit_card_types();
+  foreach ($cc_types as $type => $label) {
     if (variable_get('uc_credit_'. $type, TRUE)) {
       $title .= ' <img src="'. $path .'/images/'. $type .'.gif" style="position: relative; top: 5px;" />';
     }
@@ -494,7 +494,7 @@
       }
 
       // Validate the CVV number if enabled.
-      if (variable_get('uc_credit_cvv_enabled', TRUE) && !_valid_cvv($cc_data['cc_cvv'])) {
+      if (variable_get('uc_credit_cvv_enabled', TRUE) && !_valid_cvv($cc_data['cc_cvv'], $cc_data['cc_type'])) {
         if (!$silent) {
           drupal_set_message(t('You have entered an invalid CVV number.'), 'error');
         }
@@ -528,8 +528,9 @@
       return $return;

     case 'cart-review':
+      $cc_types = uc_credit_card_types();
       if (variable_get('uc_credit_type_enabled', FALSE)) {
-        $review[] = array('title' => t('Card Type'), 'data' => check_plain($arg1->payment_details['cc_type']));
+        $review[] = array('title' => t('Card Type'), 'data' => $cc_types[$arg1->payment_details['cc_type']]);
       }
       if (variable_get('uc_credit_owner_enabled', FALSE)) {
         $review[] = array('title' => t('Card Owner'), 'data' => filter_xss($arg1->payment_details['cc_owner']));
@@ -562,7 +563,8 @@
         $output .= '<span id="cc_details"><table style="width: auto;">';
 
         if (variable_get('uc_credit_type_enabled', TRUE)) {
-          $type = check_plain($arg1->payment_details['cc_type']);
+          $cc_types = uc_credit_card_types();
+          $type = $cc_types[$arg1->payment_details['cc_type']];
           if (strlen($type) > 0) {
             $output .= '<tr><td>'. t('Card Type:') .' </td><td>'. $type .'</td></tr>';
           }
@@ -785,12 +787,6 @@
         '#description' => t('If enabled, specify in the textarea below which card options to populate the select box with.'),
         '#default_value' => variable_get('uc_credit_type_enabled', FALSE),
       );
-      $form['cc_fields']['uc_credit_accepted_types'] = array(
-        '#type' => 'textarea',
-        '#title' => t('Card type select box options'),
-        '#description' => t('Enter one card type per line. These fields will populate the card type select box if it is enabled.'),
-        '#default_value' => variable_get('uc_credit_accepted_types', implode("\r\n", array(t('Visa'), t('Mastercard'), t('Discover'), t('American Express')))),
-      );
 
       // From elements that deal with card types accepted.
       $form['cc_types'] = array(
@@ -798,26 +794,14 @@
         '#title' => t('Accepted card types (for validation)'),
         '#description' => t('Use the checkboxes to specify which card types you accept for payment. Selected card types will show their icons in the payment method selection list and be used for card number validation.'),
       );
-      $form['cc_types']['uc_credit_visa'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Visa'),
-        '#default_value' => variable_get('uc_credit_visa', TRUE),
-      );
-      $form['cc_types']['uc_credit_mastercard'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Mastercard'),
-        '#default_value' => variable_get('uc_credit_mastercard', TRUE),
-      );
-      $form['cc_types']['uc_credit_discover'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Discover'),
-        '#default_value' => variable_get('uc_credit_discover', TRUE),
-      );
-      $form['cc_types']['uc_credit_amex'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('American Express'),
-        '#default_value' => variable_get('uc_credit_amex', TRUE),
-      );
+      $cc_types = uc_credit_card_types();
+      foreach ($cc_types as $type => $label) {
+        $form['cc_types']['uc_credit_' . $type] = array(
+          '#type' => 'checkbox',
+          '#title' => $label,
+          '#default_value' => variable_get('uc_credit_' . $type, TRUE),
+        );
+      }
 
       // Form elements that deal with credit card messages to customers.
       $form['cc_messages'] = array(
@@ -930,16 +914,13 @@
   $form['cc_policy'] = array('#value' => variable_get('uc_credit_policy', t('Your billing information must match the billing address for the credit card entered below or we will be unable to process your payment.')));
 
   if (variable_get('uc_credit_type_enabled', FALSE)) {
-    $types = variable_get('uc_credit_accepted_types', implode("\r\n", array(t('Visa'), t('Mastercard'), t('Discover'), t('American Express'))));
-    if (empty($types)) {
-      $types = array(t('N/A'));
+    $cc_types = uc_credit_card_types();
+    foreach ($cc_types as $type => $label) {
+      if (variable_get('uc_credit_' . $type, 0)) {
+        $options[$type] = $label;
+      }
     }
-    else {
-      $types = explode("\r\n", $types);
-    }
-    foreach ($types as $type) {
-      $options[check_plain($type)] = $type;
-    }
+    $options = empty($options) ? array(t('N/A')) : $options;
     $form['cc_type'] = array(
       '#type' => 'select',
       '#title' => t('Card type'),
@@ -1019,7 +1000,7 @@
 
   if (variable_get('uc_credit_cvv_enabled', TRUE)) {
     // Set up the default CVV  on the credit card form.
-    if (!_valid_cvv($order->payment_details['cc_cvv'])) {
+    if (!_valid_cvv($order->payment_details['cc_cvv'], $order->payment_details['cc_type'])) {
       // Display the CVV as is if it does not validate so it can be corrected.
       $default_cvv = $order->payment_details['cc_cvv'];
     }
@@ -1249,24 +1230,28 @@
 }
 
 // Validates a CVV number during checkout.
-function _valid_cvv($cvv) {
-  $digits = array();
+function _valid_cvv($cvv, $card_type = NULL) {
+  $cvv_length = strlen($cvv);
 
-  if (variable_get('uc_credit_visa', TRUE) ||
-      variable_get('uc_credit_mastercard', TRUE) ||
-      variable_get('uc_credit_discover', TRUE)) {
-    $digits[] = 3;
+  $digits0 = array('laser', 'maestro', 'solo');
+  $digits3 = array('visa', 'mastercard', 'discover', 'diners');;
+  $digits4 = array('amex');
+
+  // Pass validation for cards with no CVV set and shouldn't, e.g. debit cards.
+  if (!$cvv_length && in_array(strtolower($card_type), $digits0)) {
+    return TRUE;
   }
-  if (variable_get('uc_credit_amex', TRUE)) {
-    $digits[] = 4;
+  // Pass validation if cvv length is 3.
+  elseif ($cvv_length == 3 && in_array(strtolower($card_type), $digits3)) {
+    return TRUE;
   }
-
-  // Fail validation if it's non-numeric or an incorrect length.
-  if (!is_numeric($cvv) || (count($digits) > 0 && !in_array(strlen($cvv), $digits))) {
-    return FALSE;
+  // Pass validation if cvv length is 4.
+  elseif ($cvv_length == 4 && in_array(strtolower($card_type), $digits4)) {
+    return TRUE;
   }
 
-  return TRUE;
+  // Otherwise fail validation.
+  return FALSE;
 }
 
 /**
@@ -1275,10 +1260,10 @@
  */
 function _valid_card_number($number) {
   $id = substr($number, 0, 1);
-  if (($id == 3 && !variable_get('uc_credit_amex', TRUE)) ||
+  if (($id == 3 && !variable_get('uc_credit_amex', TRUE) && !variable_get('uc_credit_diners', TRUE)) ||
       ($id == 4 && !variable_get('uc_credit_visa', TRUE)) ||
       ($id == 5 && !variable_get('uc_credit_mastercard', TRUE)) ||
-      ($id == 6 && !variable_get('uc_credit_discover', TRUE)) ||
+      ($id == 6 && !variable_get('uc_credit_discover', TRUE) && !variable_get('uc_credit_laser', TRUE)) && !variable_get('uc_credit_maestro', TRUE) && !variable_get('uc_credit_solo', TRUE) ||
       !ctype_digit($number)) {
     return FALSE;
   }
@@ -1430,6 +1415,25 @@
 }
 
 /**
+ * Returns an array of support credit card types available to payment gateway
+ * modules.
+ */
+function uc_credit_card_types() {
+  $cc_types = array(
+    'visa' => t('Visa'),
+    'mastercard' => t('Mastercard'),
+    'discover' => t('Discover'),
+    'amex' => t('American Express'),
+    'laser' => t('Laser'),
+    'maestro' => t('Maestro'),
+    'solo' => t('Solo'),
+    'diners' => t("Diner's Club"),
+  );
+
+  return $cc_types;
+}
+
+/**
  * Retrieves the ID of the default credit card gateway.
  *
  * @return
Index: payment/uc_credit/uc_credit.pages.inc
===================================================================
--- payment/uc_credit/uc_credit.pages.inc	(revision 1641)
+++ payment/uc_credit/uc_credit.pages.inc	(working copy)
@@ -10,7 +10,7 @@
 // Prints the contents of the CVV information popup window.
 function uc_credit_cvv_info() {
   $output = '<b>'. t('What is the CVV?') .'</b><p>'. t('CVV stands for Card Verification Value. This number is used as a security feature to protect you from credit card fraud.  Finding the number on your card is a very simple process.  Just follow the directions below.') .'</p>';
-  $cc_types = array('visa', 'mastercard', 'discover');
+  $cc_types = array('visa', 'mastercard', 'discover', 'diners', 'solo');
   foreach ($cc_types as $type) {
     if (variable_get('uc_credit_'. $type, TRUE)) {
       $valid_types[] = ucfirst($type);
