Skip to content

Commit

Permalink
Merge pull request civicrm#10986 from eileenmcnaughton/pp
Browse files Browse the repository at this point in the history
CRM-20800 fix fatal error up updating paypal contributions
  • Loading branch information
eileenmcnaughton authored and sluc23 committed Jan 10, 2018
2 parents 5d403ea + 11ff868 commit 8a06f16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CRM/Contribute/Form/UpdateSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ 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'];
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 8a06f16

Please sign in to comment.