Skip to content

Commit

Permalink
CRM-20800 fix fatal error up updating paypal contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Sep 16, 2017
1 parent db3a540 commit 7ab2216
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CRM/Contribute/Form/UpdateSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ public function preProcess() {

$this->contributionRecurID = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->contributionRecurID) {
$this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
if (!$this->_paymentProcessor) {
try {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID);
}
catch (CRM_Core_Exception $e) {
CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
}
$this->_paymentProcessorObj = $this->_paymentProcessor['object'];
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID);
}

Expand Down
16 changes: 16 additions & 0 deletions CRM/Financial/BAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ public static function getProcessorForEntity($entityID, $component = 'contribute
WHERE con.id = %1";
}
elseif ($component == 'recur') {
// @deprecated - use getPaymentProcessorForRecurringContribution.
$sql = "
SELECT cr.payment_processor_id as ppID1, NULL as ppID2, cr.is_test
FROM civicrm_contribution_recur cr
Expand Down Expand Up @@ -549,4 +550,19 @@ public static function getProcessorForEntity($entityID, $component = 'contribute
return $result;
}

/**
* Get the payment processor associated with a recurring contribution series.
*
* @param int $contributionRecurID
*
* @return \CRM_Core_Payment
*/
public static function getPaymentProcessorForRecurringContribution($contributionRecurID) {
$paymentProcessorId = civicrm_api3('ContributionRecur', 'getvalue', array(
'id' => $contributionRecurID,
'return' => 'payment_processor_id',
));
return Civi\Payment\System::singleton()->getById($paymentProcessorId);
}

}

0 comments on commit 7ab2216

Please sign in to comment.