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

[REF] Follow up cleanup #17788

Merged
merged 1 commit into from
Jul 13, 2020
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
25 changes: 9 additions & 16 deletions CRM/Contribute/Form/CancelSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
*/

use Civi\Payment\PropertyBag;
use Civi\Payment\Exception\PaymentProcessorException;

/**
* This class provides support for canceling recurring subscriptions.
*/
class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_ContributionRecur {

protected $_userContext = NULL;
protected $_userContext;

protected $_mode = NULL;
protected $_mode;

/**
* The contributor email
Expand Down Expand Up @@ -196,10 +197,10 @@ public function setDefaultValues() {
* Process the form submission.
*
* @throws \CRM_Core_Exception
* @throws \API_Exception
*/
public function postProcess() {
$message = NULL;
$cancelSubscription = TRUE;
$params = $this->controller->exportValues($this->_name);

if ($this->isSelfService()) {
Expand All @@ -222,11 +223,10 @@ public function postProcess() {
$propertyBag->setRecurProcessorID($this->getSubscriptionDetails()->processor_id);
$message = $this->_paymentProcessorObj->doCancelRecurring($propertyBag)['message'];
}
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
catch (PaymentProcessorException $e) {
CRM_Core_Error::statusBounce($e->getMessage());
}

if ($cancelSubscription) {
try {
civicrm_api3('ContributionRecur', 'cancel', [
'id' => $this->getSubscriptionDetails()->recur_id,
Expand Down Expand Up @@ -310,24 +310,17 @@ public function postProcess() {
$status = ts('Recurring contribution could not be cancelled in the database.');
}
}
}
else {
$status = ts('The recurring contribution could not be cancelled.');
$msgTitle = 'Error Cancelling Contribution';
$msgType = 'error';
}

$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$userID = CRM_Core_Session::getLoggedInContactID();
if ($userID && $status) {
$session->setStatus($status, $msgTitle, $msgType);
CRM_Core_Session::singleton()->setStatus($status, $msgTitle, $msgType);
}
elseif (!$userID) {
if ($status) {
CRM_Utils_System::setUFMessage($status);
// keep result as 1, since we not displaying anything on the redirected page anyway
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus',
"reset=1&task=cancel&result=1"));
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus',
'reset=1&task=cancel&result=1'));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/Form/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form {
/**
* Details of the subscription (recurring contribution) to be altered.
*
* @var array
* @var \CRM_Core_DAO
*/
protected $subscriptionDetails = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

It does seem to be a DAO, so now this initialization is weird.

Otherwise agree with everything in the PR and did a quick r-run seems ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@demeritcowboy ouch - but TBH I'd rather punt on that as the change is right & I'm not touching this form other than comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok


Expand Down Expand Up @@ -179,7 +179,7 @@ protected function setSubscriptionDetails() {
/**
* Get details for the recurring contribution being altered.
*
* @return array
* @return \CRM_Core_DAO
*/
public function getSubscriptionDetails() {
return $this->subscriptionDetails;
Expand Down