Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20800 fix fatal error up updating paypal contributions #10986

Merged
merged 2 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it needs to be $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID);

I think, but the issue is a bit more than this. I think it's about making it so a cancellation happens if UI changes (changing installment number, end_date) effectively cancel it. I think it might be easier to change installments on the form when end_date changes - or force user to & possibly move this to the ContributionRecur BAO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree of what need to be addressed, I made the revert to fix a issue mentioned by reporter - https://issues.civicrm.org/jira/browse/CRM-20800?focusedCommentId=108162&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-108162

I though the same but then $this->_paymentProcessor will be set to NULL which later assigned at L140. Although I found no use of $this->_paymentProcessor anywhere in UpdateSubscription php or template, so we might need to keep any one form variable, that would be:

  1. Rename $_paymentProcessorObject to $_paymentProcessor
  2. Remove $_paymentProcessorObject

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a hard time in replicating the issue, so I am relying on reporter's response :(

}
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);
}

}