--- stc_taxes.module	2009-03-17 04:04:44.000000000 -0400
+++ stc_taxes.module.fixed	2010-11-16 23:19:10.000000000 -0500
@@ -122,19 +122,47 @@ function stc_taxes_calculate_tax($order)
   
   $line_item_results = stc_taxes_apply2line_items($order, $tax_rates);
   
-  $tax = new stdClass();
-  $tax->id = 'stc-taxes';
-  $tax->name = t('Taxes');
-  $tax->amount = $product_results['amount'] + $line_item_results['amount'];
-  
   stc_taxes_record_applications(array_merge($product_results['tax_records'], $line_item_results['tax_records']));
   
+  // Get order's total
+  $total = 0;
+  foreach($order->products as $product) {
+    $total = $total + $product->price;
+  }
+
+  $tax = (object) array(
+    'id' => _get_safe_id(),
+    'name' => t('Taxes'),
+    'amount' => $product_results['amount'] + $line_item_results['amount'],
+    'weight' => 0,
+    'summed' => 1,
+  );  
+  $tax->data = array(
+    'tax_id' => $tax->id,
+    'tax_rate' => $product_results['amount'] + $line_item_results['amount'],
+    'taxable_amount' => $total,
+  );  
+
   if (is_object($tax)) {
-    return array($tax);
+    return $tax;
   }
   else {
     return array();
   }
+
+}
+
+// Create safe id for tax
+function _get_safe_id() {
+  $maxid = 1;
+  $rates = uc_taxes_rate_load();
+  foreach ($rates as $id => $info) {
+    if ($id >= $maxid) {
+      $maxid = $id;
+    }
+  }
+
+  return $maxid + 99;
 }
 
 /**
@@ -508,7 +536,7 @@ function stc_taxes_get_rates_from_webser
   
   $key_values = array();
   $key_values[] = $zip;
-  $key_values[] = strtolower($city);
+  $key_values[] = strtolower(trim($city));
   $key_values[] = $state;
   
   $key = implode(';', $key_values);
