CRM-16975 fix for membership price set config - backport 4.7 code that allows more...
authoreileenmcnaugton <eileen@fuzion.co.nz>
Thu, 6 Aug 2015 06:05:21 +0000 (18:05 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Thu, 6 Aug 2015 08:29:32 +0000 (20:29 +1200)
multiple payments are supported

CRM/Core/Payment.php
CRM/Member/Form/MembershipBlock.php

index 5dd8ced50a62a518090390e6730eed067588f472..3a45446495579baa04ef1c631ff78d2b87a623e9 100644 (file)
@@ -162,6 +162,24 @@ abstract class CRM_Core_Payment {
     }
   }
 
+  /**
+   * Can more than one transaction be processed at once?
+   *
+   * In general processors that process payment by server to server communication support this while others do not.
+   *
+   * In future we are likely to hit an issue where this depends on whether a token already exists.
+   *
+   * @return bool
+   */
+  protected function supportsMultipleConcurrentPayments() {
+    if ($this->_paymentProcessor['billing_mode'] == 4 || $this->_paymentProcessor['payment_type'] != 1) {
+      return FALSE;
+    }
+    else {
+      return TRUE;
+    }
+  }
+
   /**
    * Are live payments supported - e.g dummy doesn't support this.
    *
@@ -763,7 +781,7 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
     }
 
     // Else default
-    return $this->_paymentProcessor['url_recur'];
+    return isset($this->_paymentProcessor['url_recur']) ? $this->_paymentProcessor['url_recur'] : '';
   }
 
 }
index 1103a7552427eed9fdadb304b65c77b5c8808b1c..c565847c04fbe6df87ccf6e809d93797f16934f0 100644 (file)
@@ -243,19 +243,13 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa
         $paymentProcessorId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $paymentProcessorIds);
 
         if (!empty($paymentProcessorId)) {
-          $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, NULL, 'name');
           foreach ($paymentProcessorId as $pid) {
             if ($pid) {
-              $paymentProcessorTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor',
-                $pid, 'payment_processor_type_id'
-              );
-            }
-            if (!($paymentProcessorTypeId == CRM_Utils_Array::key('PayPal', $paymentProcessorType) ||
-              ($paymentProcessorTypeId == CRM_Utils_Array::key('AuthNet', $paymentProcessorType)))
-            ) {
-              $errors['member_price_set_id'] = ts('The membership price set associated with this online contribution allows a user to select BOTH an auto-renew AND a non-auto-renew membership. This requires submitting multiple processor transactions, and is not supported for one or more of the payment processors enabled under the Amounts tab.');
+              $processor = Civi\Payment\System::singleton()->getById($pid);
+              if (!$processor->supports('MultipleConcurrentPayments')) {
+                $errors['member_price_set_id'] = ts('The membership price set associated with this online contribution allows a user to select BOTH an auto-renew AND a non-auto-renew membership. This requires submitting multiple processor transactions, and is not supported for one or more of the payment processors enabled under the Amounts tab.');
+              }
             }
-
           }
         }
       }