Skip to content
Snippets Groups Projects
Commit 7931a722 authored by Eileen McNaughton's avatar Eileen McNaughton
Browse files

#4189 Fix indiscriminate display of direct debit agreement

parent 9d4e2929
Branches
Tags
No related merge requests found
......@@ -782,10 +782,10 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
// The concept of contributeMode is deprecated.
// The payment processor object can provide info about the fields it shows.
if ($isMonetary && is_a($this->_paymentProcessor['object'], 'CRM_Core_Payment')) {
/** @var \CRM_Core_Payment $paymentProcessorObject */
if ($isMonetary && $this->_paymentProcessor['object'] instanceof \CRM_Core_Payment) {
$paymentProcessorObject = $this->_paymentProcessor['object'];
$this->assign('paymentAgreementTitle', $paymentProcessorObject->getText('agreementTitle', []));
$this->assign('paymentAgreementText', $paymentProcessorObject->getText('agreementText', []));
$paymentFields = $paymentProcessorObject->getPaymentFormFields();
foreach ($paymentFields as $index => $paymentField) {
if (!isset($this->_params[$paymentField])) {
......
......@@ -619,6 +619,22 @@ abstract class CRM_Core_Payment {
}
return '';
case 'agreementTitle':
if ($this->getPaymentTypeName() !== 'direct_debit' || $this->_paymentProcessor['billing_mode'] != 1) {
return '';
}
// @todo - 'encourage' processors to override...
// CRM_Core_Error::deprecatedWarning('Payment processors should override getText for agreement text');
return ts('Agreement');
case 'agreementText':
if ($this->getPaymentTypeName() !== 'direct_debit' || $this->_paymentProcessor['billing_mode'] != 1) {
return '';
}
// @todo - 'encourage' processors to override...
// CRM_Core_Error::deprecatedWarning('Payment processors should override getText for agreement text');
return ts('Your account data will be used to charge your bank account via direct debit. While submitting this form you agree to the charging of your bank account via direct debit.');
}
CRM_Core_Error::deprecatedFunctionWarning('Calls to getText must use a supported method');
return '';
......
......@@ -243,25 +243,25 @@
{$paymentFieldsetLabel}
</div>
{/if}
{if in_array('bank_account_number', $form)}
{if in_array('bank_account_number', $form) && $bank_account_number}
<div class="display-block">
{ts}Account Holder{/ts}: {$account_holder}<br/>
{ts}Bank Account Number{/ts}: {$bank_account_number}<br/>
{ts}Bank Identification Number{/ts}: {$bank_identification_number}<br/>
{ts}Bank Name{/ts}: {$bank_name}<br/>
</div>
{if $contributeMode eq 'direct'}
{if $paymentAgreementText}
<div class="crm-group debit_agreement-group">
<div class="header-dark">
{ts}Agreement{/ts}
{$paymentAgreementTitle}
</div>
<div class="display-block">
{ts}Your account data will be used to charge your bank account via direct debit. While submitting this form you agree to the charging of your bank account via direct debit.{/ts}
{$paymentAgreementText}
</div>
</div>
{/if}
{/if}
{if in_array('credit_card_number', $form)}
{if in_array('credit_card_number', $form) && $credit_card_number}
<div class="crm-section no-label credit_card_details-section">
<div class="content">{$credit_card_type}</div>
<div class="content">{$credit_card_number}</div>
......
......@@ -281,7 +281,7 @@
{/if}
{/if}
{if $contributeMode eq 'direct' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 )}
{if in_array('credit_card_number', $form) || in_array('bank_account_number', $form) && ($amount GT 0 OR $minimum_fee GT 0)}
{crmRegion name="contribution-thankyou-billing-block"}
<div class="crm-group credit_card-group">
{if $paymentFieldsetLabel}
......@@ -289,7 +289,7 @@
{$paymentFieldsetLabel}
</div>
{/if}
{if $paymentProcessor.payment_type == 2}
{if in_array('bank_account_number', $form) && $bank_account_number}
<div class="display-block">
{ts}Account Holder{/ts}: {$account_holder}<br />
{ts}Bank Identification Number{/ts}: {$bank_identification_number}<br />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment