Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted (edited)

Parse error: parse error, unexpected T_VARIABLE, expecting T_FUNCTION in C:\Inetpub\vhosts\kingunderground.com\httpdocs\catalog\includes\modules\payment\protx_form.php on line 18

 

 

<?php

/*

$Id$

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2004 osCommerce

 

Released under the GNU General Public License

*/

 

class protx_form {

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

 

 

// class constructor

function protx_form() {

$this->code = 'protx_form';

$this->title = MODULE_PAYMENT_PROTX_FORM_TEXT_TITLE;

$this->description = MODULE_PAYMENT_PROTX_FORM_TEXT_DESCRIPTION;

$this->sort_order = MODULE_PAYMENT_PROTX_FORM_SORT_ORDER;

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

 

if ((int)MODULE_PAYMENT_PROTX_FORM_ORDER_STATUS_ID > 0) {

$this->order_status = MODULE_PAYMENT_PROTX_FORM_ORDER_STATUS_ID;

}

 

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

 

if (MODULE_PAYMENT_PROTX_FORM_TEST_STATUS == 'true') {

$this->form_action_url = 'https://ukvpstest.protx.com/vps2form/submit.asp';

//$this->form_action_url = 'https://ukvpstest.protx.com/showpost/showpost.asp';

//$this->form_action_url = 'https://ukvpstest.protx.com/VSPSimulator/VSPFormGateway.asp';

//$this->form_action_url = '../../decrypt_protx.php';

} else {

$this->form_action_url = 'https://ukvps.protx.com/vps2form/submit.asp';

}

}

 

// class methods

function update_status() {

global $order;

 

if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PROTX_FORM_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_PROTX_FORM_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 simpleXor($InString, $Key) {

$KeyList = array();

$output = "";

 

for($i = 0; $i < strlen($Key); $i++){

$KeyList[$i] = ord(substr($Key, $i, 1));

}

 

for($i = 0; $i < strlen($InString); $i++) {

$output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)]));

}

 

return $output;

}

 

function getToken($thisString) {

 

$Tokens = array("Status","StatusDetail","VendorTxCode","VPSTxID","TxAuthNo","Amount","AVSCV2");

 

$output = array();

$resultArray = array();

 

for ($i = count($Tokens)-1; $i >= 0 ; $i--){

$start = strpos($thisString, $Tokens[$i]);

if ($start !== false){

$resultArray[$i]->start = $start;

$resultArray[$i]->token = $Tokens[$i];

}

}

 

sort($resultArray);

 

for ($i = 0; $i<count($resultArray); $i++){

$valueStart = $resultArray[$i]->start + strlen($resultArray[$i]->token) + 1;

if ($i==(count($resultArray)-1)) {

$output[$resultArray[$i]->token] = substr($thisString, $valueStart);

} else {

$valueLength = $resultArray[$i+1]->start - $resultArray[$i]->start - strlen($resultArray[$i]->token) - 2;

$output[$resultArray[$i]->token] = substr($thisString, $valueStart, $valueLength);

}

}

 

return $output;

}

 

function selection() {

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

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

}

 

function pre_confirmation_check() {

return false;

}

 

function confirmation() {

return false;

}

 

function process_button() {

global $order, $currencies, $currency;

 

switch (MODULE_PAYMENT_PROTX_FORM_CURRENCY) {

case 'Default Currency':

$protx_currency = DEFAULT_CURRENCY;

break;

case 'Any Currency':

default:

$protx_currency = $currency;

break;

}

 

$plain = "VendorTxCode=" . date('Ymdhis') . "&";

$plain .= "Amount=" . number_format($order->info['total'] * $currencies->get_value($protx_currency), $currencies->get_decimal_places($protx_currency)) . "&";

$plain .= "Currency=" . $protx_currency . "&";

$plain .= "Description='" . STORE_NAME . "'&";

$plain .= "SuccessURL=" . tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true) . "&";

$plain .= "FailureURL=" . tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true) . "&";

$plain .= "CustomerName=" . $order->billing['firstname'] . ' ' . $order->billing['lastname'] . "&";

$plain .= "CustomerEmail=" . $order->customer['email_address'] . "&";

$plain .= "VendorEMail=" . STORE_OWNER_EMAIL_ADDRESS . "&";

 

$delivery_address = $order->delivery['street_address'];

if (ACCOUNT_SUBURB == 'true') {

$delivery_address .= ',' . $order->delivery['suburb'];

}

 

$delivery_address .= ',' . $order->delivery['city'];

 

if (ACCOUNT_STATE == 'true') {

$delivery_address .= ',' . $order->delivery['state'];

}

 

$delivery_address .= ',' . $order->delivery['country']['title'];

 

$billing_address = $order->billing['street_address'];

 

if (ACCOUNT_SUBURB == 'true') {

$billing_address .= ',' . $order->billing['suburb'];

}

 

$billing_address .= ',' . $order->billing['city'];

 

if (ACCOUNT_STATE == 'true') {

$billing_address .= ',' . $order->billing['state'];

}

 

$billing_address .= ',' . $order->billing['country']['title'];

 

$plain .= "DeliveryAddress=" . $delivery_address . "&";

$plain .= "DeliveryPostCode=" . $order->delivery['postcode'] . "&";

$plain .= "BillingAddress=" . $billing_address . "&";

$plain .= "BillingPostCode=" . $order->billing['postcode'] . "";

 

//added by Mike Jackson*************************************************************************

*********************************************************************************

if (MODULE_PAYMENT_PROTX_FORM_SHOPCART == 'true') {

$plain .= "&"; //get ready to add more data to the query string

// now add the shopping cart to the string so it gets sent to PROTX

global $cart, $order;

$Shipping = $order->info['shipping_cost'];

$Shipping = number_format($Shipping, 2, '.', '');

$products = $cart->get_products();

$No_lines = sizeof($products);

$No_lines = $No_lines + 1; // Don't forget the shipping as an item!

$cart_string = "Basket=".$No_lines;

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

$Description = $products[$i]['name'];

$Description = str_replace(":", "", $Description); // added v1.09 MJ - Make sure that there are no colons (:) since we are producing a colon delimited list

$Qty = $products[$i]['quantity'];

$Price = $products[$i]['price'] + $cart->attributes_price($products[$i]['id']);

$Tax = $Price/100 * tep_get_tax_rate($products[$i]['tax_class_id']);

$Tax = number_format($Tax, 2, '.', '');

$final_price = $Price + $Tax;

$final_price = number_format($final_price, 2, '.', '');

$Line_Total = $Qty * $final_price;

$Line_Total = number_format($Line_Total, 2, '.', '');

$cart_string .= ":".$Description.":".$Qty.":".$Price.":".$Tax.":".$final_price.":".$Line_Total;

}

$cart_string .= ":Shipping:1:".$Shipping.":----:".$Shipping.":".$Shipping;

 

//added v1.09 MJ - remove any newlines and carrige returns - PROTX protocol does not allow these in the shopping basket.

$cart_string = str_replace("\n", "", $cart_string);

$cart_string = str_replace("\r", "", $cart_string);

 

$plain .= $cart_string;

 

}

 

// end added by Mike Jackson*************************************************************************

************************************************************************

 

$crypt = base64_encode($this->SimpleXor($plain, MODULE_PAYMENT_PROTX_FORM_PASSWORD));

 

//// PA Evers Added for Pre-Authorisation selection

if (MODULE_PAYMENT_PROTX_FORM_PREAUTH == 'true') {

$transaction_type = 'PREAUTH';

} else {

$transaction_type = 'PAYMENT';

}

//// EOF: PA Evers Added for Pre-Authorisation selection

 

$process_button_string = tep_draw_hidden_field('VPSProtocol', '2.22') .

// tep_draw_hidden_field('TxType', 'PAYMENT') . // CHANGED FOR PRE-AUTH BELOW

tep_draw_hidden_field('TxType', $transaction_type) .

tep_draw_hidden_field('Vendor', MODULE_PAYMENT_PROTX_FORM_VENDOR_NAME) .

tep_draw_hidden_field('Crypt', $crypt);

 

return $process_button_string;

}

 

 

 

 

 

 

 

 

 

 

function before_process() {

global $HTTP_POST_VARS, $crypt;

 

$crypt = $_REQUEST['crypt'];

$process_button_string = str_replace(" ", "+", $process_button_string);

$Decoded = $this->SimpleXor(base64_decode(str_replace (" ", "+", $crypt)),MODULE_PAYMENT_PROTX_FORM_PASSWORD);

$values = $this->getToken($Decoded);

 

$Status = $values['Status'];

$StatusDetail = $values['StatusDetail'];

 

if ($Status != 'OK') {

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&error_message=' . urlencode($StatusDetail), 'SSL', false, false));

}

}

 

