[Improved CC transaction logging Adrian Georgescu **20110918100033 Ignore-this: 6d6e7f722971b2d42b959b71ffb32ed3 ] hunk ./library/cc_processor.php 311 - $this->logger = new cc_logger('CreditCardProcessor', PEAR_LOG_DEBUG); + $this->logger = new cc_logger('CreditCardProcessor', PEAR_LOG_INFO); hunk ./library/cc_processor.php 428 - $this->logger->_log("Set submit action to ".$pageURL.""); + //$this->logger->_log("Set submit action to ".$pageURL.""); hunk ./library/cc_processor.php 849 - $this->logger->_log("Errors found in form ".print_r($errors, true).""); + $log=sprintf("Form transaction errors for %s %s: ",$post_vars['firstName'],$post_vars['lastName']); + foreach (array_keys($errors) as $key) { + $log.=sprintf("%s:%s ",$errors[$key]['field'],$errors[$key]['desc']); + } + $this->logger->_log($log); hunk ./library/cc_processor.php 880 + function displayFormErrors($errors=array()){ + dprint("displayFormErrors()"); + + $page_body_content .= "

"._("Transaction failed")."

"; + // we have errors; let's print and stop + $page_body_content .= sprintf(""); + foreach (array_keys($errors) as $key) { + $page_body_content .= sprintf("",$errors[$key]['field'],$errors[$key]['desc']); + } + $page_body_content .= "
FieldError
%s%s
"; + + $page_body_content .= "

"._("Go Back").", "._("correct the errors and re-submit. ")."\n"; + + return $page_body_content; + } + hunk ./library/cc_processor.php 1046 - 'correlation_id' => $response->CorrelationID + 'correlation_id' => $response->CorrelationID, + 'card_type' => $creditCardType, + 'first_name' => $firstName, + 'last_name' => $lastName hunk ./library/cc_processor.php 1053 - $log=sprintf("Error: %s (%s) %s, correlation id %s", - $response->Errors->ShortMessage, + $log=sprintf("%s card of %s %s - Transaction %s Error: %s/%s (%s)", + $creditCardType, + $firstName, + $lastName, + $response->CorrelationID, hunk ./library/cc_processor.php 1059 - $response->Errors->LongMessage, - $response->CorrelationID + $response->Errors->ShortMessage, + $response->Errors->LongMessage hunk ./library/sip_settings.php 9421 - $formcheck1 = $this->CardProcessor->checkForm($_POST); - if (count($formcheck1) > 0){ - // we have errors; let's print and stop - print $this->CardProcessor->displayProcessErrors($formcheck1); + $errors = $this->CardProcessor->checkForm($_POST); + if (count($errors) > 0){ + print $this->CardProcessor->displayFormErrors($errors); + + foreach (array_keys($errors) as $key) { + $log_text.=sprintf("%s:%s ",$errors[$key]['field'],$errors[$key]['desc']); + } + + $log=sprintf("CC transaction for %s failed with error: %s",$this->account->account,$log_text); + syslog(LOG_NOTICE, $log); hunk ./library/sip_settings.php 9451 - $log=sprintf("Error, CC transaction failed for %s: %s (%s) after %d seconds", + $log=sprintf("CC transaction for %s failed with error: %s (%s) after %d seconds", hunk ./library/sip_settings.php 9466 - $log=sprintf("CC transaction for %s %s completed succesfully in %d seconds", - $this->account->account, + $log=sprintf("CC transaction %s for %s completed succesfully in %d seconds", hunk ./library/sip_settings.php 9468 + $this->account->account, hunk ./library/sip_settings.php 9547 - $log=sprintf("Error: SIP Account %s - CC transaction %s failed to Save Order",$this->account->account, $this->CardProcessor->transaction_data['TRANSACTION_ID']); + $log=sprintf("Error: SIP Account %s - CC transaction %s failed to save order",$this->account->account, $this->CardProcessor->transaction_data['TRANSACTION_ID']);