CRM-14536 fix - Free Membership still submits to payment processor
authormonishdeb <monish.deb@webaccessglobal.com>
Fri, 7 Aug 2015 17:43:07 +0000 (23:13 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 10 Aug 2015 10:32:08 +0000 (16:02 +0530)
https://issues.civicrm.org/jira/browse/CRM-14536

CRM/Contribute/BAO/Contribution/Utils.php
templates/CRM/Contribute/Form/Contribution/Confirm.tpl
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/ThankYou.tpl

index 8b390fab83b6c95c8c93e8d1893d1ceb77d17e42..a30e26e3e287a8c729aaf86915671e90d1d6f88d 100644 (file)
@@ -264,11 +264,13 @@ class CRM_Contribute_BAO_Contribution_Utils {
           $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
         }
       }
-      if (is_object($payment)) {
-        $result = $payment->doDirectPayment($paymentParams);
-      }
-      else {
-        CRM_Core_Error::fatal($paymentObjError);
+      if ($form->_amount > 0.0) {
+        if (is_object($payment)) {
+          $result = $payment->doDirectPayment($paymentParams);
+        }
+        else {
+          CRM_Core_Error::fatal($paymentObjError);
+        }
       }
     }
 
index 8035b33f94f190199c9857c2c9ba5c37e331c5cc..47de852da3b9970dc1bf1a01145792118b870635 100644 (file)
@@ -54,7 +54,7 @@
 
     {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="confirmContribution"}
 
-    {if $amount GT 0 OR $minimum_fee GT 0 OR ( $priceSetID and $lineItem ) }
+    {if $amount GTE 0 OR $minimum_fee GTE 0 OR ( $priceSetID and $lineItem ) }
     <div class="crm-group amount_display-group">
        {if !$useForMember}
         <div class="header-dark">
index df84e8382ee2ec5f14e17f275be286589762b7d6..934a6dedd2221e42c126d789b6e8e932e52fe529 100644 (file)
   {/if}
   {literal}
 
-  function toggleConfirmButton() {
+  function toggleConfirmButton(flag) {
     var payPalExpressId = "{/literal}{$payPalExpressId}{literal}";
     var elementObj = cj('input[name="payment_processor"]');
     if ( elementObj.attr('type') == 'hidden' ) {
       var processorTypeId = elementObj.filter(':checked').val();
     }
 
-    if (payPalExpressId !=0 && payPalExpressId == processorTypeId) {
+    if (payPalExpressId !=0 && payPalExpressId == processorTypeId && flag === false) {
       cj("#crm-submit-buttons").hide();
+      cj("#paypalExpress").show();
     }
     else {
       cj("#crm-submit-buttons").show();
+      if (flag === true) {
+        cj("#paypalExpress").hide();
+      }
     }
   }
 
   cj('input[name="payment_processor"]').change( function() {
-    toggleConfirmButton();
+    toggleConfirmButton(false);
   });
 
   CRM.$(function($) {
-    toggleConfirmButton();
+    toggleConfirmButton(false);
     enableHonorType();
     showRecurHelp();
     skipPaymentMethod();
       payment_options.hide();
       payment_processor.hide();
       payment_information.hide();
-      // also unset selected payment methods
-      cj('input[name="payment_processor"]').removeProp('checked');
     }
     else {
       payment_options.show();
   
   function skipPaymentMethod() {
     var flag = false;
-    cj('.price-set-option-content input').each( function(){
-      currentTotal = cj(this).attr('data-amount').replace(/[^\/\d]/g,'');
-      if( cj(this).is(':checked') && currentTotal == 0 ) {
+    if (cj('#pricevalue').length !== 0) {
+    currentTotal = cj('#pricevalue').text().replace(/[^\/\d]/g,'');
+    flag = (currentTotal == 0) ? true : false;
+    }
+    else {
+      cj('.price-set-option-content input').each( function(){
+        currentTotal = cj(this).attr('data-amount').replace(/[^\/\d]/g,'');
+        if( cj(this).is(':checked') && currentTotal == 0 ) {
           flag = true;
-      }
-    });
-    cj('.price-set-option-content input').change( function () {
-      if (cj(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
-        flag = true;
-      } else {
-        flag = false;
-      }
-      showHidePayment(flag);
-    });
+        }
+      });
+      cj('.price-set-option-content input').change( function () {
+        if (cj(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
+          flag = true;
+        } else {
+          flag = false;
+        }
+        toggleConfirmButton(flag);
+        showHidePayment(flag);
+      });
+    }
+    toggleConfirmButton(flag);
     showHidePayment(flag);
   }
 
index 311bd5c57f706d8bb73f6d56ca3b246976cc1116..3ba22ea541399fdd81c9f355ef104fe3a59c689c 100644 (file)
@@ -90,7 +90,7 @@
 
   {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="thankContribution"}
 
-  {if $amount GT 0 OR $minimum_fee GT 0 OR ( $priceSetID and $lineItem ) }
+  {if $amount GTE 0 OR $minimum_fee GTE 0 OR ( $priceSetID and $lineItem ) }
     <div class="crm-group amount_display-group">
       {if !$useForMember}
         <div class="header-dark">