Fix display of payment processor title in cancelSubscription form
authorMatthew Wire <mjw@mjwconsult.co.uk>
Thu, 19 Mar 2020 18:19:30 +0000 (18:19 +0000)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Fri, 20 Mar 2020 18:52:52 +0000 (18:52 +0000)
CRM/Contribute/Form/CancelSubscription.php
CRM/Core/Payment.php
CRM/Financial/Form/FrontEndPaymentFormTrait.php

index 83c2580d2dd4c1b4719a49738f515a714ede71b1..7afbe299d9e0cb48be3f6ed2d3b2fd0b74ca2b3d 100644 (file)
@@ -141,7 +141,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib
         $searchRange,
         'send_cancel_request',
         ts('Send cancellation request to %1 ?',
-          [1 => $this->_paymentProcessorObj->_processorName])
+          [1 => $this->_paymentProcessorObj->getTitle()])
       );
     }
     else {
index c40d3fe09c2d7ca9ccdba47902938321ac75795f..2361c1a36dce8825a0b26838e9166687ed675918 100644 (file)
@@ -622,6 +622,15 @@ abstract class CRM_Core_Payment {
     return '';
   }
 
+  /**
+   * Get the title of the payment processor to display to the user
+   *
+   * @return string
+   */
+  public function getTitle() {
+    return $this->getPaymentProcessor()['title'] ?? $this->getPaymentProcessor()['name'];
+  }
+
   /**
    * Getter for accessing member vars.
    *
index cdedf2b61e15d1dceae8b33ebb460b5091317921..1f296801125c9383c01aa4af6952522b8f9fb852 100644 (file)
@@ -97,7 +97,7 @@ trait CRM_Financial_Form_FrontEndPaymentFormTrait {
     $pps = [];
     if (!empty($this->_paymentProcessors)) {
       foreach ($this->_paymentProcessors as $key => $processor) {
-        $pps[$key] = $processor['title'] ?? $processor['name'];
+        $pps[$key] = $this->getPaymentProcessorTitle($processor);
       }
     }
     if ($this->getPayLaterLabel()) {
@@ -106,6 +106,18 @@ trait CRM_Financial_Form_FrontEndPaymentFormTrait {
     return $pps;
   }
 
+  /**
+   * Get the title of the payment processor to display to the user
+   * Note: There is an identical function in CRM_Core_Payment
+   *
+   * @param array $processor
+   *
+   * @return string
+   */
+  protected function getPaymentProcessorTitle($processor) {
+    return $processor['title'] ?? $processor['name'];
+  }
+
   /**
    * Adds in either a set of radio buttons or hidden fields to contain the payment processors on a front end form
    */