Index: uc_moneris.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_moneris/uc_moneris.module,v
retrieving revision 1.9
diff -u -p -w -r1.9 uc_moneris.module
--- uc_moneris.module	12 Jan 2010 22:28:18 -0000	1.9
+++ uc_moneris.module	16 Dec 2010 17:51:39 -0000
@@ -328,7 +328,16 @@ function uc_moneris_charge($order_id, $a
   $order = uc_order_load($order_id);
 
   require_once(drupal_get_path('module', 'uc_moneris') .'/api/mpiClasses.php');
-  require_once(drupal_get_path('module', 'uc_moneris') .'/api/mpgClasses.php');
+
+  // This defaults to the Canadian version. To change to US set the variable uc_moneris_api_version to "us"
+  // using the Devel variable editor or the shell command drush vset uc_moneris_api_version 'us'
+  $is_us = (variable_get('uc_moneris_api_version','can') == 'us');
+  if ($is_us) {
+    require_once(drupal_get_path('module', 'uc_moneris') .'/api_us/mpgClasses.php');
+  }
+  else {
+    require_once(drupal_get_path('module', 'uc_moneris') .'/api_can/mpgClasses.php');
+  }
   /**************************** Request Variables *******************************/
   $store_id   = variable_get('uc_moneris_store_id', '');
   $api_token  = variable_get('uc_moneris_api_token', '');
@@ -458,6 +467,7 @@ function uc_moneris_charge($order_id, $a
     /******************************* Response ************************************/
     $mpgResponse  = $mpgHttpPost->getMpgResponse();
     $response_code = $mpgResponse->getResponseCode();
+
     $txn_number    = $mpgResponse->getTxnNumber();
     $completed = strtolower($mpgResponse->getComplete());
     //Check the CVD?
@@ -507,7 +517,7 @@ function uc_moneris_charge($order_id, $a
       }
     }
 
-    if (($this_trans_type == uc_moneris_preauth_string() && $txn_type == uc_moneris_transaction_type()) && intval($response_code) < 49 || $completed == 'true') {
+    if ($this_trans_type == uc_moneris_preauth_string() && $txn_type == uc_moneris_transaction_type() && (intval($response_code) <= 49 && $completed == 'true')) {
       //The previous transaction was a preauth before a capture. Run the transaction again in Capture mode.
       $txnArray = array(
         'type'        =>  variable_get('uc_moneris_api_version', '') .'completion',
