:blink: Still having problems with debit payment cards using optimal payments .... but different ones!
I think the problem is because the Optimal Payment module I am using does not collect an issue number which is found on some debit cards.
The relevant code in the optimal/firepay module is:
<?php
#
# Payment Module SureFire Commerce via FirePay for osCommerce (http://www.oscommerce.com)
# Developed by mike wOZniewski, http://www.OZmediaSolutions.com
# If you find bugs, have questions, please email
[email protected]
#
# API information, white papers, protocol info can be found at http://www.sfcommerce.com/Back-Office/merchant.asp
#
# IMPORTANT NOTES FOR THIS VERSION:
# - Since FirePay does not return a message in the header, this module uses CURL to post and receive a response. This MUST be installed on your server if this module is to work (found at http://curl.haxx.se/).
# - You cannot use your regular account, username, and password if you are using the TEST mode; you must contact SureFire and request a test account.
# - Currencies are NOT sent to SureFire. Your SureFire account has a specific default currency, and any order totals should be in that currency.
#
# THINGS STILL TO DO:
# - Add currency conversion for order total to convert it to your SureFire default currency.
# - Modify the cc_validation.php class to accept FirePay Payments
#
class firepay {
var $code, $title, $description, $enabled;
// class constructor
function firepay() {
global $order;
$this->code = 'firepay';
$this->title = MODULE_PAYMENT_FIREPAY_TEXT_TITLE;
$this->description = MODULE_PAYMENT_FIREPAY_TEXT_DESCRIPTION;
$this->enabled = ((MODULE_PAYMENT_FIREPAY_STATUS == 'True') ? true : false);
$this->sort_order = MODULE_PAYMENT_FIREPAY_SORT_ORDER;
if ((int)MODULE_PAYMENT_FIREPAY_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_FIREPAY_ORDER_STATUS_ID;
}
if (is_object($order)) $this->update_status();
$this->form_action_url = FILENAME_CHECKOUT_PROCESS;
}
// start custom firepay methods
function dp($call,$cname) {
// debug display for test mode
echo "<br/>".$cname.":<pre>";
if (!is_array($call)) $call=htmlspecialchars($call);
print_r($call);
if (is_array($call)) reset($call);
echo "</pre><hr/>\n";
}
function firepay_cardType() {
switch ($this->cc_card_type) {
case "Visa":
return "VI";
case "Master Card":
return "MC";
case "UK Electron":
return "VE";
case "UK Switch/Maestro":
return "SW";
case "UK Solo":
return "SO";
case "Delta":
return "VD";
}
return false;
}
// end custom firepay methods
// class methods
function update_status() {
global $order;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_FIREPAY_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_FIREPAY_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() {
$js = ' if (payment_value == "' . $this->code . '") {' . "\n" .
' var cc_owner = document.checkout_payment.firepay_cc_owner.value;' . "\n" .
' var cc_number = document.checkout_payment.firepay_cc_number.value;' . "\n" .
////evan added on August 27 2003
' var cc_cvd = document.checkout_payment.firepay_cvd_number.value;'. "\n".
/////evan added ends
' if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_FIREPAY_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_FIREPAY_TEXT_JS_CC_NUMBER . '";' . "\n" .
' error = 1;' . "\n" .
' }' . "\n" .
////evan added on August 27 2003
' if (cc_cvd == "" || cc_cvd.length < 3 || cc_cvd.length > 4) {'."\n".
' error_message = error_message + "CVD Number not input or number of digits incorrect";'."\n".
' error = 1;'. "\n".
' }' . "\n".
///evan added ends
' }' . "\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)));
}
$selection = array('id' => $this->code,
'module' => $this->title,
'fields' => array(array('title' => MODULE_PAYMENT_FIREPAY_TEXT_CREDIT_CARD_OWNER,
'field' => tep_draw_input_field('firepay_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),
array('title' => MODULE_PAYMENT_FIREPAY_TEXT_CREDIT_CARD_NUMBER,
'field' => tep_draw_input_field('firepay_cc_number')),
///evan added thte following on August 26 2003
array('title' => 'CVD <span style="font-size:10">(last 3 or 4 digits of the security number <br> on the back of your card-usually on the signature line)</span>',
'field'=> tep_draw_input_field('firepay_cvd_number')),
///evan added ends
array('title' => MODULE_PAYMENT_FIREPAY_TEXT_CREDIT_CARD_EXPIRES,
'field' => tep_draw_pull_down_menu('firepay_cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('firepay_cc_expires_year', $expires_year))));
return $selection;
}
function pre_confirmation_check() {
global $HTTP_POST_VARS;
include(DIR_WS_CLASSES . 'cc_validation.php');
$cc_validation = new cc_validation();
$result = $cc_validation->validate($HTTP_POST_VARS['firepay_cc_number'], $HTTP_POST_VARS['firepay_cc_expires_month'], $HTTP_POST_VARS['firepay_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) . '&firepay_cc_owner=' . urlencode($HTTP_POST_VARS['firepay_cc_owner']) . '&firepay_cc_expires_month=' . $HTTP_POST_VARS['firepay_cc_expires_month'] . '&firepay_cc_expires_year=' . $HTTP_POST_VARS['firepay_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;
}
function confirmation() {
global $HTTP_POST_VARS;
$confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
'fields' => array(array('title' => MODULE_PAYMENT_FIREPAY_TEXT_CREDIT_CARD_OWNER,
'field' => $HTTP_POST_VARS['firepay_cc_owner']),
array('title' => MODULE_PAYMENT_FIREPAY_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)),
///evan added on August 23 2003
array('title' => 'CVD Number',
'field' => $HTTP_POST_VARS['firepay_cvd_number']),
///evan added ends
array('title' => MODULE_PAYMENT_FIREPAY_TEXT_CREDIT_CARD_EXPIRES,
'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['firepay_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['firepay_cc_expires_year'])))));
return $confirmation;
}
function process_button() {
global $HTTP_SERVER_VARS, $HTTP_POST_VARS, $order, $customer_id;////evan added on August 27 2003, the $HTTP_POST_VARS
$process_button_string = // unique transaction id number:
tep_draw_hidden_field('firepay[merchantTxn]', $customer_id . '-' . date('Ymdhis')) .
// cc info:
tep_draw_hidden_field('firepay[cardNumber]', $this->cc_card_number) .
tep_draw_hidden_field('firepay[cardType]', $this->firepay_cardType()) .
///evan added on August 27 2003
tep_draw_hidden_field('firepay[cvdValue]', $HTTP_POST_VARS['firepay_cvd_number']).
///evan added ends
tep_draw_hidden_field('firepay[cardExp]', $this->cc_expiry_month . '/' . substr($this->cc_expiry_year, -2)) .
///tep_draw_hidden_field('firepay[cvdIndicator]', '0') . // indicates that no cc security number was provided
////evan commented above line and changed it to below on August 27 2003
tep_draw_hidden_field('firepay[cvdIndicator]', '1'). //indicates cvd is provided
///evan added ends
// amount owed (in cents):
tep_draw_hidden_field('firepay[amount]', round($order->info['total'],2)*100) .
// billing info:
tep_draw_hidden_field('firepay[custName1]', $order->billing['lastname'] . ', ' . $order->customer['firstname']) .
tep_draw_hidden_field('firepay[streetAddr]', $order->billing['street_address']) .
tep_draw_hidden_field('firepay[city]', $order->billing['city']) .
tep_draw_hidden_field('firepay[province]', $order->billing['state']) .
tep_draw_hidden_field('firepay[zip]', $order->billing['postcode']) .
tep_draw_hidden_field('firepay[country]', $order->billing['country']['title']) .
tep_draw_hidden_field('firepay[phone]', $order->customer['telephone']) .
tep_draw_hidden_field('firepay', $order->customer['email_address']);
$process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id());
return $process_button_string;
}
function before_process() {
global $HTTP_POST_VARS;
// transaction info:
if (MODULE_PAYMENT_FIREPAY_TESTMODE=="Production") $firepay_post_url = 'https://realtime.firepay.com:443/servlet/DPServlet';
else $firepay_post_url = 'https://realtime.test.firepay.com:443/servlet/DPServlet';
if (MODULE_PAYMENT_FIREPAY_OPERATION=='Payment') $firepay_transaction_type = "P";
else $firepay_transaction_type = "A";
// prepare vars to post to fireplay
$firepay_data_stream = '';
$firepay_account_info = array(
'account' => MODULE_PAYMENT_FIREPAY_ACCOUNT,
'merchantId' => MODULE_PAYMENT_FIREPAY_USERNAME,
'merchantPwd' => MODULE_PAYMENT_FIREPAY_PASSWORD,
'clientVersion' => '1.1',
'operation' => $firepay_transaction_type );
$firepay_input = (array)$HTTP_POST_VARS['firepay'] + (array)$firepay_account_info;
foreach ($firepay_input as $k=>$v) {
if (strlen($firepay_data_stream)>0) $firepay_data_stream .= '&';
$firepay_data_stream .= "$k=".urlencode($v);
}
//send the data and retrieve response using CURL ()
$curl_handler = curl_init($firepay_post_url);
curl_setopt($curl_handler,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handler,CURLOPT_POST,1);
curl_setopt($curl_handler,CURLOPT_POSTFIELDS,$firepay_data_stream);
$curl_result = curl_exec($curl_handler);
curl_close($curl_handler);
//re-arrange the results into an array
$curl_result = explode('&',urldecode($curl_result));
foreach ($curl_result as $v) {
list($key,$val) = explode('=',$v);
$firepay_output[$key] = $val;
}
// uncomment for debugging: (the order will NOT be placed in the catalog database, but the transaction will go through
// $this->dp($firepay_input,"INPUT PARAMETERS");
// $this->dp($firepay_output,"OUTPUT PARAMETERS");
// exit;
if (($firepay_output['status'] == 'SP') || ($firepay_output['status'] == 'A')) return;
else if ($firepay_output['status'] == 'E') tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode($firepay_output['errString']), 'SSL', true, false));
else tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_FIREPAY_TEXT_ERROR_MESSAGE), 'SSL', true, false));
}
function after_process() {
return false;
}
function get_error() {
global $HTTP_GET_VARS;
$error = array('title' => MODULE_PAYMENT_FIREPAY_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_FIREPAY_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 FirePay Module', 'MODULE_PAYMENT_FIREPAY_STATUS', 'True', 'Do you want to accept FirePay / SFCommerce 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 ('Account Number', 'MODULE_PAYMENT_FIREPAY_ACCOUNT', 'testing', 'Your FirePay / SFCommerce Account Number', '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 ('Username', 'MODULE_PAYMENT_FIREPAY_USERNAME', 'testing', 'The merchant username provided by the FirePay or SFCommerce service', '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 ('Password', 'MODULE_PAYMENT_FIREPAY_PASSWORD', 'Test', 'The merchant password provided by the FirePay or SFCommerce service', '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 ('Transaction Mode', 'MODULE_PAYMENT_FIREPAY_TESTMODE', 'Test', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(array(\'Test\', \'Production\'), ', 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 Type', 'MODULE_PAYMENT_FIREPAY_OPERATION', 'Authorization', 'What type of transaction should be used?', '6', '0', 'tep_cfg_select_option(array(\'Authorization\', \'Payment\'), ', 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_FIREPAY_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_FIREPAY_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_FIREPAY_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_FIREPAY_STATUS', 'MODULE_PAYMENT_FIREPAY_ACCOUNT', 'MODULE_PAYMENT_FIREPAY_USERNAME', 'MODULE_PAYMENT_FIREPAY_PASSWORD', 'MODULE_PAYMENT_FIREPAY_TESTMODE', 'MODULE_PAYMENT_FIREPAY_OPERATION', 'MODULE_PAYMENT_FIREPAY_ZONE', 'MODULE_PAYMENT_FIREPAY_ORDER_STATUS_ID', 'MODULE_PAYMENT_FIREPAY_SORT_ORDER');
}
}
?>
So what I ned to do is add an extra field to capture an issue number and start date if present (so not required fields).... I think!
Does anyone have any idea where to start? I have discussed this with the payment processor who told me it would be a simple thing for anyone with php knowledge... thanks... helpful... not!
...thank you ....