[Improved logging of failed CC transactions Adrian Georgescu **20091129235445] hunk ./library/cc_processor.php 810 - function displayProcessErrors($arr_errors){ + function displayProcessErrors($error=array()){ hunk ./library/cc_processor.php 813 + $page_body_content .= "

"._("Error")."

"; + hunk ./library/cc_processor.php 816 - $page_body_content .= ""._("Error").":\n"; - foreach($arr_errors as $arr_error => $error_desc){ - $page_body_content .= "".$error_desc['field'].":".$error_desc['desc']."\n"; - } - $page_body_content .= ""._("Go Back").", "._("correct the errors and re-submit. ")."\n"; + $page_body_content .= sprintf("Error code:%s\n",$error['error_code']); + $page_body_content .= sprintf("Description:%s\n",$error['short_message']); + $page_body_content .= sprintf("%s\n",$error['desc']); + hunk ./library/cc_processor.php 821 + $page_body_content .= "

"._("Go Back").", "._("correct the errors and re-submit. ")."\n"; + hunk ./library/cc_processor.php 965 - $pp_return = array('success'=>array('field'=>'Card Processing','desc'=>$response)); + $pp_return = array('success'=>array('field'=>'Card Processing', + 'desc'=>$response) + ); hunk ./library/cc_processor.php 969 - $pp_return = array('error'=>array('field'=>'Card Processing','desc'=>$response->Errors->LongMessage)); - $this->logger->_log("Response Error: ".$response->Errors->LongMessage.""); + $pp_return = array('error'=>array('field' => 'Card Processing', + 'desc' => $response->Errors->LongMessage, + 'short_message' => $response->Errors->ShortMessage, + 'error_code' => $response->Errors->ErrorCode, + 'correlation_id' => $response->CorrelationID + ) + ); + + $log=sprintf("Error: %s (%s) %s, correlation id %s", + $response->Errors->ShortMessage, + $response->Errors->ErrorCode, + $response->Errors->LongMessage, + $response->CorrelationID + ); + $this->logger->_log($log); hunk ./library/sip_settings.php 7919 - if ($this->fraudDetected()) { + if ($this->fraudDetected(&$account)) { hunk ./library/sip_settings.php 8051 - print $CardProcessor->displayProcessErrors($pay_process_results); + print $CardProcessor->displayProcessErrors($pay_process_results['error']); hunk ./library/sip_settings.php 8057 - $log=sprintf("Error: SIP Account %s - CC transaction failed to process (%s) in %d seconds",$account->account,$pay_process_results['error']['desc'],$d); + $log=sprintf("Error, CC transaction failed for %s: %s (%s) after %d seconds", + $account->account, + $pay_process_results['error']['short_message'], + $pay_process_results['error']['error_code'], + $d + ); + hunk ./library/sip_settings.php 8072 - $log=sprintf("SIP Account %s - CC transaction %s completed succesfully in %d seconds", $account->account, $pay_process_results['success']['desc']->TransactionID,$d); + $log=sprintf("CC transaction for %s %s completed succesfully in %d seconds", + $account->account, + $pay_process_results['success']['desc']->TransactionID, + $d + ); hunk ./library/sip_settings.php 8141 - function fraudDetected () { + function fraudDetected ($account) { hunk ./library/sip_settings.php 8148 + hunk ./library/sip_settings.php 8151 - if ($_loc=geoip_record_by_name($this->Preferences['ip'])) { + if ($_loc=geoip_record_by_name($account->Preferences['ip'])) { hunk ./library/sip_settings.php 8160 - if ($_loc=geoip_record_by_name($this->Preferences['ip'])) { + if ($_loc=geoip_record_by_name($account->Preferences['ip'])) {