CRM-17539 membership payments not completing AND sending emails
authoreileen <emcnaughton@wikimedia.org>
Thu, 12 Nov 2015 23:12:55 +0000 (15:12 -0800)
committereileen <emcnaughton@wikimedia.org>
Thu, 12 Nov 2015 23:16:57 +0000 (15:16 -0800)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Core/Payment.php

index 22e70789d7a9217d7cec059953a1d45e713de16b..62e4414fd39b761a33f90b87575ee42d9b0a1f2b 100644 (file)
@@ -108,7 +108,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $contributionParams['contribution_recur_id'] = $recurringContributionID;
     }
 
-    $contributionParams['contribution_status_id'] = ($pending && $contributionParams['total_amount'] != 0) ? 2 : 1;
+    $contributionParams['contribution_status_id'] = $pending ? 2 : 1;
     if (isset($contributionParams['invoice_id'])) {
       $contributionParams['id'] = CRM_Core_DAO::getFieldValue(
         'CRM_Contribute_DAO_Contribution',
index d0667b038c8dcbb7b55ba6ef9bf43802bd0737d6..2fc18e2f0d244d40274653d68e811fc38d794486 100644 (file)
@@ -916,6 +916,15 @@ abstract class CRM_Core_Payment {
   public function doPayment(&$params, $component = 'contribute') {
     $this->_component = $component;
     $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id');
+
+    // If we have a $0 amount, skip call to processor and set payment_status to Completed.
+    // Conceivably a processor might override this - perhaps for setting up a token - but we don't
+    // have an example of that at the mome.
+    if ($params['amount'] == 0) {
+      $result['payment_status_id'] = array_search('Completed', $statuses);
+      return $result;
+    }
+
     if ($this->_paymentProcessor['billing_mode'] == 4) {
       $result = $this->doTransferCheckout($params, $component);
       if (is_array($result) && !isset($result['payment_status_id'])) {