Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17610

Switch Authorize.net IPN error handling from exit to exception

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.10
    • Fix Version/s: 4.6.11
    • Component/s: None
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      Currently Authorize.net does a hard-exit when the recurring contribution ID is not found.

      I propose to change this to logging an error to the system log an throwing an exception.

      The reason for this is that we have found that real-time processing of Authorize.net IPNs is unreliable as they are prone to deadlocks notably on the line-item table) and a mysterious intermittent silent failure in sending out receipts. The latter occurs after all other processing has finished and could affect many sites without them knowing as they would only find out if the donor notified them they had missed a receipt. It was only due to intensive testing by a customer we become aware of it. The exit occurs within the smarty subsystem and my best guess is it silently exits due a conflict on a smarty file resource.

      In response to this we now block realtime processing (currently in a ham-fisted manner ) and process by a scheduled job (https://github.com/eileenmcnaughton/nz.co.fuzion.notificationlog/blob/master/api/v3/NotificationLog/Process.php#L14). However, this means that the code needs to be sensible about error handling and currently there is at least one instance where it exits - which doesn't work in multiple iterations.

      My proposal in general is that the IPN processing classes would replace instances of

      CRM_Core_Error::debug_log_message("just so you know.");

      With
      $log = new CRM_Utils_SystemLogger();
      $log->alert('payment_notification', array('message' => 'just so you know', 'ids' => array('contribution_recur_id' => x,), 'input' => array );

      AND

      CRM_Core_Error::debug_log_message("oh my god the world is ending.");
      exit;

      With

      $log = new CRM_Utils_SystemLogger();
      $log->error('payment_notification', array('message' => 'oh my god the world is ending', 'ids' => array('contribution_recur_id' => x,), 'input' => array );
      throw new CRM_Core_Exception('The world just ended');

        Attachments

          Activity

            People

            • Assignee:
              eileen Eileen McNaughton
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: