From 0733ae839763c6683edbb29125c50977bb2f24e0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 18 Oct 2023 08:55:08 +1300 Subject: [PATCH] Fix contribution page to get text from processor --- CRM/Contribute/Form/Contribution/Confirm.php | 27 +++++++++---------- CRM/Contribute/Form/ContributionBase.php | 1 - CRM/Core/Payment.php | 18 +++++++++++++ CRM/Core/Payment/Manual.php | 13 +++++---- .../Contribute/Form/Contribution/Confirm.tpl | 8 ++---- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 3888192b62..212f1e6ae7 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -565,20 +565,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $this->assign('is_separate_payment', $this->isSeparateMembershipPayment()); $this->assign('priceSetID', $this->_priceSetId); - - // The concept of contributeMode is deprecated. - if ($this->_contributeMode === 'notify' || - $this->_amount <= 0.0 || $this->_params['is_pay_later'] - ) { - $contribButton = ts('Continue'); - } - elseif (!empty($this->_ccid)) { - $contribButton = ts('Make Payment'); - } - else { - $contribButton = ts('Make Contribution'); - } - $this->assign('button', $contribButton); + $contributionButtonText = $this->getPaymentProcessorObject()->getText('contributionPageButtonText', [ + 'is_payment_to_existing' => !empty($this->_ccid), + 'amount' => $this->_amount, + ]); + $this->assign('button', $contributionButtonText); $this->assign('continueText', $this->getPaymentProcessorObject()->getText('contributionPageContinueText', [ @@ -586,11 +577,17 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 'amount' => $this->_amount, ]) ); + $this->assign('confirmText', + $this->getPaymentProcessorObject()->getText('contributionPageConfirmText', [ + 'is_payment_to_existing' => !empty($this->_ccid), + 'amount' => $this->_amount, + ]) + ); $this->addButtons([ [ 'type' => 'next', - 'name' => $contribButton, + 'name' => $contributionButtonText, 'spacing' => '         ', 'isDefault' => TRUE, ], diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 7130487d62..064f17ef8d 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -504,7 +504,6 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $this->set('amount_block_is_active', $this->isFormSupportsNonMembershipContributions()); $this->_contributeMode = $this->get('contributeMode'); - $this->assign('contributeMode', $this->_contributeMode); //assigning is_monetary and is_email_receipt to template $this->assign('is_monetary', $this->_values['is_monetary']); diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 0453ac8ad7..9e0f2a33a8 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -591,6 +591,24 @@ abstract class CRM_Core_Payment { case 'contributionPageContinueText': return ts('Click the Continue button to proceed with the payment.'); + case 'contributionPageConfirmText': + if ($params['amount'] <= 0.0) { + return ''; + } + if ((int) $this->_paymentProcessor['billing_mode'] !== 4) { + return ts('Your contribution will not be completed until you click the %1 button. Please click the button one time only.', [1 => ts('Make Contribution')]); + } + return ''; + + case 'contributionPageButtonText': + if ($params['amount'] <= 0.0 || (int) $this->_paymentProcessor['billing_mode'] === 4) { + return ts('Continue'); + } + if ($params['is_payment_to_existing']) { + return ts('Make Payment'); + } + return ts('Make Contribution'); + case 'cancelRecurDetailText': if ($params['mode'] === 'auto_renew') { return ts('Click the button below if you want to cancel the auto-renewal option for your %1 membership. This will not cancel your membership. However you will need to arrange payment for renewal when your membership expires.', diff --git a/CRM/Core/Payment/Manual.php b/CRM/Core/Payment/Manual.php index 07a008c0ec..26b348638b 100644 --- a/CRM/Core/Payment/Manual.php +++ b/CRM/Core/Payment/Manual.php @@ -272,13 +272,16 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { * * @return string */ - public function getText($context, $params) { + public function getText($context, $params): string { switch ($context) { case 'contributionPageContinueText': - if ($params['amount'] <= 0) { - return ts('To complete this transaction, click the Continue button below.'); - } - return ts('To complete your contribution, click the Continue button below.'); + return ''; + + case 'contributionPageButtonText': + return ts('Continue'); + + case 'contributionPageConfirmText': + return ''; default: return parent::getText($context, $params); diff --git a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl index 5b13d71471..5d8492e35d 100644 --- a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl @@ -276,14 +276,10 @@ {/if} - {if $contributeMode NEQ 'notify' and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 )} {* In 'notify mode, contributor is taken to processor payment forms next *} + {if $confirmText}

- {if $is_pay_later OR $amount LE 0.0} - {ts 1=$button}Your transaction will not be completed until you click the %1 button. Please click the button one time only.{/ts} - {else} - {ts 1=$button}Your contribution will not be completed until you click the %1 button. Please click the button one time only.{/ts} - {/if} + {$confirmText}

{/if} -- 2.25.1