Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi-

We are getting an error message during several of our transaction. The message says the script timed out while it was trying to post transaction results to it. This is what Auth.net recommends:

 

Thank you for contacting Authorize.Net!

This transaction resulted in a general error called an error 52.

This error is explained below.

When Authorize.Net is responding back to a script on your server our

 

system waits 10 seconds for a response. If we do not get a response

in

10 seconds, our server will time out and display an error page. In

this case the customer will see the transaction results on an error

page that Authorize.net generates.

If this happens we will either send an e-mail to you indicating:

An error occurred while trying to report this transaction to the

merchant. An e-mail has been sent to the merchant informing them of

the error. The following is a result of the attempt to charge your

credit card.

or

The transaction will be declined within your Merchant Interface. The

 

transaction detail will display (Unable to send notification to

Customer). If the customer closes the browser window before we

receive

data from your script to print to the screen we will change the

transaction response reason code to 52.

To prevent these errors the first thing that you will need to look

for is the order that your script executes. It is very important

that

something is printed to the screen before any other process is

started. If your script prints to the screen first, we will

recognize

that you have received the transaction results.

To resolve this issue:

- Before doing anything else start writing to your receipt page. For

 

example: print your page headers and the first part of the page

body.

- Check that your script permissions are correct and that it can

accept an HTTPS POST.

- Check that the script is not completing other functions before

writing to the screen, such as writing to a database or sending

emails.

- Please check to see if there are different processes that are used

 

in your script for approvals, declines, or errors. Check each

process

to be sure that they will write to the screen before any other

functions.

- Verify that your script is not using redirects upon receipt of the

 

response from our servers. Redirects strongly are discouraged

because

they can potentially interfere with the process.

On occasion, timeouts will occur that are outside of the control of

your script or our servers. Typical reasons for these timeouts are

Internet traffic, your server is overloaded or malfunctioning, or

Internet routing issues. Depending upon your server location and

what

route is used to send data, it is possible that you may occasionally

 

receive timeouts.

 

 

So, how and where, please?!

 

Thanks!

  • 6 months later...
Posted

Sorry in advance for the length of this, but I'm trying to give all the info I know. Here is what is happening to us, sounds similar to your problem. You have no idea how I wish I could tell you I know the solution. But maybe just talking about it will help:

 

Whenever I get to Authorize.NET and enter credit card info and click "submit", I get the following error:

 

 

An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.

 

This transaction has been approved.

 

It is advisable for you to contact the merchant to verify that you will receive the product or service.

 

 

 

I've spoken with Authorize.NET support and they claim the problem is not on their end. They referred me to a document that gives me this information about error code 52:

 

 

Response Reason Text: The transaction was authorized, but the client could not be notified; the transaction will not be settled.

 

Integration Team Suggestions: When Authorize.Net is responding back to a script on your server, our system waits up to 10 seconds for a response. If we do not get a response in 10 seconds, our server will time out and display an error page. The first thing that you will need to look for is the order that your script executes. It is very important that something is printed to the screen before any other process is started. If your script prints to the screen first, we will recognize that you are receiving the information. The most effective method would be to PRINT the headers, and a line of text such as "Processing, please wait."

 

To resolve this issue:

 

* Check that your script permissions are correct and that it can accept an HTTPS POST.

* Check that the script is not completing other functions before writing to the screen, such as writing to a database or sending emails.

* Please check to see if there are different processes that are used in your script for approvals, declines, or errors. Check each process to be sure that they will write to the screen before any other functions.

* Check if your script is using redirects immediately upon receipt of the response from our servers. Redirects are discouraged because they can potentially interfere with the process.

 

On occasion, timeouts will occur that are outside of the control of your script or our servers. Typical reasons for these timeouts include Internet traffic, your server is overloaded or malfunctioning, or Internet routing issues. Depending upon your server location and what route is used to send data, it is possible that you may occasionally receive the message you are seeing.

 

 

 

Other info:

Despite the info about Authorize.NET timing out after 10 seconds, I'm getting this error in less than one second.

As far as I know, my script permissions are correct - they are set to 755.

Having looked at modules/gateway/Authorize/confirm.php, it does appear to do an immediate re-direct, however not before processing the PHP code so I don't know if that's an issue or not.

 

Has anyone encountered this? And have a solution? I'm running out of ideas.

 

Thanks in advance for any information or assistance!

Posted

Having experience many of the issue discussed in these threads, I tumbled through the code and cleared up the issues.

 

Perhaps this Authorize.net code will help many users.

 

- Use the contribution Authorize.net code

- Replace authorizenet_aim.php module with the code below

