From 7b3cf4208394eff30a2a54561c6c27cf2c77ae11 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 1 Jun 2020 11:13:06 +0100 Subject: [PATCH] Don't allow Contribution.repeattransaction to be used without a recurring contribution --- api/v3/Contribution.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 859dbaed2e..bbe0169181 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -594,6 +594,14 @@ function civicrm_api3_contribution_repeattransaction($params) { throw new API_Exception( 'A valid original contribution ID is required', 'invalid_data'); } + // We don't support repeattransaction without a related recurring contribution. + if (empty($contribution->contribution_recur_id)) { + throw new API_Exception( + 'Repeattransaction API can only be used in the context of contributions that have a contribution_recur_id.', + 'invalid_data' + ); + } + $original_contribution = clone $contribution; $input['payment_processor_id'] = civicrm_api3('contributionRecur', 'getvalue', [ 'return' => 'payment_processor_id', -- 2.25.1