This is https://github.com/civicrm/civicrm-core/pull/18196 without the bit I was uncomfortable with
$this->setTitle($this->_mid ? ts('Cancel Auto-renewal') : ts('Cancel Recurring Contribution'));
$this->assign('mode', $this->_mode);
+ if ($this->isSelfService() || !$this->_paymentProcessorObj->supports('cancelRecurring')) {
+ // If we are self service (contact is cancelling for themselves via a cancel link)
+ // or the processor does not support cancellation then remove the fields
+ // specifying whether to notify the processor.
+ unset($this->entityFields['send_cancel_request']);
+ }
if ($this->isSelfService()) {
- unset($this->entityFields['send_cancel_request'], $this->entityFields['is_notify']);
+ // Arguably the is_notify field should be removed in self-service mode.
+ // Historically this has been the case...
+ unset($this->entityFields['is_notify']);
}
if ($this->getSubscriptionDetails()->contact_id) {
$links[CRM_Core_Action::DISABLE] = [
'name' => ts('Cancel'),
'title' => ts('Cancel'),
- 'ref' => 'crm-enable-disable',
+ 'url' => 'civicrm/contribute/unsubscribe',
+ 'qs' => 'reset=1&crid=%%crid%%&cid=%%cid%%&context=' . $context,
];
- if ($paymentProcessorObj->supports('cancelRecurring')) {
- unset($links[CRM_Core_Action::DISABLE]['extra'], $links[CRM_Core_Action::DISABLE]['ref']);
- $links[CRM_Core_Action::DISABLE]['url'] = "civicrm/contribute/unsubscribe";
- $links[CRM_Core_Action::DISABLE]['qs'] = "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}";
- }
-
if ($paymentProcessorObj->supports('UpdateSubscriptionBillingInfo')) {
$links[CRM_Core_Action::RENEW] = [
'name' => ts('Change Billing Details'),
}
/**
- * Test if the full fledged form is displayed on cancelling the Recurring Contribution with a payment processor which does not support cancelling a Recurring Contribution
+ * Test if the full fledged form is displayed on cancelling the Recurring
+ * Contribution with a payment processor which does not support cancelling a
+ * Recurring Contribution
*
- * @throws \CRM_Core_Exception|\API_Exception
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testCancelSubscriptionForm(): void {
$this->addContribution();
]);
$actions = CRM_Contribute_Page_Tab::recurLinks($this->getContributionRecurID());
- // Using "crm-enable-disable"
- $this->assertEquals($actions[CRM_Core_Action::DISABLE]['ref'], 'crm-enable-disable');
// Using "Cancel Recurring" form
- // $this->assertEquals($actions[CRM_Core_Action::DISABLE]['url'], 'civicrm/contribute/unsubscribe');
+ $this->assertEquals('civicrm/contribute/unsubscribe', $actions[CRM_Core_Action::DISABLE]['url']);
}
}