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

Refactor / tidy Contribution receipt mail

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.4.0
    • Component/s: None
    • Labels:
      None

      Description

      GOAL - don't have other objects call BaseIPN to send emails (e.g. send pdf emails)

      Two main functionalities being called within BaseIPN from outside

      1) Load Related Objects
      2) Construct email - by applying tokens to tpl. - should return html to calling function so it can email or pdf or otherwise render

      Also
      3) related requirement for process contribution with related objects (e.g. participant) to be available to API &
      4) API should be able to construct email (need to debate w X how that would look in terms of params)

      Relevant existing functions (generally all do some of the two functionalities listed

      CRM_Core_Payment_BaseIPN::- validate (calls load objects not important in itself)
      CRM_Core_Payment_BaseIPN::loadObjects
      CRM_Core_Payment_BaseIPN::completeTransaction
      CRM_Core_Payment_BaseIPN::pending
      CRM_Core_Payment_BaseIPN::failed
      CRM_Core_Payment_BaseIPN::cancelled
      CRM_Core_Payment_BaseIPN::updatecontributionStatus
      CRM_Contribute_BAO_Contribution_Utils::ProcessAPIContribution (called by paypal & google for BaseIPN like stuff)
      CRM_Contribute_BAO_Contribution_Utils::FormatAPIParams (probably should be function on Paypal class)
      CRM_Contribute_Form_Contribution::updateRelatedComponent
      CRM_Contribute_Form_Contribution_Confirm::processContribution
      CRM_Contribute_BAO_ContributionPage::sendmail
      CRM_Contribute_BAO_Contribution::add
      CRM_Contribute_BAO_Contribution::create
      CRM_Contribute_BAO_Contribution::getConmponentFields
      CRM_Contribute_BAO_Contribution::transitionComponents
      CRM_Contribute_Import_Parser_Contribution::processpledgepayments

      Places in the code where BaseIPN is called
      CRM_Event_Form_Task_Batch::updatePendingOnlineContribution
      CRM_Contribute_Form_Task_Status::postProcess
      CRM_Contribute_Form_Task_PDF::postProcess
      CRM_Contribute_BAO_ContributionRecur::cancelrecurcontribution
      CRM_Contribute_BAO_Contribution::transitionComponents - YES really - the core contribution BAO object calls the payment processor Instant payment Notification class - Tail, Dog anyone?

      So, I think that CRM_Contribute_BAO_Contribution should have these functions

      loadRelatedObjects -
      – initially code from CRM_Core_Payment_BaseIPN::loadObjects but stash an array of BAO objects in an array called objects or related objects which is a property of

      – composeHtmlMessage
      takes a messageId OR message_text & swaps out tokens based on contribution object & related Objects. If no message passed in defaults to component relevant receipt email (e.g. if membership exists it uses online membership email).

      – sendEmail - wrapper for composeHtmlMessage that sends result

      – renderPdf - wrapper for composeHtmlMessage that sends pdf

      – processRelatedObjects (called by create)

      These should also apply to membership etc & we need to define api actions

      Step 1 - write test for load objects on BaseIPN
      Step 2 move guts of load objects to Contribute & call it from BaseIPN
      Step 3 Write test calling BaseIPN :send mail & returning Html
      Step 4 move guts of BaseIPN compose to Contribute & call from BaseIPN
      Step 5 Create pdf & email as wrapper functions, change receipt Task to call them

        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: