Code:
<?php
/*
// $Id: paymate.php,v 2.0 2002/01/17
$Id: paymate.php,v 2.3 2005/11/27
This module was modifed and rev'd to 2.3 by Mark Edwards to provide better support for paymate.
New features in v3.0
* Uses POST instead of GET for better functionality
* Supports a return URL, which streamlines payment processing
* Supports return codes from paymate in case a payment is declined
* Supports sort order for payment choice listings
* No longer requires the use of the paymate graphic and separate payment window which
formerly depended on the user returning to the store to confirm completion of their order,
this is all done automatically now
The module works per paymate's spec as of Nov 27, 2005.
Paymate dev help and testing info:
http://www.paymate.com.au/help/help.do?helpSet=paymate&item=siteintegration
Paymate integration info:
http://www.paymate.com.au/help/help.do?helpSet=paymate&item=siteintegration
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
class paymate {
var $code, $title, $description, $enabled;
// class constructor
function paymate() {
$this->code = 'paymate';
$this->title = MODULE_PAYMENT_PAYMATE_TEXT_TITLE;
$this->description = MODULE_PAYMENT_PAYMATE_TEXT_DESCRIPTION;
$this->enabled = ((MODULE_PAYMENT_PAYMATE_STATUS == 'True') ? true : false);
$this->sort_order = MODULE_PAYMENT_PAYMATE_SORT_ORDER;
$this->form_action_url = 'https://www.paymate.com.au/PayMate/ExpressPayment';
}
// class methods
function javascript_validation() {
return false;
}
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, $currency, $currencies;
$my_currency = $currency;
$process_button_string = tep_draw_hidden_field('mid', MODULE_PAYMENT_PAYMATE_MID) .
tep_draw_hidden_field('popup', 'false') .
tep_draw_hidden_field('amt', number_format($order->info['total'] * $currencies->get_value($my_currency), 2) ).
tep_draw_hidden_field('amt_editable', 'N') .
tep_draw_hidden_field('ref',STORE_NAME).
tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL') ) .
tep_draw_hidden_field('currency', $mycurrency) .
tep_draw_hidden_field('PMT_RECIPIENT_EMAIL', MODULE_PAYMENT_PAYMATE_ID) .
tep_draw_hidden_field('PMT_TRANSACTION_ORDERREF', time()) .
tep_draw_hidden_field('PMT_SENDER_EMAIL', $order->customer['email_address']) .
tep_draw_hidden_field('PMT_CONTACT_FIRSTNAME', $order->billing['firstname']) .
tep_draw_hidden_field('PMT_CONTACT_SURNAME', $order->billing['lastname']) .
tep_draw_hidden_field('regindi_address1', $order->billing['street_address']) .
tep_draw_hidden_field('regindi_sub', $order->billing['city']) .
tep_draw_hidden_field('regindi_pcode', $order->billing['postcode']) .
tep_draw_hidden_field('PMT_TRANSACTION_SELLERAMOUNT', number_format($order->info['total'] * $currencies->get_value($my_currency), 2));
return $process_button_string;
}
function before_process() {
global $HTTP_POST_VARS;
if ($HTTP_POST_VARS['responseCode'] == 'PD') { // declined
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=YOUR PAYMENT WAS DECLINED BY YOUR PAYMENT PROCESSOR. PLEASE SELECT ANOTHER PAYMENT METHOD:', 'SSL', true, false));
}
if ($HTTP_POST_VARS['responseCode'] == 'PA') { // approved
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PROCESS, 'error_message=Your payment was approved! Thank you!', 'SSL', true, false));
}
if ($HTTP_POST_VARS['responseCode'] == 'PP') { // processing
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PROCESS, 'error_message=Your payment is being processed. Thank you!', 'SSL', true, false));
}
}
function after_process() {
return false;
}
function get_error() {
global $HTTP_GET_VARS;
$error = array('title' => 'ERROR PROCESSING YOUR PAYMENT',
'error' => stripslashes(urldecode($HTTP_GET_VARS['error'])));
return $error;
}
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_PAYMATE_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 PAYMATE Module', 'MODULE_PAYMENT_PAYMATE_STATUS', 'True', 'Do you want to accept PAYMATE payments?', '6', '3', '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 ('Paymate ID', 'MODULE_PAYMENT_PAYMATE_MID', 'your Paymate ID', 'The merchant ID paymate assigned to you for the PAYMATE service', '6', '4', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('E-Mail Address', 'MODULE_PAYMENT_PAYMATE_ID', '[email protected]', 'The e-mail address registered for the Paymate service', '6', '5', 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_PAYMATE_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
}
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() {
return array('MODULE_PAYMENT_PAYMATE_STATUS', 'MODULE_PAYMENT_PAYMATE_MID', 'MODULE_PAYMENT_PAYMATE_ID','MODULE_PAYMENT_PAYMATE_SORT_ORDER');
}
}
?>
Bookmarks