Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-08-12-15-44-44
authorKurund Jalmi <kurund@yahoo.com>
Wed, 12 Aug 2015 10:50:08 +0000 (16:20 +0530)
committerKurund Jalmi <kurund@yahoo.com>
Wed, 12 Aug 2015 10:50:08 +0000 (16:20 +0530)
Conflicts:
CRM/Contribute/BAO/Contribution/Utils.php
templates/CRM/Contribute/Form/Contribution/Main.tpl
tests/phpunit/CiviTest/CiviSeleniumTestCase.php

1  2 
CRM/Activity/Form/Activity.php
CRM/Contribute/BAO/Contribution/Utils.php
CRM/Core/BAO/CustomField.php
CRM/Export/BAO/Export.php
CRM/Price/BAO/PriceField.php
api/v3/OptionValue.php
templates/CRM/Contribute/Form/Contribution/Confirm.tpl
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Member/OnlineMembershipCreateTest.php

Simple merge
index ff5e327e8ee8bb4903dbe1f119a6820a7b895795,a30e26e3e287a8c729aaf86915671e90d1d6f88d..5ed203c184a3073be2c8c0202dc08fc6dc7070eb
@@@ -122,87 -116,256 +122,87 @@@ class CRM_Contribute_BAO_Contribution_U
          $form,
          $paymentParams,
          NULL,
 -        $contactID,
 -        $contributionType,
 -        TRUE, TRUE,
 -        $isTest,
 -        $lineItems
 +        $contributionParams,
 +        $financialType,
 +        TRUE,
 +        TRUE,
 +        $form->_bltID
        );
  
 -      if ($contribution) {
 -        $form->_params['contributionID'] = $contribution->id;
 -      }
 -
 -      $form->_params['contributionTypeID'] = $contributionTypeId;
 -      $form->_params['item_name'] = $form->_params['description'];
 +      $paymentParams['contributionTypeID'] = $contributionTypeId;
 +      $paymentParams['item_name'] = $form->_params['description'];
  
 -      if ($contribution && $form->_values['is_recur'] &&
 -        $contribution->contribution_recur_id
 +      if ($contribution && $form->_values['is_recur'] && $contribution->contribution_recur_id
        ) {
 -        $form->_params['contributionRecurID'] = $contribution->contribution_recur_id;
 +        $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
        }
  
 -      $form->set('params', $form->_params);
 -      $form->postProcessPremium($premiumParams, $contribution);
 -
 -      if ($isPaymentTransaction) {
 -        // add qfKey so we can send to paypal
 -        $form->_params['qfKey'] = $form->controller->_key;
 -        if ($component == 'membership') {
 -          $membershipResult = array(1 => $contribution);
 -          return $membershipResult;
 -        }
 -        else {
 -          if (!$isPayLater) {
 -            if (is_object($payment)) {
 -              // call postProcess hook before leaving
 -              $form->postProcessHook();
 -              // this does not return
 -              $result = $payment->doTransferCheckout($form->_params, 'contribute');
 -            }
 -            else {
 -              CRM_Core_Error::fatal($paymentObjError);
 -            }
 -          }
 -          else {
 -            // follow similar flow as IPN
 -            // send the receipt mail
 -            $form->set('params', $form->_params);
 -            if ($contributionType->is_deductible) {
 -              $form->assign('is_deductible', TRUE);
 -              $form->set('is_deductible', TRUE);
 -            }
 -            if (isset($paymentParams['contribution_source'])) {
 -              $form->_params['source'] = $paymentParams['contribution_source'];
 -            }
 -
 -            // get the price set values for receipt.
 -            if ($form->_priceSetId && $form->_lineItem) {
 -              $form->_values['lineItem'] = $form->_lineItem;
 -              $form->_values['priceSetID'] = $form->_priceSetId;
 -            }
 -
 -            $form->_values['contribution_id'] = $contribution->id;
 -            $form->_values['contribution_page_id'] = $contribution->contribution_page_id;
 -
 -            CRM_Contribute_BAO_ContributionPage::sendMail($contactID,
 -              $form->_values,
 -              $contribution->is_test
 -            );
 -            return;
 -          }
 -        }
 +      $paymentParams['qfKey'] = $form->controller->_key;
 +      if ($component == 'membership') {
 +        return array('contribution' => $contribution);
        }
 -    }
 -    elseif ($form->_contributeMode == 'express') {
 -      if ($form->_values['is_monetary'] && $form->_amount > 0.0) {
 -        // determine if express + recurring and direct accordingly
 -        if (!empty($paymentParams['is_recur']) && $paymentParams['is_recur'] == 1) {
 -          if (is_object($payment)) {
 -            $result = $payment->createRecurringPayments($paymentParams);
 -          }
 -          else {
 -            CRM_Core_Error::fatal($paymentObjError);
 -          }
 -        }
 -        else {
 -          if (is_object($payment)) {
 -            $result = $payment->doExpressCheckout($paymentParams);
 -          }
 -          else {
 -            CRM_Core_Error::fatal($paymentObjError);
 -          }
 -        }
 -      }
 -    }
 -    elseif ($isPaymentTransaction) {
 -      if (!empty($paymentParams['is_recur']) &&
 -        $form->_contributeMode == 'direct'
 -      ) {
  
 -        // For recurring contribution, create Contribution Record first.
 -        // Contribution ID, Recurring ID and Contact ID needed
 -        // When we get a callback from the payment processor
 -
 -        $paymentParams['contactID'] = $contactID;
 -
 -        // Fix for CRM-14354. If the membership is recurring, don't create a
 -        // civicrm_contribution_recur record for the additional contribution
 -        // (i.e., the amount NOT associated with the membership). Temporarily
 -        // cache the is_recur values so we can process the additional gift as a
 -        // one-off payment.
 -        $pending = FALSE;
 -        if (!empty($form->_values['is_recur'])) {
 -          if ($form->_membershipBlock['is_separate_payment'] && !empty($form->_params['auto_renew'])) {
 -            $cachedFormValue = CRM_Utils_Array::value('is_recur', $form->_values);
 -            $cachedParamValue = CRM_Utils_Array::value('is_recur', $paymentParams);
 -            unset($form->_values['is_recur']);
 -            unset($paymentParams['is_recur']);
 -          }
 -          else {
 -            $pending = TRUE;
 -          }
 -        }
 -
 -        $contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution(
 -          $form,
 -          $paymentParams,
 -          NULL,
 -          $contactID,
 -          $contributionType,
 -          $pending, TRUE,
 -          $isTest,
 -          $lineItems
 -        );
 -
 -        // restore cached values (part of fix for CRM-14354)
 -        if (!empty($cachedFormValue)) {
 -          $form->_values['is_recur'] = $cachedFormValue;
 -          $paymentParams['is_recur'] = $cachedParamValue;
 -        }
 -
 -        $paymentParams['contributionID'] = $contribution->id;
 -        //CRM-15297 deprecate contributionTypeID
 -        $paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
 -        $paymentParams['contributionPageID'] = $contribution->contribution_page_id;
 -
 -        if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
 -          $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
 -        }
 -      }
 -      if ($form->_amount > 0.0) {
 -        if (is_object($payment)) {
 -          $result = $payment->doDirectPayment($paymentParams);
 -        }
 -        else {
 -          CRM_Core_Error::fatal($paymentObjError);
 -        }
 -      }
 -    }
 -
 -    if ($component == 'membership') {
 -      $membershipResult = array();
 -    }
 -
 -    if (is_a($result, 'CRM_Core_Error')) {
 -      //make sure to cleanup db for recurring case.
 -      //@todo this clean up has always been controversial as many orgs prefer to see failed transactions.
 -      // most recent discussion has been that they should be retained and this could be altered
 -      if (!empty($paymentParams['contributionID'])) {
 -        CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
 -      }
 -      if (!empty($paymentParams['contributionRecurID'])) {
 -        CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
 -      }
 -
 -      if ($component !== 'membership') {
 -        CRM_Core_Error::displaySessionError($result);
 -        CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact',
 -          "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"
 -        ));
 -      }
 -      $membershipResult[1] = $result;
 -    }
 -    elseif ($result || ($form->_amount == 0.0 && !$form->_params['is_pay_later'])) {
 -      if ($result) {
 -        $form->_params = array_merge($form->_params, $result);
 -      }
 -      $form->set('params', $form->_params);
 -      $form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
 -
 -      // result has all the stuff we need
 -      // lets archive it to a financial transaction
 -      //@todo - this is done in 2 places - can't we just do it once straight after retrieving contribution type -
 -      // when would this be a bad thing?
 -      if ($contributionType->is_deductible) {
 -        $form->assign('is_deductible', TRUE);
 -        $form->set('is_deductible', TRUE);
 +      // restore cached values (part of fix for CRM-14354)
 +      if (!empty($cachedFormValue)) {
 +        $form->_values['is_recur'] = $cachedFormValue;
 +        $paymentParams['is_recur'] = $cachedParamValue;
        }
  
 +      $paymentParams['contributionID'] = $contribution->id;
 +      //CRM-15297 deprecate contributionTypeID
 +      $paymentParams['financialTypeID'] = $paymentParams['contributionTypeID'] = $contribution->financial_type_id;
 +      $paymentParams['contributionPageID'] = $contribution->contribution_page_id;
        if (isset($paymentParams['contribution_source'])) {
 -        $form->_params['source'] = $paymentParams['contribution_source'];
 +        $paymentParams['source'] = $paymentParams['contribution_source'];
        }
  
 -      // check if pending was set to true by payment processor
 -      $pending = FALSE;
 -      if (!empty($form->_params['contribution_status_pending'])) {
 -        $pending = TRUE;
 -      }
 -      if (!(!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct')) {
 -        $contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form,
 -          $form->_params, $result,
 -          $contactID, $contributionType,
 -          $pending, TRUE,
 -          $isTest,
 -          $lineItems
 -        );
 -      }
 -      $form->postProcessPremium($premiumParams, $contribution);
 -      if (is_array($result)) {
 -        if (!empty($result['trxn_id'])) {
 -          $contribution->trxn_id = $result['trxn_id'];
 -        }
 -        if (!empty($result['payment_status_id'])) {
 -          $contribution->payment_status_id = $result['payment_status_id'];
 -        }
 +      if ($form->_values['is_recur'] && $contribution->contribution_recur_id) {
 +        $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
        }
 -      $membershipResult[1] = $contribution;
 -    }
  
-       if ($form->_contributeMode) {
 -    if ($component == 'membership') {
 -      return $membershipResult;
 -    }
 -
 -    //  Email is done when the payment is completed (now or later)
 -    // by completetransaction, rather than the form.
 -    // We are moving towards it being done for all payment methods in completetransaction.
 -    if (!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct') {
 -      if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
++      if ($form->_contributeMode && $form->_amount > 0.0) {
          try {
 -          civicrm_api3('contribution', 'completetransaction', array(
 -            'id' => $contribution->id,
 -            'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
 -            'is_transactional' => FALSE,
 -          ));
 +          $payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
 +          if ($form->_contributeMode == 'notify') {
 +            // We want to get rid of this & make it generic - eg. by making payment processing the last thing
 +            // and always calling it first.
 +            $form->postProcessHook();
 +          }
 +          $result = $payment->doPayment($paymentParams);
 +          $form->_params = array_merge($form->_params, $result);
 +          $form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
 +          if (!empty($result['trxn_id'])) {
 +            $contribution->trxn_id = $result['trxn_id'];
 +          }
 +          if (!empty($result['payment_status_id'])) {
 +            $contribution->payment_status_id = $result['payment_status_id'];
 +          }
 +          $result['contribution'] = $contribution;
 +          return $result;
          }
 -        catch (CiviCRM_API3_Exception $e) {
 -          if ($e->getErrorCode() != 'contribution_completed') {
 -            throw new CRM_Core_Exception('Failed to update contribution in database');
 +        catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
 +          // Clean up DB as appropriate.
 +          if (!empty($paymentParams['contributionID'])) {
 +            CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'],
 +              $paymentParams['contactID'], $e->getMessage());
 +          }
 +          if (!empty($paymentParams['contributionRecurID'])) {
 +            CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
            }
 +
 +          $result['is_payment_failure'] = TRUE;
 +          $result['error'] = $e;
 +          return $result;
          }
        }
 -      return TRUE;
 +    }
 +
 +    // Only pay later or unpaid should reach this point. The theory is that paylater should get a receipt now &
 +    // processor
 +    // transaction receipts should be outcome driven.
 +    $form->set('params', $form->_params);
 +    if (isset($paymentParams['contribution_source'])) {
 +      $form->_params['source'] = $paymentParams['contribution_source'];
      }
  
      // get the price set values for receipt.
Simple merge
Simple merge
Simple merge
Simple merge
index faafb8f65aa28dfb0ca3ba764da8854fb0e4b440,832843f3c522e25b7f23cf04c8549a502a088aa2..20318ffdc3ced5c80ffb2d7e3a9d39c8e0e0b494
@@@ -852,9 -852,10 +852,11 @@@ class CiviSeleniumTestCase extends PHPU
      elseif ($processorType == 'AuthNet') {
        // FIXME: we 'll need to make a new separate account for testing
        $processorSettings = array(
-         'user_name' => '5ULu56ex',
+         //dummy live username/password are passed to bypass processor validation on live credential
+         'user_name' => '3HcY62mY',
+         'password' => '69943NrwaQA92b8J',
          'test_user_name' => '5ULu56ex',
 +        'password' => '7ARxW575w736eF5p',
          'test_password' => '7ARxW575w736eF5p',
        );
      }
index e51209ed78b4e511a28a19d35e74603cbc70e205,eda26ef03095dc48f1202dfa9e840fb795983221..3bfe9eba135b85207e04da438a85d2fdb3b45fe4
@@@ -208,9 -207,9 +208,9 @@@ class WebTest_Member_OnlineMembershipCr
     * @param $hash
     * @param bool $otherAmount
     */
-   public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE) {
+   public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE) {
      //Open Live Contribution Page
 -    $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom");
 +    $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
      // Select membership type 1
      $this->waitForElementPresent("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label");
      if ($memTypeId != 'No thank you') {