Zen Cart Logo
Forums / Bug Reports / [Done v1.3.9g] Authorize net module debug data may have mismatched id number

[Done v1.3.9g] Authorize net module debug data may have mismatched id number

Locked

Views: 1,305

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
13 Sep 2010, 9:32 PM
#1
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,699
Plugin Contributions:
56

[Done v1.3.9g] Authorize net module debug data may have mismatched id number

The call

$new_order_id = (string)$new_order_id . '-' . zen_create_random_value(6);

could produce a random string including digits, which would be misparsed by the logic which gets the order number for use in the AUTHORIZENET table:

$sql = $db->bindVars($sql, ':orderID', preg_replace('/[^0-9]/', '', $response[7]), 'integer');

I believe it would be safer to do

$new_order_id = (string)$new_order_id . '-' . zen_create_random_value(6,'chars');

Consider the string:

TEST-1530-XLWNS7

which would result in order 15307, not 1530.

13 Sep 2010, 11:53 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [Done v1.3.9g] Authorize net module debug data may have mismatched id number

So, do I assume that you're calling this a "bug" because there's some sort of mismatch in the history log table?

13 Sep 2010, 11:55 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,699
Plugin Contributions:
56

Re: [Done v1.3.9g] Authorize net module debug data may have mismatched id number

Correct. The table authorizenet gets updated with the incorrect order_id.

14 Sep 2010, 11:26 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,699
Plugin Contributions:
56

Re: [Done v1.3.9g] Authorize net module debug data may have mismatched id number

As a suggestion, would it be even better to correct the order id when it is finally known:

function after_process() { 
    if (MODULE_PAYMENT_AUTHORIZENET_AIM_STORE_DATA == 'True'){
      // Fix order_id if required
      $sql = "SELECT id, order_id FROM " . TABLE_AUTHORIZENET . "  WHERE transaction_id = :transID ORDER BY id DESC";
      $sql = $db->bindVars($sql, ':transID:', $this->transaction_id, 'string');
      $orderlist = $db->Execute($sql);
      if ($orderlist->RecordCount()) {
         if ($orderlist->fields['order_id'] != $insert_id) {
            $sql = "UPDATE " . TABLE_AUTHORIZENET . " SET order_id = :order_id WHERE id = :id); 
            $sql = $db->bindVars($sql, ':orderID', $insert_id, 'integer');
            $sql = $db->bindVars($sql, ':id', $orderlist->fields['id'], 'integer');
            $db->Execute($sql);
         }
      }
    }

... existing logic