Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Authorize.net not redirecting


RickChase

Recommended Posts

Posted

The module works great - credit cards are processed, but once they are the browser just sits at a blank page. The CC processor claims that everything is working great, and they say that my checkout_success.php is not outputting anything.

 

So I just go directly to my checkout_success.php page after placing an order (and after seeing only the blank page), and it knows what I ordered and it knows that it went through.

 

Why won't it redirect!?

 

Any input is appreciated.

Rick

Posted

Update:

 

In my authorizenet.php, I changed this

 

tep_draw_hidden_field('x_ADC_URL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false))

 

to this...

 

tep_draw_hidden_field('x_ADC_URL', tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL', false))

 

And it seems to work fine. Is there anything wrong with doing it this way? If not, then I am calling it done.

Rick

Posted

diddnt work for me. this thing is driving me crazy. What are all the references to SSL? That is the only thing I can think of. I tried using the test account at my credit card place and the test account at authnet and still get the same error "This merchants' account is not enabled on this system."

 

Our account is active. Same error on the test account too so Im guessing that the x_login isnt being sent. Does anyone know of anything that will capture or show what a form submits?

Posted
I tried using the test account at my credit card place

 

Who is your CC place, if you don't mind. Because the one I am using is not AuthNet, but they do "emulate" the AuthNet service. If we are using the same one, I'll just forward you all the changes you need to make. They have their emulator VERY close, but there are a couple changes you need to make.

 

Rick

Posted

eProcessingNetwork, please tell me thats who you are using...lol

 

They emulate as well but something isnt working the way its supposed to.

Posted

i cant believe my luck. i found a post of yours saying that you were planing on using ePN. I have been emailing them back and forth and they dont have a clue what the problems is. If you dont mind I will send them the info so they can add it to thier site. Thats if ePN is who you are using.

Posted

Here is the full authorizenet.php that I use. It works great, and you don't have to deal with ePN's horrible tech guys... Just look for "YOUR-ID-HERE" and replace that with your actual number they gave you.

 

Other than that, you should be good! If it still does not work for you, please let me know... there may be something I'm forgetting.

 

<?php

/*

 $Id: authorizenet.php,v 1.37 2002/08/13 16:00:41 dgw_ Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 class authorizenet {

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

   var $cc_number, $cc_expires_month, $cc_expires_year;



// class constructor

   function authorizenet() {

     global $HTTP_POST_VARS;



     $this->code = 'authorizenet';

     $this->title = MODULE_PAYMENT_AUTHORIZENET_TEXT_TITLE;

     $this->description = MODULE_PAYMENT_AUTHORIZENET_TEXT_DESCRIPTION;

     $this->enabled = MODULE_PAYMENT_AUTHORIZENET_STATUS;

     $this->cc_number = tep_db_prepare_input($HTTP_POST_VARS['authorizenet_cc_number']);

     $this->cc_expires_month = tep_db_prepare_input($HTTP_POST_VARS['authorizenet_cc_expires_month']);

     $this->cc_expires_year = tep_db_prepare_input($HTTP_POST_VARS['authorizenet_cc_expires_year']);

   }



// class methods

   function javascript_validation() {

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

                          '  var cc_number = document.payment.authorizenet_cc_number.value;' . "n" .

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

                          '    error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_TEXT_JS_CC_NUMBER . '";' . "n" .

                          '    error = 1;' . "n" .

                          '  }' . "n" .

                          '}' . "n";

     return $validation_string;

   }



   function selection() {

     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_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" .

                         '  <tr>' . "n" .

                         '    <td class="main"> ' . MODULE_PAYMENT_AUTHORIZENET_TEXT_CREDIT_CARD_NUMBER . ' </td>' . "n" .

                         '    <td class="main"> ' . tep_draw_input_field('authorizenet_cc_number') . ' </td>' . "n" .

                         '  </tr>' . "n" .

                         '  <tr>' . "n" .

                         '    <td class="main"> ' . MODULE_PAYMENT_AUTHORIZENET_TEXT_CREDIT_CARD_EXPIRES . ' </td>' . "n" .

                         '    <td class="main"> ' . tep_draw_pull_down_menu('authorizenet_cc_expires_month', $expires_month, date('m')) . ' / ' . tep_draw_pull_down_menu('authorizenet_cc_expires_year', $expires_year) . '</td>' . "n" .

                         '  </tr>' . "n" .

                         '</table>' . "n";



     return $selection_string;

   }



   function pre_confirmation_check() {



     include(DIR_WS_FUNCTIONS . 'ccval.php');



     $cc_val = CCValidationSolution($this->cc_number);

     if ($cc_val == '1') {

       $cc_val = ValidateExpiry($this->cc_expires_month, $this->cc_expires_year);

     }

     if ($cc_val != '1') {

       $payment_error_return = 'payment_error=' . $this->code . '&cc_val=' . urlencode($cc_val);

       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));

     }

   }



   function confirmation() {

     global $CardName, $CardNumber, $checkout_form_action;



     $confirmation_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" .

                            '  <tr>' . "n" .

                            '    <td class="main"> ' . MODULE_PAYMENT_AUTHORIZENET_TEXT_TYPE . ' ' . $CardName . ' </td>' . "n" .

                            '  </tr>' . "n" .

                            '  <tr>' . "n" .

                            '    <td class="main"> ' . MODULE_PAYMENT_AUTHORIZENET_TEXT_CREDIT_CARD_NUMBER . ' ' . $CardNumber . ' </td>' . "n" .

                            '  </tr>' . "n" .

                            '  <tr>' . "n" .

                            '    <td class="main"> ' . MODULE_PAYMENT_AUTHORIZENET_TEXT_CREDIT_CARD_EXPIRES . ' ' . strftime('%B/%Y', mktime(0,0,0,$this->cc_expires_month, 1, '20' . $this->cc_expires_year)) . ' </td>' . "n" .

                            '  </tr>' . "n" .

                            '</table>' . "n";



     $checkout_form_action = 'https://www.eProcessingNetwork.Com/cgi-bin/an/order.pl';



     return $confirmation_string;

   }



   function process_button() {

     global $HTTP_SERVER_VARS, $CardNumber, $order, $customer_id;



     $process_button_string = tep_draw_hidden_field('x_login', 'YOUR-ID-HERE') .

                              tep_draw_hidden_field('x_Card_Num', $CardNumber) .

                              tep_draw_hidden_field('x_Exp_Date', $this->cc_expires_month . $this->cc_expires_year) .

                              tep_draw_hidden_field('x_Amount', number_format($order->info['total'], 2)) .

                              tep_draw_hidden_field('x_ADC_Relay_Response', 'TRUE') .

                              tep_draw_hidden_field('x_ADC_URL', tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL', false)) .

                              tep_draw_hidden_field('x_Method', MODULE_PAYMENT_AUTHORIZENET_METHOD) .

                              tep_draw_hidden_field('x_Version', '3.0') .

                              tep_draw_hidden_field('x_Cust_ID', $customer_id) .

                              tep_draw_hidden_field('x_Email_Customer', (MODULE_PAYMENT_AUTHORIZENET_EMAIL == '1'? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_Email_Merchant', (MODULE_PAYMENT_AUTHORIZENET_EMAIL_MERCHANT == '1'? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_first_name', $order->customer['firstname']) .

                              tep_draw_hidden_field('x_last_name', $order->customer['lastname']) .

                              tep_draw_hidden_field('x_address', $order->customer['street_address']) .

                              tep_draw_hidden_field('x_city', $order->customer['city']) .

                              tep_draw_hidden_field('x_state', $order->customer['state']) .

                              tep_draw_hidden_field('x_zip', $order->customer['postcode']) .

                              tep_draw_hidden_field('x_country', $order->customer['country']['title']) .

                              tep_draw_hidden_field('x_phone', $order->customer['telephone']) .

                              tep_draw_hidden_field('x_email', $order->customer['email_address']) .

                              tep_draw_hidden_field('x_ship_to_first_name', $order->delivery['firstname']) .

                              tep_draw_hidden_field('x_ship_to_last_name', $order->delivery['lastname']) .

                              tep_draw_hidden_field('x_ship_to_address', $order->delivery['street_address']) .

                              tep_draw_hidden_field('x_ship_to_city', $order->delivery['city']) .

                              tep_draw_hidden_field('x_ship_to_state', $order->delivery['state']) .

                              tep_draw_hidden_field('x_ship_to_zip', $order->delivery['postcode']) .

                              tep_draw_hidden_field('x_ship_to_country', $order->delivery['country']['title']) .

                              tep_draw_hidden_field('x_Customer_IP', $HTTP_SERVER_VARS['REMOTE_ADDR']);

     if (MODULE_PAYMENT_AUTHORIZENET_TESTMODE == '1') $process_button_string .= tep_draw_hidden_field('x_Test_Request', 'TRUE');



     $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id());



     return $process_button_string;

   }



   function before_process() {

     global $HTTP_POST_VARS;



     if ($HTTP_POST_VARS['x_response_code'] != '1') {

       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_TEXT_ERROR_MESSAGE), 'SSL', true, false));

     }

   }



   function after_process() {

  return false;

   }



   function output_error() {

     global $HTTP_GET_VARS;



     $output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" .

                            '  <tr>' . "n" .

                            '    <td class="main"> <font color="#FF0000"><b>' . MODULE_PAYMENT_AUTHORIZENET_TEXT_ERROR . '</b></font><br> ' . stripslashes($HTTP_GET_VARS['cc_val']) . ' </td>' . "n" .

                            '  </tr>' . "n" .

                            '</table>' . "n";



     return $output_error_string;

   }



   function check() {

     if (!isset($this->_check)) {

       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_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, date_added) values ('Allow Authorize.net', 'MODULE_PAYMENT_AUTHORIZENET_STATUS', '1', 'Do you want to accept Authorize.net payments?', '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 ('Authorize.net Login', 'MODULE_PAYMENT_AUTHORIZENET_LOGIN', 'testing', 'Login used for Authorize.net payments', '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 ('Authorize.net Test Mode', 'MODULE_PAYMENT_AUTHORIZENET_TESTMODE', '1', 'Test mode for Authorize.net payments', '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 ('Authorize.net E-Mail Client', 'MODULE_PAYMENT_AUTHORIZENET_EMAIL', '0', 'Should Authorize.Net e-mail the customer too? 0=NO, 1=YES', '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 ('Authorize.net E-Mail Merchant', 'MODULE_PAYMENT_AUTHORIZENET_EMAIL_MERCHANT', '1', 'Should Authorize.Net e-mail you? 0=NO, 1=YES', '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 ('Authorize.net Method', 'MODULE_PAYMENT_AUTHORIZENET_METHOD', 'CC', 'This should be either CC or ECHECK', '6', '0', now())");

   }



   function remove() {

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_STATUS'");

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_LOGIN'");

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_TESTMODE'");

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_EMAIL'");

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_EMAIL_MERCHANT'");

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_AUTHORIZENET_METHOD'");

   }



   function keys() {

     $keys = array('MODULE_PAYMENT_AUTHORIZENET_STATUS', 'MODULE_PAYMENT_AUTHORIZENET_LOGIN', 'MODULE_PAYMENT_AUTHORIZENET_TESTMODE', 'MODULE_PAYMENT_AUTHORIZENET_EMAIL', 'MODULE_PAYMENT_AUTHORIZENET_EMAIL_MERCHANT', 'MODULE_PAYMENT_AUTHORIZENET_METHOD');



     return $keys;

   }

 }

?>

Posted

Im using it but it doesnt show up as an option when your checking out. did you have to make any changes to

 

catalog/includes/languages/english/modules/payment/authorizenet.php

 

or any other file?

Posted

It it turned on in the Admin? (turn on Auth.net, even though you are using a different cc processor - you are still using the auth.net module).

 

The only other thing I changed was in the catalog/includes/languages/english/modules/payment/authorizenet.php - but all I changed was "Authorize.net" to "Credit Card"

Posted

Man, I just don't know. Let me think about this and see, but I think all the changes I made were to the .php file I have already shown you. There were more changes than just the number - I don't remember exactly what they were, but I know there were some.

 

If that .php file isn't working for you, then I really don't know what to tell you. Sorry.

Posted

im doing a file comparison now. the includes are different in my authnet module. we may have different snapshots. I may need a couple more files to make it work.

Posted

actually its one file. mine looks for

 

include(DIR_WS_CLASSES . 'cc_validation.php');

 

yours

 

include(DIR_WS_FUNCTIONS . 'ccval.php');

 

Can you post that one for me please.

Posted

<?php

/*

$Id: ccval.php,v 1.6 2002/01/17 20:44:47 project3000 Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

 

Credit Card Validation Solution version 3.5 PHP Edition

COPYRIGHT NOTICE:

a) This code is property of The Analysis and Solutions Company.

B) It is being distributed free of charge and on an "as is" basis.

c) Use of this code, or any part thereof, is contingent upon leaving

this copyright notice, name and address information in tact.

d) Written permission must be obtained from us before this code, or any

part thereof, is sold or used in a product which is sold.

e) By using this code, you accept full responsibility for its use

and will not hold the Analysis and Solutions Company, its employees

or officers liable for damages of any sort.

f) This code is not to be used for illegal purposes.

g) Please email us any revisions made to this code.

 

Copyright 2000 http://www.AnalysisAndSolutions.com/code/

The Analysis and Solutions Company [email protected]

*/

 

function CCValidationSolution($Number) {

global $CardName, $CardNumber, $language;

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CCVAL_FUNCTION);

 

 

// Get rid of spaces and non-numeric characters.

$Number = OnlyNumericSolution($Number);

 

// Do the first four digits fit within proper ranges? If so, who's the card issuer and how long should the number be?

$NumberLeft = substr($Number, 0, 4);

$NumberLength = strlen($Number);

 

if ( ($NumberLeft >= 3000) && ($NumberLeft <= 3059) ) {

$CardName = 'Diners Club';

$ShouldLength = 14;

} elseif ( ($NumberLeft >= 3600) && ($NumberLeft <= 3699) ) {

$CardName = 'Diners Club';

$ShouldLength = 14;

} elseif ( ($NumberLeft >= 3800) && ($NumberLeft <= 3889) ) {

$CardName = 'Diners Club';

$ShouldLength = 14;

} elseif ( ($NumberLeft >= 3400) && ($NumberLeft <= 3499) ) {

$CardName = 'American Express';

$ShouldLength = 15;

} elseif ( ($NumberLeft >= 3700) && ($NumberLeft <= 3799) ) {

$CardName = 'American Express';

$ShouldLength = 15;

} elseif ( ($NumberLeft >= 3528) && ($NumberLeft <= 3589) ) {

$CardName = 'JCB';

$ShouldLength = 16;

} elseif ( ($NumberLeft >= 3890) && ($NumberLeft <= 3899) ) {

$CardName = 'Carte Blache';

$ShouldLength = 14;

} elseif ( ($NumberLeft >= 4000) && ($NumberLeft <= 4999) ) {

$CardName = 'Visa';

if ($NumberLength > 14) {

$ShouldLength = 16;

} elseif ($NumberLength < 14) {

$ShouldLength = 13;

}

} elseif ( ($NumberLeft >= 5100) && ($NumberLeft <= 5599) ) {

$CardName = 'MasterCard';

$ShouldLength = 16;

} elseif ($NumberLeft == 5610) {

$CardName = 'Australian BankCard';

$ShouldLength = 16;

} elseif ($NumberLeft == 6011) {

$CardName = 'Discover/Novus';

$ShouldLength = 16;

} else {

$cc_val = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, $NumberLeft);

return $cc_val;

}

 

// Is the number the right length?

if ($NumberLength <> $ShouldLength) {

$Missing = $NumberLength - $ShouldLength;

if ($Missing < 0) {

$cc_val = sprintf(TEXT_CCVAL_ERROR_INVALID_NUMBER, $CardName, $Number);

} else {

$cc_val = sprintf(TEXT_CCVAL_ERROR_INVALID_NUMBER, $CardName, $Number);

}

 

return $cc_val;

}

 

// Does the number pass the Mod 10 Algorithm Checksum?

if (Mod10Solution($Number)) {

$CardNumber = $Number;

return true;

} else {

$cc_val = sprintf(TEXT_CCVAL_ERROR_INVALID_NUMBER, $CardName, $Number);

return $cc_val;

}

}

 

function OnlyNumericSolution($Number) {

// Remove any non numeric characters.

// Ensure number is no more than 19 characters long.

return substr(ereg_replace('[^0-9]', '', $Number) , 0, 19);

}

 

function Mod10Solution($Number) {

$NumberLength = strlen($Number);

$Checksum = 0;

 

// Add even digits in even length strings or odd digits in odd length strings.

for ($Location = 1-($NumberLength%2); $Location<$NumberLength; $Location+=2) {

$Checksum += substr($Number, $Location, 1);

}

 

// Analyze odd digits in even length strings or even digits in odd length strings.

for ($Location = ($NumberLength%2); $Location<$NumberLength; $Location+=2) {

$Digit = substr($Number, $Location, 1) * 2;

if ($Digit < 10) {

$Checksum += $Digit;

} else {

$Checksum += $Digit - 9;

}

}

 

// Is the checksum divisible by ten?

return ($Checksum % 10 == 0);

}

 

function ValidateExpiry ($month, $year) {

$cc_val = '';

$year = '20' . $year;

 

if (date('Y') == $year) {

if (date('m') <= $month) {

$cc_val = '1';

} else {

$cc_val = sprintf(TEXT_CCVAL_ERROR_INVALID_DATE, $month, $year);

}

} elseif (date('Y') > $year) {

$cc_val = sprintf(TEXT_CCVAL_ERROR_INVALID_DATE, $month, $year);

} else {

$cc_val = '1';

}

 

return $cc_val;

}

