CRM-16559 allow recurring contributions to go against pledges for supporting processors
authorEileen McNaughton <eileen@fuzion.co.nz>
Tue, 21 Jul 2015 07:29:06 +0000 (19:29 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Tue, 21 Jul 2015 07:29:06 +0000 (19:29 +1200)
CRM/Contribute/Form/Contribution.php
CRM/Core/Payment.php
CRM/Core/Payment/AuthorizeNet.php
CRM/Core/Payment/PayPalImpl.php
templates/CRM/Contribute/Form/Contribution.tpl

index bbeab9c8d325cc1ce3abeed6fba7629638d8aa3d..5df673a7b256f6b6257ef526f1e11607711308cf 100644 (file)
@@ -592,6 +592,15 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     if (empty($this->_recurPaymentProcessors)) {
       $buildRecurBlock = FALSE;
     }
+    if ($this->_ppID) {
+      foreach ($this->_paymentProcessors as $processor) {
+        if (!empty($processor['is_recur']) && !empty($processor['object']) && $processor['object']->supports('recurContributionsForPledges')) {
+          $buildRecurBlock = TRUE;
+          break;
+        }
+        $buildRecurBlock = FALSE;
+      }
+    }
     if ($buildRecurBlock) {
       CRM_Contribute_Form_Contribution_Main::buildRecur($this);
       $this->setDefaults(array('is_recur' => 0));
index 04238bcecd45583cca5452e43f7cd9993623aac2..5dd8ced50a62a518090390e6730eed067588f472 100644 (file)
@@ -191,6 +191,22 @@ abstract class CRM_Core_Payment {
     return FALSE;
   }
 
+  /**
+   * Can recurring contributions be set against pledges.
+   *
+   * In practice all processors that use the baseIPN function to finish transactions or
+   * call the completetransaction api support this by looking up previous contributions in the
+   * series and, if there is a prior contribution against a pledge, and the pledge is not complete,
+   * adding the new payment to the pledge.
+   *
+   * However, only enabling for processors it has been tested against.
+   *
+   * @return bool
+   */
+  protected function supportsRecurContributionsForPledges() {
+    return FALSE;
+  }
+
   /**
    * Default payment instrument validation.
    *
index c0ad5f2049a8c210a0904ac73c9c8afa3fc33555..e320c8480fb995298f95a2ddaad2d9d2c6cc909f 100644 (file)
@@ -73,6 +73,22 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment {
     return TRUE;
   }
 
+  /**
+   * Can recurring contributions be set against pledges.
+   *
+   * In practice all processors that use the baseIPN function to finish transactions or
+   * call the completetransaction api support this by looking up previous contributions in the
+   * series and, if there is a prior contribution against a pledge, and the pledge is not complete,
+   * adding the new payment to the pledge.
+   *
+   * However, only enabling for processors it has been tested against.
+   *
+   * @return bool
+   */
+  protected function supportsRecurContributionsForPledges() {
+    return TRUE;
+  }
+
   /**
    * Submit a payment using Advanced Integration Method.
    *
index 85ff69aa62f6a5282705f543a079b67bf798b06b..28ba5849bdb23b59b7a96bbe97fe3bb949146544 100644 (file)
@@ -85,6 +85,22 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
     return FALSE;
   }
 
+  /**
+   * Can recurring contributions be set against pledges.
+   *
+   * In practice all processors that use the baseIPN function to finish transactions or
+   * call the completetransaction api support this by looking up previous contributions in the
+   * series and, if there is a prior contribution against a pledge, and the pledge is not complete,
+   * adding the new payment to the pledge.
+   *
+   * However, only enabling for processors it has been tested against.
+   *
+   * @return bool
+   */
+  protected function supportsRecurContributionsForPledges() {
+    return TRUE;
+  }
+
   /**
    * Express checkout code. Check PayPal documentation for more information
    *
index 09231b05300eb234ab882a3be8a87c126f1b3a52..b74152b4f2ab1f8347f5b52efff32826f7696ff0 100644 (file)
       </td>
     </tr>
 
-      {if $buildRecurBlock && !$ppID}
+      {if $buildRecurBlock}
       <tr id='recurringPaymentBlock' class='hiddenElement'>
         <td></td>
         <td>