From 4e0ebeee0f63d71030580a8a4003f15026dcbae7 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 19 Mar 2020 18:19:30 +0000 Subject: [PATCH] Fix display of payment processor title in cancelSubscription form --- CRM/Contribute/Form/CancelSubscription.php | 2 +- CRM/Core/Payment.php | 9 +++++++++ CRM/Financial/Form/FrontEndPaymentFormTrait.php | 14 +++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index 83c2580d2d..7afbe299d9 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -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 { diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index c40d3fe09c..2361c1a36d 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -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. * diff --git a/CRM/Financial/Form/FrontEndPaymentFormTrait.php b/CRM/Financial/Form/FrontEndPaymentFormTrait.php index cdedf2b61e..1f29680112 100644 --- a/CRM/Financial/Form/FrontEndPaymentFormTrait.php +++ b/CRM/Financial/Form/FrontEndPaymentFormTrait.php @@ -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 */ -- 2.25.1