Jump to content



Photo

authorize.net problems


  • Please log in to reply
73 replies to this topic

#21   AllThingsTrendy

AllThingsTrendy
  • Members
  • 91 posts
  • Real Name:Anthony David
  • Gender:Male
  • Location:Houston, TX

Posted 22 July 2008 - 21:02

Jeff, thanks for the suggestion! My site had the form tags as you described. I followed your instructions and now the form tags are properly positioned as you suggest. However, I still receive the same general error:
"There has been an error processing your credit card. Please try again and if problems persist, please try another payment method."

Any other suggestions from anyone?
Anthony David
AllThingsTrendy.com

#22   AllThingsTrendy

AllThingsTrendy
  • Members
  • 91 posts
  • Real Name:Anthony David
  • Gender:Male
  • Location:Houston, TX

Posted 22 July 2008 - 22:56

Jeff, after making the suggested change, I have noticed that the PayPal payment module does not work. Clicking the "Confirm" button results in nothing happening. I reversed the suggested changes and the PayPal module works fine.
Anthony David
AllThingsTrendy.com

#23   danthman

danthman
  • Members
  • 192 posts
  • Real Name:Dan Snyder
  • Location:Ft Lauderdale, FL

Posted 24 July 2008 - 12:07

Okay, I've been researching this for a week and still haven't figured out why my authorize.net module isn't working. I haven't even been able to find a thread which was dedicated entirely to "setting up" the authorize.net module so I've been searching the hundred of threads relating to auth.net to find a solution to my problem.

Now depending on which authorize.net module I use, I get a different error.

I've tried vger's version march 18 and I get the "There has been an error processing your credit card".

I've tried ponce's version jan 11 2008 and I get the "There has been an error processing your credit card".

I've tried the default authorize.net version bundled in OSC and still no luck.

There appears to be a million threads about the many different errors and solutions for each. I've looked through just about all of the one's that I thought pertained to my problem and I still can't get it to work.

I have followed all instructions provided by each thread and each modules without success.

Some seem to have a easy time getting auth.net to work while others never seem to find a solution to their problems.

--------------------------------------------------
"There has been an error processing your credit card
Please try again and if problems persist, please try another payment method."

above is the error I am getting using ponce's version of AIM for authorize.net. which is the version that I would prefer to use. Now if I'm told to use a different version, then I will. But it seems that ponce's version is the newest of the greatest and I'd like to get it to work.


I am hosted with pair networks (the osc sponsor) running php5/mysql5. I have curl compiled on there so I know that this is not the problem. With ponce's version of the AIM module, I tried setting the curl field to "usr/bin/curl" and just "curl". I get the same results, error.

===In my settings for A.net (TESTMODE)

-I have enabled the following in " Upload Transaction File Format":

Email Customer: yes
Apply AVS Filter: no
Apply Card Code Filter: no
field separator: comma(,)
Field Encapsulation Character: blank

-In the "transaction version", I am using the 3.1 version

-In the "response/receive URL", I have the following:

URL
https://www.mydomain...out_process.php Default Receipt URL Edit
https://www.mydomain...out_process.php Default Relay Response URL Edit

-I did not touch

-In the "address verification service", I have the default values seclected.

-I've set my MD5hash and entered it in the "MD5hash" field in OSC's administration > modules > payment > Authorize.net Credit Card AIM

-I've enabled "password required mode"

-I've enabled "file uploads capabilities"

-I do not have weblink activated

-and I've entered my API and transkey into the proper fields of OSC's administration > modules > payment > Authorize.net Credit Card AIM


Am I missing something?


I have exactly the same problem. Anyone have any ideas?

#24   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 24 July 2008 - 21:47

So I have been searching the forum for weeks now to find a solution to this same problem. I think I am getting closer with "fwrite" script.

Here is the log.

[codebox]SENT: x_login=xxxxxxxxx&x_tran_key=xxxxxxxxxxxxxxx&x_version=3.1&x_delim_data=TRUE&x_delim_char=%2C&x_encap_char=%22&x_relay_response=FALSE&x_first_name=John&x_last_name=Doe&x_company=&x_address=###+Street+Ave.&x_city=Los+Angeles&x_state=California&x_zip=#####&x_country=United+States&x_phone=6265551212&x_cust_id=2&x_customer_ip=XX.XXX.XXX.XX&x_email=johndoe%40my_provider.net&x_description=xxxxxxxxxxxxx&x_amount=3.49&x_currency_code=USD&x_method=CC&x_type=AUTH_CAPTURE&x_card_num=xxxxxxxxxxxxxxxx&x_exp_date=0108&x_card_code=xxx&x_ship_to_first_name=John&x_ship_to_last_name=Doe&x_ship_to_company=&x_ship_to_address=####+Street+Ave.&x_ship_to_city=Los+Angeles&x_ship_to_state=California&x_ship_to_zip=#####&x_ship_to_country=United+States&x_test_request=TRUE&x_freight=2.50&x_line_item=1<|>Test<|>Test<|>1<|>0.99<|>NO
RESPONSE: "3","2","13","(TESTMODE) The merchant login ID or password is invalid or the account is inactive.","000000","P","0","","","3.49","","auth_capture","","","","","","","","","","","","","","","","","","","","","","","","","","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
POST: cc_owner=John Doe
POST: cc_number_nh-dns=xxxxxxxxxxxxxxxx
POST: cc_expires_month=01
POST: cc_expires_year=08
POST: cc_cvc_nh-dns=xxx
POST: x=43
POST: y=6
Done.[/codebox]


