Guest Posted November 13, 2004 Share Posted November 13, 2004 I'm not sure if you can help on this one but I thought I'd give it a try. I've got a client that uses OSCommerce shopping cart and accepts credit cards with a custom payment module for a company called NetOne. Everything was working fine until I had to restore the server about a month ago. Now an error comes up whenever someone tries to purchase with a credit card. It's a pretty generic message "credit card error:error unknown". The person that built the payment module has it working on another server with no problems. So I'm wondering if it's a server problem or an OSC problem? Any ideas? below is the code... ************************************************** <?php /* $Id: netone.php,v 1.00 2004/07/28 10:20:50 wm3 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class netone { var $code, $title, $description, $enabled; // class constructor function netone() { global $order; $this->code = 'netone'; $this->title = MODULE_PAYMENT_NETONE_TEXT_TITLE; $this->description = MODULE_PAYMENT_NETONE_TEXT_DESCRIPTION; $this->sort_order = MODULE_PAYMENT_NETONE_SORT_ORDER; $this->enabled = ((MODULE_PAYMENT_NETONE_STATUS == 'True') ? true : false); if ((int)MODULE_PAYMENT_NETONE_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_NETONE_ORDER_STATUS_ID; } if (is_object($order)) $this->update_status(); } // class methods function update_status() { global $order; if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_NETONE_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_NETONE_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() { $js = 'if (payment_value == "' . $this->code . '") {' . "\n" . ' var netone_cc_number = document.checkout_payment.netone_cc_number.value;' . "\n" . ' if (netone_cc_number == "" || NETONE_cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" . ' error_message = error_message + "' . MODULE_PAYMENT_NETONE_TEXT_JS_CC_NUMBER . '";' . "\n" . ' error = 1;' . "\n" . ' }' . "\n" . '}' . "\n"; return $js; } function selection() { 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))); } $selection = array('id' => $this->code, 'module' => $this->title, 'fields' => array(array('title' => MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_OWNER, 'field' => $order->billing['firstname'] . ' ' . $order->billing['lastname']), array('title' => MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_NUMBER, 'field' => tep_draw_input_field('netone_cc_number')), array('title' => MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_EXPIRES, 'field' => tep_draw_pull_down_menu('netone_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('netone_cc_expires_year', $expires_year)))); return $selection; } function pre_confirmation_check() { global $payment, $HTTP_POST_VARS; //save data in session so we can pick it up in next page tep_session_register("netone_cc_number"); tep_session_register("netone_cc_expires_month"); tep_session_register("netone_cc_expires_year"); $_SESSION['netone_cc_number'] = $_POST['netone_cc_number']; $_SESSION['netone_cc_expires_year'] = $_POST['netone_cc_expires_year']; $_SESSION['netone_cc_expires_month'] = $_POST['netone_cc_expires_month']; include(DIR_WS_CLASSES . 'cc_validation.php'); $cc_validation = new cc_validation(); $result = $cc_validation->validate($HTTP_POST_VARS['netone_cc_number'], $HTTP_POST_VARS['netone_cc_expires_month'], $HTTP_POST_VARS['netone_cc_expires_year']); $error = ''; switch ($result) { case -1: $error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4)); break; case -2: case -3: case -4: $error = TEXT_CCVAL_ERROR_INVALID_DATE; break; case false: $error = TEXT_CCVAL_ERROR_INVALID_NUMBER; break; } if ( ($result == false) || ($result < 1) ) { $payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&netone_cc_owner=' . urlencode($HTTP_POST_VARS['netone_cc_owner']) . '&netone_cc_expires_month=' . $HTTP_POST_VARS['netone_cc_expires_month'] . '&netone_cc_expires_year=' . $HTTP_POST_VARS['netone_cc_expires_year']; tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false)); } $this->cc_card_type = $cc_validation->cc_type; $this->cc_card_number = $cc_validation->cc_number; $this->cc_expiry_month = $cc_validation->cc_expiry_month; $this->cc_expiry_year = $cc_validation->cc_expiry_year; } function confirmation() { global $HTTP_POST_VARS, $order; $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type, 'fields' => array(array('title' => MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_OWNER, 'field' => $order->billing['firstname'] . ' ' . $order->billing['lastname']), array('title' => MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_NUMBER, 'field' => substr($this->cc_card_number, 0, 4) . str_repeat('X', (strlen($this->cc_card_number) - 8)) . substr($this->cc_card_number, -4)), array('title' => MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_EXPIRES, 'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['netone_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['netone_cc_expires_year']))))); return $confirmation; } function process_button() { global $HTTP_SERVER_VARS, $order, $currencies; switch (MODULE_PAYMENT_NETONE_TRANSACTION_TYPE) { case 'Sale': $transaction_type = '01'; break; case 'Authorization': $transaction_type = '02'; break; default: $transaction_type = '01'; break; } $process_button_string = tep_draw_hidden_field('MerchantID', MODULE_PAYMENT_NETONE_MERCHANT_ID) . tep_draw_hidden_field('MerchantKey', MODULE_PAYMENT_NETONE_MERCHANT_KEY) . tep_draw_hidden_field('FullTotal', number_format($order->info['total'] * $currencies->get_value(MODULE_PAYMENT_NETONE_CURRENCY), $currencies->currencies[MODULE_PAYMENT_NETONE_CURRENCY]['decimal_places'])) . tep_draw_hidden_field('ThanksURL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true)) . tep_draw_hidden_field('NoThanksURL', tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'NONSSL', true)) . tep_draw_hidden_field('Bname', $order->billing['firstname'] . ' ' . $order->billing['lastname']) . tep_draw_hidden_field('Baddr1', $order->billing['street_address']) . tep_draw_hidden_field('Bcity', $order->billing['city']); if ($order->billing['country']['iso_code_2'] == 'US') { $billing_state_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_id = '" . (int)$order->billing['zone_id'] . "'"); $billing_state = tep_db_fetch_array($billing_state_query); $process_button_string .= tep_draw_hidden_field('Bstate', $billing_state['zone_code']); } else { $process_button_string .= tep_draw_hidden_field('Bstate', $order->billing['state']); } $process_button_string .= tep_draw_hidden_field('Bzip', $order->billing['postcode']) . tep_draw_hidden_field('Bcountry', $order->billing['country']['iso_code_2']) . tep_draw_hidden_field('Phone', $order->customer['telephone']) . tep_draw_hidden_field('Email', $order->customer['email_address']) . tep_draw_hidden_field('Sname', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) . tep_draw_hidden_field('Saddr1', $order->delivery['street_address']) . tep_draw_hidden_field('Scity', $order->delivery['city']) . tep_draw_hidden_field('Sstate', $order->delivery['state']) . tep_draw_hidden_field('Szip', $order->delivery['postcode']) . tep_draw_hidden_field('Scountry', $order->delivery['country']['iso_code_2']) . tep_draw_hidden_field('ChargeType', $transaction_type) . tep_draw_hidden_field('Result', $transaction_mode) . tep_draw_hidden_field('IP', $HTTP_SERVER_VARS['REMOTE_ADDR']); $process_button_string .= tep_draw_hidden_field('CardNumber', $this->cc_card_number) . tep_draw_hidden_field('ExpMonth', $this->cc_expiry_month) . tep_draw_hidden_field('ExpYear', substr($this->cc_expiry_year, -2)); return $process_button_string; } function before_process() { global $HTTP_POST_VARS, $order; /* printf(' Merchant Id: %s<br /> Merchant Key: %s<br /> Card Owner Name: %s<br /> Card Number: %s<br /> Expiration Month: %s<br /> Expiration Year: %s<br /> Address: %s<br /> City: %s<br /> State: %s<br /> Zip: %s<br /> Country: %s<br /> Email: %s<br /> Transaction Code: %s<br />', MODULE_PAYMENT_NETONE_MERCHANT_ID, MODULE_PAYMENT_NETONE_MERCHANT_KEY, $order->billing['firstname'] . ' ' . $order->billing['lastname'], $_POST['CardNumber'], $_POST['ExpMonth'], $_POST['ExpYear'], $order->billing['street_address'], $order->billing['city'], $order->billing['state'], $order->billing['postcode'], $order->billing['country']['iso_code_2'], $order->customer['email_address'], MODULE_PAYMENT_NETONE_TRANSACTION_TYPE); print_r($_POST); //exit; */ /* url to post to */ $eftsecure_url = 'https://va.eftsecure.net/cgi-bin/eftbankcard.dll?transaction'; /* format query string */ $query = sprintf('m_id=%s&m_key=%s&T_amt=%f&C_name=%s&C_address=%s&C_city=%s&C_state=%s&C_zip=%s&C_country=%s&C_cardnumber=%s&C_exp=%s&C_email=%s&T_code=%s', MODULE_PAYMENT_NETONE_MERCHANT_ID, MODULE_PAYMENT_NETONE_MERCHANT_KEY, $_POST['FullTotal'], $order->billing['firstname'] . ' ' . $order->billing['lastname'], $order->billing['street_address'], $order->billing['city'], $order->billing['state'], $order->billing['postcode'], $order->billing['country']['iso_code_2'], $_POST['CardNumber'], $_POST['ExpMonth'].$_POST['ExpYear'], $order->customer['email_address'], (MODULE_PAYMENT_NETONE_TRANSACTION_TYPE == 'Sale') ? '01' : '02' ); //var_dump($this); //exit($query); //debug the request data if ( (defined('MODULE_PAYMENT_NETONE_CURL_PATH')) && (MODULE_PAYMENT_NETONE_CURL_PATH!='') && (file_exists(MODULE_PAYMENT_NETONE_CURL_PATH)) ) { /* using the curl binary */ $binary = 'YES'; $fp=popen(MODULE_PAYMENT_NETONE_CURL_PATH . " --data \"$query\" $eftsecure_url","r"); while(!feof($fp)) $res .= fread($fp, 1024); // read all the output. pclose($fp); // close the connection to curl. } elseif ( function_exists('curl_init') ) { /* setup curl for processing */ $binary = 'NO'; $ch = curl_init(); //init curl lib curl_setopt($ch, CURLOPT_URL, $eftsecure_url); //set the url to post to curl_setopt($ch, CURLOPT_POST, 1); //use post instead of get (preferred) curl_setopt($ch, CURLOPT_POSTFIELDS, $query); //set the querystring curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return data here, do not output to file $res = curl_exec($ch); //do the post curl_close($ch); //shut down curl library } else { /* looks like you don't have the curl library */ tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NETONE_TEXT_ERROR.' '.'You need the CURL library: <a href="http://curl.haxx.se/">http://curl.haxx.se/</a>'), 'SSL', true, false)); } //print $res . "<br />\n"; //this is the response /* parse the components */ /* echo "<br /><hr><br />\n"; echo "<br />Using CURL Binary: $binary<hr><br />\n"; echo "<br />CURL Binary Path: " . MODULE_PAYMENT_NETONE_CURL_PATH . "<hr><br />\n"; echo "Approval Indicator: " . $res[1] . "<br>"; //A is approved E is declined/error. echo "Approval/Error Code: " . substr($res, 2, 6) . "<br>\n"; echo "Approval/Error Message: " . substr($res, 8, 32) . "<br>\n"; echo "Front-End Indicator: " . substr($res, 40, 2) . "<br>\n"; echo "CVV Indicator: " . $res[42] . "<br>\n"; echo "AVS Indicator: " . $res[43] . "<br>\n"; echo "Risk Indicator: " . substr($res, 44, 2) . "<br>\n"; echo "Reference: " . substr($res, 46, 10) . "<br>\n"; echo "Order Number: " . substr($res, strpos($res, chr(28)) + 1, strrpos($res, chr(28) - 1)) . "<br>\n"; exit; */ if (!$res) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NETONE_TEXT_ERROR.' '.'Unknown Error'), 'SSL', true, false)); } if ($res[1]!='A') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_NETONE_TEXT_ERROR.' '.substr($res, 8, 32)), 'SSL', true, false)); } else { $GLOBALS['netone_trans_id'] = substr($res, 46, 10); //you should pick this up in checkout_process and save it in the order } return false; } function after_process() { tep_session_unregister("cc_number"); tep_session_unregister("cc_month"); tep_session_unregister("cc_year"); return false; } function get_error() { global $HTTP_GET_VARS; if (isset($HTTP_GET_VARS['ErrMsg']) && tep_not_null($HTTP_GET_VARS['ErrMsg'])) { $error = stripslashes(urldecode($HTTP_GET_VARS['ErrMsg'])); } elseif (isset($HTTP_GET_VARS['Err']) && tep_not_null($HTTP_GET_VARS['Err'])) { $error = stripslashes(urldecode($HTTP_GET_VARS['Err'])); } elseif (isset($HTTP_GET_VARS['error']) && tep_not_null($HTTP_GET_VARS['error'])) { $error = stripslashes(urldecode($HTTP_GET_VARS['error'])); } else { $error = MODULE_PAYMENT_NETONE_TEXT_ERROR_MESSAGE; } return array('title' => MODULE_PAYMENT_NETONE_TEXT_ERROR, 'error' => $error); } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_NETONE_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 NETONE Module', 'MODULE_PAYMENT_NETONE_STATUS', 'True', 'Do you want to accept Network 1 payments?', '6', '1', '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 ('Merchant ID', 'MODULE_PAYMENT_NETONE_MERCHANT_ID', '111111111111', '12 digit Merchant ID used for the Network 1 service', '6', '2', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Merchant Key', 'MODULE_PAYMENT_NETONE_MERCHANT_KEY', 'AAAAAAAAAAAA', '12 character Merchant Key used for the Network 1 service', '6', '3', 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 Binary Path', 'MODULE_PAYMENT_NETONE_CURL_PATH', '/usr/bin/curl', 'Full path to the CURL binary', '6', '3', 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 Type', 'MODULE_PAYMENT_NETONE_TRANSACTION_TYPE', 'Sale', 'Transaction type to use for the Network 1 service', '6', '4', 'tep_cfg_select_option(array(\'Sale\', \'Authorization\'), ', 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 Currency', 'MODULE_PAYMENT_NETONE_CURRENCY', 'USD', 'The currency to use for credit card transactions', '6', '5', 'tep_cfg_select_option(array(\'CAD\', \'USD\'), ', 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_NETONE_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_NETONE_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_NETONE_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())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_PAYMENT_NETONE_STATUS', 'MODULE_PAYMENT_NETONE_MERCHANT_ID', 'MODULE_PAYMENT_NETONE_MERCHANT_KEY', 'MODULE_PAYMENT_NETONE_CURL_PATH', 'MODULE_PAYMENT_NETONE_TRANSACTION_TYPE', 'MODULE_PAYMENT_NETONE_CURRENCY', 'MODULE_PAYMENT_NETONE_ZONE', 'MODULE_PAYMENT_NETONE_ORDER_STATUS_ID', 'MODULE_PAYMENT_NETONE_SORT_ORDER'); } } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted November 14, 2004 Share Posted November 14, 2004 try doing an uninstall then install in the modules/payment and see what happens do you have the language file which goes with this? Quote Link to comment Share on other sites More sharing options...
Guest Posted November 14, 2004 Share Posted November 14, 2004 Hi John, Already tried re-installing a couple of times. Same result. Here's the language file... **************** <?php /* $Id: netone.php,v 1.00 2004/07/28 10:20:50 wm3 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License */ define('MODULE_PAYMENT_NETONE_TEXT_TITLE', 'Network 1'); define('MODULE_PAYMENT_NETONE_TEXT_DESCRIPTION', 'Credit Card Test Info:<br><br>CC#: 4111111111111111<br>Expiry: Any'); define('MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_OWNER', 'Credit Card Owner:'); define('MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_NUMBER', 'Credit Card Number:'); define('MODULE_PAYMENT_NETONE_TEXT_CREDIT_CARD_EXPIRES', 'Credit Card Expiry Date:'); define('MODULE_PAYMENT_NETONE_TEXT_TYPE', 'Type:'); define('MODULE_PAYMENT_NETONE_TEXT_JS_CC_NUMBER', '* The credit card number must be at least ' . CC_NUMBER_MIN_LENGTH . ' characters.\n'); define('MODULE_PAYMENT_NETONE_TEXT_ERROR_MESSAGE', 'There has been an error processing your credit card. Please try again.'); define('MODULE_PAYMENT_NETONE_TEXT_ERROR', 'Credit Card Error!'); ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted November 14, 2004 Share Posted November 14, 2004 I also installed the Authorizenet module and used my merchant account info instead of the clients and it went through fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.