* @return mixed
*/
public static function logPaymentNotification($params) {
- $message = '';
+ $message = 'payment_notification ';
if (!empty($params['processor_name'])) {
- $message = 'processor_name=' . $params['processor_name'];
+ $message .= 'processor_name=' . $params['processor_name'];
}
if (!empty($params['processor_id'])) {
$message .= 'processor_id=' . $params['processor_id'];
}
- $log = CRM_Utils_SystemLogger();
- $log->log('alert', $message, $_REQUEST);
+
+ $log = new CRM_Utils_SystemLogger();
+ $log->alert($message, $_REQUEST);
}
/**
/**
* This function checks to see if we have the right config values
*
- * @param string $mode the mode we are operating in (live or test)
+ * @internal param string $mode the mode we are operating in (live or test)
*
* @return string the error message if any
* @public
* (optional) Whether to include the reset GET string (if present).
* @param bool $includeForce
* (optional) Whether to include the force GET string (if present).
- * @param string $path
+ * @param string $path
* (optional) The path to use for the new url.
- * @param string $absolute
+ * @param string $absolute
* (optional) Whether to return an absolute URL.
*
* @return string
*
* @param string $content
* The content that will be themed.
- * @param bool $print
+ * @param bool $print
* (optional) Are we displaying to the screen or bypassing theming?
* @param bool $maintenance
* (optional) For maintenance mode.
return substr_replace($number, $replace, 0, -$keep);
}
- /**
+ /**
* Determine which PHP modules are loaded.
*
* @return array
* @param int $ver
* The major version of PHP that is required.
* @param bool $abort
- * (optional) Whether to fatally abort if the version requirement is not
+ * (optional) Whether to fatally abort if the version requirement is not
* met. Defaults to TRUE.
* @return bool
* Returns TRUE if the requirement is met, FALSE if the requirement is not
$address = CRM_Utils_Array::value('REMOTE_ADDR', $_SERVER);
$config = CRM_Core_Config::singleton();
- if ($config->userSystem->is_drupal) {
- //drupal function handles the server being behind a proxy securely
- $address = ip_address();
+ if ($config->userSystem->is_drupal && function_exists('ip_address')) {
+ //drupal function handles the server being behind a proxy securely. We still have legacy ipn methods
+ // that reach this point without bootstrapping hence the check that the fn exists
+ $address = ip_address();
}
// hack for safari
// getPluginList()
/**
- *
+ *
*/
static function executeScheduledJobs() {
$facility = new CRM_Core_JobManager();
*/
class CRM_Utils_SystemLogger extends Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface {
public function log($level, $message, array $context = array()) {
+ if(!isset($context['hostname'])) {
+ $context['hostname'] = CRM_Utils_System::ipAddress();
+ }
$rec = new CRM_Core_DAO_SystemLog();
$separateFields = array('contact_id', 'hostname');
foreach ($separateFields as $separateField) {
require_once '../civicrm.config.php';
$config = CRM_Core_Config::singleton();
+$log = new CRM_Utils_SystemLogger();
+$log->log('alert', 'payment_notification processor_name=AuthNet', $_REQUEST);
$authorizeNetIPN = new CRM_Core_Payment_AuthorizeNetIPN();
$authorizeNetIPN->main();
require_once '../civicrm.config.php';
$config = CRM_Core_Config::singleton();
+$log = new CRM_Utils_SystemLogger();
+$log->log('alert', 'payment_notification processor_name=Google_Checkout', $_REQUEST);
$rawPostData = file_get_contents('php://input');
CRM_Core_Payment_GoogleIPN::main($rawPostData);
/* Cache the real UF, override it with the SOAP environment */
$config = CRM_Core_Config::singleton();
-
+$log = new CRM_Utils_SystemLogger();
if (empty($_GET)) {
+ $log->log('alert', 'payment_notification processor_name=PayPal', $_REQUEST);
$paypalIPN = new CRM_Core_Payment_PayPalProIPN($_REQUEST);
}
else {
+ $log->log('alert', 'payment_notification PayPal_Standard', $_REQUEST);
$paypalIPN = new CRM_Core_Payment_PayPalIPN();
// @todo upgrade standard per Pro
}
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
-
+$log = new CRM_Utils_SystemLogger();
+$log->log('alert', 'payment_notification processor_name=Payment_Express', $_REQUEST);
/*
* Get the password from the Payment Processor's table based on the DPS user id
* being passed back from the server
+--------------------------------------------------------------------+
*/
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
- */
-class CRM_Utils_SystemLogger implements \Psr\Log\LoggerInterface {
- static public function log($level, $message, array $context = array()) {
- echo 'k';
- $rec = new CRM_Core_DAO_SystemLog();
- $separateFields = array('contact_id', 'hostname');
- foreach ($separateFields as $separateField) {
- if (isset($context[$separateField])) {
- $rec->{$separateField} = $context[$separateField];
- unset($context[$separateField]);
- }
+
+require_once 'CiviTest/CiviUnitTestCase.php';
+
+class CRM_Core_PaymentTest extends CiviUnitTestCase {
+ function get_info() {
+ return array(
+ 'name' => 'Payment Test',
+ 'description' => 'Test Payment methods.',
+ 'group' => 'Payment Processor Tests',
+ );
+ }
+
+ /**
+ * test the payment method is adequately logged - we don't expect the processing to succeed
+ */
+ function testHandlePaymentMethodLogging() {
+ $params = array('processor_name' => 'Paypal', 'data' => 'blah');
+ try {
+ CRM_Core_Payment::handlePaymentMethod('method', $params);
+ }
+ catch (Exception $e) {
+
}
- print_r($rec);
- $rec->level = $level;
- $rec->message = $message;
- $rec->context = json_encode($context);
- $rec->save();
+ $log = $this->callAPISuccess('SystemLog', 'get', array());
+ $this->assertEquals('payment_notification processor_name=Paypal', $log['values'][$log->id]['message']);
}
}
<civicrm_preferences_date />
+ <civicrm_system_log />
+
<civicrm_worldregion />
<civicrm_component />
<comment>error level per PSR3</comment>
<type>varchar</type>
<length>9</length>
- <default>info</default>
+ <default>'info'</default>
<add>4.5</add>
</field>
<field>