I think something in the script is not relaying properly. I verified that my login and transaction id were correct, but still nothing.

I have tried every possible setting from the admin. I got it to partially work 1 time. Authorize.net shows the transaction, but my site doesn't, nor was I ever routed back to my site.

I am gonna play with the code a bit and see if there is maybe a contribution I can add to solve this problem. I really need this to work as do many of us.

Joshua Morris

#25   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 24 July 2008 - 22:09

Oh yeah, I guess I should probably let everybody see my /catalog/includes/modules/paymentauthorizenet_cc_aim.php

<?php/*  $Id: authorizenet_cc_aim.php 1803 2008-01-11 18:16:37Z hpdl $osCommerce, Open Source E-Commerce Solutions  [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]  Copyright © 2008 osCommerce  Released under the GNU General Public License*/  class authorizenet_cc_aim {    var $code, $title, $description, $enabled;// class constructor    function authorizenet_cc_aim() {      global $order;      $this->signature = 'authorizenet|authorizenet_cc_aim|1.0|2.2';      $this->code = 'authorizenet_cc_aim';      $this->title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_TITLE;      $this->public_title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_PUBLIC_TITLE;      $this->description = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_DESCRIPTION;      $this->sort_order = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER;      $this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS == 'True') ? true : false);      if ((int)MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID > 0) {        $this->order_status = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID;      }      if (is_object($order)) $this->update_status();    }// class methods    function update_status() {      global $order;      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE > 0) ) {        $check_flag = false;        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");        while ($check = tep_db_fetch_array($check_query)) {          if ($check['zone_id'] < 1) {            $check_flag = true;            break;          } elseif ($check['zone_id'] == $order->billing['zone_id']) {            $check_flag = true;            break;          }        }        if ($check_flag == false) {          $this->enabled = false;        }      }    }    function javascript_validation() {      return false;    }    function selection() {      return array('id' => $this->code,                   'module' => $this->public_title);    }    function pre_confirmation_check() {      return false;    }    function confirmation() {      global $order;      for ($i=1; $i<13; $i++) {        $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));      }      $today = getdate();       for ($i=$today['year']; $i < $today['year']+10; $i++) {        $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));      }      $confirmation = array('fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_OWNER,                                                    'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),                                              array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_NUMBER,                                                    'field' => tep_draw_input_field('cc_number_nh-dns')),                                              array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_EXPIRES,                                                    'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month) . '&nbsp;' . tep_draw_pull_down_menu('cc_expires_year', $expires_year)),                                              array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CREDIT_CARD_CVC,                                                    'field' => tep_draw_input_field('cc_cvc_nh-dns', '', 'size="5" maxlength="4"'))));      return $confirmation;    }    function process_button() {      return false;    }    function before_process() {      global $HTTP_POST_VARS, $customer_id, $order, $sendto, $currency;      $params = array('x_login' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID, 0, 20),                      'x_tran_key' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY, 0, 16),                      'x_version' => '3.1',                      'x_delim_data' => 'TRUE',                      'x_delim_char' => ',',                      'x_encap_char' => '"',                      'x_relay_response' => 'FALSE',                      'x_first_name' => substr($order->billing['firstname'], 0, 50),                      'x_last_name' => substr($order->billing['lastname'], 0, 50),                      'x_company' => substr($order->billing['company'], 0, 50),                      'x_address' => substr($order->billing['street_address'], 0, 60),                      'x_city' => substr($order->billing['city'], 0, 40),                      'x_state' => substr($order->billing['state'], 0, 40),                      'x_zip' => substr($order->billing['postcode'], 0, 20),                      'x_country' => substr($order->billing['country']['title'], 0, 60),                      'x_phone' => substr($order->customer['telephone'], 0, 25),                      'x_cust_id' => substr($customer_id, 0, 20),                      'x_customer_ip' => tep_get_ip_address(),                      'x_email' => substr($order->customer['email_address'], 0, 255),                      'x_description' => substr(STORE_NAME, 0, 255),                      'x_amount' => substr($this->format_raw($order->info['total']), 0, 15),                      'x_currency_code' => substr($currency, 0, 3),                      'x_method' => 'CC',                      'x_type' => ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD == 'Capture') ? 'AUTH_CAPTURE' : 'AUTH_ONLY'),                      'x_card_num' => substr($HTTP_POST_VARS['cc_number_nh-dns'], 0, 22),                      'x_exp_date' => $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year'],                      'x_card_code' => substr($HTTP_POST_VARS['cc_cvc_nh-dns'], 0, 4));      if (is_numeric($sendto) && ($sendto > 0)) {        $params['x_ship_to_first_name'] = substr($order->delivery['firstname'], 0, 50);        $params['x_ship_to_last_name'] = substr($order->delivery['lastname'], 0, 50);        $params['x_ship_to_company'] = substr($order->delivery['company'], 0, 50);        $params['x_ship_to_address'] = substr($order->delivery['street_address'], 0, 60);        $params['x_ship_to_city'] = substr($order->delivery['city'], 0, 40);        $params['x_ship_to_state'] = substr($order->delivery['state'], 0, 40);        $params['x_ship_to_zip'] = substr($order->delivery['postcode'], 0, 20);        $params['x_ship_to_country'] = substr($order->delivery['country']['title'], 0, 60);      }      if (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE == 'Test') {        $params['x_test_request'] = 'TRUE';      }      $tax_value = 0;      foreach ($order->info['tax_groups'] as $key => $value) {        if ($value > 0) {          $tax_value += $this->format_raw($value);        }      }      if ($tax_value > 0) {        $params['x_tax'] = $this->format_raw($tax_value);      }      $params['x_freight'] = $this->format_raw($order->info['shipping_cost']);      $post_string = '';      foreach ($params as $key => $value) {        $post_string .= $key . '=' . urlencode(trim($value)) . '&';      }      $post_string = substr($post_string, 0, -1);      for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {        $post_string .= '&x_line_item=' . urlencode($i+1) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 31)) . '<|>' . urlencode(substr($order->products[$i]['name'], 0, 255)) . '<|>' . urlencode($order->products[$i]['qty']) . '<|>' . urlencode($this->format_raw($order->products[$i]['final_price'])) . '<|>' . urlencode($order->products[$i]['tax'] > 0 ? 'YES' : 'NO');      }      switch (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER) {        case 'Live':          $gateway_url = 'https://secure.authorize.net/gateway/transact.dll';          break;        default:          $gateway_url = 'https://test.authorize.net/gateway/transact.dll';          break;      }      $transaction_response = $this->sendTransactionToGateway($gateway_url, $post_string);      if (!empty($transaction_response)) {        $regs = preg_split("/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/", $transaction_response);// begin logging of post variables, authorize.net request, and authorize.net response$myFile = "my_path/catalog/file.txt";$fh = fopen($myFile, 'a') or die("can't open file");$stringData = "\nSENT: ".$post_string;fwrite($fh, $stringData);$stringData = "\nRESPONSE: ".$transaction_response;fwrite($fh, $stringData);foreach($HTTP_POST_VARS as $key => $value) {    $stringData = "\nPOST: $key=$value";    fwrite($fh, $stringData);}fwrite($fh, "\nDone.\n");fclose($fh);// end logging        foreach ($regs as $key => $value) {          $regs[$key] = substr($value, 1, -1); // remove double quotes        }      } else {        $regs = array('-1', '-1', '-1');      }      $error = false;      if ($regs[0] == '1') {        if (tep_not_null(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH)) {          if (strtoupper($regs[37]) != strtoupper(md5(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH . MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID . $regs[6] . $this->format_raw($order->info['total'])))) {            $error = 'general';          }        }      } else {        switch ($regs[2]) {          case '7':            $error = 'invalid_expiration_date';            break;          case '8':            $error = 'expired';            break;          case '6':          case '17':          case '28':            $error = 'declined';            break;          case '78':            $error = 'cvc';            break;          default:            $error = 'general';            break;        }      }      if ($error != false) {        tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . $error, 'SSL'));      }    }    function after_process() {      return false;    }    function get_error() {      global $HTTP_GET_VARS;      $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_GENERAL;      switch ($HTTP_GET_VARS['error']) {        case 'invalid_expiration_date':          $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_INVALID_EXP_DATE;          break;        case 'expired':          $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_EXPIRED;          break;        case 'declined':          $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_DECLINED;          break;        case 'cvc':          $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_CVC;          break;        default:          $error_message = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_GENERAL;          break;      }      $error = array('title' => MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ERROR_TITLE,                     'error' => $error_message);      return $error;    }    function check() {      if (!isset($this->_check)) {        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS'");        $this->_check = tep_db_num_rows($check_query);      }      return $this->_check;    }    function install() {      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Authorize.net Credit Card AIM', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS', 'False', 'Do you want to accept Authorize.net Credit Card AIM payments?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Login ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID', '', 'The login ID used for the Authorize.net service', '6', '0', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Transaction Key', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY', '', 'Transaction key used for encrypting data', '6', '0', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('MD5 Hash', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH', '', 'The MD5 hash value to verify transactions with', '6', '0', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Server', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER', 'Live', 'Perform transactions on the live or test server. The test server should only be used by developers with Authorize.net test accounts.', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Mode', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE', 'Live', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Method', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD', 'Authorization', 'The processing method to use for each transaction.', '6', '0', 'tep_cfg_select_option(array(\'Authorization\', \'Capture\'), ', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('cURL Program Location', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL', '/usr/bin/curl', 'The location to the cURL program application.', '6', '0' , now())");    }    function remove() {      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");    }    function keys() {      return array('MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_MD5_HASH', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_MODE', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_METHOD', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ZONE', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_ORDER_STATUS_ID', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER', 'MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL');    }    function _hmac($key, $data) {      if (function_exists('mhash') && defined('MHASH_MD5')) {        return bin2hex(mhash(MHASH_MD5, $data, $key));      }// RFC 2104 HMAC implementation for php.// Creates an md5 HMAC.// Eliminates the need to install mhash to compute a HMAC// Hacked by Lance Rushing      $b = 64; // byte length for md5      if (strlen($key) > $<img src='http://forums.oscommerce.com/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' /> {        $key = pack("H*",md5($key));      }      $key = str_pad($key, $b, chr(0x00));      $ipad = str_pad('', $b, chr(0x36));      $opad = str_pad('', $b, chr(0x5c));      $k_ipad = $key ^ $ipad ;      $k_opad = $key ^ $opad;      return md5($k_opad . pack("H*",md5($k_ipad . $data)));    }    function sendTransactionToGateway($url, $parameters) {      $server = parse_url($url);      if (isset($server['port']) === false) {        $server['port'] = ($server['scheme'] == 'https') ? 443 : 80;      }      if (isset($server['path']) === false) {        $server['path'] = '/';      }      if (isset($server['user']) && isset($server['pass'])) {        $header[] = 'Authorization: Basic ' . base64_encode($server['user'] . ':' . $server['pass']);      }      if (function_exists('curl_init')) {        $curl = curl_init($server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : ''));        curl_setopt($curl, CURLOPT_PORT, $server['port']);        curl_setopt($curl, CURLOPT_HEADER, 0);        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);        curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);        curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);        curl_setopt($curl, CURLOPT_POST, 1);        curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);        $result = curl_exec($curl);        curl_close($curl);      } else {        exec(escapeshellarg(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_CURL) . ' -d ' . escapeshellarg($parameters) . ' "' . $server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : '') . '" -P ' . $server['port'] . ' -k', $result);        $result = implode("\n", $result);      }      return $result;    }// format prices without currency formatting    function format_raw($number, $currency_code = '', $currency_value = '') {      global $currencies, $currency;      if (empty($currency_code) || !$this->is_set($currency_code)) {        $currency_code = $currency;      }      if (empty($currency_value) || !is_numeric($currency_value)) {        $currency_value = $currencies->currencies[$currency_code]['value'];      }      return number_format(tep_round($number * $currency_value, $currencies->currencies[$currency_code]['decimal_places']), $currencies->currencies[$currency_code]['decimal_places'], '.', '');    }  }?>

Edited by joshmorris5, 24 July 2008 - 22:11.


#26   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 25 July 2008 - 16:56

For the record, I still don't have it working. I am close though. I got the response that the payment has been authorized and it is routing me to the proper page. However, I still haven't taken Authorize.net live because I still haven't seen any transactions on their site.

Well, here's the latest.

So I found that even though you are testing, you need to make the "Authorize.net Credit Card AIM" Live. Turns out that in the default settings for osc's authorizenet, "Test" means that you are submitting requests to https://test.authori...ay/transact.dll. This is the wrong gateway to send it to unless your API login starts with "cpdev" or "cnpdev". The server will return error 13 message (basically wrong username or password). The correct test server if your API login doesn't start with "cpdev" or "cnpdev" is the same as the live server: https://secure.autho...ay/transact.dll
For testing, you need to make sure that Authorize.net is in test mode.

To do this, log in to Administration.
In the left navigation click on Modules then Payment
In the center list, click on Authorize.net Credit Card AIM
On the right, you will see the settings. Set them as follows:


--------------------------------------------------------------------------------------------------------------------------------------------
Enable Authorize.net Credit Card AIM
Do you want to accept Authorize.net Credit Card AIM payments?

True *
False

Login ID xxxxxxxxxx
The login ID used for the Authorize.net service


Transaction Key xxxxxxxxxxx
Transaction key used for encrypting data


MD5 Hash xxxxxxxxxxxxxxxxxxxxxxx (same as in authorize.net settings)
The MD5 hash value to verify transactions with


Transaction Server
Perform transactions on the live or test server. The test server should only be used by developers with Authorize.net test accounts.

Live *
Test

Transaction Mode
Transaction mode used for processing orders

Live *
Test

Transaction Method
The processing method to use for each transaction.

Authorization
Capture *

Payment Zone (personal configuration)
If a zone is selected, only enable this payment method for that zone.



Set Order Status (personal configuration)
Set the status of orders made with this payment module to this value


Sort order of display. **Not necessary**(0=first in the list 99=last in the list)
Sort order of display. Lowest is displayed first.


cURL Program Location
The location to the cURL program application.
--------------------------------------------------------------------------------------------------------------------------------------------------


After these settings were correct, I was at least getting Authorize.net to correctly identify me, but I was still getting errors. The error I was getting was that it wasn't sending an invoice number. So I added some code.

You need to BACKUP!! BACKUP!! BACKUP!! BACKUP!! then find a bit of code in catalog/includes/modules/payment/authorizenet_cc_aim.php that looks like this:

function before_process() {
global $HTTP_POST_VARS, $customer_id, $order, $sendto, $currency;

$params = array('x_login' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID, 0, 20),
'x_tran_key' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY, 0, 16),
'x_version' => '3.1',
'x_delim_data' => 'TRUE',
'x_delim_char' => ',',
'x_encap_char' => '"',
'x_relay_response' => 'FALSE',
'x_first_name' => substr($order->billing['firstname'], 0, 50),
'x_last_name' => substr($order->billing['lastname'], 0, 50),
'x_company' => substr($order->billing['company'], 0, 50),
'x_address' => substr($order->billing['street_address'], 0, 60),
'x_city' => substr($order->billing['city'], 0, 40),
'x_state' => substr($order->billing['state'], 0, 40),
'x_zip' => substr($order->billing['postcode'], 0, 20),
'x_country' => substr($order->billing['country']['title'], 0, 60),
'x_phone' => substr($order->customer['telephone'], 0, 25),
'x_cust_id' => substr($customer_id, 0, 20),
'x_customer_ip' => tep_get_ip_address(),
'x_email' => substr($order->customer['email_address'], 0, 255),
'x_description' => substr(STORE_NAME, 0, 255),
'x_amount' => substr($this->format_raw($order->info['total']), 0, 15),
'x_currency_code' => substr($currency, 0, 3),
'x_method' => 'CC',
'x_type' =>

And Replace it with this:

function before_process() {
global $HTTP_POST_VARS, $customer_id, $invoice_id, $order, $sendto, $currency;

$next_inv = '';
$inv_id = tep_db_query("select orders_id from " . TABLE_ORDERS . " order by orders_id DESC limit 1");
$last_inv = tep_db_fetch_array($inv_id);
$next_inv = $last_inv['orders_id']+1;

$params = array('x_login' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_LOGIN_ID, 0, 20),
'x_tran_key' => substr(MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_KEY, 0, 16),
'x_version' => '3.1',
'x_delim_data' => 'TRUE',
'x_delim_char' => ',',
'x_encap_char' => '"',
'x_relay_response' => 'FALSE',
'x_invoice_num' => substr($next_inv, 0, 20),
'x_first_name' => substr($order->billing['firstname'], 0, 50),
'x_last_name' => substr($order->billing['lastname'], 0, 50),
'x_company' => substr($order->billing['company'], 0, 50),
'x_address' => substr($order->billing['street_address'], 0, 60),
'x_city' => substr($order->billing['city'], 0, 40),
'x_state' => substr($order->billing['state'], 0, 40),
'x_zip' => substr($order->billing['postcode'], 0, 20),
'x_country' => substr($order->billing['country']['title'], 0, 60),
'x_phone' => substr($order->customer['telephone'], 0, 25),
'x_cust_id' => substr($customer_id, 0, 20),
'x_customer_ip' => tep_get_ip_address(),
'x_email' => substr($order->customer['email_address'], 0, 255),
'x_description' => substr(STORE_NAME, 0, 255),
'x_amount' => substr($this->format_raw($order->info['total']), 0, 15),
'x_currency_code' => substr($currency, 0, 3),
'x_method' => 'CC',
'x_type' =>


Now I am still having trouble with this script because it keeps requiring company. If you customers have a blank field where company is, then it will return a an error. I am still playing with it, but I think if you just comment out that line, it may just pass through without any errors. I realize that commenting it out isn't much of a solution, but if it posts transactions for the time being, I'm all for it.

Let me know if you guys can think of anything that might help.

Joshua Morris

#27   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 25 July 2008 - 19:19

Ok... I got it to work. Hope this helps everybody.

Its not a problem with the script. Don't comment out the script. I was on the Live help with Authorize.net for a couple of hours now.

Thurns out you need to make sure that certain fields are not required for your authorization to go through.

Go to https://account.authorize.net

Click on the following:

Under "Account"
Click=> Settings
Click=>Payment Form
Click=>Form Fields

You should come to a page that looks like this. Fill it in with your personal settings similar to this.

Remember: **If you require it here, and you don't require it in OSCommerce account setup, your customers will recieve an error for those blank fields and payment will be impossible.**
With the line of code I put above, you can now require an invoice number.


-------------------------------------------------------------------------------------------------------------------------------------------
Payment-Form Fields

Field Name--------------------------------------View-------------Edit------------Required

Payment Information

Recurring Billing Transaction-----------------o-----------------o------------------o
Card Code------------------------------------------o-----------------o------------------o

Order Information
Invoice No---------------------------------------x------------------o------------------x
Description--------------------------------------x------------------o------------------x

Customer Billing Information
First Name--------------------------------------x------------------x------------------x
Last Name--------------------------------------x------------------x------------------x
Company---------------------------------------x------------------x------------------o
Address-----------------------------------------x------------------x------------------x
City----------------------------------------------x------------------x------------------x
State--------------------------------------------x------------------x------------------x
Zip Code----------------------------------------x------------------x------------------x
Country-----------------------------------------x------------------x------------------o
Phone-------------------------------------------x------------------x------------------o
Fax----------------------------------------------x------------------x------------------o
Email--------------------------------------------x------------------x------------------x
Customer ID-----------------------------------x------------------o------------------x

Shipping Information
First Name--------------------------------------x------------------x------------------x
Last Name--------------------------------------x------------------x------------------x
Company---------------------------------------x------------------x------------------o
Address-----------------------------------------x------------------x------------------x
City----------------------------------------------x------------------x------------------x
State--------------------------------------------x------------------x------------------x
Zip Code----------------------------------------x------------------x------------------x
Country-----------------------------------------x------------------x------------------o

Additional Information
Tax-----------------------------------------------o-----------------o------------------o
Freight-------------------------------------------o-----------------o------------------o
Duty----------------------------------------------o-----------------o------------------o
Tax Exempt--------------------------------------o-----------------o------------------o
PO Number--------------------------------------o-----------------o------------------o
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

Let me know if this helps anybody.

Joshua Morris

#28   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 25 July 2008 - 22:24

So I have been searching the forum for weeks now to find a solution to this same problem. I think I am getting closer with "fwrite" script.

Here is the log.

SENT: x_login=xxxxxxxxx&x_tran_key=xxxxxxxxxxxxxxx&[truncated]RESPONSE: "3","2","13","(TESTMODE) The merchant login ID or password is invalid or the account is [truncated]POST: x=43POST: y=6Done.


I think something in the script is not relaying properly. I verified that my login and transaction id were correct, but still nothing.

I have tried every possible setting from the admin. I got it to partially work 1 time. Authorize.net shows the transaction, but my site doesn't, nor was I ever routed back to my site.

I am gonna play with the code a bit and see if there is maybe a contribution I can add to solve this problem. I really need this to work as do many of us.

Joshua Morris


Josh,

Would you mind describing how and where you set up fwrite to write all those POST/RESPONSE variables to a log? I've been having trouble with the AIM module as well (stopped working out of the blue), and I'd like to capture whatever error codes might be coming through so I can troubleshoot further.

Thanks!

#29   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 26 July 2008 - 00:01

(Sorry for the double post, but can we not edit out own posts here?)

Josh: what version of the AIM module are you using? Emailmaomao's (Vger's originally, I think) or ponce's?

Also, I tried adding the code from this topic: http://forums.oscomm...hp?t103839.html , but the versions of the AIM module that I'm using don't even have a file called authorize_direct.php, so I'm assuming it only works with a very old version. Does the code you're using look similar? In what file did you have to insert it to get it to write the response codes to a file?

Thanks

#30   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 28 July 2008 - 06:12

Hey madinchina,

Sorry I didn't respond right away. Its the weekend and all.....

So what you want to do is add a bit of script to your authorizenet file found here:

catalog/includes/modules/payment/authorizenet_cc_aim.php, about line 182

After a script that looks about like so:

switch (MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TRANSACTION_SERVER) {
case 'Live':
$gateway_url = 'https://secure.authorize.net/gateway/transact.dll';
break;

default:
$gateway_url = 'https://test.authorize.net/gateway/transact.dll';
break;
}

$transaction_response = $this->sendTransactionToGateway($gateway_url, $post_string);


if (!empty($transaction_response)) {
$regs = preg_split("/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/", $transaction_response);



Add this script:

// begin logging of post variables, authorize.net request, and authorize.net response

$myFile = "/home/your-path/file.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "\nSENT: ".$post_string;
fwrite($fh, $stringData);
$stringData = "\nRESPONSE: ".$transaction_response;
fwrite($fh, $stringData);
foreach($HTTP_POST_VARS as $key => $value) {
$stringData = "\nPOST: $key=$value";
fwrite($fh, $stringData);
}
fwrite($fh, "\nDone.\n");
fclose($fh);

// end logging

IMPORTANT!!!

In this line...

$myFile = "./home/your-path/file.txt";

make sure that you put the correct path. The WHOLE path...NOT JUST "www.mysite.com/catalog..." Its got to include the server path.

You can find this information pretty much all over your site, but a quick dirty way to find this path would be on the admin side. Log into your oscommerce administration and on the left side click:

Tools > File Manager

Up at the top under the heading "File Manager" you will see your full path. While you are in the file manager, create a new file in the path in which you want to store your logs called "file.txt". Use this path to the file. I recommend adding a few folders to try and hide the info a bit.

Once you read the file, if you still need it, copy and past it to your local machine, but DO NOT under any circumstances, leave this info on your live server. That is a hackers paradise, and I'd love you to death if you did that for me... **WINK** **WINK**

NO...SERIOUSLY!!! DO NOT LEAVE IT THERE! DELETE IT IMMEDIATELY!

To read the file all you have to do is type in your web address bar the path and the file like so:

http://www.yoursite....r_file/file.txt

REMEMBER!! Once you read it, CLEAR IT! You can easily and quickly do this by using the "File Manger"


Once you have fixed your problem, and you are back on line.... you should simply comment out the script like this:

/*

<script>

*/

This way, if it ever fails again, you can easily turn the script back on for troubleshooting.

You can also leave the file.txt there, just make sure it is blank and the fwrite script is blank.

Also, for the record, I am using V1.0.

Let me know if this helps you guys.

Joshua Morris

#31   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 28 July 2008 - 06:36

Thank you very much! I'll try this tomorrow and see what I get. Then maybe Authorize.net's support will be a bit more helpful.

#32   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 28 July 2008 - 08:27

I've never been so excited to get an error message in my life. /laugh.gif' class='bbc_emoticon' alt=':lol:' />

Here's the (censored where appropriate) info from my log:

SENT: x_login=[...]&x_tran_key=[...]&x_version=3.1&x_delim_data=TRUE&x_delim_char=%2C&x_encap_char=%22&
x_relay_response=FALSE&x_first_name=Peter&x_last_name=Magenheimer&x_company=&x_address=[...]&x_city=[...]&x_state=[...]&
x_zip=[...]&x_country=United+States&x_phone=[...]&x_cust_id=[...]&x_customer_ip=[...]&x_email=[...]&x_description=[...]&
x_amount=7.30&x_currency_code=USD&x_method=CC&x_type=AUTH_CAPTURE&x_card_num=&x_exp_date=&x_card_code=&
x_ship_to_first_name=Peter&x_ship_to_last_name=Magenheimer&x_ship_to_company=&x_ship_to_address=[...]&x_ship_to_city=[...]&
x_ship_to_state=[...]&x_ship_to_zip=80526&x_ship_to_country=United+States&x_freight=6.30&x_line_item=1<|>[...]<|>[...]<|>1<|>1.00<|>NO
RESPONSE: "3","2","33","Credit card number is required.","","P","0","","[...]","7.30","CC","auth_capture","[...]","Peter","Magenheimer",""
,"[...]","[...]","[...]","[...]","United States","[...]","","[...]","Peter","Magenheimer","","[...]","[...]","[...]","[...]","United States"
,"","","6.3000","","","[...a 128 bit hex value]","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
POST: x=45
POST: y=7
Done.

(Note specifically the blank x_card_num, x_exp_date, and x_card_code, despite the fact that I gave valid CC info for the transaction. Also, the 128-bit hex value I censored in the RESPONSE, but it looks like an MD5 hash.)

I should probably also note that the MD5 hash field in the AIM module config (and as far as I know, on the authorize.net account setup) is blank, since the site had previously been using a different AIM module (one without the MD5 field). Is the MD5 required by this module/a.net? If so, do I just need to set any MD5 hash in a.net's account settings and then match it on osC's side, or is there another process? I'd check myself, but I don't have the client's authorize.net login details, so I'll need to guide him through the process.

#33   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 28 July 2008 - 19:43

I would definitely include an MD5 Hash. In fact, here is a free site that will generate one for you. Simply put any string of characters like (password, or p@55w0rD!, or even something as simple as "me") and then click md5. POOF!!! There is your new MD5 Hash. Past the same string on your website and at authorize.net.

Should look kinda like this: 3c6e0b8a9c15224a8228b9a98ca1531d

Thats all there is to it.

I don't know if that will solve your problem though. Check your code to make sure that it is submitting the proper info.

If you need help with that, let me know. I'll go into greater detail.

Joshua Morris

#34   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 28 July 2008 - 20:00

Thanks again. I'm still waiting on the client so I can have him log in to a.net and make the changes, so for now, I've been casually playing around with authorizenet_cc_aim.php to see if I can make it send the CC info without using the MD5 hash. It looks like the code does have a conditional to avoid using that hash function if there isn't an MD5 hash specified in the module's config, but I'm not sure if that's working correctly since the module is just sending blank CC info.

Another possibility that I was thinking of is that the module itself is significantly newer than the version of osCommerce I'm using on the site (2.2-MS2), so it might be attempting to send variables to one of the checkout_.php pages when that page isn't equipped to accept those variables. For example, the AIM module that the site was using before requested the user's CC info on the checkout_payment.php page, whereas this module requests the user's CC info on checkout_confirmation.php instead. Could this be a problem?

Any ideas? Also, what version of osCommerce are you using?

Edited by madinchina, 28 July 2008 - 20:01.


#35   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 28 July 2008 - 20:56

Thank you very much! I'll try this tomorrow and see what I get. Then maybe Authorize.net's support will be a bit more helpful.


I didn't find Authorize.net to be very helpful at all. I contacted their online live support because I was looking at all the setting, and they were correct. I asked her to change the requirements of the info I am supposed to be sending. She told me that they don't have requirements, so it is a problem in the carts script. She said that I needed to contact my provider. She proceeded to mock me when I explained to her that I was using a highly modified open source shopping cart and that I was the provider of that cart, and the script was correct. Frustrated, I ultimately started asking her simple questions about my account which lead her right into my trap. Whatever she did during he research to answer my questions, somehow my account started working.

Good times, Good times!

Sorry I forgot to include the hash generator last time. http://www.miraclesa...ebtools/md5.php

I am using OSC v2.2 RC 2a. What version are you using?

#36   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 28 July 2008 - 21:01

Well, this is strange... Suddenly, the authorizenet_cc_aim.php module is giving me an error:

Fatal error: Cannot redeclare class authorizenet_cc_aim in /home/mnhookah/public_html/includes/modules/payment/authorizenet_cc_aim.php on line 13

I tried reverting to the original file, but still the same problem (it obviously has nothing to do with your fwrite script, since the error's on the first non-comment line of the code). Any ideas on why that's appearing out of the blue? I'm starting to think that this site's webhost (Siteground) sucks...

I'm using osCommerce 2.2-MS2.

Edited by madinchina, 28 July 2008 - 21:02.


#37   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 28 July 2008 - 21:16

Fix your code with this. Here is the first part of the class constructor code.

[codebox]// class constructor
function authorizenet_cc_aim() {
global $order;

$this->signature = 'authorizenet|authorizenet_cc_aim|1.0|2.2';

$this->code = 'authorizenet_cc_aim';
$this->title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_TITLE;
$this->public_title = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_PUBLIC_TITLE;
$this->description = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_AUTHORIZENET_CC_AIM_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_CC_AIM_STATUS == 'True') ? true : false);[/codebox]

#38   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 28 July 2008 - 22:06

Hmmm... That code (exactly as shown) already exists in my module file.

On a side note, I really appreciate how helpful you've been. Let me know if there's anything I can do to return the favor.

#39   madinchina

madinchina
  • Members
  • 24 posts
  • Real Name:Peter M

Posted 29 July 2008 - 00:36

Argh, my own stupid mistake strikes again! /rolleyes.gif' class='bbc_emoticon' alt=':rolleyes:' />

I'd accidentally uploaded the authorizenet_cc_aim.php module into the /includes/languages/english/modules/payment/ folder, instead of the appropriate language file. The module was in the correct folder, calling a duplicate of itself (or something) from that language folder. That's why I was getting the redeclare PHP error.

Anyway, now that I've got this module back, I'll try the MD5 hash and get back to you.

Edited by madinchina, 29 July 2008 - 00:38.


#40   joshmorris5

joshmorris5
  • Members
  • 9 posts
  • Real Name:Joshua Morris

Posted 29 July 2008 - 20:10

Any update on the MD5 Hash? Were you able to get it working?