From: Eileen McNaughton Date: Tue, 21 Jul 2015 07:29:06 +0000 (+1200) Subject: CRM-16559 allow recurring contributions to go against pledges for supporting processors X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=677fe56c2e441aa5e9ef60ee465bc625fcde570d;p=civicrm-core.git CRM-16559 allow recurring contributions to go against pledges for supporting processors --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index bbeab9c8d3..5df673a7b2 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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)); diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 04238bcecd..5dd8ced50a 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -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. * diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index c0ad5f2049..e320c8480f 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -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. * diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 85ff69aa62..28ba5849bd 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -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 * diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 09231b0530..b74152b4f2 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -118,7 +118,7 @@ - {if $buildRecurBlock && !$ppID} + {if $buildRecurBlock}