Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

One Page Checkout Support


Guest

Recommended Posts

Exactly the same issue "confirmation password does not match the password" on 1.4

 

Everything pre-fills and loads fine,but the error message pops up when trying to checkout. This only happens when using OPC to login.

 

Also the Breadcrumbs bar does not load the logout link which should show when a customer is logged into their account.

If after logging in on OPC and you click to go anywhere else on the website - then the logout option appears in the breadcrumbs bar and when checking out with OPC there is no error.

Link to comment
Share on other sites

I am having the same problem with OPC "Address Errors: The confirmation password does not match the password" when the customer clicks the "continue" button to checkout.

 

Are you saying that was solved at the URL below? Because I can't find any solution on that page. Unless you mean the person who said to roll back to 1.3 from 1.4. I would really prefer not to go to that length. I think we should solve this issue :) Please let me know if that was what you meant, or if you actually do know of a fix that was posted.

 

thanks :)

Hi

 

open onepage_checkout.php in includes/classes.

 

find on line 1122:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

 

 

replace with:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_status'        => '1',
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

This post has been edited by BenCox: 13 September 2010 - 12:37 PM

Link to comment
Share on other sites

Ok I will post the complete issue so hopefully we can come to a solution since a few people have reported the same problem.

 

I have installed OPC I assume it's 1.4, it's marked as such and is the latest download from http://addons.oscommerce.com/info/6646 dated 25 Aug 2010. I'm running PHP 5.3.3 in Windows Server 2003 and MySql 5 using Paypal web payments standard. In general OPC works great, except for one issue which I describe here.

 

If the customer is not logged in and they add a product to the cart and then go to checkout, OPC loads fine. When the customer clicks on the log in button, the popup login opens up and the customer can log in, and all the tables load the correct data for shipping, addresses, payment, etc. But then when the customer clicks on the "continue" button which should take them to Paypal, this annoying javascript alert box pops up saying "Address errors: Confirmation Password doesn't match the password!" And the customer is denied from checking out (and I don't get the sale :( )

 

I have noticed that if the customer then browses to another page and then returns to the checkout page, this error does NOT occur again, and checkout can proceed normally. It seems only to occur when the user is forced to log in on the checkout page, some value is not transmitted to the javascript (ajax I assume) code. In fact, I did a test on the values:

 

/catalog/includes/checkout.js

 

if($(':password[name=password]').val() != '')

{

if($(':password[name=confirmation]').val() == '' || $(':password[name=confirmation]').val() != $(':password[name=password]').val() )

{

 

// I added this to see what was going on:

alert("1:" + $(':password[name=confirmation]').val() + "; 2: " + $(':password[name=password]').val() );

// end of my add

 

errMsg += 'Confirmation password does not match the password.' + "\n";

}
}

 

my alert revealed that the value of $(':password[name=password]').val() does contain the customer's password but the value of $(':password[name=confirmation]').val() equals "undefined".

 

I can continue to reverse-engineer this to try to get to the bottom of it but I was hoping that the developer or a developer out there might already be able to tell us exactly what is going wrong here... would sure appreciate any assistance... I have so many other bug fixes I have to get done, it would sure shorten my workload if someone out there could solve this easily. Otherwise I will keep hacking away... thanks profusely in advance....

 

screen shot:

 

 

address_errors.jpg

Hi The developer does not support this via free support, you could email them and report it as a bug

 

Steve

Link to comment
Share on other sites

One Page checkout together with QT Pro..

 

Its crashes when im trying to go to the checkout page..

 

I get two errors..

 

Warning: array_keys() [function.array-keys]: The first argument should be an array in /x/public_html/includes/functions/general.php on line 115

 

Warning: implode() [function.implode]: Invalid arguments passed in /x/public_html/includes/functions/general.php on line 115

 

Line 115:

$options_list=implode(",",array_keys($attributes));

 

Has anyone worked QT Pro with OPC? ANy tips and pointers?

Link to comment
Share on other sites

I tried to unravel the spaghetti code of the Ajax interface which gives us this problem, but in the end I decided the best way to avoid the whole thing was to change the setting for "Require Login" in the Admin section at Admin->Configuration->OnePageCheckout.

 

If you navigate to that section in the admin console and set "Require Login" to "true", then what happens is the user is redirected to the login page prior to accessing the Onepage Checkout area. To my sensibilities, this is much better and much more intuitive. And it looks better, because the user never sees the unpopulated Onepage checkout page (which to me looks rather ugly.) So all the login and/or registration occurs before they ever get to that page, and the offending "Address Errors" popup never has a chance to pop up.

 

works for me :)

 

