<?  logger("



################################################################################
################################################################################
### NEW FILE:  [/BANGK!/shared/process_sepa_pavision+bs.shared]  .................................


");
################################################################################
################################################################################
################################################################################




################################################################################################
### GET & SET API VARS:
$_SESSION['gateway']['processor']['service'] = $processor_shared_api_service;  // ("RETRY" or "STANDARD")
$_SESSION['gateway']['processor']['business_account_number'] = $_SESSION['payme']['business']['account']['accountid'];
$_SESSION['gateway']['processor']['gateway_name'] = $processor_shared_api_gateway_name;
if($processor_shared_api_gateway_action) {  // ("Payment", "Authorize", "Capture", "Void", "Refund") -- specific to processor (i.e., PAYVISION)
	$_SESSION['gateway']['processor']['gateway_action'] = $processor_shared_api_gateway_action;
} else {
	$_SESSION['gateway']['processor']['gateway_action'] = "Payment"; // default / straight-through
}
$_SESSION['gateway']['processor']['customer_ip'] = $processor_shared_api_customer_ip;
$_SESSION['gateway']['processor']['amount'] = $_SESSION['payme']['currency']['base']['amount'];
$_SESSION['gateway']['processor']['transactionId'] = $processor_shared_api_transactionId;
$_SESSION['gateway']['processor']['transactionGuid'] = $processor_shared_api_transactionGuid;
/*
$_SESSION['gateway']['processor'][''] = "";
*/



### SET COMMON VARS:
$_SESSION['gateway']['processor']['geobytes'] = geobytes($_SESSION['gateway']['processor']['customer_ip']);
$_SESSION['gateway']['processor']['business']['account'] = account($_SESSION['gateway']['processor']['business_account_number']);

$_SESSION['gateway']['processor']['bank_account']['country'] 			= $_SESSION['payme']['customer']['bank_account']['country'];
$_SESSION['gateway']['processor']['bank_account']['country_text'] 		= $_SESSION['payme']['customer']['bank_account']['country_text'];
$_SESSION['gateway']['processor']['bank_account']['bank_name'] 			= $_SESSION['payme']['customer']['bank_account']['bank_name'];
$_SESSION['gateway']['processor']['bank_account']['account_number'] 	= $_SESSION['payme']['customer']['bank_account']['account_number'];
$_SESSION['gateway']['processor']['bank_account']['routing_number'] 	= $_SESSION['payme']['customer']['bank_account']['routing_number'];
$_SESSION['gateway']['processor']['bank_account']['iban'] 				= $_SESSION['payme']['customer']['bank_account']['iban'];
$_SESSION['gateway']['processor']['bank_account']['bic'] 				= $_SESSION['payme']['customer']['bank_account']['bic'];
$_SESSION['gateway']['processor']['bank_account']['city'] 				= $_SESSION['payme']['customer']['bank_account']['mailing_city'];
$_SESSION['gateway']['processor']['bank_account']['first_name'] 		= $_SESSION['payme']['customer']['bank_account']['bank_first_name'];
$_SESSION['gateway']['processor']['bank_account']['last_name']			= $_SESSION['payme']['customer']['bank_account']['bank_last_name'];
$_SESSION['gateway']['processor']['bank_account']['street'] 			= $_SESSION['payme']['customer']['bank_account']['mailing_street_1'] ."; " . $_SESSION['payme']['customer']['bank_account']['mailing_street_2'];
$_SESSION['gateway']['processor']['bank_account']['zip'] 				= $_SESSION['payme']['customer']['bank_account']['mailing_postal_code'];
$_SESSION['gateway']['processor']['bank_account']['city_address'] 		= $_SESSION['payme']['customer']['bank_account']['mailing_city'];
$_SESSION['gateway']['processor']['bank_account']['email_address'] 		= $_SESSION['payme']['customer']['member']['emailaddress']; 

/// SET LEGACY VAR: "HOLDER"  (maybe not necessary)
$_SESSION['payme']['customer']['bank_account']['holder'] = $_SESSION['payme']['customer']['bank_account']['bank_first_name'] . " " . $_SESSION['payme']['customer']['bank_account']['bank_last_name'];
$_SESSION['gateway']['processor']['bank_account']['holder'] = $_SESSION['payme']['customer']['bank_account']['holder'];


logger("gateway['processor']['business_account_number']: " . $_SESSION['gateway']['processor']['business_account_number']);
logger("gateway['processor']['business_account']: "); logger($_SESSION['gateway']['processor']['business_account']);



################################################################################################
### SET PREFERENCES:

## SEPA PREFERENCES:


### PROCESSING FACILITIES:
if(strtoupper($master_config_type) == "LIVE") {
	$sepa_url 					= "https://clearing.webbilling.com:8080/init?request=";
	$sepa_merchant_id 			= "nsdb";
	$sepa_merchant_password 	= "x44dg";
} else {
	$sepa_url 					= "http://testclearing.eupay.BillingPartner.com:8080/init?request=";
	$sepa_merchant_id 			= "nsdb";
	$sepa_merchant_password 	= "tgkag";
}

/// postal code
$prepared_postalcode = $input_transaction['process_sepa']['bank_account']['zip'];
//$prepared_postalcode = str_replace(" ", "", $prepared_postalcode); //$_SESSION['gateway']['processor']['bank_account']['zip']; 	
//$prepared_postalcode = ereg_replace("[^A-Za-z0-9]", "", $prepared_postalcode);

$sepa_new_url				= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=new';
$sepa_success_url			= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=success';
$sepa_error_url				= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=error';
$sepa_chargeback_url		= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=chargeback';
$sepa_reversal_url			= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=reversal';
$sepa_refund_url			= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=refund';
$sepa_credit_url			= $http . $_SESSION['template']['company']['host_gateway'] . '/sepa_callback.gate?action=credit';
$sepa_domain				= $http . $_SESSION['template']['company']['domain'];
$sepa_profile_id 			= "default";
$sepa_language				= "en";
$sepa_account_number 		= $input_transaction['process_sepa']['bank_account']['account_number']; //$_SESSION['gateway']['processor']['bank_account']['account_number'];
$sepa_routing_number 		= $input_transaction['process_sepa']['bank_account']['routing_number']; //$_SESSION['gateway']['processor']['bank_account']['routing_number'];
$sepa_holder				= $input_transaction['process_sepa']['bank_account']['holder']; //$_SESSION['gateway']['processor']['bank_account']['holder'];
$sepa_bank_name 			= $input_transaction['process_sepa']['bank_account']['bank_name']; //$_SESSION['gateway']['processor']['bank_account']['bank_name'];
$sepa_bank_country			= $input_transaction['process_sepa']['bank_account']['country']; //$_SESSION['gateway']['processor']['bank_account']['country'];
$sepa_iban					= $input_transaction['process_sepa']['bank_account']['iban']; //$_SESSION['gateway']['processor']['bank_account']['iban'];
$sepa_bic					= $input_transaction['process_sepa']['bank_account']['bic']; //$_SESSION['gateway']['processor']['bank_account']['bic'];
$sepa_city					= $input_transaction['process_sepa']['bank_account']['city']; //$_SESSION['gateway']['processor']['bank_account']['city'];
$sepa_first_name			= $input_transaction['process_sepa']['bank_account']['first_name']; //$_SESSION['gateway']['processor']['bank_account']['first_name']; 	
$sepa_last_name				= $input_transaction['process_sepa']['bank_account']['last_name']; //$_SESSION['gateway']['processor']['bank_account']['last_name'];		
$sepa_street				= $input_transaction['process_sepa']['bank_account']['street']; //$_SESSION['gateway']['processor']['bank_account']['street']; 		
$sepa_zip					= $prepared_postalcode;
$sepa_city_address			= $input_transaction['process_sepa']['bank_account']['city_address']; //$_SESSION['gateway']['processor']['bank_account']['city_address']; 
$sepa_country_address		= $input_transaction['process_sepa']['bank_account']['country']; //$_SESSION['gateway']['processor']['bank_account']['country'];
$sepa_email_address			= "webbilling_receipts@nsdb.com"; //$_SESSION['gateway']['processor']['bank_account']['email_address'];
$sepa_amount				= $input_transaction['process_sepa']['currency']['base']['total']; //$_SESSION['payme']['currency']['base']['amount'];
$sepa_currency 				= $_SESSION['payme']['currency']['base']['code'];
$sepa_tadescriptor			= $_SESSION['payme']['business']['account']['accountname'];

################################################################################################
### LOG PREFERNCES:


logger3("sepa_url",$sepa_url);
logger3("sepa_new_url",$sepa_new_url);
logger3("sepa_success_url",$sepa_success_url);
logger3("sepa_error_url",$sepa_error_url);
logger3("sepa_chargeback_url",$sepa_chargeback_url);
logger3("sepa_reversal_url",$sepa_reversal_url);
logger3("sepa_refund_url",$sepa_refund_url);
logger3("sepa_credit_url",$sepa_credit_url);
logger3("sepa_domain",$sepa_domain);
logger3("sepa_merchant_id",$sepa_merchant_id);
logger3("sepa_merchant_password",$sepa_merchant_password);
logger3("sepa_profile_id",$sepa_profile_id);
logger3("sepa_language",$sepa_language);
logger3("sepa_account_number",$sepa_account_number);
logger3("sepa_routing_number",$sepa_routing_number);
logger3("sepa_holder",$sepa_holder);
logger3("sepa_bank_name",$sepa_bank_name);
logger3("sepa_country",$sepa_country);
logger3("sepa_iban",$sepa_iban);
logger3("sepa_bic",$sepa_bic);
logger3("sepa_city",$sepa_city);
logger3("sepa_first_name",$sepa_first_name );	
logger3("sepa_last_name",$sepa_last_name);		
logger3("sepa_street",$sepa_street);
logger3("sepa_zip",$sepa_zip); 			
logger3("sepa_city_address",$sepa_city_address);
logger3("sepa_email_address",$sepa_email_address);
logger3("sepa_amount",$sepa_amount);
logger3("sepa_currency",$sepa_currency);
logger3("sepa_tadescriptor",$sepa_tadescriptor);


################################################################################################
### PREPARE SEPA PARAMETERS

/// FINAL, PRE-XML ADJUSTMENS:

if($sepa_bank_country == "GB") $sepa_bank_country = "UK";
if($sepa_country == "NL") {
	$sepa_bank_name = "other";
	if( (stristr($sepa_bank_name, "post")) || (stristr($sepa_bank_name, "pb")) ) $sepa_bank_name = "Postbank";
}


## START XML

$xml 				= new SimpleXMLElement('<Transaction/>');
$xml_request 		= $xml->addChild('Request');

## MERCHANT
$xml_merchant 		= $xml_request->addChild('Merchant');
$xml_merchant->addChild('MerchantID', $sepa_merchant_id);
$xml_merchant->addChild('Password', $sepa_merchant_password);
$xml_merchant->addChild('ProfileID', $sepa_profile_id);

## LANGUAGE
$xml_language 		= $xml_request->addChild('Language', $sepa_language);

## DIRECT DEBIT
$xml_directdebit	= $xml_request->addChild('DirectDebitData');

if($sepa_country=="NL") {
	$xml_directdebit->addChild('BankAccountNumber', $sepa_account_number);
	$xml_directdebit->addChild('BankName', $sepa_bank_name);
	$xml_directdebit->addChild('BankAccountOwner', $sepa_holder);
	$xml_directdebit->addChild('CountryID', $sepa_bank_country);
	$xml_directdebit->addChild('City', $sepa_city);
} else {
	if($sepa_account_number) 	$xml_directdebit->addChild('BankAccountNumber', $sepa_account_number);
	if($sepa_iban) 				$xml_directdebit->addChild('IBAN', $sepa_iban);
	if($sepa_bic) 				$xml_directdebit->addChild('BIC', $sepa_bic);
	if($sepa_routing_number) 	$xml_directdebit->addChild('BankRoutingNumber', $sepa_routing_number);
	if($sepa_holder) 		 	$xml_directdebit->addChild('BankAccountOwner', $sepa_holder);
	if($sepa_bank_country) 		 	$xml_directdebit->addChild('CountryID', $sepa_bank_country);
}




## ADDRESS DATA
$xml_address		= $xml_request->addChild('AddressData');
$xml_address->addChild('FirstName', $sepa_first_name);
$xml_address->addChild('LastName', $sepa_last_name);
$xml_address->addChild('Street', $sepa_street);
$xml_address->addChild('ZIP', $sepa_zip);
$xml_address->addChild('City', $sepa_city_address);
$xml_address->addChild('CountryID', $sepa_country_address);

## PIN CALL
$xml_pincall		= $xml_request->addChild('PinCallData');
$xml_pincall->addChild('Language', $sepa_language);
$xml_pincall->addChild('Length', 5);
$xml_pincall->addChild('PhoneNumber', '+49000000');

## EMAIL
$xml_email			= $xml_request->addChild('EmailData');
$xml_email->addChild('EmailAddress', $sepa_email_address);

## PAYMENT
$xml_payment		= $xml_request->addChild('Payment');
$xml_payment->addAttribute('type', 'single');
$xml_payment->addChild('Amount', $sepa_amount);
$xml_payment->addChild('Currency', $sepa_currency);
$xml_payment->addChild('TADescriptor', $sepa_tadescriptor);

$xml_on_new = $xml_payment->addChild('NotificationURL', $sepa_new_url);
$xml_on_new->addAttribute('signal', 'onNew');
$xml_on_success = $xml_payment->addChild('NotificationURL', $sepa_success_url);
$xml_on_success->addAttribute('signal', 'onSuccess');
$xml_on_error = $xml_payment->addChild('NotificationURL', $sepa_error_url);
$xml_on_error->addAttribute('signal', 'onError');
$xml_on_chargeback = $xml_payment->addChild('NotificationURL', $sepa_chargeback_url);
$xml_on_chargeback->addAttribute('signal', 'onChargeBack');
$xml_on_reversal = $xml_payment->addChild('NotificationURL', $sepa_reversal_url);
$xml_on_reversal->addAttribute('signal', 'onReversal');
$xml_on_refund = $xml_payment->addChild('NotificationURL', $sepa_refund_url);
$xml_on_refund->addAttribute('signal', 'onRefund');
$xml_on_credit = $xml_payment->addChild('NotificationURL', $sepa_credit_url);
$xml_on_credit->addAttribute('signal', 'onCredit');

## DOMAIN
$xml_domain			= $xml_request->addChild('Domain', $sepa_domain);

$_SESSION['gateway']['processor']['sepa']['parameters'] = $xml->asXML();
logger3("_SESSION['gateway']['processor']['sepa']['parameters']",$_SESSION['gateway']['processor']['sepa']['parameters']);



### CURL IT ###
$processor_parameters = $_SESSION['gateway']['processor']['sepa']['parameters'];
logger("sepa_url: " . $sepa_url);
logger("sepa_parameters: " . $processor_parameters);


$tmp_encoded_parameters = urlencode($processor_parameters);
$_SESSION['gateway']['processor']['sepa']['response']['raw'] = simpleCURLER($sepa_url, $tmp_encoded_parameters);

logger("


#############  KURL RESULTS FROM SEPA:


" . $_SESSION['gateway']['processor']['sepa']['response']['raw']);


#####  EXTRACT XML:


logger3("_SESSION['gateway']['processor']['sepa']['response']['raw']",$_SESSION['gateway']['processor']['sepa']['response']['raw']);
$tmp_translation_of_xml_results = (array) simplexml_load_string($_SESSION['gateway']['processor']['sepa']['response']['raw']);
logger3("1. tmp_translation_of_xml_results",$tmp_translation_of_xml_results);
$tmp_translation_of_xml_results = (array) $tmp_translation_of_xml_results['Response'];
logger3("2. tmp_translation_of_xml_results",$tmp_translation_of_xml_results);
$_SESSION['gateway']['processor']['sepa']['response']['array'] = $tmp_translation_of_xml_results;
logger3("** _SESSION['gateway']['processor']['sepa']['response']['array']",$_SESSION['gateway']['processor']['sepa']['response']['array']);


$_SESSION['gateway']['processor']['sepa']['response']['transaction_id'] = $tmp_translation_of_xml_results['TransactionID'];
$_SESSION['gateway']['processor']['sepa']['response']['status'] = $tmp_translation_of_xml_results['Status'];
$_SESSION['gateway']['processor']['sepa']['response']['error_text'] = $tmp_translation_of_xml_results['ErrorText'];


## LOG ['RESPONSE']
logger3("_SESSION['gateway']['processor']['sepa']['response']",$_SESSION['gateway']['processor']['sepa']['response']);



#
#
#
#
#  end basic payvision transaction
#
#
####################################################################################
####################################################################################








####################################################################################
####################################################################################
### SET/UPDATE $_SESSION['transaction'][] SESSION VARS:
####################################################################################
####################################################################################



####################################################################################
/// LINK RESULTS:
$_SESSION['transaction']['process_webilling']['results'] = $_SESSION['gateway']['processor']['sepa']['response']['array'];
$_SESSION['transaction']['process_webbilling']['raw'] = $_SESSION['transaction']['process_payvision']['raw'] = $_SESSION['gateway']['processor']['sepa']['response']['raw'];

logger3("** _SESSION['transaction']['process_webilling']['results']",$_SESSION['transaction']['process_webilling']['results']);
logger3("** _SESSION['transaction']['process_webbilling']['raw']",$_SESSION['transaction']['process_webbilling']['raw']);

####################################################################################


/// bank specific
$_SESSION['transaction']['process_payvision']['gateway'] = $_SESSION['transaction']['process_payvision']['results'];
$_SESSION['transaction']['process_payvision']['sepa']['status'] = $_SESSION['gateway']['processor']['sepa']['response']['status'];
$_SESSION['transaction']['process_payvision']['sepa']['message'] = $_SESSION['gateway']['processor']['sepa']['response']['error_text'];
$_SESSION['transaction']['process_payvision']['sepa']['transaction_id'] = $_SESSION['gateway']['processor']['sepa']['response']['transaction_id'];
logger("transaction['process_payvision']['sepa']..."); logger($_SESSION['transaction']['process_payvision']['sepa']);


/// response
#####	0: OK - The transaction has been successful.
#####   1: Pending - The outcome of the transaction can't be determined at this time.
#####   3: UserActionAwaited - We have all data of the user but there is no payment.
$success_code = array(0,1,3);
logger3("success_code",$success_code);
logger3("_SESSION['transaction']['process_payvision']['sepa']['status']",$_SESSION['transaction']['process_payvision']['sepa']['status']);
	
if(in_array($_SESSION['transaction']['process_payvision']['sepa']['status'], $success_code)) {
	$_SESSION['transaction']['response'] = "APPROVED";	
} else {
	$_SESSION['transaction']['response'] = "FAILED";
}

/// message
if($_SESSION['transaction']['process_payvision']['sepa']['message']) {
	$_SESSION['transaction']['message'] = $_SESSION['transaction']['process_payvision']['sepa']['message'];
} else {
	$_SESSION['transaction']['message'] = NULL;
}


logger3("transaction['response']", $_SESSION['transaction']['response']);
logger3("transaction['message']: ",$_SESSION['transaction']['message']);







####################################################################################
####################################################################################
### SET/UPDATE $_SESSION['gateway'][] SESSION VARS:
####################################################################################
####################################################################################


####################################################################################
/// link results:
$_SESSION['gateway']['processor']['response']['array'] =  $_SESSION['gateway']['processor']['sepa']['response']['array'];
$_SESSION['gateway']['processor']['response']['raw'] = $_SESSION['gateway']['processor']['sepa']['response']['raw'];

logger3("gateway['processor']['response']['array']...",$_SESSION['gateway']['processor']['response']['array']);
logger3("gateway['processor']['response']['raw']...",$_SESSION['gateway']['processor']['response']['raw']);

####################################################################################




### set final result value
if(in_array($_SESSION['gateway']['processor']['response']['array']['Status'], $success_code)) {
	if($_SESSION['gateway']['processor']['gateway_action'] == "Authorize") {
		$_SESSION['gateway']['processor']['response']['result'] = "AUTHORIZED";
	
	} else if($_SESSION['gateway']['processor']['gateway_action'] == "Capture") {
		$_SESSION['gateway']['processor']['response']['result'] = "CAPTURED";
	
	} else if($_SESSION['gateway']['processor']['gateway_action'] == "Payment") {
		$_SESSION['gateway']['processor']['response']['result'] = "APPROVED";
	
	} else {
		$_SESSION['gateway']['processor']['response']['result'] = NULL;
	}
	
} else {
	$_SESSION['gateway']['processor']['response']['result'] = "DECLINED";
}

### LOG TO DB:

$tmp_business_id = $_SESSION['payme']['business']['account']['accountid'];


$translog_translogid = "";
$translog_gatewayid = $_SESSION['gateway']['gatewayid'];
$translog_hash = make_hash("SHA1");
$translog_service = $_SESSION['gateway']['processor']['service'];
$translog_action = $_SESSION['gateway']['processor']['gateway_action'];
$translog_business_accountid = $_SESSION['payme']['business']['account']['accountid'];
$translog_business_account_number = $_SESSION['payme']['business']['account']['hash'];
$translog_memberid = $_SESSION['member']['memberid'];
$translog_accountid = $_SESSION['account']['accountid'];
$translog_acquirer = $_SESSION['gateway']['processor']['gateway_name'];
$translog_amount = currency_format($sepa_amount,null);
$translog_type = "SEPA";
$translog_name = $sepa_holder;
$translog_number = "";
$translog_credit_card_number = "";
$translog_expdate = "";
$translog_expiration_month = "";
$translog_expiration_year = "";
$translog_streetaddress1 = "";
$translog_streetaddress2 = "";
$translog_city = $_SESSION['gateway']['processor']['geobytes']['city'];
$translog_region = $_SESSION['gateway']['processor']['geobytes']['region'];
$translog_country = $_SESSION['gateway']['processor']['geobytes']['country'];
$translog_postalcode = "";
$translog_phone = "";
$translog_cvv2 = "";
$translog_iswipe = "";
$translog_ordernumber = "";
$translog_response_raw = serialize($_SESSION['transaction']['process_webbilling']['raw']);
$translog_response = serialize($_SESSION['transaction']['process_webilling']['results']);
$translog_result = $_SESSION['gateway']['processor']['response']['result'];
$translog_status =  $_SESSION['gateway']['processor']['response']['array']['Status'];
$translog_message = $_SESSION['transaction']['message'];
$translog_maxmind_response = "";
$translog_maxmind_result = "";
$translog_payvision_transactionId = $_SESSION['gateway']['processor']['response']['array']['TransactionID'];
$translog_payvision_transactionGuid = "";
$translog_error = "";
$translog_avs = "";
$translog_code = "";
$translog_note = "";
$translog_datetime_created = datetime();
$translog_datetime_updated = datetime();
$translog_UID = "";
$translog_sepa_country = $sepa_country;
$translog_sepa_bank_name = $sepa_bank_name;
$translog_sepa_account_number = $sepa_account_number;
$translog_sepa_routing_number = $sepa_routing_number;
$translog_sepa_iban = $sepa_iban;
$translog_sepa_bic = $sepa_bic;
$translog_sepa_bank_city = $sepa_city;
$translog_sepa_firstname = $sepa_first_name;
$translog_sepa_lastname = $sepa_last_name;
$translog_sepa_street = $sepa_street;
$translog_sepa_zip = $sepa_zip;
$translog_sepa_city = $sepa_city_address;



$tmp_sql = "INSERT INTO translog 
	(`translogid`,
	`gatewayid`,
	`hash`,
	`service`,
	`action`,
	`business_accountid`,
	`business_account_number`,
	`memberid`, 
	`accountid`, 
	`acquirer`, 
	`amount`, 
	`type`, 
	`name`, 
	`number`,
	`credit_card_number`,
	`expdate`, 
	`expiration_month`,
	`expiration_year`,
	`streetaddress1`, 
	`streetaddress2`, 
	`city`, 
	`region`, 
	`country`, 
	`postalcode`, 
	`phone`, 
	`cvv2`, 
	`iswipe`, 
	`ordernumber`, 
	`response_raw`,
	`response`, 
	`result`,
	`status`,
	`message`,
	`maxmind_response`,
	`maxmind_result`,
	`payvision_transactionId`,
	`payvision_transactionGuid`,
	`error`, 
	`avs`, 
	`code`, 
	`note`, 
	`datetime_created`, 
	`datetime_updated`, 
	`UID`,
	`sepa_country`, 
	`sepa_bank_name`, 
	`sepa_account_number`, 
	`sepa_routing_number`, 
	`sepa_iban`, 
	`sepa_bic`, 
	`sepa_bank_city`, 
	`sepa_firstname`, 
	`sepa_lastname`, 
	`sepa_street`, 
	`sepa_zip`, 
	`sepa_city`) 
VALUES 
	('" . $translog_translogid . "', 
	'" . $translog_gatewayid . "',
	'" . $translog_hash . "', 
	'" . $translog_service . "', 
	'" . $translog_action . "', 
	'" . $translog_business_accountid . "', 
	'" . $translog_business_account_number . "',
	'" . $translog_memberid . "', 
	'" . $translog_accountid . "', 
	'" . $translog_acquirer . "', 
	'" . $translog_amount . "', 
	'" . $translog_type . "', 
	'" . $translog_name . "', 
	'" . $translog_number . "', 
	'" . $translog_credit_card_number . "',
	'" . $translog_expdate . "', 
	'" . $translog_expiration_month . "',
	'" . $translog_expiration_year . "',
	'" . $translog_streetaddress1 . "', 
	'" . $translog_streetaddress2 . "', 
	'" . $translog_city . "', 
	'" . $translog_region . "', 
	'" . $translog_country . "', 
	'" . $translog_postalcode . "', 
	'" . $translog_phone . "', 
	'" . $translog_cvv2 . "', 
	'" . $translog_iswipe . "', 
	'" . $translog_ordernumber . "', 
	'" . $translog_response_raw . "',
	'" . $translog_response . "', 
	'" . $translog_result . "',
	'" . $translog_status . "',
	'" . $translog_message . "', 
	'" . $translog_maxmind_response . "',
	'" . $translog_maxmind_result . "',
	'" . $translog_payvision_transactionId . "',
	'" . $translog_payvision_transactionGuid . "',
	'" . $translog_error . "', 
	'" . $translog_avs . "', 
	'" . $translog_code . "', 
	'" . $translog_note . "', 
	'" . $translog_datetime_created . "', 
	'" . $translog_datetime_updated . "', 
	'" . $translog_UID . "',
	'" . $translog_sepa_country . "',
	'" . $translog_sepa_bank_name . "',
	'" . $translog_sepa_account_number . "',
	'" . $translog_sepa_routing_number . "',
	'" . $translog_sepa_iban . "',
	'" . $translog_sepa_bic . "',
	'" . $translog_sepa_bank_city . "',
	'" . $translog_sepa_firstname . "',
	'" . $translog_sepa_lastname . "',
	'" . $translog_sepa_street . "',
	'" . $translog_sepa_zip . "',
	'" . $translog_sepa_city . "') ;";

$_SESSION['gateway']['processor']['translogid'] = insertTHECASHIER($tmp_sql);
logger("tmp_sql: " . $tmp_sql);
logger("gateway['processor']['translogid']: " . $_SESSION['gateway']['processor']['translogid']);

/// SET DATETIME OF TRANSACTION
/// referenced in transaction responses/updates to the business
$_SESSION['gateway']['processor']['datetime'] = $translog_datetime_updated;


/// update gateway record
if($_SESSION['gateway']['gatewayid']) {

	$tmp_sql = "UPDATE gateway SET session_status = 'AUTHORIZED', datetime_updated = '" . $translog_datetime_updated . "' WHERE gatewayid = '" . $_SESSION['gateway']['gatewayid'] . "';";
	updateTHECASHIER($tmp_sql);
}

?>