Skip to content

Commit

Permalink
Merge pull request #25910 from eileenmcnaughton/regression_dd
Browse files Browse the repository at this point in the history
dev/core#4189 Fix indiscriminate display of direct debit agreement
  • Loading branch information
mlutfy authored Mar 25, 2023
2 parents c8eeafc + 7931a72 commit 425aeaf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
6 changes: 3 additions & 3 deletions CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,10 @@ public function assignPaymentFields() {

// 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])) {
Expand Down
16 changes: 16 additions & 0 deletions CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,22 @@ public function getText($context, $params) {
}
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 '';
Expand Down
10 changes: 5 additions & 5 deletions templates/CRM/Contribute/Form/Contribution/Confirm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@
{/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}
<div class="header-dark">
{$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 />
Expand Down

0 comments on commit 425aeaf

Please sign in to comment.