CRM-18688: Cancel IPN cancels entire membership
authorroot <nishant.bhorodia@gmail.com>
Wed, 8 Jun 2016 12:26:22 +0000 (17:56 +0530)
committerroot <nishant.bhorodia@gmail.com>
Wed, 8 Jun 2016 12:26:22 +0000 (17:56 +0530)
CRM/Core/Payment/BaseIPN.php

index f8cba5dadfb156656bd3e2353751dfc21e852fda..8bbbd788cbd876c74207e5e9304393ddbd13f681 100644 (file)
@@ -328,8 +328,15 @@ class CRM_Core_Payment_BaseIPN {
             'labelColumn' => 'name',
             'flip' => 1,
           ));
+        // Prevent active memberships from being cancelled
+        // CRM-18688
+        $activeStatuses = array(
+          $membershipStatuses['New'],
+          $membershipStatuses['Current'],
+          $membershipStatuses['Grace'],
+        );
         foreach ($memberships as $membership) {
-          if ($membership) {
+          if ($membership && !in_array($membership->status_id, $activeStatuses)) {
             $membership->status_id = $membershipStatuses['Cancelled'];
             $membership->save();