jalil Posted November 6, 2002 Posted November 6, 2002 Hi, The code is taken from the Revecom payment module file under /catalog/includes/modules/payment/revecom.php which was contributed by Ola Svensson. <?php /* $Id: revecom.php,v 1.0 2002/08/18 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License */ class revecom { var $code, $title, $description, $enabled; var $cc_number, $cc_expires_month, $cc_expires_year; // class constructor function revecom() { global $HTTP_POST_VARS; $this->code = 'revecom'; $this->title = MODULE_PAYMENT_REVECOM_TEXT_TITLE; $this->description = MODULE_PAYMENT_REVECOM_TEXT_DESCRIPTION; $this->enabled = MODULE_PAYMENT_REVECOM_STATUS; $this->cc_number = tep_db_prepare_input($HTTP_POST_VARS['revecom_cc_number']); $this->cc_expires_month = tep_db_prepare_input($HTTP_POST_VARS['revecom_cc_expires_month']); $this->cc_expires_year = tep_db_prepare_input($HTTP_POST_VARS['revecom_cc_expires_year']); } // class methods function javascript_validation() { $validation_string = 'if (payment_value == "' . $this->code . '") {' . "n" . ' var cc_number = document.payment.revecom_cc_number.value;' . "n" . ' if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "n" . ' error_message = error_message + "' . MODULE_PAYMENT_REVECOM_TEXT_JS_CC_NUMBER . '";' . "n" . ' error = 1;' . "n" . ' }' . "n" . '}' . "n"; return $validation_string; } function selection() { for ($i=1; $i < 13; $i++) { $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000))); } $today = getdate(); for ($i=$today['year']; $i < $today['year']+10; $i++) { $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i))); } $selection_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" . ' <tr>' . "n" . ' <td class="main"> ' . MODULE_PAYMENT_REVECOM_TEXT_CREDIT_CARD_NUMBER . ' </td>' . "n" . ' <td class="main"> ' . tep_draw_input_field('revecom_cc_number') . ' </td>' . "n" . ' </tr>' . "n" . ' <tr>' . "n" . ' <td class="main"> ' . MODULE_PAYMENT_REVECOM_TEXT_CREDIT_CARD_EXPIRES . ' </td>' . "n" . ' <td class="main"> ' . tep_draw_pull_down_menu('revecom_cc_expires_month', $expires_month, date('m')) . ' / ' . tep_draw_pull_down_menu('revecom_cc_expires_year', $expires_year) . '</td>' . "n" . ' </tr>' . "n" . '</table>' . "n"; return $selection_string; } function pre_confirmation_check() { include(DIR_WS_FUNCTIONS . 'ccval.php'); $cc_val = CCValidationSolution($this->cc_number); if ($cc_val == '1') { $cc_val = ValidateExpiry($this->cc_expires_month, $this->cc_expires_year); } if ($cc_val != '1') { $payment_error_return = 'payment_error=' . $this->code . '&cc_val=' . urlencode($cc_val); tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false)); } } function confirmation() { global $CardName, $CardNumber, $checkout_form_action; $confirmation_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" . ' <tr>' . "n" . ' <td class="main"> ' . MODULE_PAYMENT_REVECOM_TEXT_TYPE . ' ' . $CardName . ' </td>' . "n" . ' </tr>' . "n" . ' <tr>' . "n" . ' <td class="main"> ' . MODULE_PAYMENT_REVECOM_TEXT_CREDIT_CARD_NUMBER . ' ' . $CardNumber . ' </td>' . "n" . ' </tr>' . "n" . ' <tr>' . "n" . ' <td class="main"> ' . MODULE_PAYMENT_REVECOM_TEXT_CREDIT_CARD_EXPIRES . ' ' . strftime('%B/%Y', mktime(0,0,0,$this->cc_expires_month, 1, '20' . $this->cc_expires_year)) . ' </td>' . "n" . ' </tr>' . "n" . '</table>' . "n"; $checkout_form_action = 'https://secure.paysystems1.com/cgi-v310/payment/onlinesale-tpppro.asp'; return $confirmation_string; } function process_button() { global $HTTP_SERVER_VARS, $CardNumber, $order, $customer_id; for ($i=0; $i<sizeof($order->products); $i++) { if ($i==0) { $products_list = $products_list. "" .$order->products[$i]['name']; }else{ $products_list = $products_list. ", " .$order->products[$i]['name']; } } $process_button_string = tep_draw_hidden_field('product1',$products_list) . tep_draw_hidden_field('companyid', MODULE_PAYMENT_REVECOM_LOGIN) . tep_draw_hidden_field('formget','Y') . tep_draw_hidden_field('redirect',tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) . tep_draw_hidden_field('redirectfail',tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', false)) . tep_draw_hidden_field('reoccur','N') . tep_draw_hidden_field('cycle','') . tep_draw_hidden_field('totalperiod','') . tep_draw_hidden_field('repeatamount','') . tep_draw_hidden_field('total', number_format($order->info['total'], 2)) . tep_draw_hidden_field('b_firstname', $order->customer['firstname']) . tep_draw_hidden_field('b_middlename','') . tep_draw_hidden_field('b_lastname', $order->customer['lastname']) . tep_draw_hidden_field('b_address', $order->customer['street_address']) . tep_draw_hidden_field('b_city', $order->customer['city']) . tep_draw_hidden_field('b_state', $order->customer['state']) . tep_draw_hidden_field('b_zip', $order->customer['postcode']) . tep_draw_hidden_field('b_country',$order->customer['country']['iso_code_2']) . tep_draw_hidden_field('b_tel', $order->customer['telephone']) . tep_draw_hidden_field('email', $order->customer['email_address']) . tep_draw_hidden_field('s_firstname', $order->delivery['firstname']) . tep_draw_hidden_field('s_middlename','') . tep_draw_hidden_field('s_lastname', $order->delivery['lastname']) . tep_draw_hidden_field('s_address', $order->delivery['street_address']) . tep_draw_hidden_field('s_city', $order->delivery['city']) . tep_draw_hidden_field('s_state', $order->delivery['state']) . tep_draw_hidden_field('s_zip', $order->delivery['postcode']) . tep_draw_hidden_field('s_country', $order->delivery['country']['iso_code_2']) . tep_draw_hidden_field('s_tel','') . $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id()); return $process_button_string; } function before_process() { global $HTTP_GET_VARS; if ($HTTP_GET_VARS['cc_status'] != 'pass') { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_REVECOM_TEXT_ERROR_MESSAGE), 'SSL', true, false)); } } function after_process() { return false; } function output_error() { global $HTTP_GET_VARS; $output_error_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" . ' <tr>' . "n" . ' <td class="main"> <font color="#FF0000"><b>' . MODULE_PAYMENT_REVECOM_TEXT_ERROR . '</b></font><br> ' . stripslashes($HTTP_GET_VARS['cc_val']) . ' </td>' . "n" . ' </tr>' . "n" . '</table>' . "n"; return $output_error_string; } function check() { if (!isset($this->check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_STATUS'"); $this->check = tep_db_num_rows($check_query); } return $this->check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Allow revecom', 'MODULE_PAYMENT_REVECOM_STATUS', '1', 'Do you want to accept Revecom payments?', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Revecom Login', 'MODULE_PAYMENT_REVECOM_LOGIN', 'YOUR LOGIN ID', 'Login used for Revecom payments', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Revecom E-Mail Client', 'MODULE_PAYMENT_REVECOM_EMAIL', '0', 'Should Revecom e-mail the customer too? 0=NO, 1=YES', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Revecom E-Mail Merchant', 'MODULE_PAYMENT_REVECOM_EMAIL_MERCHANT', '1', 'Should Revecom e-mail you? 0=NO, 1=YES', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_STATUS'"); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_LOGIN'"); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_EMAIL'"); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_EMAIL_MERCHANT'"); } function keys() { $keys = array('MODULE_PAYMENT_REVECOM_STATUS', 'MODULE_PAYMENT_REVECOM_LOGIN', 'MODULE_PAYMENT_REVECOM_EMAIL', 'MODULE_PAYMENT_REVECOM_EMAIL_MERCHANT'); return $keys; } } ?> The mod above requires credit card info to be entered during the checkout confirmation. However, when at the payment page at Revecom, you still have to enter again your credit card info as I understand Revecom does not allow any credit info to be entered on our website. I would appreciate for those expert in PHP to give some guidance on how to modify the code above so that we do not need to enter any credit card info in our checkout page. Only the credit card info is not required, the rest such as customer and order details can still be intact. Thank you for any helps provided. Regards, Jalil Quote Please give your rating on OSCommerce at FreebiesCafe.com, a search directory for free scripts, software, services and resources.
jalil Posted November 6, 2002 Author Posted November 6, 2002 Hi, Sorry to post all this lengthy code since I need somebody to verify it before I get it tested on my website to achieve the above objective. Since I do not have any technical background, I would appreciate somebody expert in PHP programming to check the coding so that it works as intended. The purpose is to avoid the customer to enter their credit card info (if not they have to do it twice) in the checkout confirmation on our website and thus meet Revecom requirement. <?php /* $Id: revecom.php,v 1.0.1 2002/11/06 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Modified by Abdul Jalil Abdul Rahman based on sample.php Released under the GNU General Public License */ class revecom { var $code, $title, $description, $enabled; // !Class constructor function revecom() { global $HTTP_POST_VARS; $this->code = 'revecom'; $this->title = MODULE_PAYMENT_REVECOM_TEXT_TITLE; $this->description = MODULE_PAYMENT_REVECOM_TEXT_DESCRIPTION; $this->enabled = MODULE_PAYMENT_REVECOM_STATUS; } function javascript_validation() { return false; } function selection() { return false; } function pre_confirmation_check() { return false; } function confirmation() { global $CardName, $checkout_form_action; $confirmation_string = '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "n" . ' <tr>' . "n" . ' <td class="main"> ' . MODULE_PAYMENT_REVECOM_TEXT_TYPE . ' ' . $CardName . ' </td>' . "n" . ' </tr>' . "n" . '</table>' . "n"; $checkout_form_action = 'https://secure.paysystems1.com/cgi-v310/payment/onlinesale-tpppro.asp'; return $confirmation_string; } function process_button() { global $HTTP_SERVER_VARS, $order, $customer_id; for ($i=0; $i<sizeof($order->products); $i++) { if ($i==0) { $products_list = $products_list. "" .$order->products[$i]['name']; }else{ $products_list = $products_list. ", " .$order->products[$i]['name']; } } $process_button_string = tep_draw_hidden_field('product1',$products_list) . tep_draw_hidden_field('companyid', MODULE_PAYMENT_REVECOM_LOGIN) . tep_draw_hidden_field('formget','Y') . tep_draw_hidden_field('redirect',tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) . tep_draw_hidden_field('redirectfail',tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', false)) . tep_draw_hidden_field('reoccur','N') . tep_draw_hidden_field('cycle','') . tep_draw_hidden_field('totalperiod','') . tep_draw_hidden_field('repeatamount','') . tep_draw_hidden_field('total', number_format($order->info['total'], 2)) . tep_draw_hidden_field('b_firstname', $order->customer['firstname']) . tep_draw_hidden_field('b_middlename','') . tep_draw_hidden_field('b_lastname', $order->customer['lastname']) . tep_draw_hidden_field('b_address', $order->customer['street_address']) . tep_draw_hidden_field('b_city', $order->customer['city']) . tep_draw_hidden_field('b_state', $order->customer['state']) . tep_draw_hidden_field('b_zip', $order->customer['postcode']) . tep_draw_hidden_field('b_country',$order->customer['country']['iso_code_2']) . tep_draw_hidden_field('b_tel', $order->customer['telephone']) . tep_draw_hidden_field('email', $order->customer['email_address']) . tep_draw_hidden_field('s_firstname', $order->delivery['firstname']) . tep_draw_hidden_field('s_middlename','') . tep_draw_hidden_field('s_lastname', $order->delivery['lastname']) . tep_draw_hidden_field('s_address', $order->delivery['street_address']) . tep_draw_hidden_field('s_city', $order->delivery['city']) . tep_draw_hidden_field('s_state', $order->delivery['state']) . tep_draw_hidden_field('s_zip', $order->delivery['postcode']) . tep_draw_hidden_field('s_country', $order->delivery['country']['iso_code_2']) . tep_draw_hidden_field('s_tel','') . $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id()); return $process_button_string; } function before_process() { return false; } function after_process() { return false; } function output_error() { return false; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Allow revecom', 'MODULE_PAYMENT_REVECOM_STATUS', '1', 'Do you want to accept Revecom payments?', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Revecom Login', 'MODULE_PAYMENT_REVECOM_LOGIN', 'MERCHANT ID', 'Login used for Revecom payments', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Revecom E-Mail Client', 'MODULE_PAYMENT_REVECOM_EMAIL', '0', 'Should Revecom e-mail the customer too? 0=NO, 1=YES', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Revecom E-Mail Merchant', 'MODULE_PAYMENT_REVECOM_EMAIL_MERCHANT', '1', 'Should Revecom e-mail you? 0=NO, 1=YES', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_STATUS'"); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_LOGIN'"); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_EMAIL'"); tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_REVECOM_EMAIL_MERCHANT'"); } function keys() { $keys = array('MODULE_PAYMENT_REVECOM_STATUS', 'MODULE_PAYMENT_REVECOM_LOGIN', 'MODULE_PAYMENT_REVECOM_EMAIL', 'MODULE_PAYMENT_REVECOM_EMAIL_MERCHANT'); return $keys; } } ?> Any helps appreciated, thank you. Regards, Jalil Quote Please give your rating on OSCommerce at FreebiesCafe.com, a search directory for free scripts, software, services and resources.
nyckeln Posted November 7, 2002 Posted November 7, 2002 Hi! Take a look here.. http://www.oscommerce.com/downloads.php/co...ions,638/type,1 Please let me know if it works.. Regards, Patrick Andersson Quote
nyckeln Posted November 7, 2002 Posted November 7, 2002 Oooops.. Forgott.. PaySystems offer 4 currencies.. At row 70 in /modules/payment/revecom.php $currencies->currencies['EUR'] Change EUR to the currency you want.. Regards, Patrick Andersson Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.