- Works with PHP 4, not tested in PHP 5

 

********************* Begin Code **************************************************************

<?php

 

/* $Id: authorizenet_aim.php 23rd August, 2006 18:50:00 Brent O'Keeffe $

Released under the GNU General Public License

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Original portions copyright 2003 osCommerce

Updated portions copyright 2004 Jason LeBaron ([email protected])

Restoration of original portions and addition of new portions Copyright © 2006 osCommerce

Updated portions and additions copyright 2006 Brent O'Keeffe - JK Consulting. ([email protected])

Updated portions of file MC January 2009

*/

 

class authorizenet_aim {

var $code, $title, $description, $enabled, $response;

 

// class constructor

function authorizenet_aim() {

 

$this->code = 'authorizenet_aim';

 

if ($_GET['main_page'] != '') {

$this->title = MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CATALOG_TITLE; // Module title in Catalog

} else {

$this->title = MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_ADMIN_TITLE; // Module title it Admin

}

 

$this->description = MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_DESCRIPTION; // Description of Module in Admin

$this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_AIM_STATUS == 'True') ? true : false); // If the module is installed or not

$this->sort_order = MODULE_PAYMENT_AUTHORIZENET_AIM_SORT_ORDER; // Sort Order of this payment option on the checkout_payment.php page

$this->form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true); // checkout_process.php - page to go to on completion

 

if ((int)MODULE_PAYMENT_AUTHORIZENET_AIM_ORDER_STATUS_ID > 0) {

$this->order_status = MODULE_PAYMENT_AUTHORIZENET_AIM_ORDER_STATUS_ID;

}

 

if (is_object($order)) $this->update_status();

 

}

 

function update_status() {

global $order, $db;

 

if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_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_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;

}

}

}

 

// Validate the credit card information via javascript (Number, Owner, and CVV Lengths)

function javascript_validation() {

$js = ' if (payment_value == "' . $this->code . '") {' . "\n" .

' var cc_owner = document.checkout_payment.authorizenet_aim_cc_owner.value;' . "\n" .

' var cc_number = document.checkout_payment.authorizenet_aim_cc_number.value;' . "\n";

 

if (MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV == 'True') {

$js .= ' var cc_cvv = document.checkout_payment.authorizenet_aim_cc_cvv.value;' . "\n";

}

 

$js .= ' if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .

' error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_JS_CC_OWNER . '";' . "\n" .

' error = 1;' . "\n" .

' }' . "\n" .

' if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .

' error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_JS_CC_NUMBER . '";' . "\n" .

' error = 1;' . "\n" .

' }' . "\n";

if (MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV == 'True') {

$js .= ' if (cc_cvv == "" || cc_cvv.length < "3" || cc_cvv.length > "4") {' . "\n".

' error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_JS_CC_CVV . '";' . "\n" .

' error = 1;' . "\n" .

' }' . "\n" .

' }' . "\n";

}

 

return $js;

}

 

// Display Credit Card information on the checkout_payment.php page

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' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CATALOG_TITLE,

'fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_OWNER,

'field' => tep_draw_input_field('authorizenet_aim_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),

array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_NUMBER,

'field' => tep_draw_input_field('authorizenet_aim_cc_number')),

array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_EXPIRES,

'field' => tep_draw_pull_down_menu('authorizenet_aim_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('authorizenet_aim_cc_expires_year', $expires_year))));

 

if (MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV == 'True') {

$selection['fields'][] = array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CVV,

'field' => tep_draw_input_field('authorizenet_aim_cc_cvv','',"size=4, maxlength=4"));

}

 

return $selection;

}

 

 

// Evaluates the Credit Card Type for acceptance and validity of the Credit Card Number and Expiry Date

function pre_confirmation_check() {

 

require_once(DIR_WS_CLASSES . 'cc_validation.php');

 

$cc_validation = new cc_validation();

$result = $cc_validation->validate($_POST['authorizenet_aim_cc_number'], $_POST['authorizenet_aim_cc_expires_month'], $_POST['authorizenet_aim_cc_expires_year'], $_POST['authorizenet_aim_cc_cvv']);

$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) . '&authorizenet_aim_cc_owner=' . urlencode($_POST['authorizenet_aim_cc_owner']) . '&authorizenet_aim_cc_expires_month=' . $_POST['authorizenet_aim_cc_expires_month'] . '&authorizenet_aim_cc_expires_year=' . $_POST['authorizenet_aim_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;

}

 

// Display Credit Card Information on the Checkout Confirmation Page

function confirmation() {

global $order;

 

if (ereg('^4[0-9]{12}([0-9]{3})?$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Visa';

} elseif (ereg('^5[1-5][0-9]{14}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Master Card';

} elseif (ereg('^3[47][0-9]{13}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'American Express';

} elseif (ereg('^3(0[0-5]|[68][0-9])[0-9]{11}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Diners Club';

} elseif (ereg('^6011[0-9]{12}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Discover';

}

 

$confirmation = array('fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_TYPE,

'field' => $cc_type),

array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_OWNER,

'field' => $_POST['authorizenet_aim_cc_owner']),

array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_NUMBER,

'field' => $_POST['authorizenet_aim_cc_number']),

array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CREDIT_CARD_EXPIRES,

'field' => $_POST['authorizenet_aim_cc_expires_month'] . substr($_POST['authorizenet_aim_cc_expires_year'], -2))));

 

if (MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV == 'True') {

$confirmation['fields'][] = array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_CVV,

'field' => $_POST['authorizenet_aim_cc_cvv']);

}

 

return $confirmation;

}

 

function process_button() {

// Hidden fields on the checkout confirmation page

$process_button_string = tep_draw_hidden_field('authorizenet_aim_cc_owner', $_POST['authorizenet_aim_cc_owner']) .

tep_draw_hidden_field('authorizenet_aim_cc_expires_month', $_POST['authorizenet_aim_expires_month']) .

tep_draw_hidden_field('authorizenet_aim_cc_expires_year', $_POST['authorizenet_aim_expires_year'], -2) .

tep_draw_hidden_field('authorizenet_aim_cc_type', $this->cc_card_type) .

tep_draw_hidden_field('authorizenet_aim_cc_number', $this->cc_card_number) .

tep_draw_hidden_field(tep_session_name(), tep_session_id());

 

if (MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV == 'True') {

$process_button_string .= tep_draw_hidden_field('authorizenet_aim_cc_cvv', $_POST['authorizenet_aim_cc_cvv']);

}

 

return $process_button_string;

}

 

function before_process() {

global $HTTP_POST_VARS, $order, $regs, $new_order_id;

 

if (empty($this->cc_card_type)) {

$this->pre_confirmation_check();

}

 

// Create a variable that holds the order time

$order_time = date("F j, Y, g:i a");

 

// Calculate the next expected order id MFC

$last_order_id = tep_db_query("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");

$last_inv = tep_db_fetch_array($last_order_id);

$new_order_id = $last_inv['orders_id'] + 1;

 

// Populate an array that contains all of the data to be submitted

$submit_data = array(

'x_login' => MODULE_PAYMENT_AUTHORIZENET_AIM_LOGIN, // The login name as assigned to you by authorize.net

'x_tran_key' => MODULE_PAYMENT_AUTHORIZENET_AIM_TXNKEY, // The Transaction Key (16 digits) is generated through the merchant interface

'x_relay_response' => 'FALSE', // AIM uses direct response, not relay response

'x_delim_char' => ',',

'x_delim_data' => 'TRUE', // The default delimiter is a comma

'x_version' => '3.1', // 3.1 is required to use CVV codes

'x_encap_char' => '"',

'x_type' => MODULE_PAYMENT_AUTHORIZENET_AIM_AUTHORIZATION_TYPE == 'Authorize' ? 'AUTH_ONLY': 'AUTH_CAPTURE',

'x_method' => 'CC',

'x_amount' => number_format($order->info['total'], 2),

'x_card_num' => $_POST['authorizenet_aim_cc_number'],

'x_exp_date' => $_POST['authorizenet_aim_cc_expires_month'] . substr($_POST['authorizenet_aim_cc_expires_year'], -2),

'x_card_code' => $_POST['authorizenet_aim_cc_cvv'],

'x_email_customer' => MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_CUSTOMER == 'True' ? 'TRUE': 'FALSE',

'x_email_merchant' => MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_MERCHANT == 'True' ? 'TRUE': 'FALSE',

'x_cust_id' => $_SESSION['customer_id'],

'x_invoice_num' => $new_order_id,

'x_first_name' => $order->billing['firstname'],

'x_last_name' => $order->billing['lastname'],

'x_company' => $order->billing['company'],

'x_address' => $order->billing['street_address'],

'x_city' => $order->billing['city'],

'x_state' => $order->billing['state'],

'x_zip' => $order->billing['postcode'],

'x_country' => $order->billing['country']['title'],

'x_phone' => $order->customer['telephone'],

'x_email' => $order->customer['email_address'],

'x_ship_to_first_name' => $order->delivery['firstname'],

'x_ship_to_last_name' => $order->delivery['lastname'],

'x_ship_to_address' => $order->delivery['street_address'],

'x_ship_to_city' => $order->delivery['city'],

'x_ship_to_state' => $order->delivery['state'],

'x_ship_to_zip' => $order->delivery['postcode'],

'x_ship_to_country' => $order->delivery['country']['title'],

'x_description' => substr(STORE_NAME, 0, 255),

'x_test_request' => (MODULE_PAYMENT_AUTHORIZENET_AIM_TESTMODE == 'Test' ? 'TRUE' : 'FALSE'),

 

'Date' => $order_time,

'IP' => $_SERVER['REMOTE_ADDR'],

'Session' => tep_session_id());

 

$tax_value = 0;

 

foreach ($order->info['tax_groups'] as $key => $value) {

if ($value > 0) {

$tax_value += $this->format_raw($value);

}

}

 

if ($tax_value > 0) {

$submit_data['x_tax'] = $this->format_raw($tax_value);

}

 

$submit_data['x_freight'] = $this->format_raw($order->info['shipping_cost']);

 

// concatenate the submission data and put into variable $data

foreach ($submit_data as $key => $value) {

$data .= $key . '=' . urlencode(trim($value)) . '&';

}

 

// Remove the last "&" from the string

$data = substr($data, 0, -1);

 

// Add items ordered to merchants email as merchant defined fields Order - Product model, Product name and Qty ordered MC

if (MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_MERCHANT == 'True' && MODULE_PAYMENT_AUTHORIZENET_AIM_ADD_ITEMS == 'True')

{

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

$x = $i + 1;

$data .= '&item' . $x . '=' . urlencode($order->products[$i]['model']) . ' -|- ' . urlencode(substr($order->products[$i]['name'], 0, 255)) . ' -|- ' . urlencode($order->products[$i]['qty']);

}

}

 

// Post order info data to Authorize.net

// cURL must be compiled into PHP

// Connection must be https

// Test or Live Server address set

// using 'Test' or 'Live' mode in

// osCommerce admin panel

// When working in test mode, a flag that is set to true, indicates transaction is a test.

if (MODULE_PAYMENT_AUTHORIZENET_AIM_TESTMODE == 'Test') {

$gateway_url = 'https://secure.authorize.net/gateway/transact.dll'; // Changed test mode url MC

} else {

$gateway_url = 'https://secure.authorize.net/gateway/transact.dll';

}

 

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

 

if (!empty($transaction_response)) {

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

 

foreach ($regs as $key => $value) {

$regs[$key] = substr($value, 1, -1); // remove double quotes

}

} else {

$regs = array('-1', '-1', '-1');

}

 

// If the response code is not 1 (approved) then redirect back to the payment page with the appropriate error message

// Added a few more error code values MC

if ($regs[0] <> '1') {

$ecode = ' Error Code: ' . $regs[2] . '. ';

switch ($regs[2]) {

case '6':

$error = $ecode . ' The credit card number is invalid. ';

break;

 

case '7':

$error = $ecode . ' The credit card expiration date is invalid. ';

break;

 

case '8':

$error = $ecode . ' The credit card has expired. ';

break;

 

case '17':

$error = $ecode . ' The merchant does not accept this type of credit card. ';

break;

 

case '28':

$error = $ecode . ' The merchant does not accept this type of credit card. ';

break;

 

case '78':

$error = $ecode . ' The Card Code (CVV2/CVC2/CID) is invalid. ';

break;

 

default:

$error = $ecode . ' The credit card has a general error. ';

break;

}

 

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_DECLINED_MESSAGE1) . urlencode($error) . urlencode(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_DECLINED_MESSAGE2), 'SSL', true, false));

}

}

 

