Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21134 fix enotices in payment processor code assignment. #10935

Merged
merged 1 commit into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,23 +580,36 @@ public function assignToTemplate() {

// The concept of contributeMode is deprecated.
// The payment processor object can provide info about the fields it shows.
if ($this->_contributeMode == 'direct' && $assignCCInfo) {
if ($this->_paymentProcessor &&
$this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT
) {
$this->assign('account_holder', $this->_params['account_holder']);
$this->assign('bank_identification_number', $this->_params['bank_identification_number']);
$this->assign('bank_name', $this->_params['bank_name']);
$this->assign('bank_account_number', $this->_params['bank_account_number']);
if ($assignCCInfo) {
/** @var $paymentProcessorObject \CRM_Core_Payment */
$paymentProcessorObject = $this->_paymentProcessor['object'];
$paymentFields = $paymentProcessorObject->getPaymentFormFields();
foreach ($paymentFields as $index => $paymentField) {
if (!isset($this->_params[$paymentField])) {
unset($paymentFields[$index]);
continue;
}
if ($paymentField === 'credit_card_exp_date') {
$date = CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $this->_params));
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
}
elseif ($paymentField === 'credit_card_number') {
$this->assign('credit_card_number',
CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $this->_params))
);
}
else {
$this->assign($paymentField, $this->_params[$paymentField]);
}
}
else {
$date = CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $this->_params));
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number',
CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $this->_params))
);
$paymentFieldsetLabel = ts('%1 Information', array($paymentProcessorObject->getPaymentTypeLabel()));
if (empty($paymentFields)) {
$paymentFieldsetLabel = '';
}
$this->assign('paymentFieldsetLabel', $paymentFieldsetLabel);
$this->assign('paymentFields', $paymentFields);

}

$this->assign('email',
Expand Down
11 changes: 10 additions & 1 deletion CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,17 @@ public function getPaymentTypeLabel() {

/**
* Get array of fields that should be displayed on the payment form.
* @todo make payment type an option value & use it in the function name - currently on debit & credit card work
*
* Common results are
* array('credit_card_type', 'credit_card_number', 'cvv2', 'credit_card_exp_date')
* or
* array('account_holder', 'bank_account_number', 'bank_identification_number', 'bank_name')
* or
* array()
*
* @return array
* Array of payment fields appropriate to the payment processor.
*
* @throws CiviCRM_API3_Exception
*/
public function getPaymentFormFields() {
Expand Down
14 changes: 6 additions & 8 deletions templates/CRM/Contribute/Form/Contribution/Confirm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,12 @@
{crmRegion name="contribution-confirm-billing-block"}
{if ($credit_card_number or $bank_account_number)}
<div class="crm-group credit_card-group">
<div class="header-dark">
{if $paymentProcessor.payment_type & 2}
{ts}Direct Debit Information{/ts}
{else}
{ts}Credit Card Information{/ts}
{if $paymentFieldsetLabel}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure the paymentFieldsetLabel includes the label 'Direct Debit Information' or 'Direct Debit Information'.

<div class="header-dark">
{$paymentFieldsetLabel}
</div>
{/if}
</div>
{if $paymentProcessor.payment_type & 2}
{if $paymentProcessor.payment_type == 2}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed, the & operator couldn't be more confusing ...

<div class="display-block">
{ts}Account Holder{/ts}: {$account_holder}<br />
{ts}Bank Account Number{/ts}: {$bank_account_number}<br />
Expand All @@ -251,7 +249,7 @@
<div class="crm-section no-label credit_card_details-section">
<div class="content">{$credit_card_type}</div>
<div class="content">{$credit_card_number}</div>
<div class="content">{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}</div>
<div class="content">{if $credit_card_exp_date}{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}{/if}</div>
<div class="clear"></div>
</div>
{/if}
Expand Down
16 changes: 7 additions & 9 deletions templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,12 @@
{if $contributeMode eq 'direct' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 )}
{crmRegion name="contribution-thankyou-billing-block"}
<div class="crm-group credit_card-group">
<div class="header-dark">
{if $paymentProcessor.payment_type & 2}
{ts}Direct Debit Information{/ts}
{else}
{ts}Credit Card Information{/ts}
{/if}
</div>
{if $paymentProcessor.payment_type & 2}
{if $paymentFieldsetLabel}
<div class="header-dark">
{$paymentFieldsetLabel}
</div>
{/if}
{if $paymentProcessor.payment_type == 2}
<div class="display-block">
{ts}Account Holder{/ts}: {$account_holder}<br />
{ts}Bank Identification Number{/ts}: {$bank_identification_number}<br />
Expand All @@ -292,7 +290,7 @@
<div class="crm-section no-label credit_card_details-section">
<div class="content">{$credit_card_type}</div>
<div class="content">{$credit_card_number}</div>
<div class="content">{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}</div>
<div class="content">{if $credit_card_exp_date}{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}{/if}</div>
<div class="clear"></div>
</div>
{/if}
Expand Down