From: Eileen McNaughton Date: Wed, 3 Sep 2014 09:37:49 +0000 (+1200) Subject: CRM-15207 membership payment incorrectly recorded X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=059906845969fa999a3e9aaae517ad20a223687a;p=civicrm-core.git CRM-15207 membership payment incorrectly recorded --- diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index af13ceb89d..14a98fe1b8 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -1699,10 +1699,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr */ public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems) { try { - $membershipTypeID = (array) $membershipParams['selectMembership']; - - $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this); - + $membershipTypeIDs = (array) $membershipParams['selectMembership']; + $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs); $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes); $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType)); @@ -1724,7 +1722,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID, - $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeID, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId, + $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId, $membershipLineItems ); $this->assign('membership_assign', TRUE); diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 030b04de67..1b6331f437 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1255,10 +1255,10 @@ AND civicrm_membership.is_test = %2"; * * @param array $membershipDetails * - * @param array $membershipTypeID + * @param array $membershipTypeIDs * * @param bool $isPaidMembership - * @param integer $membershipID + * @param array $membershipID * * @param $isProcessSeparateMembershipTransaction * @@ -1270,7 +1270,7 @@ AND civicrm_membership.is_test = %2"; * @access public */ public static function postProcessMembership($membershipParams, $contactID, &$form, $premiumParams, - $customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeID, $isPaidMembership, $membershipID, + $customFieldsFormatted = NULL, $includeFieldTypes = NULL, $membershipDetails, $membershipTypeIDs, $isPaidMembership, $membershipID, $isProcessSeparateMembershipTransaction, $defaultContributionTypeID, $membershipLineItems) { $result = $membershipContribution = NULL; $isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE); @@ -1315,9 +1315,9 @@ AND civicrm_membership.is_test = %2"; $form->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id']; } //@todo it should no longer be possible for it to get to this point & membership to not be an array - if (is_array($membershipTypeID)) { + if (is_array($membershipTypeIDs)) { $typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array()); - foreach ($membershipTypeID as $memType) { + foreach ($membershipTypeIDs as $memType) { $numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1); $createdMemberships[$memType] = self::createOrRenewMembership($membershipParams, $contactID, $customFieldsFormatted, $membershipID, $memType, $isTest, $numTerms, $membershipContribution, $form); } @@ -2096,11 +2096,16 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND * * @param $contactID * @param CRM_Contribute_Form_Contribution_Confirm $form - * @param $membershipDetails * @param $tempParams * @param $isTest * + * @param $lineItems + * @param $minimumFee + * @param $financialTypeID + * * @throws CRM_Core_Exception + * @throws Exception + * @internal param $membershipDetails * @return CRM_Contribute_BAO_Contribution */ public static function processSecondaryFinancialTransaction($contactID, &$form, $tempParams, $isTest, $lineItems, $minimumFee, $financialTypeID) { diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 6023d64c96..d97c02ad4b 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -217,6 +217,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']); } + /** * set up membership contribution page * @param bool $isSeparatePayment