### Eclipse Workspace Patch 1.0
#P uc_payflowpro-6.1
Index: uc_payflowpro.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_payflowpro/uc_payflowpro.module,v
retrieving revision 1.2.2.29
diff -u -r1.2.2.29 uc_payflowpro.module
--- uc_payflowpro.module	12 Dec 2010 21:19:09 -0000	1.2.2.29
+++ uc_payflowpro.module	8 Jan 2011 17:43:43 -0000
@@ -1018,6 +1018,15 @@
   return $xml;
 }
 
+function _uc_payflowpro_generate_invoice_id($order) {
+  // PayPal only allows 1 transaction per invoice Id. Send a unique Id for test
+  // orders to avoid a duplicate id error message on live transactions.
+  if (variable_get('uc_payflowpro_mode', 'test') == 'test') {
+    return $order->order_id . '-TEST-' . uniqid();
+  }
+  return intval($order->order_id);
+}
+
 // Generate XML for Invoice section of request
 function _uc_payflowpro_invoice_xml($order) {
   $billing_country = uc_get_country_data(array('country_id' => $order->billing_country));
@@ -1054,8 +1063,10 @@
   	$comment = _uc_get_skus($order);
   }
 
-  $xml = '            <Invoice>
-              <InvNum>' . intval($order->order_id) . '</InvNum>
+  $invoice_id = _uc_payflowpro_generate_invoice_id($order);
+
+  $xml = '	<Invoice>
+              <InvNum>' . $invoice_id . '</InvNum>
               <Comment>' . check_plain($comment) . '</Comment>
               <BillTo>
                 <Name>' . trim(check_plain($order->billing_first_name . ' ' . $order->billing_last_name)) . '</Name>
@@ -1238,8 +1249,10 @@
     }
   }
 
-  $xml = '            <Invoice>
-              <InvNum>' . intval($order->order_id) . '</InvNum>
+  $invoice_id = _uc_payflowpro_generate_invoice_id($order);
+
+  $xml = '  <Invoice>
+              <InvNum>' . $invoice_id . '</InvNum>
               <BillTo>
                 <Name>' . trim(check_plain($order->billing_first_name . ' ' . $order->billing_last_name)) . '</Name>
                 <Phone>' . check_plain($order->billing_phone) . '</Phone>
