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

Add getPaymentDescription function to payment pclass

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.8
    • Fix Version/s: 4.7
    • Component/s: None
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Contributed Code

      Description

      I just noticed that a useful helper function for payment processors is not in core - it's just a function for getting a useful description to send to processors.

      I'll probably backport to 4.6 in the future after it has gone LTS in the interests of keeping developer consistency - or can do straight to 4.6. I'll duplicate it in my processors for now

      /**

      • Get description of payment to pass to processor.
        *
      • This is often what people see in the interface so we want to get
      • as much unique information in as possible within the field length (& presumably the early part of the field)
        *
      • People seeing these can be assumed to be advanced users so quantity of information probably trumps
      • having field names to clarify
        *
      • @param array $params
      • @param int $length
        *
      • @return string
        */
        protected function getPaymentDescription($params, $length = 24) {
        $parts = array('contactID', 'contributionID', 'description', 'billing_first_name', 'billing_last_name');
        $validParts = array();
        if (isset($params['description'])) { $uninformativeStrings = array(ts('Online Event Registration: '), ts('Online Contribution: ')); $params['description'] = str_replace($uninformativeStrings, '', $params['description']); }

        foreach ($parts as $part)

        Unknown macro: { if ((!empty($params[$part]))) { $validParts[] = $params[$part]; } }

        return substr(implode('-', $validParts), 0, $length);
        }

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: