Hiya. I have been trying to work on the Linkpoint 2.0 Module to see if I can figure out why the orders do not hit the database, because I NEED this module, and I figure it’s a good way for me to learn about php at the same time. The main 2 sections I edited are to function after process (I removed the return false, and added code), and the first part of function install (I installed the the $check Query, $status Query, and $flags Query) If anyone can be so kind as to look over my coding at this point and maybe point me in the right direction if something isn’t OK, that would be fabulous!!!
Here it is, all 50 zillion lines of code!!
[php]<?php
/*
$Id: linkpointconnectoffsite.php $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright © 2009 osCommerce
Released under the GNU General Public License
*/
class linkpointconnectoffsite {
var $code, $title, $description, $enabled, $cc_type, $transtype,
$transmode, $zipcode;
// class constructor
function linkpointconnectoffsite() {
global $order;
$this->code = ‘linkpointconnectoffsite’;
$this->title = MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TEXT_TITLE;
$this->description =
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TEXT_DESCRIPTION;
$this->enabled = ((MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_STATUS
== ‘True’) ? true : false);
$this->sort_order =
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_SORT_ORDER;
if ((int)MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_ORDER_STATUS_ID >
- {
$this->order_status =
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
if (MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_YOURPAY == ‘False’) {
$this->form_action_url =
‘https://www.linkpointcentral.com/lpc/servlet/lppay’;
} else {
$this->form_action_url =
‘https://secure.linkpt.net/lpcentral/servlet/lppay’;
}
if (MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TESTMODE == ‘Test’) {
$this->transmode = ‘test’;
} else {
$this->transmode = ‘live’;
}
if (MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_METHOD == ‘Sale’) {
$this->transtype = ‘sale’;
} else {
$this->transtype = ‘preauth’;
}
}
// class methods
function update_status() {
global $order;
if ( ($this->enabled == true) && ((int)
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_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_LINKPOINTCONNECTOFFSITE_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() {
$selection = array(‘id’ => $this->code,
‘module’ => $this->title,
);
return $selection;
}
function pre_confirmation_check() {
return false;
}
function confirmation() {
return false;
}
function process_button() {
global $HTTP_SERVER_VARS, $order, $customer_id;
// set state to a useful default
$bstate = $order->billing[‘state’];
// get the two character code for state based on the entry zone
ID
// a better solution would probably add this code to the order
class
// where it could fetch all the zone info at once
// however, that’s out of scope for a payment module
// Linkpoint wants the two character code rather than the name
$zone_query = tep_db_query("select zone_code from " . TABLE_ZONES
. " where zone_id = ‘" . $order->billing[‘zone_id’] . "’");
if ($zone = tep_db_fetch_array($zone_query)) {
// ensure uppercase
$bstate = strtoupper($zone[‘zone_code’]);
}
// Linkpoint has different fields for US states and other
countries
$bstate_field = ‘bstate2’;
if ($order->billing[‘country’][‘iso_code_2’] == ‘US’) {
$bstate_field = ‘bstate’;
}
$sstate_field = ‘sstate2’;
if ($order->delivery[‘country’][‘iso_code_2’] == ‘US’) {
$sstate_field = ‘sstate’;
}
$process_button_string = tep_draw_hidden_field(‘storename’,
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_LOGIN) .
tep_draw_hidden_field(‘chargetotal’,
number_format($order->info[‘total’], 2)) .
tep_draw_hidden_field(‘userid’,
$customer_id) .
tep_draw_hidden_field(‘bname’, $order-
billing[‘firstname’] . ’ ’ . $order->billing[‘lastname’]) .
tep_draw_hidden_field(‘baddr1’, $order-
billing[‘street_address’]) .
tep_draw_hidden_field(‘bcity’, $order-
billing[‘city’]) .
tep_draw_hidden_field($bstate_field,
$bstate) .
tep_draw_hidden_field(‘bzip’, $order-
billing[‘postcode’]) .
tep_draw_hidden_field(‘bcountry’,
$order->billing[‘country’][‘iso_code_2’]) .
tep_draw_hidden_field(‘phone’, $order-
customer[‘telephone’]) .
tep_draw_hidden_field(‘email’, $order-
customer[‘email_address’]) .
tep_draw_hidden_field(‘sname’, $order-
delivery[‘firstname’] .’ '. $order->delivery[‘lastname’]) .
tep_draw_hidden_field(‘saddr1’, $order-
delivery[‘street_address’]) .
tep_draw_hidden_field(‘scity’, $order-
delivery[‘city’]) .
tep_draw_hidden_field($sstate_field,
$order->delivery[‘state’]) .
tep_draw_hidden_field(‘szip’, $order-
delivery[‘postcode’]) .
tep_draw_hidden_field(‘scountry’,
$order->delivery[‘country’][‘iso_code_2’]) .
tep_draw_hidden_field(‘customer_ip’,
$HTTP_SERVER_VARS[‘REMOTE_ADDR’]) .
tep_draw_hidden_field(‘2000’, ‘Submit’)
.
// ponumber and taxexempt are needed
for business-corporate credit cards
// leave off for off site processing
// if needed, the customer should be able to enter on
Linkpoint’s site
// tep_draw_hidden_field(‘ponumber’,
‘1001’) .
// tep_draw_hidden_field(‘taxexempt’,
‘1’) .
tep_draw_hidden_field(‘txntype’, $this-
transtype) .
tep_draw_hidden_field(‘txnmode’, $this-
transmode) .
// tep_draw_hidden_field(‘referurl’,
‘http://www’) .
tep_draw_hidden_field(‘mode’,
‘payonly’);
$process_button_string .= tep_draw_hidden_field(tep_session_name
(), tep_session_id());
return $process_button_string;
}
function before_process() {
global $HTTP_POST_VARS;
if ($HTTP_POST_VARS[‘status’] == ‘APPROVED’) return;
if ($HTTP_POST_VARS[‘status’] == ‘DECLINED’) {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT,
‘error_message=’ . urlencode
(MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TEXT_DECLINED_MESSAGE), ‘SSL’,
true, false));
}
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT,
‘error_message=’ . urlencode
(MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TEXT_ERROR_MESSAGE), ‘SSL’,
true, false));
}
function after_process() {
global $response_array, $insert_id,
$order, $payerstatus, $addressstatus;
$result = 'Payer Status: ’ .
tep_output_string_protected($payerstatus) . “\n” .
'Address Status: ’ . tep_output_string_protected($addressstatus) . "\n
\n" .
'Payment Status: ’ .
tep_output_string_protected($response_array[‘PAYMENTSTATUS’]) . “\n” .
'Payment Type: ’ . tep_output_string_protected
($response_array[‘PAYMENTTYPE’]) . “\n” .
'Pending
Reason: ’ . tep_output_string_protected($response_array
[‘PENDINGREASON’]) . “\n” .
'Reversal Code: ’ .
tep_output_string_protected($response_array[‘REASONCODE’]);
$sql_data_array = array(‘orders_id’ => $insert_id,
‘orders_status_id’ =>
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_ORDER_STATUS_ID,
‘date_added’ => ‘now()’,
‘customer_notified’ => ‘0’,
‘comments’ =>
$result);
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
tep_session_unregister(‘payerstatus’);
tep_session_unregister(‘addressstatus’);
}
function get_error() {
global $HTTP_GET_VARS;
$error = array(‘title’ =>
MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TEXT_ERROR,
‘error’ => stripslashes(urldecode($HTTP_GET_VARS
[‘failReason’])));
return $error;
}
function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("select configuration_value from "
. TABLE_CONFIGURATION . " where configuration_key =
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_STATUS’");
$this->_check = tep_db_num_rows($check_query);
}
return $this->_check;
}
function install() {
$check_query = tep_db_query("select orders_status_id from " .
TABLE_ORDERS_STATUS . " where orders_status_name = ’ Linkpoint
[Transactions]’ limit 1");
if (tep_db_num_rows($check_query) < 1) {
$status_query = tep_db_query("select max(orders_status_id) as status_id
from " . TABLE_ORDERS_STATUS);
$status = tep_db_fetch_array($status_query);
$status_id =
$status[‘status_id’]+1;
$languages = tep_get_languages();
foreach ($languages as $lang)
{
tep_db_query("insert into " . TABLE_ORDERS_STATUS . "
(orders_status_id, language_id, orders_status_name) values (’" .
$status_id . “’, '” . $lang[‘id’] . “’, ‘Linkpoint [Transactions]’)”);
}
$flags_query = tep_db_query("describe " . TABLE_ORDERS_STATUS . "
public_flag");
if (tep_db_num_rows($flags_query) == 1) {
tep_db_query("update " . TABLE_ORDERS_STATUS . " set public_flag = 0
and downloads_flag = 0 where orders_status_id = ‘" . $status_id . "’");
}
} else {
$check = tep_db_fetch_array
($check_query);
$status_id = $check[‘orders_status_id’];
}
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 LinkPoint Connect Module’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_STATUS’, ‘True’, 'Do you want
to accept Linkpoint Basic 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 (‘Store Number’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_LOGIN’, ‘000001’, 'The store
number for LinkPoint’, ‘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 (‘Yourpay’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_YOURPAY’, ‘False’, 'Yourpay
Account’, ‘6’, ‘0’, 'tep_cfg_select_option(array(‘False’, ‘True’),
', 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_LINKPOINTCONNECTOFFSITE_TESTMODE’, ‘Test’, 'Transaction
mode used for processing orders’, ‘6’, ‘0’, 'tep_cfg_select_option
(array(‘Test’, ‘Live’), ', 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_LINKPOINTCONNECTOFFSITE_METHOD’, ‘Sale’, 'Transaction
method used for processing orders’, ‘6’, ‘0’, 'tep_cfg_select_option
(array(‘Sale’, ‘Auth’), ', 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_LINKPOINTCONNECTOFFSITE_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_LINKPOINTCONNECTOFFSITE_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_LINKPOINTCONNECTOFFSITE_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_LINKPOINTCONNECTOFFSITE_STATUS’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_LOGIN’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_YOURPAY’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_TESTMODE’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_METHOD’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_SORT_ORDER’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_ZONE’,
‘MODULE_PAYMENT_LINKPOINTCONNECTOFFSITE_ORDER_STATUS_ID’);
}
}
?>
Quote
MultiQuote
[/php]