Jump to content

joker2040

Members
  • Content count

    3
  • Joined

  • Last visited

Profile Information

  • Real Name
    Mike Johnson
  1. joker2040

    veloct - capture transaction id

    So I have the veloct payment module integrated and working. I would like to however capture the transaction id that is returned and store it somewhere in the database. I've seen posts with it being done for worldpay but I'm not sure how to accomplish it within the veloct.php file. Below is the veloct.php file I'm using: <?php /* $Id: VELOCT.php,v 1.00 2004/08/24 10:32:00 mpoole Exp $ Direct Mode VELOCT osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2004 FastTransact (www.fasttransact.com) Released under the GNU General Public License */ class VELOCT { var $code, $title, $description, $enabled; // class constructor function VELOCT() { global $order; $this->code = 'VELOCT'; $this->title = MODULE_PAYMENT_VELOCT_TEXT_TITLE; $this->description = MODULE_PAYMENT_VELOCT_TEXT_DESCRIPTION; $this->enabled = ((MODULE_PAYMENT_VELOCT_STATUS == 'True') ? true : false); $this->sort_order = MODULE_PAYMENT_VELOCT_SORT_ORDER; $this->error = ''; if ((int)MODULE_PAYMENT_VELOCT_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_VELOCT_ORDER_STATUS_ID; } $this->form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false); } // class methods function javascript_validation() { $js = ' if (payment_value == "' . $this->code . '") {' . "\n" . ' var cc_owner = document.checkout_payment.VELOCT_cc_owner.value;' . "\n" . ' var cc_number = document.checkout_payment.VELOCT_cc_number.value;' . "\n" . ' if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" . ' error_message = error_message + "' . MODULE_PAYMENT_VELOCT_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_VELOCT_TEXT_JS_CC_NUMBER . '";' . "\n" . ' error = 1;' . "\n" . ' }' . "\n" . ' }' . "\n"; return $js; } function selection() { global $order; for ($i=1; $i<13; $i++) { $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000))); } $today = getdate(); for ($i=$today['year']; $i < $today['year']+10; $i++) { $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i))); } if(MODULE_PAYMENT_VELOCT_CVV2_REQUIRED == 'True') { $selection = array('id' => $this->code, 'module' => $this->title, 'fields' => array(array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_OWNER, 'field' => tep_draw_input_field('VELOCT_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])), array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_NUMBER, 'field' => tep_draw_input_field('VELOCT_cc_number')), array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_CVV, 'field' => tep_draw_input_field('VELOCT_cc_cvv', '', 'size="4"')), array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_EXPIRES, 'field' => tep_draw_pull_down_menu('VELOCT_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('VELOCT_cc_expires_year', $expires_year)))); } else { $selection = array('id' => $this->code, 'module' => $this->title, 'fields' => array(array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_OWNER, 'field' => tep_draw_input_field('VELOCT_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])), array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_NUMBER, 'field' => tep_draw_input_field('VELOCT_cc_number')), array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_EXPIRES, 'field' => tep_draw_pull_down_menu('VELOCT_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('VELOCT_cc_expires_year', $expires_year)))); } return $selection; } function pre_confirmation_check() { global $HTTP_POST_VARS, $cc_array; include(DIR_WS_CLASSES . 'cc_validation.php'); $cc_validation = new cc_validation(); $result = $cc_validation->validate($HTTP_POST_VARS['VELOCT_cc_number'], $HTTP_POST_VARS['VELOCT_cc_expires_month'], $HTTP_POST_VARS['VELOCT_cc_expires_year']); $error = ''; switch ($result) { case -1: $error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4)); break; case -2: case -3: case -4: $error = TEXT_CCVAL_ERROR_INVALID_DATE; break; case false: $error = TEXT_CCVAL_ERROR_INVALID_NUMBER; break; } if ( ($result == false) || ($result < 1) ) { $payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&VELOCT_cc_owner=' . urlencode($HTTP_POST_VARS['VELOCT_cc_owner']) . '&VELOCT_cc_expires_month=' . $HTTP_POST_VARS['VELOCT_cc_expires_month'] . '&VELOCT_cc_expires_year=' . $HTTP_POST_VARS['VELOCT_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; if(MODULE_PAYMENT_VELOCT_CVV2_REQUIRED == 'True') { $this->cc_cvv = $HTTP_POST_VARS['VELOCT_cc_cvv']; } else { $this->cc_cvv = ''; } tep_session_register('cc_array'); $cc_array = array('card_type' => $this->cc_card_type, 'card_number' => $this->cc_card_number, 'card_code' => $this->cc_cvv, 'expiration' => $this->cc_expiry_month . substr($this->cc_expiry_year, -2)); } function confirmation() { global $HTTP_POST_VARS; $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type, 'fields' => array(array('title' => MODULE_PAYMENT_VELOCT_TEXT_CREDIT_CARD_OWNER, 'field' => $HTTP_POST_VARS['VELOCT_cc_owner']), array('title' => MODULE_PAYMENT_VELOCT_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_VELOCT_TEXT_CREDIT_CARD_EXPIRES, 'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['VELOCT_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['VELOCT_cc_expires_year']))))); return $confirmation; } function process_button() { $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id()); return $process_button_string; } function before_process() { global $customer_id, $order, $HTTP_POST_VARS, $HTTP_SERVER_VARS, $cc_array; $form_data = array( 'pay_type' => 'C', 'tran_type' => 'A', 'account_id' => MODULE_PAYMENT_VELOCT_ACCOUNT_ID, 'card_number' => $cc_array['card_number'], 'card_expire' => $cc_array['expiration'], 'amount' => number_format($order->info['total'], 2), 'card_cvv2' => $cc_array['card_code'], 'bill_name1' => $order->billing['firstname'], 'bill_name2' => $order->billing['lastname'], 'bill_street' => $order->billing['street_address'], 'bill_city' => $order->billing['city'], 'bill_state' => $order->billing['state'], 'bill_zip' => $order->billing['postcode'], 'bill_country' => $order->billing['country']['title']); // concatenate order information variables to $data while(list($key, $value) = each($form_data)) { $data .= $key . '=' . urlencode(ereg_replace(',', '', $value)) . '&'; } // take the last & out for the string $data = substr($data, 0, -1); // Post order info data to VELOCT, make sure you have curl installed // BEGIN PHP_CURL.DLL CODE - Author: Peter Drake - 4/29/03 // Use for Win32 or Unix-type systems with php-curl.dll // Get a CURL handle $curl_handle = curl_init(); // Tell CURL the URL of the CGI curl_setopt($curl_handle, CURLOPT_URL, "https://secure.fasttransact.com:1402/gw/sas/direct3.0"); // This section sets various options. See http://www.php.net/manual/en/function.curl-setopt.php // for more details curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 0); // Perform the POST and get the data returned by the server. $response = curl_exec ($curl_handle) or die ("There has been an error connecting to VELOCT."); // Close the CURL handle curl_close ($curl_handle); //END PUP_CURL.DLL CODE $response_vars = explode('&', $response); foreach ($response_vars as $pairvalue) { $value = explode('=', $pairvalue); if($value[0] == 'status_code') { $status_code = $value[1]; } if($value[0] == 'trans_id') { $trans_id = $value[1]; } if($value[0] == 'auth_code') { $auth_code = $value[1]; } if($value[0] == 'auth_date') { $auth_date = $value[1]; } if($value[0] == 'auth_msg') { $auth_msg = $value[1]; } if($value[0] == 'avs_code') { $avs_code = $value[1]; } if($value[0] == 'cvv2_code') { $cvv2_code = $value[1]; } } if ($status_code == '0' || $status_code == 'F' || $status_code == '') { $this->error = array('title' => ' VELOCT error message: ', 'error' => $auth_msg); tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_VELOCT_TEXT_ERROR_MESSAGE . implode(': ', $this->error)), 'SSL', true, false)); } else { if (!tep_session_is_registered('cc_transaction_id')) { tep_session_register('cc_transaction_id'); } global $cc_transaction_id; $cc_transaction_id = $trans_id; } } function after_process() { tep_session_unregister('cc_array'); return false; } function get_error() { global $HTTP_GET_VARS; $error = array('title' => MODULE_PAYMENT_VELOCT_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_VELOCT_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 VELOCTModule', 'MODULE_PAYMENT_VELOCT_STATUS', 'True', 'Do you want to accept VELOCTpayments?', '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 ('account_id', 'MODULE_PAYMENT_VELOCT_ACCOUNT_ID', '', 'The Account ID used for the VELOCTservice', '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 ('Enable CVV2', 'MODULE_PAYMENT_VELOCT_CVV2_REQUIRED', 'True', 'Do you want to allow the CVV2 number to be entered?', '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_VELOCT_STATUS', 'MODULE_PAYMENT_VELOCT_ACCOUNT_ID', 'MODULE_PAYMENT_VELOCT_CVV2_REQUIRED'); } } ?>
  2. joker2040

    Fancier Invoice & Packingslip v1.0

    My invoice that is being sent to the customer and the one in the admin is missing the Shipping Total. I've read through most of this thread to find that others are having the issue but I have yet to find a solution. The total of the order is correct with the shipping added but it isn't broken down.
×