From e364c7621f10c8d6b9fa8b1fc2309ed15d94c6fa Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 8 Mar 2019 13:35:06 +1300 Subject: [PATCH] Allow payment processor to determine the text around 'continue' This text traditionally depends on the outdated payment processor 'mode' concept. Since the 'right' text depends on what the payment processor plans to do moving it out to the processor classes makes sense We could also do the same with 'button' --- CRM/Contribute/Form/Contribution/Confirm.php | 9 +++++++ CRM/Contribute/Form/ContributionBase.php | 13 ++++++++++ CRM/Core/Payment.php | 18 +++++++++++-- CRM/Core/Payment/Manual.php | 26 +++++++++++++++++++ .../Contribute/Form/Contribution/Confirm.tpl | 12 ++------- 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 0afaf65fb1..dcf82c4b27 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -598,6 +598,15 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $contribButton = ts('Make Contribution'); } $this->assign('button', $contribButton); + + $this->assign('continueText', + $this->getPaymentProcessorObject()->getText('contributionPageContinueText', [ + 'is_payment_to_existing' => !empty($this->_ccid), + 'amount' => $this->_amount, + ] + ) + ); + $this->addButtons(array( array( 'type' => 'next', diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index f8b6f1a146..c8e488f34b 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -1390,4 +1390,17 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { } } + + /** + * Get the payment processor object for the submission, returning the manual one for offline payments. + * + * @return CRM_Core_Payment + */ + protected function getPaymentProcessorObject() { + if (!empty($this->_paymentProcessor)) { + return $this->_paymentProcessor['object']; + } + return new CRM_Core_Payment_Manual(); + } + } diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index f21aeec500..fb465033e8 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -522,9 +522,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 Continue button below.'); + } + if ($this->_paymentProcessor['billing_mode'] == 4) { + return ts('Click the Continue 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 Make Payment button below.'); + } + return ts('To complete your contribution, click the Continue button below.'); + } - return $gotText; + CRM_Core_Error::deprecatedFunctionWarning('Calls to getText must use a supported method'); + return ''; } /** diff --git a/CRM/Core/Payment/Manual.php b/CRM/Core/Payment/Manual.php index f31524474f..8798f5cce9 100644 --- a/CRM/Core/Payment/Manual.php +++ b/CRM/Core/Payment/Manual.php @@ -231,4 +231,30 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { return TRUE; } + /** + * Get help text information (help, description, etc.) about this payment, + * to display to the user. + * + * @param string $context + * Context of the text. + * Only explicitly supported contexts are handled without error. + * Currently supported: + * - contributionPageRecurringHelp (params: is_recur_installments, is_email_receipt) + * + * @param array $params + * Parameters for the field, context specific. + * + * @return string + */ + public function getText($context, $params) { + 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.'); + + } + } + } diff --git a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl index bb48dddede..b9f3e1fbc4 100644 --- a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl @@ -31,16 +31,8 @@
-

{ts}Please verify the information below carefully. ClickGo Backif you need to make changes.{/ts} - {if $contributeMode EQ 'notify' and ! $is_pay_later} - {ts 1=$paymentProcessor.name 2=$button}Click the - %2 - button to go to %1, where you will select your payment method and complete the contribution.{/ts} - {elseif ! $is_monetary or $amount LE 0.0 or $is_pay_later} - {ts 1=$button}To complete this transaction, click the%1button below.{/ts} - {else} - {ts 1=$button}To complete your contribution, click the%1button below.{/ts} - {/if} +

{ts}Please verify the information below carefully. Click Go Back if you need to make changes.{/ts} + {$continueText}

-- 2.25.1