function after_process() {

global $regs, $new_order_id;

// Store card type, last 4 digits of credit card number and expiration date. CVC code is not stored MFC

if ($new_order_id < 1 || !is_array($regs)) return false;

 

if (ereg('^4[0-9]{12}([0-9]{3})?$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Visa';

} elseif (ereg('^5[1-5][0-9]{14}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Master Card';

} elseif (ereg('^3[47][0-9]{13}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'American Express';

} elseif (ereg('^3(0[0-5]|[68][0-9])[0-9]{11}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Diners Club';

} elseif (ereg('^6011[0-9]{12}$', $_POST['authorizenet_aim_cc_number'])) {

$cc_type = 'Discover';

}

 

$cc_number = preg_replace('/[^0-9]/', '', $_POST['authorizenet_aim_cc_number']);

$cc_number = str_repeat('X', strlen($cc_number) - 4) . substr($cc_number, -4);

 

tep_db_query("UPDATE orders SET cc_type = '" . $cc_type . "', cc_owner = '" . $_POST['cc_owner'] . "', cc_number = '" . $cc_number . "', cc_expires = '" . $_POST['authorizenet_aim_cc_expires_month'] . substr($_POST['authorizenet_aim_cc_expires_year'], -2) . "' WHERE orders_id = " . $new_order_id . " LIMIT 1");

 

return false;

}

 

function get_error() {

global $_GET;

 

$error = array('title' => MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_ERROR,

'error' => stripslashes(urldecode($_GET['error'])));

 

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_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 AIM Module', 'MODULE_PAYMENT_AUTHORIZENET_AIM_STATUS', 'True', 'Do you want to accept Authorize.net payments via the AIM Method?', '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 Username', 'MODULE_PAYMENT_AUTHORIZENET_AIM_LOGIN', 'Your User Name', 'The login username 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_AIM_TXNKEY', '16 digit key', 'Transaction Key used for encrypting TP data', '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 Mode', 'MODULE_PAYMENT_AUTHORIZENET_AIM_TESTMODE', 'Test', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(array(\'Test\', \'Live\'), ', 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 ('Authorization Type', 'MODULE_PAYMENT_AUTHORIZENET_AIM_AUTHORIZATION_TYPE', 'Authorize/Capture', 'Do you want submitted credit card transactions to be authorized only, or authorized and captured?', '6', '0', 'tep_cfg_select_option(array(\'Authorize\', \'Authorize/Capture\'), ', 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 ('Customer Notifications', 'MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_CUSTOMER', 'False', 'Should Authorize.Net e-mail a receipt to the customer?', '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, set_function, date_added) values ('Merchant Notifications', 'MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_MERCHANT', 'True', 'Should Authorize.Net e-mail a receipt to the merchant?', '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, set_function, date_added) values ('Merchant Notifications', 'MODULE_PAYMENT_AUTHORIZENET_AIM_ADD_ITEMS', 'True', 'Add items ordered to Merchants email?', '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, set_function, date_added) values ('Request CVV Number', 'MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV', 'True', 'Do you want to ask the customer for the card\'s CVV number', '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 ('Sort order of display.', 'MODULE_PAYMENT_AUTHORIZENET_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_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_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 Proxy URL', 'MODULE_PAYMENT_AUTHORIZENET_AIM_CURL_PROXY', 'none', 'CURL Proxy URL. Some hosting providers require you to use their CURL Proxy. Enter the full URL here. If Not necessary, use - none', '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_AIM_STATUS', 'MODULE_PAYMENT_AUTHORIZENET_AIM_LOGIN', 'MODULE_PAYMENT_AUTHORIZENET_AIM_TXNKEY', 'MODULE_PAYMENT_AUTHORIZENET_AIM_TESTMODE', 'MODULE_PAYMENT_AUTHORIZENET_AIM_AUTHORIZATION_TYPE', 'MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_CUSTOMER', 'MODULE_PAYMENT_AUTHORIZENET_AIM_EMAIL_MERCHANT', 'MODULE_PAYMENT_AUTHORIZENET_AIM_ADD_ITEMS', 'MODULE_PAYMENT_AUTHORIZENET_AIM_USE_CVV', 'MODULE_PAYMENT_AUTHORIZENET_AIM_SORT_ORDER', 'MODULE_PAYMENT_AUTHORIZENET_AIM_ZONE', 'MODULE_PAYMENT_AUTHORIZENET_AIM_ORDER_STATUS_ID', 'MODULE_PAYMENT_AUTHORIZENET_AIM_CURL_PROXY'); //'MODULE_PAYMENT_AUTHORIZENET_AIM_METHOD'

}

 

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'] : ''));

// ****** Added for Godaddy shared server ******

curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, TRUE);

curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);

curl_setopt($curl, CURLOPT_PROXY, "http://proxy.shr.secureserver.net:3128");

// ****** End Modification **********

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'], '.', '');

}

 

}

?>

 

 

********************** End Code ************************************

 

Enjoy,

 

RookuhShay

  • 3 months later...
Posted

I am not sure I am comfortable pasting such a large section of code into my script without specifically knowing what changed. Are there any details as to what you changed to make this work?

  • 2 months later...
Posted

Here is how I fixed it:

1 - used winmerge to compare my customer's authorizenet_aim.php to the one pasted above

2 - took most of the above changes, preserved a couple from the original module (use WinMerge -- maybe you don't care about the differenced)

3 - Find this in the before_process() function:

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

 

change it to this:

$regs = explode("|", $transaction_response);

 

All done.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...