From fb49fa485b631adcb043044e8becaeac16ff5024 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 20 May 2014 12:09:00 +1200 Subject: [PATCH] clarify isSeparatePayment into it's own function --- CRM/Contribute/Form/Contribution/Confirm.php | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 5abaf71aa0..67287c1d4d 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1756,12 +1756,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr //enabled and contribution amount is not selected. fix for CRM-3010 $isPaidMembership = TRUE; } - $isProcessSeparateMembershipTransaction = FALSE; - if (!empty($memBlockDetails['is_separate_payment']) && $this->_values['amount_block_is_active']) { - // ie the membership block supports a separate transactions AND the contribution form has been configured for both - // a membership transaction AND a contribution transaction (this feels pretty legacy) - $isProcessSeparateMembershipTransaction = TRUE; - } + $isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']); CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipDetails, $membershipTypeID, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction @@ -1774,4 +1769,23 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}")); } } + + /** + * Are we going to do 2 financial transactions? + * ie the membership block supports a separate transactions AND the contribution form has been configured for a contribution + * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style) + * + * + * @param integer $formID + * @param bool $amountBlockActiveOnForm + * + * @return bool + */ + public function isSeparateMembershipTransaction($formID, $amountBlockActiveOnForm) { + $memBlockDetails = CRM_Member_BAO_Membership::getMembershipBlock($formID); + if (!empty($memBlockDetails['is_separate_payment']) && $amountBlockActiveOnForm) { + return TRUE; + } + return FALSE; + } } -- 2.25.1