? uc_linkpoint_api-1001744.patch
Index: uc_linkpoint_api.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_linkpoint_api/uc_linkpoint_api.module,v
retrieving revision 1.12
diff -u -p -r1.12 uc_linkpoint_api.module
--- uc_linkpoint_api.module	17 Dec 2010 21:53:31 -0000	1.12
+++ uc_linkpoint_api.module	24 Dec 2010 22:20:53 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: uc_linkpoint_api.module,v 1.12 2010/12/17 21:53:31 jrust Exp $
+// $Id: uc_linkpoint_api.module,v 1.11 2010/12/08 23:37:15 jrust Exp $
 /**
  * @file
  * A module used for Linkpint API payment gateway
@@ -157,6 +157,7 @@ function uc_linkpoint_api_charge($order_
     $_SESSION['uc_linkpoint_order'] = $order_id;
     unset($_SESSION['uc_linkpoint_attempt']);
   }
+  $_SESSION['uc_linkpoint_attempt'] = empty($_SESSION['uc_linkpoint_attempt']) ? 1 : ($_SESSION['uc_linkpoint_attempt'] + 1);
 
   $order = uc_order_load($order_id);
 
@@ -167,20 +168,6 @@ function uc_linkpoint_api_charge($order_
     // Order numbers must be unique in Linkpoint, so if someone attempted a transaction (then failed),
     // then went back and changed details, we must alter the order ID to avoid an error from Linkpoint
     $order_id = $order->order_id;
-    if (empty($_SESSION['uc_linkpoint_attempt'])) {
-      $_SESSION['uc_linkpoint_attempt'] = 0;
-    }
-    // If we are charging the account through the backend, we'll need a unique order number based on authorized order
-    $orig_order_id = empty($order->data['cc_txns']['authorizations']) ? NULL : end(array_keys($order->data['cc_txns']['authorizations']));
-    if ($_SESSION['uc_linkpoint_attempt'] == 0 && !empty($orig_order_id)) {
-      if (preg_match('/-(\d+)$/', $orig_order_id, $matches)) {
-        $_SESSION['uc_linkpoint_attempt'] = $matches[1];
-      }
-      else {
-        $_SESSION['uc_linkpoint_attempt'] = 1;
-      }
-    }
-    $_SESSION['uc_linkpoint_attempt']++;
 
     $unique_oid = $_SESSION['uc_linkpoint_attempt'] > 1 ? "$order_id-{$_SESSION['uc_linkpoint_attempt']}" : $order_id;
     $unique_oid = variable_get('linkpoint_api_order_prefix', '') . $unique_oid;
@@ -201,6 +188,9 @@ function uc_linkpoint_api_charge($order_
     );
     return $result;
   }
+  
+  // Log the transaction that just occured, no matter the result of it.
+  _uc_linkpt_save_order_comment($order_id, $data, $transaction_result, _uc_linkpt_txn_map($data['txn_type']));
 
   // Credit card was declined for whatever reason
   if ($transaction_result['approved'] != 'APPROVED') {
@@ -210,13 +200,9 @@ function uc_linkpoint_api_charge($order_
       'message' => t('Credit card payment declined: @text', array('@text' => $transaction_result['error'])),
       'uid' => $user->uid,
     );
-    _uc_linkpt_save_order_comment($order_id, $data, $transaction_result, _uc_linkpt_txn_map($data['txn_type']));
   }
   // Credit card was accepted, continue on but check if it passes fraud detection
   else {
-    // log the transaction that just occured
-    _uc_linkpt_save_order_comment($order_id, $data, $transaction_result, _uc_linkpt_txn_map($data['txn_type']));
-
     // Should this order be voided?
     if (($fraud_reason = _uc_linkpt_is_fraud($transaction_result)) != null) {
       // Need to void order... indicate such in the log