function after_process() {

return false;

}

 

function get_error() {

global $HTTP_GET_VARS;

 

if (isset($HTTP_GET_VARS['message']) && (strlen($HTTP_GET_VARS['message']) > 0)) {

$error = stripslashes(urldecode($HTTP_GET_VARS['message']));

} else {

$error = MODULE_PAYMENT_PROTX_FORM_TEXT_ERROR_MESSAGE;

}

 

return array('title' => MODULE_PAYMENT_PROTX_FORM_TEXT_ERROR,

'error' => $error);

}

 

function check() {

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

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PROTX_FORM_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 Protx Form Module', 'MODULE_PAYMENT_PROTX_FORM_STATUS', 'True', 'Do you want to accept Protx Form payments?', '6', '1', '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 ('Merchant ID', 'MODULE_PAYMENT_PROTX_FORM_VENDOR_NAME', 'TestVendor', 'Vendor Name to use with the Protx Form service', '6', '2', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Password', 'MODULE_PAYMENT_PROTX_FORM_PASSWORD', 'testvendor', 'Password to use with the Protx Form service', '6', '2', 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 Currency', 'MODULE_PAYMENT_PROTX_FORM_CURRENCY', 'Any Currency', 'The currency to use for credit card transactions', '6', '3', 'tep_cfg_select_option(array(\'Any Currency\', \'Default Currency\'), ', 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_PROTX_FORM_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_PROTX_FORM_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_PROTX_FORM_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 ('Test Mode', 'MODULE_PAYMENT_PROTX_FORM_TEST_STATUS', 'true', 'Use Test Mode?', '6', '4', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");

 

//// PA Evers Added for Pre-Authorisation selection

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 ('Use Pre-Authorisation', 'MODULE_PAYMENT_PROTX_FORM_PREAUTH', 'true', 'Use Pre-Authorisation for all transactions?', '6', '5', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");

//// EOF: PA Evers Added for Pre-Authorisation selection

//added by Mike Jackson for shopping cart selection***********************************************************************

********************************************************

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 ('Shopping cart', 'MODULE_PAYMENT_PROTX_FORM_SHOPCART', 'true', 'Send shopping cart details to Protx?', '6', '6', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");

//end added by Mike Jackson for shopping cart selection***********************************************************************

********************************************************

 

 

}

 

function remove() {

$keys = '';

$keys_array = $this->keys();

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

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

}

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

 

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

}

 

function keys() {

//changed by Mike Jackson for shopping cart selection***********************************************************************

********************************************************

return array('MODULE_PAYMENT_PROTX_FORM_STATUS', 'MODULE_PAYMENT_PROTX_FORM_VENDOR_NAME', 'MODULE_PAYMENT_PROTX_FORM_PASSWORD', 'MODULE_PAYMENT_PROTX_FORM_CURRENCY', 'MODULE_PAYMENT_PROTX_FORM_ZONE', 'MODULE_PAYMENT_PROTX_FORM_ORDER_STATUS_ID', 'MODULE_PAYMENT_PROTX_FORM_SORT_ORDER', 'MODULE_PAYMENT_PROTX_FORM_TEST_STATUS', 'MODULE_PAYMENT_PROTX_FORM_PREAUTH', 'MODULE_PAYMENT_PROTX_FORM_SHOPCART');

// return array('MODULE_PAYMENT_PROTX_FORM_STATUS', 'MODULE_PAYMENT_PROTX_FORM_VENDOR_NAME', 'MODULE_PAYMENT_PROTX_FORM_PASSWORD', 'MODULE_PAYMENT_PROTX_FORM_CURRENCY', 'MODULE_PAYMENT_PROTX_FORM_ZONE', 'MODULE_PAYMENT_PROTX_FORM_ORDER_STATUS_ID', 'MODULE_PAYMENT_PROTX_FORM_SORT_ORDER', 'MODULE_PAYMENT_PROTX_FORM_TEST_STATUS', 'MODULE_PAYMENT_PROTX_FORM_PREAUTH');

//end changed by Mike Jackson for shopping cart selection***********************************************************************

********************************************************

 

}

}

?>

 

 

any help on this one ?

 

thanks

 

Darren

Edited by toefinger

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.

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