Hugh J. Hitchcock

Link to comment
Share on other sites

thank you! I'll try that

 

Hi

 

open onepage_checkout.php in includes/classes.

 

find on line 1122:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

 

 

replace with:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_status'        => '1',
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

This post has been edited by BenCox: 13 September 2010 - 12:37 PM

Link to comment
Share on other sites

hmmmm.... I tried this and unfortunately I still get excatly the same error. I Think I will stick with "Require Login" in the admin section to completely circumvent this issue. But thanks anyway!

 

Hugh

 

Hi

 

open onepage_checkout.php in includes/classes.

 

find on line 1122:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

 

 

replace with:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_status'        => '1',
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

This post has been edited by BenCox: 13 September 2010 - 12:37 PM

Link to comment
Share on other sites

Steve,

 

I am using Credit Card with CVV2 v2.3

 

Thanks

Hi

 

does that normally output the fileds to be entered on the order confirmation screen? if it does that is the problem, on function process_order for that payment module file could add

 

global $HTTP_POST_VARS;

 

Steve

Link to comment
Share on other sites

Hi

 

does that normally output the fileds to be entered on the order confirmation screen? if it does that is the problem, on function process_order for that payment module file could add

 

global $HTTP_POST_VARS;

 

Steve

 

 

Thanks Steve, but that didnt do anything either.

 

Here is a screenshot of the problem:

 

cc.jpg

 

 

 

Here is the code for the module:

 

 

<?php
/*
 $Id: cc.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 class cc {
   var $code, $title, $description, $enabled;

// class constructor
   function cc() {
     global $order;

     $this->code = 'cc';
     $this->title = MODULE_PAYMENT_CC_TEXT_TITLE;
     $this->public_title = MODULE_PAYMENT_CC_TEXT_PUBLIC_TITLE;
     $this->description = MODULE_PAYMENT_CC_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_PAYMENT_CC_SORT_ORDER;
     $this->enabled = ((MODULE_PAYMENT_CC_STATUS == 'True') ? true : false);

     if ((int)MODULE_PAYMENT_CC_ORDER_STATUS_ID > 0) {
       $this->order_status = MODULE_PAYMENT_CC_ORDER_STATUS_ID;
     }

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

// class methods
   function update_status() {
     global $order;

     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_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_CC_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() {
     if (MODULE_PAYMENT_CC_CVV2 == 'True') {
           $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
           '    var cc_owner = document.checkout_payment.cc_owner.value;' . "\n" .
           '    var cc_number = document.checkout_payment.cc_number.value;' . "\n" .
           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_TEXT_JS_CC_NUMBER . '";' . "\n" .
           '      error = 1;' . "\n" .
           '    }' . "\n" .
           '  }' . "\n";
           }else{
           $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
           '    var cc_owner = document.checkout_payment.cc_owner.value;' . "\n" .
           '    var cc_number = document.checkout_payment.cc_number.value;' . "\n" .
           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_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 = (int)date('Y'); 
     for ($i=$today; $i < $today+10; $i++) {
       $expires_year[] = array('id' => substr((string)$i, -2), 'text' => (string)$i);
     }

     $func_name = "set_" . $this->code . "()";
     $func_def = '<script language="javascript"><!-- 
function ' . $func_name . ' {
 for (var i=0; i<document.checkout_payment.payment.length; i++) {
   if (document.checkout_payment.payment[i].value == "' . $this->code . '") {
     document.checkout_payment.payment[i].checked = true;
   }
 }
}//--></script>';
     $oc = 'onChange="' . $func_name . '"';

           if (MODULE_PAYMENT_CC_CVV2 == 'True') {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_CVV2,
                                                'field' => tep_draw_input_field('cc_cvv2', '', $oc) . ' <strong onclick="openexpwindow();">' . TEXT_EXPLANATION . '</strong>'),
                                                                                         array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     } else {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     }
     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['cc_number'], $HTTP_POST_VARS['cc_expires_month'], $HTTP_POST_VARS['cc_expires_year'], $HTTP_POST_VARS['cc_cvv2']);

     $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 -5:
         $error = TEXT_CCVAL_ERROR_INVALID_CVV2;
         break;
       case -6:
         $error = TEXT_CVV_ERROR_AMEX;
         break;
       case -7:
         $error = TEXT_CVV_ERROR_OTHER;
         break;
       case -8:
         $error = TEXT_CARD_NOT_ACCEPTED;
         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) . '&cc_owner=' . urlencode($HTTP_POST_VARS['cc_owner']) . '&cc_expires_month=' . $HTTP_POST_VARS['cc_expires_month'] . '&cc_expires_year=' . $HTTP_POST_VARS['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;
   }

   function confirmation() {
     global $HTTP_POST_VARS;

           if (MODULE_PAYMENT_CC_CVV2 == 'True') {
       $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
                             'fields' => array(array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                     'field' => $HTTP_POST_VARS['cc_owner']),
                                               array('title' => MODULE_PAYMENT_CC_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_CC_TEXT_CREDIT_CARD_CVV2,
                                                     'field' => $HTTP_POST_VARS['cc_cvv2']),
                                               array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                     'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['cc_expires_month'], 1, '20' . $HTTP_POST_VARS['cc_expires_year'])))));
     } else {
       $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
                             'fields' => array(array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                     'field' => $HTTP_POST_VARS['cc_owner']),
                                               array('title' => MODULE_PAYMENT_CC_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_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                     'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['cc_expires_month'], 1, '20' . $HTTP_POST_VARS['cc_expires_year'])))));
     }
     return $confirmation;
   }

   function process_button() {
     global $HTTP_POST_VARS;

     $process_button_string = tep_draw_hidden_field('cc_owner', $HTTP_POST_VARS['cc_owner']) .
                              tep_draw_hidden_field('cc_expires', $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year']) .
                              tep_draw_hidden_field('cc_type', $this->cc_card_type) .
                              tep_draw_hidden_field('cc_cvv2', $HTTP_POST_VARS['cc_cvv2']) .
                              tep_draw_hidden_field('cc_number', $this->cc_card_number);

     return $process_button_string;
   }

   function before_process() {
     global $HTTP_POST_VARS, $order;

     if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
       $len = strlen($HTTP_POST_VARS['cc_number']);

       $this->cc_middle = substr($HTTP_POST_VARS['cc_number'], 4, ($len-8));
       $order->info['cc_number'] = substr($HTTP_POST_VARS['cc_number'], 0, 4) . str_repeat('X', (strlen($HTTP_POST_VARS['cc_number']) - 8)) . substr($HTTP_POST_VARS['cc_number'], -4);
       $this->cc_cvv = $HTTP_POST_VARS['cc_cvv2'];
       $order->info['cc_cvv2'] = str_repeat('X', strlen($HTTP_POST_VARS['cc_cvv2']));
     }
   }

   function after_process() {
     global $insert_id;

     if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
       $message = 'Order #' . $insert_id . "\n\n" . 'Middle: ' . $this->cc_middle . "\n\n" . 'CVV: ' . $this->cc_cvv . "\n\n";

       tep_mail('', MODULE_PAYMENT_CC_EMAIL, 'Extra Order Info: #' . $insert_id, $message, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
     }
   }

   function get_error() {
     global $HTTP_GET_VARS;

     $error = array('title' => MODULE_PAYMENT_CC_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_CC_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 Credit Card Module', 'MODULE_PAYMENT_CC_STATUS', 'True', 'Do you want to accept credit card 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 ('Split Credit Card E-Mail Address', 'MODULE_PAYMENT_CC_EMAIL', '', 'If an e-mail address is entered, the middle digits of the credit card number will be sent to the e-mail address (the outside digits are stored in the database with the middle digits censored)', '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 ('Sort order of display.', 'MODULE_PAYMENT_CC_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_CC_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_CC_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, set_function, date_added) values ('Require CCV2', 'MODULE_PAYMENT_CC_CVV2', 'True', 'Require cvv2 numbers', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_PAYMENT_CC_STATUS', 'MODULE_PAYMENT_CC_EMAIL', 'MODULE_PAYMENT_CC_ZONE', 'MODULE_PAYMENT_CC_ORDER_STATUS_ID', 'MODULE_PAYMENT_CC_SORT_ORDER', 'MODULE_PAYMENT_CC_CVV2' );
   }
 }
?>

 

 

 

Thanks

Link to comment
Share on other sites

Hi Steve!

 

Incredible how much you are helping out in here! great!

 

I dont think that this question about newsletter has been up in here before, i could not find anything.

 

We would like that if a customer choose not to make an account they still can register to our newsletter, but in my tests it doesnt work?

 

I have a addon maillist wich makes that customer can register to the newsletter in an box on the index page.

somewhere i need to add some code but where? or if we could change that the newsletter registers for everyone.

 

best regards.

Link to comment
Share on other sites

Thanks Steve, but that didnt do anything either.

 

Here is a screenshot of the problem:

 

cc.jpg

 

 

 

Here is the code for the module:

 

 

 

Thanks

Hi

 

Replace code in cc.php with this code

<?php
/*
 $Id: cc.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 class cc {
   var $code, $title, $description, $enabled;

// class constructor
   function cc() {
     global $order;

     $this->code = 'cc';
     $this->title = MODULE_PAYMENT_CC_TEXT_TITLE;
     $this->public_title = MODULE_PAYMENT_CC_TEXT_PUBLIC_TITLE;
     $this->description = MODULE_PAYMENT_CC_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_PAYMENT_CC_SORT_ORDER;
     $this->enabled = ((MODULE_PAYMENT_CC_STATUS == 'True') ? true : false);

     if ((int)MODULE_PAYMENT_CC_ORDER_STATUS_ID > 0) {
       $this->order_status = MODULE_PAYMENT_CC_ORDER_STATUS_ID;
     }

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

// class methods
   function update_status() {
     global $order;

     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_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_CC_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() {
     if (MODULE_PAYMENT_CC_CVV2 == 'True') {
           $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
           '    var cc_owner = document.checkout_payment.cc_owner.value;' . "\n" .
           '    var cc_number = document.checkout_payment.cc_number.value;' . "\n" .
           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_TEXT_JS_CC_NUMBER . '";' . "\n" .
           '      error = 1;' . "\n" .
           '    }' . "\n" .
           '  }' . "\n";
           }else{
           $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
           '    var cc_owner = document.checkout_payment.cc_owner.value;' . "\n" .
           '    var cc_number = document.checkout_payment.cc_number.value;' . "\n" .
           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_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 = (int)date('Y'); 
     for ($i=$today; $i < $today+10; $i++) {
       $expires_year[] = array('id' => substr((string)$i, -2), 'text' => (string)$i);
     }

     $func_name = "set_" . $this->code . "()";
     $func_def = '<script language="javascript"><!-- 
function ' . $func_name . ' {
 for (var i=0; i<document.checkout_payment.payment.length; i++) {
   if (document.checkout_payment.payment[i].value == "' . $this->code . '") {
     document.checkout_payment.payment[i].checked = true;
   }
 }
}//--></script>';
     $oc = 'onchange="' . $func_name . '"';

           if (MODULE_PAYMENT_CC_CVV2 == 'True') {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_CVV2,
                                                'field' => tep_draw_input_field('cc_cvv2', '', $oc) . ' <strong onclick="openexpwindow();">' . TEXT_EXPLANATION . '</strong>'),
                                                                                         array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     } else {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     }
     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['cc_number'], $HTTP_POST_VARS['cc_expires_month'], $HTTP_POST_VARS['cc_expires_year'], $HTTP_POST_VARS['cc_cvv2']);

     $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 -5:
         $error = TEXT_CCVAL_ERROR_INVALID_CVV2;
         break;
       case -6:
         $error = TEXT_CVV_ERROR_AMEX;
         break;
       case -7:
         $error = TEXT_CVV_ERROR_OTHER;
         break;
       case -8:
         $error = TEXT_CARD_NOT_ACCEPTED;
         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) . '&cc_owner=' . urlencode($HTTP_POST_VARS['cc_owner']) . '&cc_expires_month=' . $HTTP_POST_VARS['cc_expires_month'] . '&cc_expires_year=' . $HTTP_POST_VARS['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;
   }

   function confirmation() {
     global $order, $HTTP_POST_VARS;

                    if (MODULE_PAYMENT_CC_CVV2 == 'True') {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_CVV2,
                                                'field' => tep_draw_input_field('cc_cvv2', '', $oc) . ' <strong onclick="openexpwindow();">' . TEXT_EXPLANATION . '</strong>'),
                                                                                         array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     } else {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     }
     return $selection;
   }

   function process_button() {
     global $HTTP_POST_VARS;

     $process_button_string = tep_draw_hidden_field('cc_owner', $HTTP_POST_VARS['cc_owner']) .
                              tep_draw_hidden_field('cc_expires', $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year']) .
                              tep_draw_hidden_field('cc_type', $this->cc_card_type) .
                              tep_draw_hidden_field('cc_cvv2', $HTTP_POST_VARS['cc_cvv2']) .
                              tep_draw_hidden_field('cc_number', $this->cc_card_number);

     return $process_button_string;
   }

   function before_process() {
     global $HTTP_POST_VARS, $order;

     if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
       $len = strlen($HTTP_POST_VARS['cc_number']);

       $this->cc_middle = substr($HTTP_POST_VARS['cc_number'], 4, ($len-8));
       $order->info['cc_number'] = substr($HTTP_POST_VARS['cc_number'], 0, 4) . str_repeat('X', (strlen($HTTP_POST_VARS['cc_number']) - 8)) . substr($HTTP_POST_VARS['cc_number'], -4);
       $this->cc_cvv = $HTTP_POST_VARS['cc_cvv2'];
       $order->info['cc_cvv2'] = str_repeat('X', strlen($HTTP_POST_VARS['cc_cvv2']));
     }
   }

   function after_process() {
     global $insert_id;

     if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
       $message = 'Order #' . $insert_id . "\n\n" . 'Middle: ' . $this->cc_middle . "\n\n" . 'CVV: ' . $this->cc_cvv . "\n\n";

       tep_mail('', MODULE_PAYMENT_CC_EMAIL, 'Extra Order Info: #' . $insert_id, $message, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
     }
   }

   function get_error() {
     global $HTTP_GET_VARS;

     $error = array('title' => MODULE_PAYMENT_CC_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_CC_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 Credit Card Module', 'MODULE_PAYMENT_CC_STATUS', 'True', 'Do you want to accept credit card 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 ('Split Credit Card E-Mail Address', 'MODULE_PAYMENT_CC_EMAIL', '', 'If an e-mail address is entered, the middle digits of the credit card number will be sent to the e-mail address (the outside digits are stored in the database with the middle digits censored)', '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 ('Sort order of display.', 'MODULE_PAYMENT_CC_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_CC_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_CC_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, set_function, date_added) values ('Require CCV2', 'MODULE_PAYMENT_CC_CVV2', 'True', 'Require cvv2 numbers', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_PAYMENT_CC_STATUS', 'MODULE_PAYMENT_CC_EMAIL', 'MODULE_PAYMENT_CC_ZONE', 'MODULE_PAYMENT_CC_ORDER_STATUS_ID', 'MODULE_PAYMENT_CC_SORT_ORDER', 'MODULE_PAYMENT_CC_CVV2' );
   }
 }
?>

 

Steve

Link to comment
Share on other sites

Hi Steve!

 

Incredible how much you are helping out in here! great!

 

I dont think that this question about newsletter has been up in here before, i could not find anything.

 

We would like that if a customer choose not to make an account they still can register to our newsletter, but in my tests it doesnt work?

 

I have a addon maillist wich makes that customer can register to the newsletter in an box on the index page.

somewhere i need to add some code but where? or if we could change that the newsletter registers for everyone.

 

best regards.

Hi please tell me which version of that you are using? if its the ajax one we might have problems integrating that with one page checkout

 

Steve

Link to comment
Share on other sites

Here is the Authorize.net aim code I slightly modified. I'm currently running it live and it works for my customers. Good luck.

 

<?php

/*

$Id: authorizenet_cc_aim.php 1803 2008-01-11 18:16:37Z hpdl $

* modified to work with One Page Checkout Contribution*

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

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() {

/* One Page Checkout - BEGIN */

$js = '';

/* One Page Checkout - END */

return array('id' => $this->code,

'module' => $this->public_title);

}

 

function pre_confirmation_check() {

return false;

}

 

function confirmation() {

global $order, $HTTP_POST_VARS;

 

for ($i=1; $i<13; $i++) {

$expires_month[] = array('id' => sprintf('%02d', $i), 'text' => "(" . $i . ") " . 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) . ' ' . 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' => $HTTP_POST_VARS['cc_number_nh-dns'],

'x_exp_date' => $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year'],

'x_card_code' => $HTTP_POST_VARS['cc_cvc_nh-dns']

);

 

 

 

 

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);

 

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

}

}

?>

Link to comment
Share on other sites

Thank Steve it worked!!!

 

But now there is a problem with the Credit Card Expiration drop down menu....they're blank

 

Here is a picture

 

ccexp.jpg

Hi

 

try this code

<?php
/*
 $Id: cc.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 class cc {
   var $code, $title, $description, $enabled;

// class constructor
   function cc() {
     global $order;

     $this->code = 'cc';
     $this->title = MODULE_PAYMENT_CC_TEXT_TITLE;
     $this->public_title = MODULE_PAYMENT_CC_TEXT_PUBLIC_TITLE;
     $this->description = MODULE_PAYMENT_CC_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_PAYMENT_CC_SORT_ORDER;
     $this->enabled = ((MODULE_PAYMENT_CC_STATUS == 'True') ? true : false);

     if ((int)MODULE_PAYMENT_CC_ORDER_STATUS_ID > 0) {
       $this->order_status = MODULE_PAYMENT_CC_ORDER_STATUS_ID;
     }

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

// class methods
   function update_status() {
     global $order;

     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_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_CC_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() {
     if (MODULE_PAYMENT_CC_CVV2 == 'True') {
           $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
           '    var cc_owner = document.checkout_payment.cc_owner.value;' . "\n" .
           '    var cc_number = document.checkout_payment.cc_number.value;' . "\n" .
           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_TEXT_JS_CC_NUMBER . '";' . "\n" .
           '      error = 1;' . "\n" .
           '    }' . "\n" .
           '  }' . "\n";
           }else{
           $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
           '    var cc_owner = document.checkout_payment.cc_owner.value;' . "\n" .
           '    var cc_number = document.checkout_payment.cc_number.value;' . "\n" .
           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_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 = (int)date('Y'); 
     for ($i=$today; $i < $today+10; $i++) {
       $expires_year[] = array('id' => substr((string)$i, -2), 'text' => (string)$i);
     }

     $func_name = "set_" . $this->code . "()";
     $func_def = '<script language="javascript"><!-- 
function ' . $func_name . ' {
 for (var i=0; i<document.checkout_payment.payment.length; i++) {
   if (document.checkout_payment.payment[i].value == "' . $this->code . '") {
     document.checkout_payment.payment[i].checked = true;
   }
 }
}//--></script>';
     $oc = 'onchange="' . $func_name . '"';

           if (MODULE_PAYMENT_CC_CVV2 == 'True') {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_CVV2,
                                                'field' => tep_draw_input_field('cc_cvv2', '', $oc) . ' <strong onclick="openexpwindow();">' . TEXT_EXPLANATION . '</strong>'),
                                                                                         array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     } else {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     }
     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['cc_number'], $HTTP_POST_VARS['cc_expires_month'], $HTTP_POST_VARS['cc_expires_year'], $HTTP_POST_VARS['cc_cvv2']);

     $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 -5:
         $error = TEXT_CCVAL_ERROR_INVALID_CVV2;
         break;
       case -6:
         $error = TEXT_CVV_ERROR_AMEX;
         break;
       case -7:
         $error = TEXT_CVV_ERROR_OTHER;
         break;
       case -8:
         $error = TEXT_CARD_NOT_ACCEPTED;
         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) . '&cc_owner=' . urlencode($HTTP_POST_VARS['cc_owner']) . '&cc_expires_month=' . $HTTP_POST_VARS['cc_expires_month'] . '&cc_expires_year=' . $HTTP_POST_VARS['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;
   }

   function confirmation() {
     global $HTTP_POST_VARS, $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 = (int)date('Y'); 
     for ($i=$today; $i < $today+10; $i++) {
       $expires_year[] = array('id' => substr((string)$i, -2), 'text' => (string)$i);
     }


     $oc = 'onchange="' . $func_name . '"';

                    if (MODULE_PAYMENT_CC_CVV2 == 'True') {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_CVV2,
                                                'field' => tep_draw_input_field('cc_cvv2', '', $oc) . ' <strong onclick="openexpwindow();">' . TEXT_EXPLANATION . '</strong>'),
                                                                                         array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     } else {
       $selection = array('id' => $this->code,
                          'module' => $this->title,
                          'fields' => array(array('title' => '',
                                                'field' => $func_def),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'], $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                'field' => tep_draw_input_field('cc_number', '', $oc)),
                                            array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month, '', $oc) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year, '', $oc))));
     }
     return $selection;
   }

   function process_button() {
     global $HTTP_POST_VARS;

     $process_button_string = tep_draw_hidden_field('cc_owner', $HTTP_POST_VARS['cc_owner']) .
                              tep_draw_hidden_field('cc_expires', $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year']) .
                              tep_draw_hidden_field('cc_type', $this->cc_card_type) .
                              tep_draw_hidden_field('cc_cvv2', $HTTP_POST_VARS['cc_cvv2']) .
                              tep_draw_hidden_field('cc_number', $this->cc_card_number);

     return $process_button_string;
   }

   function before_process() {
     global $HTTP_POST_VARS, $order;

     if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
       $len = strlen($HTTP_POST_VARS['cc_number']);

       $this->cc_middle = substr($HTTP_POST_VARS['cc_number'], 4, ($len-8));
       $order->info['cc_number'] = substr($HTTP_POST_VARS['cc_number'], 0, 4) . str_repeat('X', (strlen($HTTP_POST_VARS['cc_number']) - 8)) . substr($HTTP_POST_VARS['cc_number'], -4);
       $this->cc_cvv = $HTTP_POST_VARS['cc_cvv2'];
       $order->info['cc_cvv2'] = str_repeat('X', strlen($HTTP_POST_VARS['cc_cvv2']));
     }
   }

   function after_process() {
     global $insert_id;

     if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
       $message = 'Order #' . $insert_id . "\n\n" . 'Middle: ' . $this->cc_middle . "\n\n" . 'CVV: ' . $this->cc_cvv . "\n\n";

       tep_mail('', MODULE_PAYMENT_CC_EMAIL, 'Extra Order Info: #' . $insert_id, $message, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
     }
   }

   function get_error() {
     global $HTTP_GET_VARS;

     $error = array('title' => MODULE_PAYMENT_CC_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_CC_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 Credit Card Module', 'MODULE_PAYMENT_CC_STATUS', 'True', 'Do you want to accept credit card 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 ('Split Credit Card E-Mail Address', 'MODULE_PAYMENT_CC_EMAIL', '', 'If an e-mail address is entered, the middle digits of the credit card number will be sent to the e-mail address (the outside digits are stored in the database with the middle digits censored)', '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 ('Sort order of display.', 'MODULE_PAYMENT_CC_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_CC_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_CC_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, set_function, date_added) values ('Require CCV2', 'MODULE_PAYMENT_CC_CVV2', 'True', 'Require cvv2 numbers', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_PAYMENT_CC_STATUS', 'MODULE_PAYMENT_CC_EMAIL', 'MODULE_PAYMENT_CC_ZONE', 'MODULE_PAYMENT_CC_ORDER_STATUS_ID', 'MODULE_PAYMENT_CC_SORT_ORDER', 'MODULE_PAYMENT_CC_CVV2' );
   }
 }
?>

 

Steve

Link to comment
Share on other sites

Hi

 

open onepage_checkout.php in includes/classes.

 

find on line 1122:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

 

 

replace with:

     $sql_data_array = array(
       'customers_firstname'     => $onepage['billing']['firstname'],
       'customers_lastname'      => $onepage['billing']['lastname'],
       'customers_email_address' => $onepage['customer']['email_address'],
       'customers_telephone'     => $onepage['customer']['telephone'],
       'customers_fax'           => $onepage['customer']['fax'],
       'customers_newsletter'    => $onepage['customer']['newsletter'],
       'customers_status'        => '1',
       'customers_password'      => tep_encrypt_password($onepage['customer']['password'])
     );

 

This post has been edited by BenCox: 13 September 2010 - 12:37 PM

hi steve,

i have noticed the same problem

this update does not work and also when ordering without an account can not pass the additional fiels customer status = error page

do you have any other suggestion

valerif

Link to comment
Share on other sites

hi steve,

i have noticed the same problem

this update does not work and also when ordering without an account can not pass the additional fiels customer status = error page

do you have any other suggestion

valerif

Hi Valerif

 

I dont see if their demo does same thing if it does report it as a bug

 

Steve

Link to comment
Share on other sites

That did it! Thank you so much Steve, you're a life saver!

 

Firstly, everybody helping out on this topic and the forum in general deserve shiny gold stars and karma for helping out free of charge. This really is a golden example of open source in action. I am composing a sonnet dedicated to Steve in particular for being such a hero. :thumbsup:

 

I had a very similar problem that kalcable was experiencing with the CVV2 contribution and one page checkout. I have been keeping my eye on this topic now for about six months and decided two days ago to try it again (forced to switch web hosts due to recent PCI DSS compliance issues and new SSL certificates). Here was my procedure:

 

I installed the vanilla osC v2.2 RC2a. Over this I installed the ready made store red bubble (highly recommended contrib). I imported my SQL for products, categories, etc. Then I configured the store and customised the design and text elements. I added my shipping modules and all payment modules except CVV2, which I saved until last because I knew it would run into problems working with OPC. Backing up at every step of the way until I was ready to give OPC a go...

 

...All of the horrible old errors I encountered with OPC last time were gone but I was still left with a bizarre problem. When I tried to select my credit card payment method on the checkout page (paypal standard and cheque method worked fine) I received the popup box error: "There was an error setting payment method, please inform "storename" about this error." After clicking OK I was not presented with any credit card input boxes, but was allowed to press continue at the bottom. This would reload the checkout page, saving all of the input I typed. But in the course of reloading, this time the credit card fields were visible and I could enter the credit card details BUT ONLY AFTER PRESSING THE SAME POPUP BOX ERROR MESSAGE 5 TIMES (presumably one for each of the credit card fields for cc_owner, cc_number, cc_cvv2, cc_expires_month, cc_expires_year ??? ).

 

Pressing continue this time reloaded the page once more, again saving all of my input, but the popup box error only appeared once. Pressing OK just once this time had all of the input saved. Pressing continue at the bottom successfully captured the details, saved them to the database and I was shown the checkout success page - as if nothing wrong had happened! So the functionality was working but only after going through error messages. Hmm...

 

...All I needed to do to fix was to copy the code posted by steve in post #1948. All fixed! Thank you so so much.

 

Evidence for working OPC with CVV2 store can be seen at www.naturalflow.co.uk/catalog.

 

I was not able to reproduce the other bugs mentioned earlier in this topic (touch wood). Now all that remains for me to solve are broken "buy now" buttons (that link to dead 404 error pages throughout the store) and on the checkout page next to my CVV2 field where it says "What is this?" (should link to a popup info box " <strong onclick="openexpwindow();">' . TEXT_EXPLANATION . '</strong>) " but these are more related to contribs other than OPC methinks.

 

If I can be of any use to anyone who needs to know specifics of how I configured OPC and my other installed contribs I'd be happy to help if I can. Perhaps I stumbled upon a compatible method by chance. Perhaps my patience and care editing files paid off. But I recon a lot of it is down to the red bubble ready made store. It contains a lot of the other useful contribs inside it, and getting OPC to work with it seems less hassle than other people's stories on this topic.

 

All that remains is for me to get SSL back up and running when my host gets around to mailing my CSR. Hopefully installing SSL won't upset OPC at all... I can't see how it would. Do I speak too soon? Tune in next time for another exciting episode of Adventures in OPC!!! :P

 

Many thanks once again! I will be donating when the cherry is on top of the cake and the fat lady is singing.

Link to comment
Share on other sites

hi steve,

i have noticed the same problem

this update does not work and also when ordering without an account can not pass the additional fiels customer status = error page

do you have any other suggestion

valerif

 

steve,

 

i think the problem is related to the fact that the page does not refresh once put login name and password

for example if i refresh the page manually everything is fine

 

there if something to do with the java integration for this feature

 

i wonder if you could suggest a way to force page refresh once clicked "login"

 

this will sort out the problem temporary until is fixed

 

thanks

valeri

Link to comment
Share on other sites

steve,

 

i think the problem is related to the fact that the page does not refresh once put login name and password

for example if i refresh the page manually everything is fine

 

there if something to do with the java integration for this feature

 

i wonder if you could suggest a way to force page refresh once clicked "login"

 

this will sort out the problem temporary until is fixed

 

thanks

valeri

I'm no Java pro, but this seems to do the trick:

 

In checkout.php, find:

	if (updateTotals == true){
		       onePage.updateOrderTotals();
		  }

This is around line 453.

 

Add right after:

 

javascript:location.reload(true);

Link to comment
Share on other sites

I'm no Java pro, but this seems to do the trick:

 

In checkout.php, find:

	if (updateTotals == true){
		       onePage.updateOrderTotals();
		  }

This is around line 453.

 

Add right after:

 

javascript:location.reload(true);

thanks for the script steve,

it works as far as i can see

valerif

Link to comment
Share on other sites

Hello,

I have read all 98 pages but not found what I was looking for.(ore I missed it). I have two questions and hope that somebody can help me with them. (I'm a beginner in scripting). I’m using 1.2.

 

The first one:

I have two separate stores which use one database. Because using one database, all orders appear in the same order list without a name of the store. Now I want, for own use, to know which order came from which store. I figure that this is possible with a hidden field in the checkout.php from both stores, each with its own name. Of course this field have to be visible in the admin order list. But how can I do this?

 

The second one:

How can I remove a required field? (the country field)

 

Thanks a lot!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...