?>


Posted

your authnet file is completly different then mine. mine is

 

authorizenet.php,v 1.38 2002/11/01 05:01:41

 

yours

 

authorizenet.php,v 1.37 2002/08/13 16:00:41

 

 

I think mine uses the new proccess. Im confused now

Posted

here is mine....there are to many differences to make any sence out of it....to me anyway.

 

<?php

/*

 $Id: authorizenet.php,v 1.38 2002/11/01 05:01:41 hpdl Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



 class authorizenet {

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



// class constructor

   function authorizenet() {

     $this->code = 'authorizenet';

     $this->title = MODULE_PAYMENT_AUTHORIZENET_TEXT_TITLE;

     $this->description = MODULE_PAYMENT_AUTHORIZENET_TEXT_DESCRIPTION;

     $this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_STATUS == 'True') ? true : false);



     $this->form_action_url = 'https://www.eProcessingNetwork.Com/cgi-bin/an/order.pl';

   }



// class methods

   function javascript_validation() {

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

           '    var cc_owner = document.checkout_payment.authorizenet_cc_owner.value;' . "n" .

           '    var cc_number = document.checkout_payment.authorizenet_cc_number.value;' . "n" .

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

           '      error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_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_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_AUTHORIZENET_TEXT_CREDIT_CARD_OWNER,

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

                                          array('title' => MODULE_PAYMENT_AUTHORIZENET_TEXT_CREDIT_CARD_NUMBER,

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

                                          array('title' => MODULE_PAYMENT_AUTHORIZENET_TEXT_CREDIT_CARD_EXPIRES,

                                                'field' => tep_draw_pull_down_menu('authorizenet_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('authorizenet_cc_expires_year', $expires_year))));



     return $selection;

   }



   function pre_confirmation_check() {

     global $HTTP_POST_VARS;



     include(DIR_WS_CLASSES . 'cc_validation.php');



     $cc_validation = new cc_validation();

     $result = $cc_validation->validate($HTTP_POST_VARS['authorizenet_cc_number'], $HTTP_POST_VARS['authorizenet_cc_expires_month'], $HTTP_POST_VARS['authorizenet_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) . '&authorizenet_cc_owner=' . urlencode($HTTP_POST_VARS['authorizenet_cc_owner']) . '&authorizenet_cc_expires_month=' . $HTTP_POST_VARS['authorizenet_cc_expires_month'] . '&authorizenet_cc_expires_year=' . $HTTP_POST_VARS['authorizenet_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;



     $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,

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

                                                   'field' => $HTTP_POST_VARS['authorizenet_cc_owner']),

                                             array('title' => MODULE_PAYMENT_AUTHORIZENET_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_AUTHORIZENET_TEXT_CREDIT_CARD_EXPIRES,

                                                   'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['authorizenet_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['authorizenet_cc_expires_year'])))));



     return $confirmation;

   }



   function process_button() {

     global $HTTP_SERVER_VARS, $order, $customer_id;



     $process_button_string = tep_draw_hidden_field('x_Login', MODULE_PAYMENT_AUTHORIZENET_LOGIN) .

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

                              tep_draw_hidden_field('x_Exp_Date', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) .

                              tep_draw_hidden_field('x_Amount', number_format($order->info['total'], 2)) .

                              tep_draw_hidden_field('x_ADC_Relay_Response', 'TRUE') .

                              tep_draw_hidden_field('x_ADC_URL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) .

                              tep_draw_hidden_field('x_Method', ((MODULE_PAYMENT_AUTHORIZENET_METHOD == 'Credit Card') ? 'CC' : 'ECHECK')) .

                              tep_draw_hidden_field('x_Version', '3.0') .

                              tep_draw_hidden_field('x_Cust_ID', $customer_id) .

                              tep_draw_hidden_field('x_Email_Customer', ((MODULE_PAYMENT_AUTHORIZENET_EMAIL_CUSTOMER == 'True') ? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_Email_Merchant', ((MODULE_PAYMENT_AUTHORIZENET_EMAIL_MERCHANT == 'True') ? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_first_name', $order->customer['firstname']) .

                              tep_draw_hidden_field('x_last_name', $order->customer['lastname']) .

                              tep_draw_hidden_field('x_address', $order->customer['street_address']) .

                              tep_draw_hidden_field('x_city', $order->customer['city']) .

                              tep_draw_hidden_field('x_state', $order->customer['state']) .

                              tep_draw_hidden_field('x_zip', $order->customer['postcode']) .

                              tep_draw_hidden_field('x_country', $order->customer['country']['title']) .

                              tep_draw_hidden_field('x_phone', $order->customer['telephone']) .

                              tep_draw_hidden_field('x_email', $order->customer['email_address']) .

                              tep_draw_hidden_field('x_ship_to_first_name', $order->delivery['firstname']) .

                              tep_draw_hidden_field('x_ship_to_last_name', $order->delivery['lastname']) .

                              tep_draw_hidden_field('x_ship_to_address', $order->delivery['street_address']) .

                              tep_draw_hidden_field('x_ship_to_city', $order->delivery['city']) .

                              tep_draw_hidden_field('x_ship_to_state', $order->delivery['state']) .

                              tep_draw_hidden_field('x_ship_to_zip', $order->delivery['postcode']) .

                              tep_draw_hidden_field('x_ship_to_country', $order->delivery['country']['title']) .

                              tep_draw_hidden_field('x_Customer_IP', $HTTP_SERVER_VARS['REMOTE_ADDR']);

     if (MODULE_PAYMENT_AUTHORIZENET_TESTMODE == 'Test') $process_button_string .= tep_draw_hidden_field('x_Test_Request', 'TRUE');



     $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id());



     return $process_button_string;

   }



   function before_process() {

     global $HTTP_POST_VARS;



     if ($HTTP_POST_VARS['x_response_code'] != '1') {

       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AUTHORIZENET_TEXT_ERROR_MESSAGE), 'SSL', true, false));

     }

   }



   function after_process() {

     return false;

   }



   function get_error() {

     global $HTTP_GET_VARS;



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

                    'error' => stripslashes(urldecode($HTTP_GET_VARS['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_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 Module', 'MODULE_PAYMENT_AUTHORIZENET_STATUS', 'True', 'Do you want to accept Authorize.net 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 Username', 'MODULE_PAYMENT_AUTHORIZENET_LOGIN', 'testing', '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, set_function, date_added) values ('Transaction Mode', 'MODULE_PAYMENT_AUTHORIZENET_TESTMODE', 'Test', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(array('Test', 'Production'), ', 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_METHOD', 'Credit Card', 'Transaction method used for processing orders', '6', '0', 'tep_cfg_select_option(array('Credit Card', 'eCheck'), ', 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_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_EMAIL_MERCHANT', 'True', 'Should Authorize.Net e-mail a receipt to the store owner?', '6', '0', 'tep_cfg_select_option(array('True', 'False'), ', now())");

   }



   function remove() {

     $keys = '';

     $keys_array = $this->keys();

     for ($i=0; $i<sizeof($keys_array); $i++) {

       $keys .= "'" . $keys_array[$i] . "',";

     }

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



     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");

   }



   function keys() {

     return array('MODULE_PAYMENT_AUTHORIZENET_STATUS', 'MODULE_PAYMENT_AUTHORIZENET_LOGIN', 'MODULE_PAYMENT_AUTHORIZENET_TESTMODE', 'MODULE_PAYMENT_AUTHORIZENET_METHOD', 'MODULE_PAYMENT_AUTHORIZENET_EMAIL_CUSTOMER', 'MODULE_PAYMENT_AUTHORIZENET_EMAIL_MERCHANT');

   }

 }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...