[REF] Simplify sendNotification determination
authoreileen <emcnaughton@wikimedia.org>
Wed, 25 Nov 2020 19:20:24 +0000 (08:20 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 25 Nov 2020 19:22:54 +0000 (08:22 +1300)
CRM/Core/Payment/PayPalIPN.php

index 14279e30a768029d42f9db298c60276ea92b63c9..5a26991b6b9821acf847336d03506165da08e4d8 100644 (file)
@@ -95,7 +95,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
 
     $now = date('YmdHis');
 
-    $sendNotification = FALSE;
     $subscriptionPaymentStatus = NULL;
     // set transaction type
     $txnType = $this->retrieve('txn_type', 'String');
@@ -113,7 +112,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
         }
         $recur->processor_id = $this->retrieve('subscr_id', 'String');
         $recur->trxn_id = $recur->processor_id;
-        $sendNotification = TRUE;
         $subscriptionPaymentStatus = CRM_Core_Payment::RECURRING_PAYMENT_START;
         break;
 
@@ -122,7 +120,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
           $recur->contribution_status_id = $contributionStatuses['Completed'];
         }
         $recur->end_date = $now;
-        $sendNotification = TRUE;
         $subscriptionPaymentStatus = CRM_Core_Payment::RECURRING_PAYMENT_END;
         break;
 
@@ -159,7 +156,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
 
     $recur->save();
 
-    if ($sendNotification) {
+    if (in_array($this->retrieve('txn_type', 'String'), ['subscr_signup', 'subscr_eot'])) {
       $autoRenewMembership = FALSE;
       if ($recur->id &&
         isset($ids['membership']) && $ids['membership']