diff --git a/CRM/Core/Payment/StripeIPN.php b/CRM/Core/Payment/StripeIPN.php
index 528fd1e57a50b4c058a42338b001ae7d6c505c92..41fecef8cdaa3aa636f3066ab9a9d1ca1407ae60 100644
--- a/CRM/Core/Payment/StripeIPN.php
+++ b/CRM/Core/Payment/StripeIPN.php
@@ -221,9 +221,9 @@ class CRM_Core_Payment_StripeIPN {
           }
         }
         if (civicrm_api3('Mjwpayment', 'get_payment', [
-          'trxn_id' => $this->charge_id,
-          'status_id' => 'Completed'
-        ])['count'] > 0) {
+            'trxn_id' => $this->charge_id,
+            'status_id' => 'Completed'
+          ])['count'] > 0) {
           // Payment already recorded
           return TRUE;
         }
@@ -263,16 +263,6 @@ class CRM_Core_Payment_StripeIPN {
         }
         return TRUE;
 
-      case 'customer.subscription.deleted':
-        // Subscription is cancelled
-        if (!$this->getSubscriptionDetails()) {
-          // Subscription was not found in CiviCRM
-          return TRUE;
-        }
-        // Cancel the recurring contribution
-        $this->updateRecurCancelled(['id' => $this->contribution_recur_id, 'cancel_date' => $this->retrieve('cancel_date', 'String', FALSE)]);
-        return TRUE;
-
       // One-time donation and per invoice payment.
       case 'charge.failed':
         // If we don't have a customer_id we can't do anything with it!
@@ -383,6 +373,16 @@ class CRM_Core_Payment_StripeIPN {
           'frequency_interval' => $this->frequency_interval,
         ]);
         return TRUE;
+
+      case 'customer.subscription.deleted':
+        // Subscription is cancelled
+        if (!$this->getSubscriptionDetails()) {
+          // Subscription was not found in CiviCRM
+          return TRUE;
+        }
+        // Cancel the recurring contribution
+        $this->updateRecurCancelled(['id' => $this->contribution_recur_id, 'cancel_date' => $this->retrieve('cancel_date', 'String', FALSE)]);
+        return TRUE;
     }
     // Unhandled event type.
     return TRUE;