Index: uc_linkpoint_api.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_linkpoint_api/uc_linkpoint_api.module,v
retrieving revision 1.17
diff -u -p -r1.17 uc_linkpoint_api.module
--- uc_linkpoint_api.module	4 Jan 2011 23:47:28 -0000	1.17
+++ uc_linkpoint_api.module	5 Feb 2011 05:54:28 -0000
@@ -197,7 +197,7 @@ function uc_linkpoint_api_charge($order_
   else {
     // Did it trigger fraud settings?
     if (($fraud_reason = _uc_linkpt_is_fraud($transaction_result)) != NULL &&
-        _uc_linkpt_void_fraudulent_txn($order, $unique_oid, $data, $fraud_reason)) {
+      _uc_linkpt_void_fraudulent_txn($order, $unique_oid, $data, $fraud_reason)) {
       $result = array(
         'success' => FALSE,
         'comment' => t('Credit card did not pass fraud detection: @reason',array('@reason' => $fraud_reason)),
@@ -310,7 +310,7 @@ function _uc_linkpt_send_transaction($xm
   // There was a cURL error
   if ($result === false) {
     $response['approved'] = 'ERROR';
-    $response['error'] = curl_error($ch);
+    $response['error'] = curl_errno($ch) . ': ' . curl_error($ch);
     return $response;
   }
 
@@ -441,18 +441,37 @@ function _uc_linkpt_xml_payment($order, 
       $tax += $tax_item->amount;
     }
   }
+  
   $subtotal = $order->order_total - $tax - $shipping;
+  
+  $context = array(
+    'revision' => 'formatted-original',
+    'type' => 'order_total',
+    'subject' => array(
+      'order' => $order,
+    ),
+  );
+  $options = array(
+    'sign' => FALSE,
+    'thou' => FALSE,
+    'dec' => '.',
+  );
 
   $xml = '';
   $xml .="<payment>";
+    $amount_round = uc_price($amount, $context, $options);
     // Only break down the payment information if it totals up to the chargetotal.
     if ($subtotal + $tax + $shipping == $amount) {
-      if (!empty($subtotal)) $xml .="<subtotal>" . $subtotal . "</subtotal>";
-      if (!empty($tax)) $xml .="<tax>" . $tax . "</tax>";
-      if (!empty($shipping)) $xml .="<shipping>" . $shipping . "</shipping>";
+      $tax_round = uc_price($tax, $context, $options);
+      $shipping_round = uc_price($shipping, $context, $options);
+      $realsubtotal = $amount_round - $tax_round - $shipping_round; // due to bug in ubercart, tax or shipping or something is not rounded properly. need this to make everything add up
+      if (!empty($subtotal)) $xml .="<subtotal>" . uc_price($realsubtotal, $context, $options) . "</subtotal>";
+      if (!empty($tax)) $xml .="<tax>" . $tax_round . "</tax>";
+      if (!empty($shipping)) $xml .="<shipping>" . $shipping_round . "</shipping>";
     }
-    $xml .="<chargetotal>".$amount."</chargetotal>";
+    $xml .="<chargetotal>".uc_price($amount_round, $context, $options)."</chargetotal>";
   $xml .="</payment>";
+
   return $xml;
 }
 
