* Recur contribution params
*
* @return bool
+ * @throws \CRM_Core_Exception
+ * @internal
+ *
*/
- public static function cancelRecurContribution($params) {
- if (is_numeric($params)) {
- CRM_Core_Error::deprecatedFunctionWarning('You are using a BAO function whose signature has changed. Please use the ContributionRecur.cancel api');
- $params = ['id' => $params];
- }
- $recurId = $params['id'];
- if (!$recurId) {
+ public static function cancelRecurContribution(array $params): bool {
+ if (!$params['id']) {
return FALSE;
}
$activityParams = [
$cancelledId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', 'Cancelled');
$recur = new CRM_Contribute_DAO_ContributionRecur();
- $recur->id = $recurId;
+ $recur->id = $params['id'];
$recur->whereAdd("contribution_status_id != $cancelledId");
if ($recur->find(TRUE)) {
$recur->save();
// @fixme https://lab.civicrm.org/dev/core/issues/927 Cancelling membership etc is not desirable for all use-cases and we should be able to disable it
- $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurId);
+ $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params['id']);
if ($dao && $dao->recur_id) {
$details = $activityParams['details'] ?? NULL;
if ($dao->auto_renew && $dao->membership_id) {
* @param array $params
* Array containing id of the recurring contribution.
*
- * @return bool
+ * @return array
* returns true is successfully cancelled
+ * @throws \CRM_Core_Exception
*/
-function civicrm_api3_contribution_recur_cancel($params) {
+function civicrm_api3_contribution_recur_cancel(array $params): array {
return CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($params) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while cancelling recurring contribution'));
}