Move handling of participant.cancel to contributioncancelactions extension
[civicrm-core.git] / CRM / Core / Payment / BaseIPN.php
index daa0988b56470a7aaa02ca6e07c85a975167dafa..7bf95e4710fbc7e4e0e5af20f0905333747e8c9e 100644 (file)
@@ -237,6 +237,7 @@ class CRM_Core_Payment_BaseIPN {
    * @throws \CiviCRM_API3_Exception|\CRM_Core_Exception
    */
   public function cancelled($objects) {
+    CRM_Core_Error::deprecatedFunctionWarning('Use Contribution create api to cancel the contribution');
     $contribution = &$objects['contribution'];
 
     if (empty($contribution->id)) {
@@ -270,6 +271,11 @@ class CRM_Core_Payment_BaseIPN {
           }
         }
       }
+      $participant = &$objects['participant'];
+
+      if ($participant) {
+        $this->cancelParticipant($participant->id);
+      }
     }
     else {
       Contribution::update(FALSE)->setValues([
@@ -277,11 +283,6 @@ class CRM_Core_Payment_BaseIPN {
         'contribution_status_id:name' => 'Cancelled',
       ])->addWhere('id', '=', $contribution->id)->execute();
     }
-    $participant = &$objects['participant'];
-
-    if ($participant) {
-      $this->cancelParticipant($participant->id);
-    }
 
     Civi::log()->debug("Setting contribution status to Cancelled");
     return TRUE;
@@ -309,6 +310,8 @@ class CRM_Core_Payment_BaseIPN {
    * Logic to cancel a participant record when the related contribution changes to failed/cancelled.
    * @todo This is part of a bigger refactor for dev/core/issues/927 - "duplicate" functionality exists in CRM_Contribute_BAO_Contribution::cancel()
    *
+   * @deprecated
+   *
    * @param $participantID
    *
    * @throws \CiviCRM_API3_Exception