osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

Getting error when using credit card module

This is a discussion on Getting error when using credit card module within the osCMax v2 Customization/Mods forums, part of the osCMax v2.0 Forums category; Using version2 and have installed a credit card module for transaction central. Contrib is here: http://www.oscommerce.com/community/...action+central It comes up with ...


Go Back   osCommerce and osCMax shopping cart software forums > osCMax v2.0 Forums > osCMax v2 Customization/Mods

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 06-14-2006, 03:54 PM
Active Member
 
Join Date: May 2003
Posts: 137
Thanks: 3
Thanked 1 Time in 1 Post
Rep Power: 0
countingsheep
Default Getting error when using credit card module

Using version2 and have installed a credit card module for transaction central.
Contrib is here:
http://www.oscommerce.com/community/...action+central

It comes up with an error when trying to checkout saying that
" The first four digits of the number entered are: <br>If that number is correct, we do not accept that type of credit card.<br>If it is wrong, please try again."

If someone can help me with this, please let me know what the charge would be to get it to work with oscmax.


Code:
<?php
/*
  $Id: aa_trancentral.php,v 2.2.1 2005/03/06 
  based on pm_2checkout.php,v 1.19 2003/01/29 19:57:15
  
  Developed by Dave Ferrise (dave@ferrisedesign.com) specifically for
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  http://www.ferrisedesign.com
  
  Modified by Maribeth C. Snow (maribeth@onee-net.com) specifically for
  osCommerce, Open Source E-Commerce Solutions (06/29/2005)
  http://www.oscommerce.com


  Copyright (c) 2003 osCommerce
  Copyright (c) 2005 Ferrise Consulting & Design

  Released under the GNU General Public License

  *** RELEASE NOTES ***
  
  * Added CVV2 field for added security
  * Changed "Credit Card" to "Online Credit Card" to avoid confusion with osc delivered offline credit card module
  * Changed default Merchant# to 10011 (test account)
  
  * Changed form_action_url to reference processCC.asp

  *** NOTE ***
  
  This code draws HEAVILY from the pm_2checkout code.  I have modified to work with the
  Transaction Central gateway from Merchant Anywhere.  For testing purpose
  set the merchant account number to 10011 in the admin - no credit card will be charged
  that way.
  
  *** IMPORTANT ***
  
  In order for this module to work you will need an account with Payment Resources International (http://www.paymentresource.com/)
  
  *** INSTALLATION ***
  
  * Place this file in catalog/includes/modules/payment
  * If you already have the older version installed delete the file trancentral.php from your catalog/includes/modules/payment and catalog/includes/languages/whatever/modules/payment folders

*/

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

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

      $this->code = 'aa_trancentral';
      $this->title = MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_TITLE;
      $this->description = MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_AA_TRANCENTRAL_SORT_ORDER;
      $this->enabled = ((MODULE_PAYMENT_AA_TRANCENTRAL_STATUS == 'True') ? true : false);

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

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

