CRM-15207 membership payment incorrectly recorded
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 3 Sep 2014 09:37:49 +0000 (21:37 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 3 Sep 2014 22:00:16 +0000 (10:00 +1200)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Member/BAO/Membership.php
tests/phpunit/api/v3/ContributionPageTest.php

index af13ceb89d139afaea3f100ae7e72668c5f39209..14a98fe1b852d037a653caa9b4b427fb8ad60c89 100644 (file)
@@ -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);
index 030b04de67d76511f58068fd330545df67530222..1b6331f437271e458fc27e4ff78eb132ff50ff57 100644 (file)
@@ -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) {
index 6023d64c96723427b2b0cb948f10880c7c1a1c5d..d97c02ad4bdd58a8345b6edce3e6d11d83219c54 100644 (file)
@@ -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