Improve interaction between payment processor & cancelling
I've just taken a look at why some contributions don't show the full cancel screen but only the disable screen for cancelling recurring ie
vs
And what I see is the former shows if the payment processor supports CancelRecurring - this is set to TRUE - which is the case if the function cancelSubscription exists
However, it's only relevant if 'send_cancel_request' is checked.
if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) {
$cancelParams = ['subscriptionId' => $this->_subscriptionDetails->subscription_id];
$cancelSubscription = $this->_paymentProcessorObj->cancelSubscription($message, $cancelParams);
}
So we have 2 decision points
- do we show the cancel form or the disable form
- do we show the notify payment processor checkbox / call cancelSubscription
PROPOSAL I feel like a better mix would be.
- always show the cancel screen rather than the if supportsCancelRecurring is TRUE. (I'm about 70% of the way to just saying 'always' - I don't see the advantage of the disable screen)
- add an additional parameter supportsCancelNotifyProcessor that determines whether the check box shows up - we would need to default to TRUE for grandfathering (probably at the form level) unless supportsCancelRecurring is FALSE
- always call the cancelRecurring button on submit IF the function cancelRecurring exists. (new preferred behaviour to grandfather in)
- if cancelRecurring does not exist fall back to cancelSubscription IF exists AND 'send_cancel_request' is true (current behaviour)
5
Changes to documentation would be
- if your processor allows recurring contributions to be cancelled then implement supportsCancelRecurring and return a boolean (relying on the parent is deprecated)
- implement supportsCancelNotifyProcessor to determine whether the 'Send cancellation request to xx' radio button will show (default = yes )
- add the current disabled text in if not showing the 'send to processor' box but use $processor->getText() so it can be overridden & set to null
- implement cancelRecurring function if your processor needs to take an action on cancelling (it will need to parse the 'send_cancel_request' param in that function as it will be called either way.
- cancelSubscription is deprectated
Secondary thoughts
- I'm not a fan of it defaulting to notify the person but OK
- I'm really not a fan of the backstop implementation of supportsCancelRecurring
protected function supportsCancelRecurring() {
return method_exists(CRM_Utils_System::getClassName($this), 'cancelSubscription');
}
I'd rather see us expect the payment processor to return TRUE or FALSE