HunTelWebProgrammer
asked on
PHP Code If Then Statement help URGENT!
I am working on a site that is using osCommerce and using Payfuse to handle transactions. The transactions are getting to Payfuse and processing correctly, however the cart is not completing the transaction and is reporting an error in the returned url, but it contains no error number. When confirming the order, it returns the user to the payment screen with a URL parameter of error_ message which contains no value. I am posting the class file, and the module file here. Anyone that can help will be rewarded. This needs to be fixed by Friday! YIKES! Thanks in advance for all your work!
Please Help!
MODULE FILE -------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
<?php
class payfuse {
var $code, $title, $description, $enabled;
// class constructor
function payfuse() {
global $order;
$this->code = 'payfuse';
if ($HTTP_GET_VARS['main_page '] != '') {
$this->title = MODULE_PAYMENT_PAYFUSE_TEX T_CATALOG_ TITLE; // Payment module title in Catalog
} else {
$this->title = MODULE_PAYMENT_PAYFUSE_TEX T_ADMIN_TI TLE; // Payment module title in Admin
}
$this->description = MODULE_PAYMENT_PAYFUSE_TEX T_DESCRIPT ION; // Descriptive Info about module in Admin
$this->enabled = ((MODULE_PAYMENT_PAYFUSE_S TATUS == 'True') ? true : false); // Whether the module is installed or not
$this->sort_order = MODULE_PAYMENT_PAYFUSE_SOR T_ORDER; // Sort Order of this payment option on the customer payment page
$this->form_action_url = tep_href_link(FILENAME_CHE CKOUT_PROC ESS, '', 'SSL', false); // Page to go to upon submitting page info
if ((int)MODULE_PAYMENT_PAYFU SE_ORDER_S TATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_PAYFUSE_ORD ER_STATUS_ ID;
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYFU SE_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_PAYFUSE_ZON E . "' 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;
}
}
}
// Validate the credit card information via javascript (Number, Owner, and CVV Lengths)
function javascript_validation() {
$js = ' if (payment_value == "' . $this->code . '") {' . "\n" .
' var cc_owner = document.checkout_payment. payfuse_cc _owner.val ue;' . "\n" .
' var cc_number = document.checkout_payment. payfuse_cc _number.va lue;' . "\n";
$js .= ' if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PAYFUSE_TEX T_JS_CC_OW NER . '";' . "\n" .
' error = 1;' . "\n" .
' }' . "\n" .
' if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PAYFUSE_TEX T_JS_CC_NU MBER . '";' . "\n" .
' error = 1;' . "\n" .
' }' . "\n" ;
return $js;
}
// Display Credit Card Information Submission Fields on the Checkout Payment Page
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' => MODULE_PAYMENT_PAYFUSE_TEX T_CATALOG_ TITLE,
'fields' => array(array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CREDIT_C ARD_OWNER,
'field' => tep_draw_input_field('payf use_cc_own er', $order->billing['firstname '] . ' ' . $order->billing['lastname' ])),
array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CREDIT_C ARD_NUMBER ,
'field' => tep_draw_input_field('payf use_cc_num ber')),
array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CREDIT_C ARD_EXPIRE S,
'field' => tep_draw_pull_down_menu('p ayfuse_cc_ expires_mo nth', $expires_month) . ' ' . tep_draw_pull_down_menu('p ayfuse_cc_ expires_ye ar', $expires_year)),
array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CVV . ' ' .'<a href="javascript:popupWind ow(\'' . tep_href_link(FILENAME_POP UP_CVV_HEL P) . '\')">' . MODULE_PAYMENT_PAYFUSE_TEX T_POPUP_CV V_LINK . '</a>',
'field' => tep_draw_input_field('payf use_cc_cvv ', '', "size=4, maxlength=4"))));
return $selection;
}
// Evaluates the Credit Card Type for acceptance and the validity of the Credit Card Number & Expiration Date
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['payf use_cc_num ber'], $HTTP_POST_VARS['payfuse_c c_expires_ month'], $HTTP_POST_VARS['payfuse_c c_expires_ year'], $HTTP_POST_VARS['payfuse_c c_cvv']);
$error = '';
switch ($result) {
case -1:
$error = sprintf(TEXT_CCVAL_ERROR_U NKNOWN_CAR D, substr($cc_validation->cc_ number, 0, 4));
break;
case -2:
case -3:
case -4:
$error = TEXT_CCVAL_ERROR_INVALID_D ATE;
break;
case false:
$error = TEXT_CCVAL_ERROR_INVALID_N UMBER;
break;
}
if ( ($result == false) || ($result < 1) ) {
$payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&payfuse_cc_owner=' . urlencode($HTTP_POST_VARS[ 'payfuse_c c_owner']) . '&payfuse_cc_expires_month =' . $HTTP_POST_VARS['payfuse_c c_expires_ month'] . '&payfuse_cc_expires_year= ' . $HTTP_POST_VARS['payfuse_c c_expires_ year'];
tep_redirect(tep_href_link (FILENAME_ CHECKOUT_P AYMENT, $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;
}
// Display Credit Card Information on the Checkout Confirmation Page
function confirmation() {
global $HTTP_POST_VARS;
$confirmation = array(//'title' => MODULE_PAYMENT_PAYFUSE_TEX T_CATALOG_ TITLE, // Redundant
'fields' => array(array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CREDIT_C ARD_OWNER,
'field' => $HTTP_POST_VARS['payfuse_c c_owner']) ,
array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CREDIT_C ARD_NUMBER ,
'field' => substr($this->cc_card_numb er, 0, 4) . str_repeat('X', (strlen($this->cc_card_num ber) - 8)) . substr($this->cc_card_numb er, -4)),
array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_CREDIT_C ARD_EXPIRE S,
'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VA RS['payfus e_cc_expir es_month'] , 1, '20' . $HTTP_POST_VARS['payfuse_c c_expires_ year'])))) );
return $confirmation;
}
function process_button() {
global $HTTP_POST_VARS;
// These are hidden fields on the checkout confirmation page
$process_button_string = tep_draw_hidden_field('cc_ owner', $HTTP_POST_VARS['payfuse_c c_owner']) .
tep_draw_hidden_field('cc_ expires', $this->cc_expiry_month . substr($this->cc_expiry_ye ar, -2)) .
tep_draw_hidden_field('cc_ expires_mo nth', $this->cc_expiry_month) .
tep_draw_hidden_field('cc_ expires_ye ar', substr($this->cc_expiry_ye ar, -2)) .
tep_draw_hidden_field('cc_ type', $this->cc_card_type) .
tep_draw_hidden_field('cc_ number', $this->cc_card_number) .
tep_draw_hidden_field('cc_ cvv', $HTTP_POST_VARS['payfuse_c c_cvv']);
$process_button_string .= tep_draw_hidden_field(tep_ session_na me(), tep_session_id());
return $process_button_string;
}
function before_process() {
global $HTTP_POST_VARS, $HTTP_SERVER_VARS, $order, $currency, $customer_id;
$order->info['cc_type'] = $HTTP_POST_VARS['cc_type'] ;
$order->info['cc_owner'] = $HTTP_POST_VARS['cc_owner' ];
$order->info['cc_cvv'] = $HTTP_POST_VARS['cc_cvv'];
// Build Info to send to Gateway
require_once(DIR_WS_MODULE S . 'payment/payfuse/class.pay fuse.php') ;
$pf = new PayfusePayment;
$pf->setGatewayURL(((MODUL E_PAYMENT_ PAYFUSE_TR ANSACTION_ MODE == 'Production') ? 'https://xmlic.payfuse.com:443' : 'https://test5x.clearcommerce.com:11500'));
$pf->setStoreID(MODULE_PAY MENT_PAYFU SE_STORE_I D);
$pf->setPassPhrase(MODULE_ PAYMENT_PA YFUSE_PASS PHRASE); // Assures authenticity
$pf->setClientID(MODULE_PA YMENT_PAYF USE_CLIENT _ID);
$pf->setPaymentType('CC');
$pf->setCardAction(((MODUL E_PAYMENT_ PAYFUSE_AU THORIZATIO N_MODE == 'Authorize') ? '1' : '0'));
$pf->setSubTotal($order->i nfo['total ']);
$pf->setCardNumber($HTTP_P OST_VARS[' cc_number' ]);
$pf->setCardExpMonth($HTTP _POST_VARS ['cc_expir es_month'] );
$pf->setCardExpYear($HTTP_ POST_VARS[ 'cc_expire s_year']);
$pf->setUserID($customer_i d);
$pf->setBname($order->bill ing['first name'] . ' ' . $order->billing['lastname' ]);
$pf->setBcompany($order->b illing['co mpany']);
$pf->setBaddress1($order-> billing['s treet_addr ess']);
$pf->setBaddress2($order-> billing['s uburb']);
$pf->setBcity($order->bill ing['city' ]);
$pf->setBprovince($order-> billing['s tate']);
$pf->setBpostalCode($order ->billing[ 'postcode' ]);
$pf->setBcountry($order->b illing['co untry']['i so_code_2' ]);
$pf->setSname($order->deli very['firs tname'] . ' ' . $order->delivery['lastname ']);
$pf->setScompany($order->d elivery['c ompany']);
$pf->setSaddress1($order-> delivery[' street_add ress']);
$pf->setSaddress2($order-> delivery[' suburb']);
$pf->setScity($order->deli very['city ']);
$pf->setSprovince($order-> delivery[' state']);
$pf->setSpostalCode($order ->delivery ['postcode ']);
$pf->setScountry($order->d elivery['c ountry'][' iso_code_2 ']);
$pf->setPhone($order->cust omer['tele phone']);
$pf->setEmail($order->cust omer['emai l_address' ]);
$pf->setComments("OsCommer ce XML Interface 1.0");
$pf->setCustomerIP($HTTP_S ERVER_VARS ['REMOTE_A DDR']);
$pf->setCardIDCode('1');
$pf->setCardIDNumber($HTTP _POST_VARS ['cc_cvv'] );
if (MODULE_PAYMENT_PAYFUSE_TR ANSACTION_ MODE == 'Test') {
switch (MODULE_PAYMENT_PAYFUSE_TR ANSACTION_ TEST_RESUL T) {
case "Approved": $pf->setMode('Y'); break;
case "Declined": $pf->setMode('N'); break;
case "Random": $pf->setMode('R'); break;
//case "Fraud": $pf->setTestResult('F'); break;
}
}
else
$pf->setMode('P');
// Send transaction data to the gateway
$pf_xml_error = ($pf->doPayment() != PAYFUSE_TRANSACTION_OK);
// Gateway Response fields in values to put into the database storage
/*$Pf_TransTime = $pf->getTrxnTransTime();
$Pf_OrderID = $pf->getTrxnOrderID();
$Pf_Approved = $pf->getTrxnApproved();
$Pf_ReturnCode = $pf->getTrxnReturnCode();
$Pf_ErrMsg = $pf->getTrxnErrMsg();
$Pf_TaxTotal = $pf->getTrxnTaxTotal();
$Pf_ShipTotal = $pf->getTrxnShipTotal();
$Pf_SubTotal = $pf->getTrxnSubTotal();
$Pf_FullTotal = $pf->getTrxnFullTotal();
$Pf_PaymentType = $pf->getTrxnPaymentType();
$Pf_CardNumber = $pf->getTrxnCardNumber();
$Pf_CardExpMonth = $pf->getTrxnCardExpMonth() ;
$Pf_CardExpYear = $pf->getTrxnCardExpYear();
$Pf_RefNumber = $pf->getTrxnTransRefNumber ();
$Pf_CardIDResult = $pf->getTrxnCardIDResult() ;
$Pf_AVSResult = $pf->getTrxnAVSResult();
$Pf_CardAuthNumber = $pf->getTrxnCardAuthNumber ();
$Pf_CardRefNumber = $pf->getTrxnCardRefNumber( );
$Pf_CardType = $pf->getTrxnCardType();
$Pf_IPResult = $pf->getTrxnIPResult();
$Pf_IPCountry = $pf->getTrxnIPCountry();
$Pf_IPRegion = $pf->getTrxnIPRegion();
$Pf_IPCity = $pf->getTrxnIPCity();*/
// Do we want to store the responses from the gateway in the database ?
// if (MODULE_PAYMENT_PAYFUSE_ST ORE_DATA == 'True') {
// tep_db_query("insert into " . TABLE_PAYFUSE . " (id, customer_id, osc_order_id, payfuse_order_id, transaction_time, approved, return_code, error_message, trans_ref, cvv_result, avs_result, card_auth, card_ref, ip_result, ip_country, ip_region, ip_city) values ('', '" . $HTTP_SESSION_VARS['custom er_id'] . "', '', '" . $Pf_OrderID . "', '" . $Pf_TransTime . "', '" . $Pf_Approved . "', '" . $Pf_ReturnCode . "', '" . $Pf_ErrMsg . "', '" . $Pf_RefNumber . "', '" . $Pf_CardIDResult . "', '" . $Pf_AVSResult . "', '" . $Pf_CardAuthNumber . "', '" . $Pf_CardRefNumber . "', '" . $Pf_IPResult . "', '" . $Pf_IPCountry . "', '" . $Pf_IPRegion . "', '" . $Pf_IPCity . "')");
// }
// Transaction was not approved. Send to checkout_payment page again and display error to customer
if ($pf_xml_error) {
tep_redirect(tep_href_link (FILENAME_ CHECKOUT_P AYMENT, 'error_message=' . $Pf_ErrMsg . ' - ' . urlencode(MODULE_PAYMENT_P AYFUSE_TEX T_DECLINED _MESSAGE), 'SSL', true, false));
}
}
function after_process() {
return false;
}
function get_error() {
global $HTTP_GET_VARS;
$error = array('title' => MODULE_PAYMENT_PAYFUSE_TEX T_ERROR,
'error' => stripslashes(urldecode($HT TP_GET_VAR S['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_PAYFUSE_ST ATUS'");
$this->_check = tep_db_num_rows($check_que ry);
}
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 Payfuse Payment Module', 'MODULE_PAYMENT_PAYFUSE_ST ATUS', 'True', 'Do you want to accept Payfuse credit card payments?', '6', '0', 'tep_cfg_select_option(arr ay(\'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 ('Payfuse Store ID - CAD', 'MODULE_PAYMENT_PAYFUSE_ST ORE_ID_CAD ', 'teststore', 'Please enter your Payfuse Store ID for CAD currency', '6', '6', now())");
// tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payfuse Passphrase - CAD', 'MODULE_PAYMENT_PAYFUSE_PA SSPHRASE_C AD', 'psigate1234', 'Please enter your Payfuse Passphrase for CAD currency', '6', '6', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payfuse Store ID', 'MODULE_PAYMENT_PAYFUSE_ST ORE_ID', 'teststore', 'Please enter your Payfuse Store ID', '6', '6', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payfuse Passphrase', 'MODULE_PAYMENT_PAYFUSE_PA SSPHRASE', 'psigate1234', 'Please enter your Payfuse Passphrase', '6', '6', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payfuse Client ID', 'MODULE_PAYMENT_PAYFUSE_CL IENT_ID', '1234', 'Please enter your Payfuse Client ID', '6', '6', 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_PAYFUSE_TR ANSACTION_ MODE', 'Production', 'Transaction mode used for processing orders', '6', '0', 'tep_cfg_select_option(arr ay(\'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 ('Test Mode Result', 'MODULE_PAYMENT_PAYFUSE_TR ANSACTION_ TEST_RESUL T', 'Approved', 'Simulated responses when in test mode. Not used when in production mode.', '6', '5', 'tep_cfg_select_option(arr ay(\'Appro ved\', \'Declined\', \'Random\'), ', 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 ('Authorization Type', 'MODULE_PAYMENT_PAYFUSE_AU THORIZATIO N_MODE', 'Authorize', 'Do you want submitted credit card transactions to be authorized only, or immediately charge?', '6', '0', 'tep_cfg_select_option(arr ay(\'Autho rize\', \'Immediate Charge\'), ', 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 ('Enable Database Storage', 'MODULE_PAYMENT_PAYFUSE_ST ORE_DATA', 'False', 'Do you want to save the gateway data to the database? (Note: You must add a table first)', '6', '0', 'tep_cfg_select_option(arr ay(\'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 ('Sort order of display.', 'MODULE_PAYMENT_PAYFUSE_SO RT_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_PAYFUSE_ZO NE', '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_cl asses(', 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_PAYFUSE_OR DER_STATUS _ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_s tatuses(', '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_PAYFUSE_ST ATUS',
//'MODULE_PAYMENT_PAYFUSE_ STORE_ID_C AD',
//'MODULE_PAYMENT_PAYFUSE_ PASSPHRASE _CAD',
'MODULE_PAYMENT_PAYFUSE_ST ORE_ID',
'MODULE_PAYMENT_PAYFUSE_PA SSPHRASE',
'MODULE_PAYMENT_PAYFUSE_CL IENT_ID',
'MODULE_PAYMENT_PAYFUSE_TR ANSACTION_ MODE',
'MODULE_PAYMENT_PAYFUSE_TR ANSACTION_ TEST_RESUL T',
//'MODULE_PAYMENT_PAYFUSE_ AUTHORIZAT ION_MODE',
//'MODULE_PAYMENT_PAYFUSE_ STORE_DATA ',
'MODULE_PAYMENT_PAYFUSE_SO RT_ORDER',
'MODULE_PAYMENT_PAYFUSE_ZO NE',
'MODULE_PAYMENT_PAYFUSE_OR DER_STATUS _ID');
}
}
?>
CLASS FILE -------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
<?php
define( 'PAYFUSE_CURL_ERROR_OFFSET ', 1000 );
define( 'PAYFUSE_ERROR_OFFSET', 2000 );
define( 'PAYFUSE_TRANSACTION_OK', APPROVED );
define( 'PAYFUSE_TRANSACTION_DECLI NED', DECLINED );
define( 'PAYFUSE_TRANSACTION_ERROR ', ERROR );
class PayfusePayment {
var $parser;
var $xmlData;
var $currentTag;
var $myGatewayURL;
var $myStoreID;
var $myPassphrase;
var $myClientID;
var $myPaymentType;
var $myCardAction;
var $mySubtotal;
var $myCardNumber;
var $myCardExpMonth;
var $myCardExpYear;
var $myCardIDCode;
var $myCardIDNumber;
var $myMode;
var $myOrderID;
var $myUserID;
var $myBname;
var $myBcompany;
var $myBaddress1;
var $myBaddress2;
var $myBcity;
var $myBprovince;
var $myBpostalcode;
var $myBcountry;
var $mySname;
var $myScompany;
var $mySaddress1;
var $mySaddress2;
var $myScity;
var $mySprovince;
var $mySpostalcode;
var $myScountry;
var $myPhone;
var $myFax;
var $myEmail;
var $myComments;
var $myCustomerIP;
//var $myResultTrxnTransTime;
//var $myResultTrxnOrderID;
//var $myResultTrxnApproved;
//var $myResultTrxnReturnCode;
//var $myResultTrxnErrMsg;
//var $myResultTrxnTaxTotal;
//var $myResultTrxnShipTotal;
//var $myResultTrxnSubTotal;
//var $myResultTrxnFullTotal;
//var $myResultTrxnPaymentType;
//var $myResultTrxnCardNumber;
//var $myResultTrxnCardExpMonth;
//var $myResultTrxnCardExpYear;
//var $myResultTrxnTransRefNumbe r;
//var $myResultTrxnCardIDResult;
//var $myResultTrxnAVSResult;
//var $myResultTrxnCardAuthNumbe r;
//var $myResultTrxnCardRefNumber ;
//var $myResultTrxnCardType;
//var $myResultTrxnIPResult;
//var $myResultTrxnIPCountry;
//var $myResultTrxnIPRegion;
//var $myResultTrxnIPCity;
var $myResultText;
var $myResultProcReturnMsg;
var $myError;
var $myErrorMessage;
/************************* ********** ********** ********** ********** ******
*** XML Parser - Callback functions ***
************************** ********** ********** ********** ********** *****/
function ElementStart ($parser, $tag, $attributes) {
$this->currentTag = $tag;
}
function ElementEnd ($parser, $tag) {
$this->currentTag = "";
}
function charachterData ($parser, $cdata) {
$this->xmlData[$this->curr entTag] = $cdata;
}
/************************* ********** ********** ********** ********** ******
*** SET values to send to PsiGate ***
************************** ********** ********** ********** ********** *****/
function setGatewayURL($GatewayURL) {
$this->myGatewayURL = $GatewayURL;
}
function setStoreID( $StoreID ) {
$this->myStoreID = $StoreID;
}
function setPassphrase( $Passphrase ) {
$this->myPassphrase = $Passphrase;
}
function setClientID( $ClientID ) {
$this->myClientID = $ClientID;
}
function setPaymentType( $PaymentType ) {
$this->myPaymentType = $PaymentType;
}
function setCardAction( $CardAction ) {
$this->myCardAction = $CardAction;
}
function setSubtotal( $Subtotal ) {
$this->mySubtotal = $Subtotal;
}
function setCardNumber( $CardNumber ) {
$this->myCardNumber = $CardNumber;
}
function setCardExpMonth( $CardExpMonth ) {
$this->myCardExpMonth = $CardExpMonth;
}
function setCardExpYear( $CardExpYear ) {
$this->myCardExpYear = $CardExpYear;
}
function setCardIDCode( $CardIDCode ) {
$this->myCardIDCode = $CardIDCode;
}
function setCardIDNumber( $CardIDNumber ) {
$this->myCardIDNumber = $CardIDNumber;
}
function setMode( $TestResult ) {
$this->myMode = $TestResult;
}
function setOrderID( $OrderID ) {
$this->myOrderID = $OrderID;
}
function setUserID( $UserID ) {
$this->myUserID = $UserID;
}
function setBname( $Bname ) {
$this->myBname = $Bname;
}
function setBcompany( $Bcompany ) {
$this->myBcompany = $Bcompany;
}
function setBaddress1( $Baddress1 ) {
$this->myBaddress1 = $Baddress1;
}
function setBaddress2( $Baddress2 ) {
$this->myBaddress2 = $Baddress2;
}
function setBcity( $Bcity ) {
$this->myBcity = $Bcity;
}
function setBprovince( $Bprovince ) {
$this->myBprovince = $Bprovince;
}
function setBpostalcode( $Bpostalcode) {
$this->myBpostalcode = $Bpostalcode;
}
function setBcountry( $Bcountry) {
$this->myBcountry = $Bcountry;
}
function setSname( $Sname) {
$this->mySname = $Sname;
}
function setScompany( $Scompany) {
$this->myScompany = $Scompany;
}
function setSaddress1( $Saddress1) {
$this->mySaddress1 = $Saddress1;
}
function setSaddress2( $Saddress2) {
$this->mySaddress2 = $Saddress2;
}
function setScity( $Scity) {
$this->myScity = $Scity;
}
function setSprovince( $Sprovince) {
$this->mySprovince = $Sprovince;
}
function setSpostalcode( $Spostalcode) {
$this->mySpostalcode = $Spostalcode;
}
function setScountry( $Scountry) {
$this->myScountry = $Scountry;
}
function setPhone( $Phone) {
$this->myPhone = $Phone;
}
function setFax( $Fax) {
$this->myFax = $Fax;
}
function setEmail( $Email) {
$this->myEmail = $Email;
}
function setComments( $Comments) {
$this->myComments = $Comments;
}
function setCustomerIP( $CustomerIP) {
$this->myCustomerIP = $CustomerIP;
}
/************************* ********** ********** ********** ********** ******
*** GET values returned by PsiGate ***
************************** ********** ********** ********** ********** *****/
/* function getTrxnTransTime() {
return $this->myResultTrxnTransTi me;
}
function getTrxnOrderID() {
return $this->myResultTrxnOrderID ;
}
function getTrxnApproved() {
return $this->myResultTrxnApprove d;
}
function getTrxnReturnCode() {
return $this->myResultTrxnReturnC ode;
}
function getTrxnErrMsg() {
return $this->myResultTrxnErrMsg;
}
function getTrxnTaxTotal() {
return $this->myResultTrxnTaxTota l;
}
function getTrxnShipTotal() {
return $this->myResultTrxnShipTot al;
}
function getTrxnSubTotal() {
return $this->myResultTrxnSubTota l;
}
function getTrxnFullTotal() {
return $this->myResultTrxnFullTot al;
}
function getTrxnPaymentType() {
return $this->myResultTrxnPayment Type;
}
function getTrxnCardNumber() {
return $this->myResultTrxnCardNum ber;
}
function getTrxnCardExpMonth() {
return $this->myResultTrxnCardExp Month;
}
function getTrxnCardExpYear() {
return $this->myResultTrxnCardExp Year;
}
function getTrxnTransRefNumber() {
return $this->myResultTrxnTransRe fNumber;
}
function getTrxnCardIDResult() {
return $this->myResultTrxnCardIDR esult;
}
function getTrxnAVSResult() {
return $this->myResultTrxnAVSResu lt;
}
function getTrxnCardAuthNumber() {
return $this->myResultTrxnCardAut hNumber;
}
function getTrxnCardRefNumber() {
return $this->myResultTrxnCardRef Number;
}
function getTrxnCardType() {
return $this->myResultTrxnCardTyp e;
}
function getTrxnIPResult() {
return $this->myResultTrxnIPResul t;
}
function getTrxnIPCountry() {
return $this->myResultTrxnIPCount ry;
}
function getTrxnIPRegion() {
return $this->myResultTrxnIPRegio n;
}
function getTrxnIPCity() {
return $this->myResultTrxnIPCity;
}
*/
// function getResultText() { return $this->myResultText; }
// function getResultProcReturnMsg() { return $this->myResultProcReturnM sg; }
function getError() {
if( $this->myError != 0 ) {
// Internal Error
return $this->myError;
} else {
if($this->myResultProcRetu rnMsg == 'Approved')
return PAYFUSE_TRANSACTION_OK;
else if($this->myResultProcRetu rnMsg == 'Declined')
return PAYFUSE_TRANSACTION_DECLIN ED;
else
return PAYFUSE_TRANSACTION_ERROR;
}
}
function getErrorMessage() {
if( $this->myError != 0 ) {
// Internal Error
return $this->myErrorMessage;
} else {
if(!empty($this->myResultT ext))
return $this->myResultText;
else
return $this->myResultProcReturnM sg;
}
}
/************************* ********** ********** ********** ********** ******
*** Class Constructor ***
************************** ********** ********** ********** ********** *****/
function PayfusePayment() {
}
/************************* ********** ********** ********** ********** ******
*** Business Logic ***
************************** ********** ********** ********** ********** *****/
function doPayment() {
/* $xmlRequest = "<Order>".
"<StoreID>".htmlentities( $this->myStoreID )."</StoreID>".
"<Passphrase>".htmlentitie s( $this->myPassphrase)."</Pa ssphrase>" .
"<Subtotal>".htmlentities( $this->mySubtotal )."</Subtotal>".
"<PaymentType>".htmlentiti es( $this->myPaymentType )."</PaymentType>".
"<CardAction>".htmlentitie s( $this->myCardAction )."</CardAction>".
"<CardNumber>".htmlentitie s( $this->myCardNumber )."</CardNumber>".
"<CardExpMonth>".htmlentit ies( $this->myCardExpMonth )."</CardExpMonth>".
"<CardExpYear>".htmlentiti es( $this->myCardExpYear )."</CardExpYear>".
"<CardIDCode>".htmlentitie s( $this->myCardIDCode )."</CardIDCode>".
"<CardIDNumber>".htmlentit ies( $this->myCardIDNumber )."</CardIDNumber>".
"<TestResult>".htmlentitie s( $this->myTestResult )."</TestResult>".
"<OrderID>".htmlentities( $this->myOrderID )."</OrderID>".
"<UserID>".htmlentities( $this->myUserID )."</UserID>".
"<Bname>".htmlentities( $this->myBname )."</Bname>".
"<Bcompany>".htmlentities( $this->myBcompany )."</Bcompany>".
"<Baddress1>".htmlentities ( $this->myBaddress1 )."</Baddress1>".
"<Baddress2>".htmlentities ( $this->myBaddress2 )."</Baddress2>".
"<Bcity>".htmlentities( $this->myBcity )."</Bcity>".
"<Bprovince>".htmlentities ( $this->myBprovince )."</Bprovince>".
"<Bpostalcode>".htmlentiti es( $this->myBpostalcode )."</Bpostalcode>".
"<Bcountry>".htmlentities( $this->myBcountry )."</Bcountry>".
"<Sname>".htmlentities( $this->mySname )."</Sname>".
"<Scompany>".htmlentities( $this->myScompany )."</Scompany>".
"<Saddress1>".htmlentities ( $this->mySaddress1 )."</Saddress1>".
"<Saddress2>".htmlentities ( $this->mySaddress2 )."</Saddress2>".
"<Scity>".htmlentities( $this->myScity )."</Scity>".
"<Sprovince>".htmlentities ( $this->mySprovince )."</Sprovince>".
"<Spostalcode>".htmlentiti es( $this->mySpostalcode )."</Spostalcode>".
"<Scountry>".htmlentities( $this->myScountry )."</Scountry>".
"<Phone>".htmlentities( $this->myPhone )."</Phone>".
"<Email>".htmlentities( $this->myEmail )."</Email>".
"<Comments>".htmlentities( $this->myComments )."</Comments>".
"<CustomerIP>".htmlentitie s( $this->myCustomerIP )."</CustomerIP>".
"</Order>";*/
$xmlRequest['CLRCMRC_XML'] = 'CLRCMRC_XML=
<EngineDocList>
<DocVersion>1.0</DocVersio n>
<EngineDoc>
<ContentType>OrderFormDoc< /ContentTy pe>
<User>
<Name>'.htmlentities($this ->myStoreI D).'</Name >
<Password>'.htmlentities($ this->myPa ssphrase). '</Passwor d>
<Alias>'.htmlentities($thi s->myClien tID).'</Al ias>
</User>
<Instructions>
<Pipeline>PaymentNoFraud</ Pipeline>
</Instructions>
<OrderFormDoc>
<Mode>'.htmlentities($this ->myMode). '</Mode>
<Consumer>
<PaymentMech>
<CreditCard>
<Number>'.htmlentities($th is->myCard Number).'< /Number>
<Expires DataType="ExpirationDate" Locale="840">'.htmlentitie s($this->m yCardExpMo nth).'/'.h tmlentitie s($this->m yCardExpYe ar).'</Exp ires>
<Cvv2Val>'.htmlentities($t his->myCar dIDNumber) .'</Cvv2Va l>
<Cvv2Indicator>1</Cvv2Indi cator>
</CreditCard>
</PaymentMech>
<BillTo>
<Location>
<Address>
<Name>'.htmlentities($this ->myBname) .'</Name>
<Street1>'.htmlentities($t his->myBad dress1).'< /Street1>
<Street2>'.htmlentities($t his->myBad dress2).'< /Street2>
<City>'.htmlentities($this ->myBcity) .'</City>
<StateProv>'.htmlentities( $this->myB province). '</StatePr ov>
<PostalCode>'.htmlentities ($this->my BpostalCod e).'</Post alCode>
<Country>840</Country>
<Company>'.htmlentities($t his->myBco mpany).'</ Company>
</Address>
</Location>
</BillTo>
</Consumer>
<Transaction>
<Type>Auth</Type>
<CurrentTotals>
<Totals>
<Total DataType="Money" Currency="840">'.(int)($th is->mySubt otal * 100).'</Total>
</Totals>
</CurrentTotals>
</Transaction>
</OrderFormDoc>
</EngineDoc>
</EngineDocList>';
/* Use CURL to execute XML POST and write output into a string */
$ch = curl_init( $this->myGatewayURL );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xmlRequest );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
$xmlResponse = curl_exec( $ch );
// Check whether the curl_exec worked.
if( curl_errno( $ch ) == CURLE_OK ) {
// It worked, so setup an XML parser for the result.
$this->parser = xml_parser_create();
// Disable XML tag capitalisation (Case Folding)
xml_parser_set_option ($this->parser, XML_OPTION_CASE_FOLDING, FALSE);
// Define Callback functions for XML Parsing
xml_set_object($this->pars er, &$this);
xml_set_element_handler ($this->parser, "ElementStart", "ElementEnd");
xml_set_character_data_han dler ($this->parser, "charachterData");
// Parse the XML response
xml_parse($this->parser, $xmlResponse, TRUE);
if( xml_get_error_code( $this->parser ) == XML_ERROR_NONE ) {
// Get the result into local variables.
// $this->myResultTrxnTransTi me = $this->xmlData['TransTime' ];
// $this->myResultTrxnOrderID = $this->xmlData['OrderID'];
// $this->myResultTrxnApprove d = $this->xmlData['Approved'] ;
// $this->myResultTrxnReturnC ode = $this->xmlData['ReturnCode '];
// $this->myResultTrxnErrMsg = $this->xmlData['ErrMsg'];
// $this->myResultTrxnTaxTota l = $this->xmlData['TaxTotal'] ;
// $this->myResultTrxnShipTot al = $this->xmlData['ShipTotal' ];
// $this->myResultTrxnSubTota l = $this->xmlData['SubTotal'] ;
// $this->myResultTrxnFullTot al = $this->xmlData['FullTotal' ];
// $this->myResultTrxnPayment Type = $this->xmlData['PaymentTyp e'];
// $this->myResultTrxnCardNum ber = $this->xmlData['CardNumber '];
// $this->myResultTrxnCardExp Month = $this->xmlData['CardExpMon th'];
// $this->myResultTrxnCardExp Year = $this->xmlData['CardExpYea r'];
// $this->myResultTrxnTransRe fNumber = $this->xmlData['TransRefNu mber'];
// $this->myResultTrxnCardIDR esult = $this->xmlData['CardIDResu lt'];
// $this->myResultTrxnAVSResu lt = $this->xmlData['AVSResult' ];
// $this->myResultTrxnCardAut hNumber = $this->xmlData['CardAuthNu mber'];
// $this->myResultTrxnCardRef Number = $this->xmlData['CardRefNum ber'];
// $this->myResultTrxnCardTyp e = $this->xmlData['CardType'] ;
// $this->myResultTrxnIPResul t = $this->xmlData['IPResult'] ;
// $this->myResultTrxnIPCount ry = $this->xmlData['IPCountry' ];
// $this->myResultTrxnIPRegio n = $this->xmlData['IPRegion'] ;
// $this->myResultTrxnIPCity = $this->xmlData['IPCity'];
$this->myResultText = $this->xmlData['Text'];
$this->myResultProcReturnM sg = $this->xmlData['ProcReturn Msg'];
$this->myError = 0;
$this->myErrorMessage = '';
} else {
// An XML error occured. Return the error message and number.
$this->myError = xml_get_error_code( $this->parser ) + PAYFUSE_ERROR_OFFSET;
$this->myErrorMessage = xml_error_string( $myError );
}
// Clean up our XML parser
xml_parser_free( $this->parser );
} else {
// A CURL Error occured. Return the error message and number. (offset so we can pick the error apart)
$this->myError = curl_errno( $ch ) + PAYFUSE_CURL_ERROR_OFFSET;
$this->myErrorMessage = curl_error( $ch );
}
// Clean up CURL, and return any error.
curl_close( $ch );
/************************* ********** ********** ********** ********** ******
*** Optional commented-out Debug. Dont mess with it. ***
************************** ********** ********** ********** ********** *****/
//echo $xmlRequest['CLRCMRC_XML'] ."\n\n\n";
//echo $xmlResponse."\n\n\n";
//echo $this->myResultText."\n\n\ n";
//echo $this->myResultProcReturnM sg."\n\n\n ";
//exit();
return $this->getError();
}
}
?>
Please Help!
MODULE FILE --------------------------
<?php
class payfuse {
var $code, $title, $description, $enabled;
// class constructor
function payfuse() {
global $order;
$this->code = 'payfuse';
if ($HTTP_GET_VARS['main_page
$this->title = MODULE_PAYMENT_PAYFUSE_TEX
} else {
$this->title = MODULE_PAYMENT_PAYFUSE_TEX
}
$this->description = MODULE_PAYMENT_PAYFUSE_TEX
$this->enabled = ((MODULE_PAYMENT_PAYFUSE_S
$this->sort_order = MODULE_PAYMENT_PAYFUSE_SOR
$this->form_action_url = tep_href_link(FILENAME_CHE
if ((int)MODULE_PAYMENT_PAYFU
$this->order_status = MODULE_PAYMENT_PAYFUSE_ORD
}
if (is_object($order)) $this->update_status();
}
// class methods
function update_status() {
global $order;
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYFU
$check_flag = false;
$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYFUSE_ZON
while ($check = tep_db_fetch_array($check_
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;
}
}
}
// Validate the credit card information via javascript (Number, Owner, and CVV Lengths)
function javascript_validation() {
$js = ' if (payment_value == "' . $this->code . '") {' . "\n" .
' var cc_owner = document.checkout_payment.
' var cc_number = document.checkout_payment.
$js .= ' if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PAYFUSE_TEX
' error = 1;' . "\n" .
' }' . "\n" .
' if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PAYFUSE_TEX
' error = 1;' . "\n" .
' }' . "\n" ;
return $js;
}
// Display Credit Card Information Submission Fields on the Checkout Payment Page
function selection() {
global $order;
for ($i=1; $i<13; $i++) {
$expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0
}
$today = getdate();
for ($i=$today['year']; $i < $today['year']+10; $i++) {
$expires_year[] = array('id' => strftime('%y',mktime(0,0,0
}
$selection = array('id' => $this->code,
'module' => MODULE_PAYMENT_PAYFUSE_TEX
'fields' => array(array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => tep_draw_input_field('payf
array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => tep_draw_input_field('payf
array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => tep_draw_pull_down_menu('p
array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => tep_draw_input_field('payf
return $selection;
}
// Evaluates the Credit Card Type for acceptance and the validity of the Credit Card Number & Expiration Date
function pre_confirmation_check() {
global $HTTP_POST_VARS;
include(DIR_WS_CLASSES . 'cc_validation.php');
$cc_validation = new cc_validation();
$result = $cc_validation->validate($
$error = '';
switch ($result) {
case -1:
$error = sprintf(TEXT_CCVAL_ERROR_U
break;
case -2:
case -3:
case -4:
$error = TEXT_CCVAL_ERROR_INVALID_D
break;
case false:
$error = TEXT_CCVAL_ERROR_INVALID_N
break;
}
if ( ($result == false) || ($result < 1) ) {
$payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&payfuse_cc_owner=' . urlencode($HTTP_POST_VARS[
tep_redirect(tep_href_link
}
$this->cc_card_type = $cc_validation->cc_type;
$this->cc_card_number = $cc_validation->cc_number;
$this->cc_expiry_month = $cc_validation->cc_expiry_
$this->cc_expiry_year = $cc_validation->cc_expiry_
}
// Display Credit Card Information on the Checkout Confirmation Page
function confirmation() {
global $HTTP_POST_VARS;
$confirmation = array(//'title' => MODULE_PAYMENT_PAYFUSE_TEX
'fields' => array(array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => $HTTP_POST_VARS['payfuse_c
array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => substr($this->cc_card_numb
array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VA
return $confirmation;
}
function process_button() {
global $HTTP_POST_VARS;
// These are hidden fields on the checkout confirmation page
$process_button_string = tep_draw_hidden_field('cc_
tep_draw_hidden_field('cc_
tep_draw_hidden_field('cc_
tep_draw_hidden_field('cc_
tep_draw_hidden_field('cc_
tep_draw_hidden_field('cc_
tep_draw_hidden_field('cc_
$process_button_string .= tep_draw_hidden_field(tep_
return $process_button_string;
}
function before_process() {
global $HTTP_POST_VARS, $HTTP_SERVER_VARS, $order, $currency, $customer_id;
$order->info['cc_type'] = $HTTP_POST_VARS['cc_type']
$order->info['cc_owner'] = $HTTP_POST_VARS['cc_owner'
$order->info['cc_cvv'] = $HTTP_POST_VARS['cc_cvv'];
// Build Info to send to Gateway
require_once(DIR_WS_MODULE
$pf = new PayfusePayment;
$pf->setGatewayURL(((MODUL
$pf->setStoreID(MODULE_PAY
$pf->setPassPhrase(MODULE_
$pf->setClientID(MODULE_PA
$pf->setPaymentType('CC');
$pf->setCardAction(((MODUL
$pf->setSubTotal($order->i
$pf->setCardNumber($HTTP_P
$pf->setCardExpMonth($HTTP
$pf->setCardExpYear($HTTP_
$pf->setUserID($customer_i
$pf->setBname($order->bill
$pf->setBcompany($order->b
$pf->setBaddress1($order->
$pf->setBaddress2($order->
$pf->setBcity($order->bill
$pf->setBprovince($order->
$pf->setBpostalCode($order
$pf->setBcountry($order->b
$pf->setSname($order->deli
$pf->setScompany($order->d
$pf->setSaddress1($order->
$pf->setSaddress2($order->
$pf->setScity($order->deli
$pf->setSprovince($order->
$pf->setSpostalCode($order
$pf->setScountry($order->d
$pf->setPhone($order->cust
$pf->setEmail($order->cust
$pf->setComments("OsCommer
$pf->setCustomerIP($HTTP_S
$pf->setCardIDCode('1');
$pf->setCardIDNumber($HTTP
if (MODULE_PAYMENT_PAYFUSE_TR
switch (MODULE_PAYMENT_PAYFUSE_TR
case "Approved": $pf->setMode('Y'); break;
case "Declined": $pf->setMode('N'); break;
case "Random": $pf->setMode('R'); break;
//case "Fraud": $pf->setTestResult('F'); break;
}
}
else
$pf->setMode('P');
// Send transaction data to the gateway
$pf_xml_error = ($pf->doPayment() != PAYFUSE_TRANSACTION_OK);
// Gateway Response fields in values to put into the database storage
/*$Pf_TransTime = $pf->getTrxnTransTime();
$Pf_OrderID = $pf->getTrxnOrderID();
$Pf_Approved = $pf->getTrxnApproved();
$Pf_ReturnCode = $pf->getTrxnReturnCode();
$Pf_ErrMsg = $pf->getTrxnErrMsg();
$Pf_TaxTotal = $pf->getTrxnTaxTotal();
$Pf_ShipTotal = $pf->getTrxnShipTotal();
$Pf_SubTotal = $pf->getTrxnSubTotal();
$Pf_FullTotal = $pf->getTrxnFullTotal();
$Pf_PaymentType = $pf->getTrxnPaymentType();
$Pf_CardNumber = $pf->getTrxnCardNumber();
$Pf_CardExpMonth = $pf->getTrxnCardExpMonth()
$Pf_CardExpYear = $pf->getTrxnCardExpYear();
$Pf_RefNumber = $pf->getTrxnTransRefNumber
$Pf_CardIDResult = $pf->getTrxnCardIDResult()
$Pf_AVSResult = $pf->getTrxnAVSResult();
$Pf_CardAuthNumber = $pf->getTrxnCardAuthNumber
$Pf_CardRefNumber = $pf->getTrxnCardRefNumber(
$Pf_CardType = $pf->getTrxnCardType();
$Pf_IPResult = $pf->getTrxnIPResult();
$Pf_IPCountry = $pf->getTrxnIPCountry();
$Pf_IPRegion = $pf->getTrxnIPRegion();
$Pf_IPCity = $pf->getTrxnIPCity();*/
// Do we want to store the responses from the gateway in the database ?
// if (MODULE_PAYMENT_PAYFUSE_ST
// tep_db_query("insert into " . TABLE_PAYFUSE . " (id, customer_id, osc_order_id, payfuse_order_id, transaction_time, approved, return_code, error_message, trans_ref, cvv_result, avs_result, card_auth, card_ref, ip_result, ip_country, ip_region, ip_city) values ('', '" . $HTTP_SESSION_VARS['custom
// }
// Transaction was not approved. Send to checkout_payment page again and display error to customer
if ($pf_xml_error) {
tep_redirect(tep_href_link
}
}
function after_process() {
return false;
}
function get_error() {
global $HTTP_GET_VARS;
$error = array('title' => MODULE_PAYMENT_PAYFUSE_TEX
'error' => stripslashes(urldecode($HT
return $error;
}
function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYFUSE_ST
$this->_check = tep_db_num_rows($check_que
}
return $this->_check;
}
function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
// tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
// tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
// tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
// tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description,
}
function remove() {
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
return array(
'MODULE_PAYMENT_PAYFUSE_ST
//'MODULE_PAYMENT_PAYFUSE_
//'MODULE_PAYMENT_PAYFUSE_
'MODULE_PAYMENT_PAYFUSE_ST
'MODULE_PAYMENT_PAYFUSE_PA
'MODULE_PAYMENT_PAYFUSE_CL
'MODULE_PAYMENT_PAYFUSE_TR
'MODULE_PAYMENT_PAYFUSE_TR
//'MODULE_PAYMENT_PAYFUSE_
//'MODULE_PAYMENT_PAYFUSE_
'MODULE_PAYMENT_PAYFUSE_SO
'MODULE_PAYMENT_PAYFUSE_ZO
'MODULE_PAYMENT_PAYFUSE_OR
}
}
?>
CLASS FILE --------------------------
<?php
define( 'PAYFUSE_CURL_ERROR_OFFSET
define( 'PAYFUSE_ERROR_OFFSET', 2000 );
define( 'PAYFUSE_TRANSACTION_OK', APPROVED );
define( 'PAYFUSE_TRANSACTION_DECLI
define( 'PAYFUSE_TRANSACTION_ERROR
class PayfusePayment {
var $parser;
var $xmlData;
var $currentTag;
var $myGatewayURL;
var $myStoreID;
var $myPassphrase;
var $myClientID;
var $myPaymentType;
var $myCardAction;
var $mySubtotal;
var $myCardNumber;
var $myCardExpMonth;
var $myCardExpYear;
var $myCardIDCode;
var $myCardIDNumber;
var $myMode;
var $myOrderID;
var $myUserID;
var $myBname;
var $myBcompany;
var $myBaddress1;
var $myBaddress2;
var $myBcity;
var $myBprovince;
var $myBpostalcode;
var $myBcountry;
var $mySname;
var $myScompany;
var $mySaddress1;
var $mySaddress2;
var $myScity;
var $mySprovince;
var $mySpostalcode;
var $myScountry;
var $myPhone;
var $myFax;
var $myEmail;
var $myComments;
var $myCustomerIP;
//var $myResultTrxnTransTime;
//var $myResultTrxnOrderID;
//var $myResultTrxnApproved;
//var $myResultTrxnReturnCode;
//var $myResultTrxnErrMsg;
//var $myResultTrxnTaxTotal;
//var $myResultTrxnShipTotal;
//var $myResultTrxnSubTotal;
//var $myResultTrxnFullTotal;
//var $myResultTrxnPaymentType;
//var $myResultTrxnCardNumber;
//var $myResultTrxnCardExpMonth;
//var $myResultTrxnCardExpYear;
//var $myResultTrxnTransRefNumbe
//var $myResultTrxnCardIDResult;
//var $myResultTrxnAVSResult;
//var $myResultTrxnCardAuthNumbe
//var $myResultTrxnCardRefNumber
//var $myResultTrxnCardType;
//var $myResultTrxnIPResult;
//var $myResultTrxnIPCountry;
//var $myResultTrxnIPRegion;
//var $myResultTrxnIPCity;
var $myResultText;
var $myResultProcReturnMsg;
var $myError;
var $myErrorMessage;
/*************************
*** XML Parser - Callback functions ***
**************************
function ElementStart ($parser, $tag, $attributes) {
$this->currentTag = $tag;
}
function ElementEnd ($parser, $tag) {
$this->currentTag = "";
}
function charachterData ($parser, $cdata) {
$this->xmlData[$this->curr
}
/*************************
*** SET values to send to PsiGate ***
**************************
function setGatewayURL($GatewayURL)
$this->myGatewayURL = $GatewayURL;
}
function setStoreID( $StoreID ) {
$this->myStoreID = $StoreID;
}
function setPassphrase( $Passphrase ) {
$this->myPassphrase = $Passphrase;
}
function setClientID( $ClientID ) {
$this->myClientID = $ClientID;
}
function setPaymentType( $PaymentType ) {
$this->myPaymentType = $PaymentType;
}
function setCardAction( $CardAction ) {
$this->myCardAction = $CardAction;
}
function setSubtotal( $Subtotal ) {
$this->mySubtotal = $Subtotal;
}
function setCardNumber( $CardNumber ) {
$this->myCardNumber = $CardNumber;
}
function setCardExpMonth( $CardExpMonth ) {
$this->myCardExpMonth = $CardExpMonth;
}
function setCardExpYear( $CardExpYear ) {
$this->myCardExpYear = $CardExpYear;
}
function setCardIDCode( $CardIDCode ) {
$this->myCardIDCode = $CardIDCode;
}
function setCardIDNumber( $CardIDNumber ) {
$this->myCardIDNumber = $CardIDNumber;
}
function setMode( $TestResult ) {
$this->myMode = $TestResult;
}
function setOrderID( $OrderID ) {
$this->myOrderID = $OrderID;
}
function setUserID( $UserID ) {
$this->myUserID = $UserID;
}
function setBname( $Bname ) {
$this->myBname = $Bname;
}
function setBcompany( $Bcompany ) {
$this->myBcompany = $Bcompany;
}
function setBaddress1( $Baddress1 ) {
$this->myBaddress1 = $Baddress1;
}
function setBaddress2( $Baddress2 ) {
$this->myBaddress2 = $Baddress2;
}
function setBcity( $Bcity ) {
$this->myBcity = $Bcity;
}
function setBprovince( $Bprovince ) {
$this->myBprovince = $Bprovince;
}
function setBpostalcode( $Bpostalcode) {
$this->myBpostalcode = $Bpostalcode;
}
function setBcountry( $Bcountry) {
$this->myBcountry = $Bcountry;
}
function setSname( $Sname) {
$this->mySname = $Sname;
}
function setScompany( $Scompany) {
$this->myScompany = $Scompany;
}
function setSaddress1( $Saddress1) {
$this->mySaddress1 = $Saddress1;
}
function setSaddress2( $Saddress2) {
$this->mySaddress2 = $Saddress2;
}
function setScity( $Scity) {
$this->myScity = $Scity;
}
function setSprovince( $Sprovince) {
$this->mySprovince = $Sprovince;
}
function setSpostalcode( $Spostalcode) {
$this->mySpostalcode = $Spostalcode;
}
function setScountry( $Scountry) {
$this->myScountry = $Scountry;
}
function setPhone( $Phone) {
$this->myPhone = $Phone;
}
function setFax( $Fax) {
$this->myFax = $Fax;
}
function setEmail( $Email) {
$this->myEmail = $Email;
}
function setComments( $Comments) {
$this->myComments = $Comments;
}
function setCustomerIP( $CustomerIP) {
$this->myCustomerIP = $CustomerIP;
}
/*************************
*** GET values returned by PsiGate ***
**************************
/* function getTrxnTransTime() {
return $this->myResultTrxnTransTi
}
function getTrxnOrderID() {
return $this->myResultTrxnOrderID
}
function getTrxnApproved() {
return $this->myResultTrxnApprove
}
function getTrxnReturnCode() {
return $this->myResultTrxnReturnC
}
function getTrxnErrMsg() {
return $this->myResultTrxnErrMsg;
}
function getTrxnTaxTotal() {
return $this->myResultTrxnTaxTota
}
function getTrxnShipTotal() {
return $this->myResultTrxnShipTot
}
function getTrxnSubTotal() {
return $this->myResultTrxnSubTota
}
function getTrxnFullTotal() {
return $this->myResultTrxnFullTot
}
function getTrxnPaymentType() {
return $this->myResultTrxnPayment
}
function getTrxnCardNumber() {
return $this->myResultTrxnCardNum
}
function getTrxnCardExpMonth() {
return $this->myResultTrxnCardExp
}
function getTrxnCardExpYear() {
return $this->myResultTrxnCardExp
}
function getTrxnTransRefNumber() {
return $this->myResultTrxnTransRe
}
function getTrxnCardIDResult() {
return $this->myResultTrxnCardIDR
}
function getTrxnAVSResult() {
return $this->myResultTrxnAVSResu
}
function getTrxnCardAuthNumber() {
return $this->myResultTrxnCardAut
}
function getTrxnCardRefNumber() {
return $this->myResultTrxnCardRef
}
function getTrxnCardType() {
return $this->myResultTrxnCardTyp
}
function getTrxnIPResult() {
return $this->myResultTrxnIPResul
}
function getTrxnIPCountry() {
return $this->myResultTrxnIPCount
}
function getTrxnIPRegion() {
return $this->myResultTrxnIPRegio
}
function getTrxnIPCity() {
return $this->myResultTrxnIPCity;
}
*/
// function getResultText() { return $this->myResultText; }
// function getResultProcReturnMsg() { return $this->myResultProcReturnM
function getError() {
if( $this->myError != 0 ) {
// Internal Error
return $this->myError;
} else {
if($this->myResultProcRetu
return PAYFUSE_TRANSACTION_OK;
else if($this->myResultProcRetu
return PAYFUSE_TRANSACTION_DECLIN
else
return PAYFUSE_TRANSACTION_ERROR;
}
}
function getErrorMessage() {
if( $this->myError != 0 ) {
// Internal Error
return $this->myErrorMessage;
} else {
if(!empty($this->myResultT
return $this->myResultText;
else
return $this->myResultProcReturnM
}
}
/*************************
*** Class Constructor ***
**************************
function PayfusePayment() {
}
/*************************
*** Business Logic ***
**************************
function doPayment() {
/* $xmlRequest = "<Order>".
"<StoreID>".htmlentities( $this->myStoreID )."</StoreID>".
"<Passphrase>".htmlentitie
"<Subtotal>".htmlentities(
"<PaymentType>".htmlentiti
"<CardAction>".htmlentitie
"<CardNumber>".htmlentitie
"<CardExpMonth>".htmlentit
"<CardExpYear>".htmlentiti
"<CardIDCode>".htmlentitie
"<CardIDNumber>".htmlentit
"<TestResult>".htmlentitie
"<OrderID>".htmlentities( $this->myOrderID )."</OrderID>".
"<UserID>".htmlentities( $this->myUserID )."</UserID>".
"<Bname>".htmlentities( $this->myBname )."</Bname>".
"<Bcompany>".htmlentities(
"<Baddress1>".htmlentities
"<Baddress2>".htmlentities
"<Bcity>".htmlentities( $this->myBcity )."</Bcity>".
"<Bprovince>".htmlentities
"<Bpostalcode>".htmlentiti
"<Bcountry>".htmlentities(
"<Sname>".htmlentities( $this->mySname )."</Sname>".
"<Scompany>".htmlentities(
"<Saddress1>".htmlentities
"<Saddress2>".htmlentities
"<Scity>".htmlentities( $this->myScity )."</Scity>".
"<Sprovince>".htmlentities
"<Spostalcode>".htmlentiti
"<Scountry>".htmlentities(
"<Phone>".htmlentities( $this->myPhone )."</Phone>".
"<Email>".htmlentities( $this->myEmail )."</Email>".
"<Comments>".htmlentities(
"<CustomerIP>".htmlentitie
"</Order>";*/
$xmlRequest['CLRCMRC_XML']
<EngineDocList>
<DocVersion>1.0</DocVersio
<EngineDoc>
<ContentType>OrderFormDoc<
<User>
<Name>'.htmlentities($this
<Password>'.htmlentities($
<Alias>'.htmlentities($thi
</User>
<Instructions>
<Pipeline>PaymentNoFraud</
</Instructions>
<OrderFormDoc>
<Mode>'.htmlentities($this
<Consumer>
<PaymentMech>
<CreditCard>
<Number>'.htmlentities($th
<Expires DataType="ExpirationDate" Locale="840">'.htmlentitie
<Cvv2Val>'.htmlentities($t
<Cvv2Indicator>1</Cvv2Indi
</CreditCard>
</PaymentMech>
<BillTo>
<Location>
<Address>
<Name>'.htmlentities($this
<Street1>'.htmlentities($t
<Street2>'.htmlentities($t
<City>'.htmlentities($this
<StateProv>'.htmlentities(
<PostalCode>'.htmlentities
<Country>840</Country>
<Company>'.htmlentities($t
</Address>
</Location>
</BillTo>
</Consumer>
<Transaction>
<Type>Auth</Type>
<CurrentTotals>
<Totals>
<Total DataType="Money" Currency="840">'.(int)($th
</Totals>
</CurrentTotals>
</Transaction>
</OrderFormDoc>
</EngineDoc>
</EngineDocList>';
/* Use CURL to execute XML POST and write output into a string */
$ch = curl_init( $this->myGatewayURL );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xmlRequest );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
$xmlResponse = curl_exec( $ch );
// Check whether the curl_exec worked.
if( curl_errno( $ch ) == CURLE_OK ) {
// It worked, so setup an XML parser for the result.
$this->parser = xml_parser_create();
// Disable XML tag capitalisation (Case Folding)
xml_parser_set_option ($this->parser, XML_OPTION_CASE_FOLDING, FALSE);
// Define Callback functions for XML Parsing
xml_set_object($this->pars
xml_set_element_handler ($this->parser, "ElementStart", "ElementEnd");
xml_set_character_data_han
// Parse the XML response
xml_parse($this->parser, $xmlResponse, TRUE);
if( xml_get_error_code( $this->parser ) == XML_ERROR_NONE ) {
// Get the result into local variables.
// $this->myResultTrxnTransTi
// $this->myResultTrxnOrderID
// $this->myResultTrxnApprove
// $this->myResultTrxnReturnC
// $this->myResultTrxnErrMsg = $this->xmlData['ErrMsg'];
// $this->myResultTrxnTaxTota
// $this->myResultTrxnShipTot
// $this->myResultTrxnSubTota
// $this->myResultTrxnFullTot
// $this->myResultTrxnPayment
// $this->myResultTrxnCardNum
// $this->myResultTrxnCardExp
// $this->myResultTrxnCardExp
// $this->myResultTrxnTransRe
// $this->myResultTrxnCardIDR
// $this->myResultTrxnAVSResu
// $this->myResultTrxnCardAut
// $this->myResultTrxnCardRef
// $this->myResultTrxnCardTyp
// $this->myResultTrxnIPResul
// $this->myResultTrxnIPCount
// $this->myResultTrxnIPRegio
// $this->myResultTrxnIPCity = $this->xmlData['IPCity'];
$this->myResultText = $this->xmlData['Text'];
$this->myResultProcReturnM
$this->myError = 0;
$this->myErrorMessage = '';
} else {
// An XML error occured. Return the error message and number.
$this->myError = xml_get_error_code( $this->parser ) + PAYFUSE_ERROR_OFFSET;
$this->myErrorMessage = xml_error_string( $myError );
}
// Clean up our XML parser
xml_parser_free( $this->parser );
} else {
// A CURL Error occured. Return the error message and number. (offset so we can pick the error apart)
$this->myError = curl_errno( $ch ) + PAYFUSE_CURL_ERROR_OFFSET;
$this->myErrorMessage = curl_error( $ch );
}
// Clean up CURL, and return any error.
curl_close( $ch );
/*************************
*** Optional commented-out Debug. Dont mess with it. ***
**************************
//echo $xmlRequest['CLRCMRC_XML']
//echo $xmlResponse."\n\n\n";
//echo $this->myResultText."\n\n\
//echo $this->myResultProcReturnM
//exit();
return $this->getError();
}
}
?>
Do you have any idea at all which function is failing?
I understand you aren't getting any error message,
but you have to narrow it down some more.
If you can reproduce the error, then you should
trace through the process and add var_dump
commands to each function. Assuming you aren't
using Zend Studio, in which case you can set
break points.
Make note of which functions seem to complete
successfully and which one does not. Then
see what data is in the variables for that failing
function.
Hopefully, this gives you some insight on
troubleshooting you're issue.
--brian
I understand you aren't getting any error message,
but you have to narrow it down some more.
If you can reproduce the error, then you should
trace through the process and add var_dump
commands to each function. Assuming you aren't
using Zend Studio, in which case you can set
break points.
Make note of which functions seem to complete
successfully and which one does not. Then
see what data is in the variables for that failing
function.
Hopefully, this gives you some insight on
troubleshooting you're issue.
--brian
ASKER
I can tell you this is the redirect lines that is causing it....
//if ($pf_xml_error) {
// tep_redirect(tep_href_link (FILENAME_ CHECKOUT_P AYMENT, 'error_message=' . $result . ' - ' . urlencode(MODULE_PAYMENT_P AYFUSE_TEX T_DECLINED _MESSAGE), 'SSL', true, false));
// tep_redirect(tep_href_link (FILENAME_ CHECKOUT_P AYMENT, 'error_message=' . $Pf_ErrMsg . ' - ' . urlencode(MODULE_PAYMENT_P AYFUSE_TEX T_DECLINED _MESSAGE), 'SSL', true, false));
//}
However I am not sure of the error that is being caused. When I comment these lines out all goes well. Otherwise it seems to fail 100% of the time, even thought the funds are changing hands sucessfully. If I check the variable $pf_xml_error it evalutes to 1. So we need to trap out the error number one????
I have no idea....unfortunatly I am not a PHP coder, I am jsut trying to make this work before I head from this company. Thanks for your help so far!
//if ($pf_xml_error) {
// tep_redirect(tep_href_link
// tep_redirect(tep_href_link
//}
However I am not sure of the error that is being caused. When I comment these lines out all goes well. Otherwise it seems to fail 100% of the time, even thought the funds are changing hands sucessfully. If I check the variable $pf_xml_error it evalutes to 1. So we need to trap out the error number one????
I have no idea....unfortunatly I am not a PHP coder, I am jsut trying to make this work before I head from this company. Thanks for your help so far!
This is where $pf_xml_error is set:
$pf_xml_error = ($pf->doPayment() != PAYFUSE_TRANSACTION_OK);
If doPayment()'s output does not match the value of PAYFUSE_TRANSACTION_OK,
then $pf_xml_error should equal 1 (effectively boolean True). If they do equal,
it should set $pf_xml_error to 0 (boolean false and basically NULL in PHP).
The doPayment() function will return one of three constants:
PAYFUSE_TRANSACTION_OK;
PAYFUSE_TRANSACTION_DECLIN ED;
PAYFUSE_TRANSACTION_ERROR;
Since the payment goes through, my guess is that you are not returning DECLINED.
So, that leaves ERROR. The trick now it to get the error to show itself.
In the class.payfuse.php file I would look at the doPayment() function near the bottom:
$this->myErrorMessage = xml_error_string( $myError );
}
// Clean up our XML parser
xml_parser_free( $this->parser );
} else {
// A CURL Error occured. Return the error message and number. (offset so we can pick the error apart)
$this->myError = curl_errno( $ch ) + PAYFUSE_CURL_ERROR_OFFSET;
$this->myErrorMessage = curl_error( $ch );
After each $this->myErrorMessage is set, I would probably var_dump($this->myErrorMes sage)
to see what is going on. You may have to pipe them out to a file instead, but that is the place
where I think the error must be. If you can read it, maybe it will help you fix this thing.
--brian
$pf_xml_error = ($pf->doPayment() != PAYFUSE_TRANSACTION_OK);
If doPayment()'s output does not match the value of PAYFUSE_TRANSACTION_OK,
then $pf_xml_error should equal 1 (effectively boolean True). If they do equal,
it should set $pf_xml_error to 0 (boolean false and basically NULL in PHP).
The doPayment() function will return one of three constants:
PAYFUSE_TRANSACTION_OK;
PAYFUSE_TRANSACTION_DECLIN
PAYFUSE_TRANSACTION_ERROR;
Since the payment goes through, my guess is that you are not returning DECLINED.
So, that leaves ERROR. The trick now it to get the error to show itself.
In the class.payfuse.php file I would look at the doPayment() function near the bottom:
$this->myErrorMessage = xml_error_string( $myError );
}
// Clean up our XML parser
xml_parser_free( $this->parser );
} else {
// A CURL Error occured. Return the error message and number. (offset so we can pick the error apart)
$this->myError = curl_errno( $ch ) + PAYFUSE_CURL_ERROR_OFFSET;
$this->myErrorMessage = curl_error( $ch );
After each $this->myErrorMessage is set, I would probably var_dump($this->myErrorMes
to see what is going on. You may have to pipe them out to a file instead, but that is the place
where I think the error must be. If you can read it, maybe it will help you fix this thing.
--brian
ASKER
I added the following code after each one at a time, replacing the var, and the text file always stayed blank.
$your_data = var_dump($this->myError);
// Open the file and erase the contents if any
$fp = fopen("error_log.txt", "w");
// Write the data to the file
fwrite($fp, $your_data);
// Close the file
fclose($fp);
Maybe I am doing ti wrong.
$your_data = var_dump($this->myError);
// Open the file and erase the contents if any
$fp = fopen("error_log.txt", "w");
// Write the data to the file
fwrite($fp, $your_data);
// Close the file
fclose($fp);
Maybe I am doing ti wrong.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$HTTP_GET_VARS
$HTTP_SERVER_VARS
$HTTP_POST_VARS
The new versions of these:
$_GET
$_SERVER
$_POST
They are superglobals and do not need to be made global. Don't change your code. Maybe your php is not the most current version, just thought I should mention it.