// old value      $this->form_action_url = 'https://webservices.primerchants.com/billing/TransactionCentral/processcreditcard.asp?';
      $this->form_action_url = 'https://webservices.primerchants.com/billing/TransactionCentral/processCC.asp?';
 }

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

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AA_TRANCENTRAL_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_AA_TRANCENTRAL_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->billing['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
    }

    function javascript_validation() {
      $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
            '    var cc_number = document.checkout_payment.AA_TRANCENTRAL_cc_number.value;' . "\n" .
            '    if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .
            '      error_message = error_message + "' . MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_JS_CC_NUMBER . '";' . "\n" .
            '      error = 1;' . "\n" .
            '    }' . "\n" .
            '    var cvv2_number = document.checkout_payment.AA_TRANCENTRAL_cvv2.value;' . "\n" .
            '    if (cvv2_number == "" || cvv2_number.length < ' . 3 . ') {' . "\n" .
            '      error_message = error_message + "' . MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_JS_CVV2_NUMBER . '";' . "\n" .
            '      error = 1;' . "\n" .
            '    }' . "\n" .
           '  }' . "\n";

      return $js;
    }


    function selection() {
      global $order;
      include "../retail/includes/functions/NewWindow.js";
      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_AA_TRANCENTRAL_TEXT_CREDIT_CARD_OWNER_FIRST_NAME,
                                                 'field' => tep_draw_input_field('AA_TRANCENTRAL_cc_owner_firstname', $order->billing['firstname'])),
                                           array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_CREDIT_CARD_OWNER_LAST_NAME,
                                                 'field' => tep_draw_input_field('AA_TRANCENTRAL_cc_owner_lastname', $order->billing['lastname'])),
                                           array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_CREDIT_CARD_NUMBER,
                                                 'field' => tep_draw_input_field('AA_TRANCENTRAL_cc_number')),
										   array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_CREDIT_CARD_CVV2,             
                                                 'field' => tep_draw_input_field('AA_TRANCENTRAL_cvv2','','size="4" maxlength="4"') . '  <small><a href="javascript:PopUpWindow(\'' . tep_href_link(FILENAME_POPUP_CVS_HELP) . '\');">' . MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_SEARCH_CVS_HELP . '</a></small>'),
                                           array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_CREDIT_CARD_EXPIRES,
                                                 'field' => tep_draw_pull_down_menu('AA_TRANCENTRAL_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('AA_TRANCENTRAL_cc_expires_year', $expires_year)),
                                           array('title' => '',
                                                 'field' => tep_image('images/ccards2.jpg', 'VISA, M/C and AMEX', '123', '25'))));

      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_checkcode'], $HTTP_POST_VARS['cc_card_type']); 
  


      $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) . '&AA_TRANCENTRAL_cc_owner_firstname=' . urlencode($HTTP_POST_VARS['AA_TRANCENTRAL_cc_owner_firstname']) . '&AA_TRANCENTRAL_cc_owner_lastname=' . urlencode($HTTP_POST_VARS['AA_TRANCENTRAL_cc_owner_lastname']) . '&AA_TRANCENTRAL_cc_expires_month=' . $HTTP_POST_VARS['AA_TRANCENTRAL_cc_expires_month'] . '&AA_TRANCENTRAL_cc_expires_year=' . $HTTP_POST_VARS['AA_TRANCENTRAL_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;
	  $this->cc_cvv2 = $HTTP_POST_VARS['AA_TRANCENTRAL_cvv2'];
    }

    function confirmation() {
      global $HTTP_POST_VARS;

      $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
                            'fields' => array(array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_CREDIT_CARD_OWNER,
                                                    'field' => $HTTP_POST_VARS['AA_TRANCENTRAL_cc_owner_firstname'] . ' ' . $HTTP_POST_VARS['AA_TRANCENTRAL_cc_owner_lastname']),
                                              array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_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_AA_TRANCENTRAL_TEXT_CREDIT_CARD_CVV2,
                                                    'field' => $HTTP_POST_VARS['AA_TRANCENTRAL_cvv2']),
                                              array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_CREDIT_CARD_EXPIRES,
                                                    'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['AA_TRANCENTRAL_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['AA_TRANCENTRAL_cc_expires_year'])))));

      return $confirmation;
    }

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

      $process_button_string = tep_draw_hidden_field('MerchantID', MODULE_PAYMENT_AA_TRANCENTRAL_LOGIN) .
                               tep_draw_hidden_field('RegKey', MODULE_PAYMENT_AA_TRANCENTRAL_REGKEY) .
                               tep_draw_hidden_field('Amount', number_format($order->info['total'], 2)) .
                               tep_draw_hidden_field('REFID', date('YmdHis')) .
                               tep_draw_hidden_field('AccountNo', $this->cc_card_number) .
                               tep_draw_hidden_field('CVV2', $this->cc_cvv2) .
                               tep_draw_hidden_field('CCMonth', $this->cc_expiry_month) .
                               tep_draw_hidden_field('CCYear', $this->cc_expiry_year) .
                               tep_draw_hidden_field('NameonAccount', $HTTP_POST_VARS['AA_TRANCENTRAL_cc_owner_firstname'] . " " . $HTTP_POST_VARS['AA_TRANCENTRAL_cc_owner_lastname']) .
                               tep_draw_hidden_field('AVSADDR', $order->customer['street_address']) .
                               tep_draw_hidden_field('AVSZIP', $order->customer['postcode']) .
                               tep_draw_hidden_field('CCRURL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'));

      return $process_button_string;
    }

      function before_process() {
      global $HTTP_POST_VARS, $tranID;
      if (($HTTP_POST_VARS['TransID'] != '')||($HTTP_POST_VARS['TransID'] != 0)){ 
        if (($HTTP_POST_VARS['Auth'] == 'Declined')||($HTTP_POST_VARS['Auth'] == '')) {
           tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_ERROR_MESSAGE), 'SSL', true, false));
        } else {
	   	$tranID = $HTTP_POST_VARS['TransID'];
	    }
	  }
	  else {
	   	tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_AA_TRANCENTRAL_TEXT_ERROR_MESSAGE), 'SSL', true, false));
	  }
    }

    function after_process() {
      return false;
    }

    function get_error() {
      global $HTTP_GET_VARS;

      $error = array('title' => MODULE_PAYMENT_AA_TRANCENTRAL_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_AA_TRANCENTRAL_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 Payment Resources Module Call JP at 888.729.3539 x155', 'MODULE_PAYMENT_AA_TRANCENTRAL_STATUS', 'True', 'Do you want to accept Payment Resources/Transaction Central 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/Store Number', 'MODULE_PAYMENT_AA_TRANCENTRAL_LOGIN', '10011', 'Login/Store Number used for the Payment Resources service. Call JP at 888.729.3539 x155 for setup.', '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 ('RegKey Number', 'MODULE_PAYMENT_AA_TRANCENTRAL_REGKEY', 'KK48NPYEJHMAH6DK', 'Payment Resource Security number', '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_AA_TRANCENTRAL_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_AA_TRANCENTRAL_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_AA_TRANCENTRAL_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
    }

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

    function keys() {
      return array('MODULE_PAYMENT_AA_TRANCENTRAL_STATUS', 'MODULE_PAYMENT_AA_TRANCENTRAL_LOGIN', 'MODULE_PAYMENT_AA_TRANCENTRAL_REGKEY', 'MODULE_PAYMENT_AA_TRANCENTRAL_ZONE', 'MODULE_PAYMENT_AA_TRANCENTRAL_ORDER_STATUS_ID', 'MODULE_PAYMENT_AA_TRANCENTRAL_SORT_ORDER');
    }
  }
  
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Credit card module clauska osCMax v2 Customization/Mods 0 06-15-2006 06:42 AM
modifing credit card module jschafer52 osCMax v2 Customization/Mods 4 02-08-2006 04:12 PM
Credit card - payment module msadriano osCommerce 2.2 Discussion 0 12-26-2005 03:02 AM
Installation of new credit card module mshaffer osCommerce 2.2 Modification Help 0 02-06-2004 08:35 AM
Credit Card Processing module JeremyTaye osCommerce 2.2 Modification Help 1 11-03-2003 12:34 PM


All times are GMT -8. The time now is 11:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax