Merge pull request #13986 from seamuslee001/coder_upgrade_uf_tag_sms
[civicrm-core.git] / CRM / Core / Payment.php
index 7603137137a55ee3612bb0e9c68d725b8eb88b8c..1aaa4aa5f5c379b105dacb4cb95a1319bb2ef474 100644 (file)
@@ -336,6 +336,15 @@ abstract class CRM_Core_Payment {
     return TRUE;
   }
 
+  /**
+   * Does this payment processor support refund?
+   *
+   * @return bool
+   */
+  public function supportsRefund() {
+    return FALSE;
+  }
+
   /**
    * Should the first payment date be configurable when setting up back office recurring payments.
    *
@@ -413,7 +422,8 @@ abstract class CRM_Core_Payment {
    *   - pre_approval_parameters (this will be stored on the calling form & available later)
    *   - redirect_url (if set the browser will be redirected to this.
    */
-  public function doPreApproval(&$params) {}
+  public function doPreApproval(&$params) {
+  }
 
   /**
    * Get any details that may be available to the payment processor due to an approval process having happened.
@@ -426,7 +436,7 @@ abstract class CRM_Core_Payment {
    * @return array
    */
   public function getPreApprovalDetails($storedDetails) {
-    return array();
+    return [];
   }
 
   /**
@@ -509,7 +519,10 @@ abstract class CRM_Core_Payment {
     switch ($context) {
       case 'contributionPageRecurringHelp':
         // require exactly two parameters
-        if (array_keys($params) == array('is_recur_installments', 'is_email_receipt')) {
+        if (array_keys($params) == [
+            'is_recur_installments',
+            'is_email_receipt',
+          ]) {
           $gotText = ts('Your recurring contribution will be processed automatically.');
           if ($params['is_recur_installments']) {
             $gotText .= ' ' . ts('You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.');
@@ -518,9 +531,23 @@ abstract class CRM_Core_Payment {
             $gotText .= ' ' . ts('You will receive an email receipt for each recurring contribution.');
           }
         }
-        break;
+        return $gotText;
+
+      case 'contributionPageContinueText':
+        if ($params['amount'] <= 0) {
+          return ts('To complete this transaction, click the <strong>Continue</strong> button below.');
+        }
+        if ($this->_paymentProcessor['billing_mode'] == 4) {
+          return ts('Click the <strong>Continue</strong> button to go to %1, where you will select your payment method and complete the contribution.', [$this->_paymentProcessor['payment_processor_type']]);
+        }
+        if ($params['is_payment_to_existing']) {
+          return ts('To complete this transaction, click the <strong>Make Payment</strong> button below.');
+        }
+        return ts('To complete your contribution, click the <strong>Continue</strong> button below.');
+
     }
-    return $gotText;
+    CRM_Core_Error::deprecatedFunctionWarning('Calls to getText must use a supported method');
+    return '';
   }
 
   /**
@@ -571,7 +598,7 @@ abstract class CRM_Core_Payment {
    */
   public function getPaymentFormFields() {
     if ($this->_paymentProcessor['billing_mode'] == 4) {
-      return array();
+      return [];
     }
     return $this->_paymentProcessor['payment_type'] == 1 ? $this->getCreditCardFormFields() : $this->getDirectDebitFormFields();
   }
@@ -603,7 +630,7 @@ abstract class CRM_Core_Payment {
    */
   public function getEditableRecurringScheduleFields() {
     if ($this->supports('changeSubscriptionAmount')) {
-      return array('amount');
+      return ['amount'];
     }
   }
 
@@ -627,7 +654,7 @@ abstract class CRM_Core_Payment {
    * @return array;
    */
   protected function getMandatoryFields() {
-    $mandatoryFields = array();
+    $mandatoryFields = [];
     foreach ($this->getAllFields() as $field_name => $field_spec) {
       if (!empty($field_spec['is_required'])) {
         $mandatoryFields[$field_name] = $field_spec;
@@ -646,18 +673,19 @@ abstract class CRM_Core_Payment {
     $billingFields = array_intersect_key($this->getBillingAddressFieldsMetadata(), array_flip($this->getBillingAddressFields()));
     return array_merge($paymentFields, $billingFields);
   }
+
   /**
    * Get array of fields that should be displayed on the payment form for credit cards.
    *
    * @return array
    */
   protected function getCreditCardFormFields() {
-    return array(
+    return [
       'credit_card_type',
       'credit_card_number',
       'cvv2',
       'credit_card_exp_date',
-    );
+    ];
   }
 
   /**
@@ -666,12 +694,12 @@ abstract class CRM_Core_Payment {
    * @return array
    */
   protected function getDirectDebitFormFields() {
-    return array(
+    return [
       'account_holder',
       'bank_account_number',
       'bank_identification_number',
       'bank_name',
-    );
+    ];
   }
 
   /**
@@ -684,160 +712,164 @@ abstract class CRM_Core_Payment {
    */
   public function getPaymentFormFieldsMetadata() {
     //@todo convert credit card type into an option value
-    $creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard();
+    $creditCardType = ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::creditCard();
     $isCVVRequired = Civi::settings()->get('cvv_backoffice_required');
     if (!$this->isBackOffice()) {
       $isCVVRequired = TRUE;
     }
-    return array(
-      'credit_card_number' => array(
+    return [
+      'credit_card_number' => [
         'htmlType' => 'text',
         'name' => 'credit_card_number',
         'title' => ts('Card Number'),
-        'attributes' => array(
+        'attributes' => [
           'size' => 20,
           'maxlength' => 20,
           'autocomplete' => 'off',
           'class' => 'creditcard',
-        ),
+        ],
         'is_required' => TRUE,
         // 'description' => '16 digit card number', // If you enable a description field it will be shown below the field on the form
-      ),
-      'cvv2' => array(
+      ],
+      'cvv2' => [
         'htmlType' => 'text',
         'name' => 'cvv2',
         'title' => ts('Security Code'),
-        'attributes' => array(
+        'attributes' => [
           'size' => 5,
           'maxlength' => 10,
           'autocomplete' => 'off',
-        ),
+        ],
         'is_required' => $isCVVRequired,
-        'rules' => array(
-          array(
+        'rules' => [
+          [
             'rule_message' => ts('Please enter a valid value for your card security code. This is usually the last 3-4 digits on the card\'s signature panel.'),
             'rule_name' => 'integer',
             'rule_parameters' => NULL,
-          ),
-        ),
-      ),
-      'credit_card_exp_date' => array(
+          ],
+        ],
+      ],
+      'credit_card_exp_date' => [
         'htmlType' => 'date',
         'name' => 'credit_card_exp_date',
         'title' => ts('Expiration Date'),
         'attributes' => CRM_Core_SelectValues::date('creditCard'),
         'is_required' => TRUE,
-        'rules' => array(
-          array(
+        'rules' => [
+          [
             'rule_message' => ts('Card expiration date cannot be a past date.'),
             'rule_name' => 'currentDate',
             'rule_parameters' => TRUE,
-          ),
-        ),
+          ],
+        ],
         'extra' => ['class' => 'crm-form-select'],
-      ),
-      'credit_card_type' => array(
+      ],
+      'credit_card_type' => [
         'htmlType' => 'select',
         'name' => 'credit_card_type',
         'title' => ts('Card Type'),
         'attributes' => $creditCardType,
         'is_required' => FALSE,
-      ),
-      'account_holder' => array(
+      ],
+      'account_holder' => [
         'htmlType' => 'text',
         'name' => 'account_holder',
         'title' => ts('Account Holder'),
-        'attributes' => array(
+        'attributes' => [
           'size' => 20,
           'maxlength' => 34,
           'autocomplete' => 'on',
-        ),
+        ],
         'is_required' => TRUE,
-      ),
+      ],
       //e.g. IBAN can have maxlength of 34 digits
-      'bank_account_number' => array(
+      'bank_account_number' => [
         'htmlType' => 'text',
         'name' => 'bank_account_number',
         'title' => ts('Bank Account Number'),
-        'attributes' => array(
+        'attributes' => [
           'size' => 20,
           'maxlength' => 34,
           'autocomplete' => 'off',
-        ),
-        'rules' => array(
-          array(
+        ],
+        'rules' => [
+          [
             'rule_message' => ts('Please enter a valid Bank Identification Number (value must not contain punctuation characters).'),
             'rule_name' => 'nopunctuation',
             'rule_parameters' => NULL,
-          ),
-        ),
+          ],
+        ],
         'is_required' => TRUE,
-      ),
+      ],
       //e.g. SWIFT-BIC can have maxlength of 11 digits
-      'bank_identification_number' => array(
+      'bank_identification_number' => [
         'htmlType' => 'text',
         'name' => 'bank_identification_number',
         'title' => ts('Bank Identification Number'),
-        'attributes' => array(
+        'attributes' => [
           'size' => 20,
           'maxlength' => 11,
           'autocomplete' => 'off',
-        ),
+        ],
         'is_required' => TRUE,
-        'rules' => array(
-          array(
+        'rules' => [
+          [
             'rule_message' => ts('Please enter a valid Bank Identification Number (value must not contain punctuation characters).'),
             'rule_name' => 'nopunctuation',
             'rule_parameters' => NULL,
-          ),
-        ),
-      ),
-      'bank_name' => array(
+          ],
+        ],
+      ],
+      'bank_name' => [
         'htmlType' => 'text',
         'name' => 'bank_name',
         'title' => ts('Bank Name'),
-        'attributes' => array(
+        'attributes' => [
           'size' => 20,
           'maxlength' => 64,
           'autocomplete' => 'off',
-        ),
+        ],
         'is_required' => TRUE,
 
-      ),
-      'check_number' => array(
+      ],
+      'check_number' => [
         'htmlType' => 'text',
         'name' => 'check_number',
         'title' => ts('Check Number'),
         'is_required' => FALSE,
         'attributes' => NULL,
-      ),
-      'pan_truncation' => array(
+      ],
+      'pan_truncation' => [
         'htmlType' => 'text',
         'name' => 'pan_truncation',
         'title' => ts('Last 4 digits of the card'),
         'is_required' => FALSE,
-        'attributes' => array(
+        'attributes' => [
           'size' => 4,
           'maxlength' => 4,
           'minlength' => 4,
           'autocomplete' => 'off',
-        ),
-        'rules' => array(
-          array(
+        ],
+        'rules' => [
+          [
             'rule_message' => ts('Please enter valid last 4 digit card number.'),
             'rule_name' => 'numeric',
             'rule_parameters' => NULL,
-          ),
-        ),
-      ),
-      'payment_token' => array(
+          ],
+        ],
+      ],
+      'payment_token' => [
         'htmlType' => 'hidden',
         'name' => 'payment_token',
         'title' => ts('Authorization token'),
         'is_required' => FALSE,
-        'attributes' => ['size' => 10, 'autocomplete' => 'off', 'id' => 'payment_token'],
-      ),
-    );
+        'attributes' => [
+          'size' => 10,
+          'autocomplete' => 'off',
+          'id' => 'payment_token',
+        ],
+      ],
+    ];
   }
 
   /**
@@ -858,9 +890,9 @@ abstract class CRM_Core_Payment {
       $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
     }
     if ($this->_paymentProcessor['billing_mode'] != 1 && $this->_paymentProcessor['billing_mode'] != 3) {
-      return array();
+      return [];
     }
-    return array(
+    return [
       'first_name' => 'billing_first_name',
       'middle_name' => 'billing_middle_name',
       'last_name' => 'billing_last_name',
@@ -869,7 +901,7 @@ abstract class CRM_Core_Payment {
       'country' => "billing_country_id-{$billingLocationID}",
       'state_province' => "billing_state_province_id-{$billingLocationID}",
       'postal_code' => "billing_postal_code-{$billingLocationID}",
-    );
+    ];
   }
 
   /**
@@ -887,103 +919,103 @@ abstract class CRM_Core_Payment {
       // So taking this as a param is possibly something to be removed in favour of the standard default.
       $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
     }
-    $metadata = array();
-    $metadata['billing_first_name'] = array(
+    $metadata = [];
+    $metadata['billing_first_name'] = [
       'htmlType' => 'text',
       'name' => 'billing_first_name',
       'title' => ts('Billing First Name'),
       'cc_field' => TRUE,
-      'attributes' => array(
+      'attributes' => [
         'size' => 30,
         'maxlength' => 60,
         'autocomplete' => 'off',
-      ),
+      ],
       'is_required' => TRUE,
-    );
+    ];
 
-    $metadata['billing_middle_name'] = array(
+    $metadata['billing_middle_name'] = [
       'htmlType' => 'text',
       'name' => 'billing_middle_name',
       'title' => ts('Billing Middle Name'),
       'cc_field' => TRUE,
-      'attributes' => array(
+      'attributes' => [
         'size' => 30,
         'maxlength' => 60,
         'autocomplete' => 'off',
-      ),
+      ],
       'is_required' => FALSE,
-    );
+    ];
 
-    $metadata['billing_last_name'] = array(
+    $metadata['billing_last_name'] = [
       'htmlType' => 'text',
       'name' => 'billing_last_name',
       'title' => ts('Billing Last Name'),
       'cc_field' => TRUE,
-      'attributes' => array(
+      'attributes' => [
         'size' => 30,
         'maxlength' => 60,
         'autocomplete' => 'off',
-      ),
+      ],
       'is_required' => TRUE,
-    );
+    ];
 
-    $metadata["billing_street_address-{$billingLocationID}"] = array(
+    $metadata["billing_street_address-{$billingLocationID}"] = [
       'htmlType' => 'text',
       'name' => "billing_street_address-{$billingLocationID}",
       'title' => ts('Street Address'),
       'cc_field' => TRUE,
-      'attributes' => array(
+      'attributes' => [
         'size' => 30,
         'maxlength' => 60,
         'autocomplete' => 'off',
-      ),
+      ],
       'is_required' => TRUE,
-    );
+    ];
 
-    $metadata["billing_city-{$billingLocationID}"] = array(
+    $metadata["billing_city-{$billingLocationID}"] = [
       'htmlType' => 'text',
       'name' => "billing_city-{$billingLocationID}",
       'title' => ts('City'),
       'cc_field' => TRUE,
-      'attributes' => array(
+      'attributes' => [
         'size' => 30,
         'maxlength' => 60,
         'autocomplete' => 'off',
-      ),
+      ],
       'is_required' => TRUE,
-    );
+    ];
 
-    $metadata["billing_state_province_id-{$billingLocationID}"] = array(
+    $metadata["billing_state_province_id-{$billingLocationID}"] = [
       'htmlType' => 'chainSelect',
       'title' => ts('State/Province'),
       'name' => "billing_state_province_id-{$billingLocationID}",
       'cc_field' => TRUE,
       'is_required' => TRUE,
-    );
+    ];
 
-    $metadata["billing_postal_code-{$billingLocationID}"] = array(
+    $metadata["billing_postal_code-{$billingLocationID}"] = [
       'htmlType' => 'text',
       'name' => "billing_postal_code-{$billingLocationID}",
       'title' => ts('Postal Code'),
       'cc_field' => TRUE,
-      'attributes' => array(
+      'attributes' => [
         'size' => 30,
         'maxlength' => 60,
         'autocomplete' => 'off',
-      ),
+      ],
       'is_required' => TRUE,
-    );
+    ];
 
-    $metadata["billing_country_id-{$billingLocationID}"] = array(
+    $metadata["billing_country_id-{$billingLocationID}"] = [
       'htmlType' => 'select',
       'name' => "billing_country_id-{$billingLocationID}",
       'title' => ts('Country'),
       'cc_field' => TRUE,
-      'attributes' => array(
-        '' => ts('- select -'),
-      ) + CRM_Core_PseudoConstant::country(),
+      'attributes' => [
+          '' => ts('- select -'),
+        ] + CRM_Core_PseudoConstant::country(),
       'is_required' => TRUE,
-    );
+    ];
     return $metadata;
   }
 
@@ -1047,20 +1079,20 @@ abstract class CRM_Core_Payment {
     }
 
     if ($this->_component == 'event') {
-      return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
+      return CRM_Utils_System::url($this->getBaseReturnUrl(), [
         'reset' => 1,
         'cc' => 'fail',
         'participantId' => $participantID,
-      ),
+      ],
         TRUE, NULL, FALSE
       );
     }
 
-    return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
+    return CRM_Utils_System::url($this->getBaseReturnUrl(), [
       '_qf_Main_display' => 1,
       'qfKey' => $qfKey,
       'cancel' => 1,
-    ),
+    ],
       TRUE, NULL, FALSE
     );
   }
@@ -1077,10 +1109,10 @@ abstract class CRM_Core_Payment {
       return $this->successUrl;
     }
 
-    return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
+    return CRM_Utils_System::url($this->getBaseReturnUrl(), [
       '_qf_ThankYou_display' => 1,
       'qfKey' => $qfKey,
-    ),
+    ],
       TRUE, NULL, FALSE
     );
   }
@@ -1123,10 +1155,10 @@ abstract class CRM_Core_Payment {
    * @return string url
    */
   protected function getGoBackUrl($qfKey) {
-    return CRM_Utils_System::url($this->getBaseReturnUrl(), array(
+    return CRM_Utils_System::url($this->getBaseReturnUrl(), [
       '_qf_Confirm_display' => 'true',
       'qfKey' => $qfKey,
-    ),
+    ],
       TRUE, NULL, FALSE
     );
   }
@@ -1143,7 +1175,7 @@ abstract class CRM_Core_Payment {
   protected function getNotifyUrl() {
     $url = CRM_Utils_System::url(
       'civicrm/payment/ipn/' . $this->_paymentProcessor['id'],
-      array(),
+      [],
       TRUE,
       NULL,
       FALSE,
@@ -1183,6 +1215,13 @@ abstract class CRM_Core_Payment {
    * Once this function is fully rolled out then it will be preferred for processors to throw exceptions than to
    * return Error objects
    *
+   * Usage:
+   * Payment processors should override this function directly instead of using doDirectPayment/doTransferCheckout which are deprecated.
+   * Payment processors should set and return payment_status_id (Pending if the IPN will complete it, Completed if successful).
+   * @fixme For the contribution workflow we have a contributionID, but for the event and membership workflow the contribution has not yet been created
+   *  so we can't update params directly on the contribution.  However if you return trxn_id, fee_amount, net_amount they will be set on the contribution
+   *  by those workflows.  Ideally all workflows would create a pending contribution BEFORE calling doPayment (eg. https://github.com/civicrm/civicrm-core/pull/13763 for events)
+   *
    * @param array $params
    *
    * @param string $component
@@ -1228,6 +1267,17 @@ abstract class CRM_Core_Payment {
     return $result;
   }
 
+  /**
+   * Refunds payment
+   *
+   * Payment processors should set payment_status_id if it set the status to Refunded in case the transaction is successful
+   *
+   * @param array $params
+   *
+   * @throws \Civi\Payment\Exception\PaymentProcessorException
+   */
+  public function doRefund(&$params) {}
+
   /**
    * Query payment processor for details about a transaction.
    *
@@ -1243,7 +1293,7 @@ abstract class CRM_Core_Payment {
    *   - fee_amount Amount of fee paid
    */
   public function doQuery($params) {
-    return array();
+    return [];
   }
 
   /**
@@ -1288,14 +1338,23 @@ abstract class CRM_Core_Payment {
    * Page callback for civicrm/payment/ipn
    */
   public static function handleIPN() {
-    self::handlePaymentMethod(
-      'PaymentNotification',
-      array(
-        'processor_name' => @$_GET['processor_name'],
-        'processor_id' => @$_GET['processor_id'],
-        'mode' => @$_GET['mode'],
-      )
-    );
+    try {
+      self::handlePaymentMethod(
+        'PaymentNotification',
+        [
+          'processor_name' => CRM_Utils_Request::retrieveValue('processor_name', 'String'),
+          'processor_id' => CRM_Utils_Request::retrieveValue('processor_id', 'Integer'),
+          'mode' => CRM_Utils_Request::retrieveValue('mode', 'Alphanumeric'),
+        ]
+      );
+    }
+    catch (CRM_Core_Exception $e) {
+      Civi::log()->error('ipn_payment_callback_exception', [
+        'context' => [
+          'backtrace' => CRM_Core_Error::formatBacktrace(debug_backtrace()),
+        ],
+      ]);
+    }
     CRM_Utils_System::civiExit();
   }
 
@@ -1316,7 +1375,7 @@ abstract class CRM_Core_Payment {
    * @throws \CRM_Core_Exception
    * @throws \Exception
    */
-  public static function handlePaymentMethod($method, $params = array()) {
+  public static function handlePaymentMethod($method, $params = []) {
     if (!isset($params['processor_id']) && !isset($params['processor_name'])) {
       $q = explode('/', CRM_Utils_Array::value(CRM_Core_Config::singleton()->userFrameworkURLVar, $_GET, ''));
       $lastParam = array_pop($q);
@@ -1339,25 +1398,25 @@ abstract class CRM_Core_Payment {
 
     if (isset($params['processor_id'])) {
       $sql .= " WHERE pp.id = %2";
-      $args[2] = array($params['processor_id'], 'Integer');
-      $notFound = ts("No active instances of payment processor %1 were found.", array(1 => $params['processor_id']));
+      $args[2] = [$params['processor_id'], 'Integer'];
+      $notFound = ts("No active instances of payment processor %1 were found.", [1 => $params['processor_id']]);
     }
     else {
       // This is called when processor_name is passed - passing processor_id instead is recommended.
       $sql .= " WHERE ppt.name = %2 AND pp.is_test = %1";
-      $args[1] = array(
+      $args[1] = [
         (CRM_Utils_Array::value('mode', $params) == 'test') ? 1 : 0,
         'Integer',
-      );
-      $args[2] = array($params['processor_name'], 'String');
-      $notFound = ts("No active instances of payment processor '%1' were found.", array(1 => $params['processor_name']));
+      ];
+      $args[2] = [$params['processor_name'], 'String'];
+      $notFound = ts("No active instances of payment processor '%1' were found.", [1 => $params['processor_name']]);
     }
 
     $dao = CRM_Core_DAO::executeQuery($sql, $args);
 
     // Check whether we found anything at all.
     if (!$dao->N) {
-      CRM_Core_Error::fatal($notFound);
+      throw new CRM_Core_Exception($notFound);
     }
 
     $method = 'handle' . $method;
@@ -1383,7 +1442,7 @@ abstract class CRM_Core_Payment {
 
       // Does PP implement this method, and can we call it?
       if (!method_exists($processorInstance, $method) ||
-        !is_callable(array($processorInstance, $method))
+        !is_callable([$processorInstance, $method])
       ) {
         // on the off chance there is a double implementation of this processor we should keep looking for another
         // note that passing processor_id is more reliable & we should work to deprecate processor_name
@@ -1401,7 +1460,10 @@ abstract class CRM_Core_Payment {
     if (!$extension_instance_found) {
       $message = "No extension instances of the '%1' payment processor were found.<br />" .
         "%2 method is unsupported in legacy payment processors.";
-      CRM_Core_Error::fatal(ts($message, array(1 => $params['processor_name'], 2 => $method)));
+      throw new CRM_Core_Exception(ts($message, [
+        1 => $params['processor_name'],
+        2 => $method,
+      ]));
     }
   }
 
@@ -1512,7 +1574,12 @@ abstract class CRM_Core_Payment {
       FROM civicrm_contribution_recur rec
 INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
      WHERE rec.id = %1";
-          $contactID = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($entityID, 'Integer')));
+          $contactID = CRM_Core_DAO::singleValueQuery($sql, [
+            1 => [
+              $entityID,
+              'Integer',
+            ],
+          ]);
           $entityArg = 'crid';
           break;
       }
@@ -1551,10 +1618,19 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
    * @return string
    */
   protected function getPaymentDescription($params, $length = 24) {
-    $parts = array('contactID', 'contributionID', 'description', 'billing_first_name', 'billing_last_name');
-    $validParts = array();
+    $parts = [
+      'contactID',
+      'contributionID',
+      'description',
+      'billing_first_name',
+      'billing_last_name',
+    ];
+    $validParts = [];
     if (isset($params['description'])) {
-      $uninformativeStrings = array(ts('Online Event Registration: '), ts('Online Contribution: '));
+      $uninformativeStrings = [
+        ts('Online Event Registration: '),
+        ts('Online Contribution: '),
+      ];
       $params['description'] = str_replace($uninformativeStrings, '', $params['description']);
     }
     foreach ($parts as $part) {