[REF] Move sendNotification out of recur, remove unused related_contact
authoreileen <emcnaughton@wikimedia.org>
Mon, 25 Jan 2021 19:27:00 +0000 (08:27 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 25 Jan 2021 19:34:26 +0000 (08:34 +1300)
We no longer use ids['related_contact'] & are attempting to simplify (& eventually remove
the ids variable)

CRM/Core/Payment/PayPalIPN.php
CRM/Core/Payment/PayPalProIPN.php

index 2ec2c0f509ea19697954d1cb5580d4f4694948f3..26e1367b17a9e35c44a0bf186044527a11d9c0e6 100644 (file)
@@ -89,8 +89,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
     // make sure the invoice is valid and matches what we have in the contribution record
     if ($recur->invoice_id != $input['invoice']) {
       Civi::log()->debug('PayPalIPN: Invoice values dont match between database and IPN request (RecurID: ' . $recur->id . ').');
-      echo "Failure: Invoice values dont match between database and IPN request<p>";
-      return;
+      throw new CRM_Core_Exception("Failure: Invoice values dont match between database and IPN request");
     }
 
     $now = date('YmdHis');
@@ -153,16 +152,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
 
     $recur->save();
 
-    if ($this->getFirstOrLastInSeriesStatus()) {
-      //send recurring Notification email for user
-      CRM_Contribute_BAO_ContributionPage::recurringNotify($this->getFirstOrLastInSeriesStatus(),
-        $ids['contact'],
-        $ids['contributionPage'],
-        $recur,
-        !empty($ids['membership'])
-      );
-    }
-
     if ($txnType !== 'subscr_payment') {
       return;
     }
@@ -193,7 +182,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
     }
 
     $this->single($input, [
-      'related_contact' => $ids['related_contact'] ?? NULL,
       'participant' => $ids['participant'] ?? NULL,
       'contributionRecur' => $recur->id,
     ], $contribution, TRUE);
@@ -358,6 +346,15 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
           $first = FALSE;
         }
         $this->recur($input, $ids, $contributionRecur, $contribution, $first);
+        if ($this->getFirstOrLastInSeriesStatus()) {
+          //send recurring Notification email for user
+          CRM_Contribute_BAO_ContributionPage::recurringNotify($this->getFirstOrLastInSeriesStatus(),
+            $ids['contact'],
+            $ids['contributionPage'],
+            $contributionRecur,
+            !empty($ids['membership'])
+          );
+        }
         return;
       }
 
@@ -387,7 +384,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
         return;
       }
       $this->single($input, [
-        'related_contact' => $ids['related_contact'] ?? NULL,
         'participant' => $ids['participant'] ?? NULL,
         'contributionRecur' => $contributionRecurID,
       ], $contribution);
index 45dc5c2c06729493e94b3d5e3da7d6e3607e88b2..87b568654665899a9c937da608522eddf916e00c 100644 (file)
@@ -274,7 +274,6 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN {
     $contribution->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])) : $now;
 
     $this->single($input, [
-      'related_contact' => $ids['related_contact'] ?? NULL,
       'participant' => $ids['participant'] ?? NULL,
       'contributionRecur' => $recur->id ?? NULL,
     ], $contribution, TRUE, $first);
@@ -493,7 +492,6 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr
       }
 
       $this->single($input, [
-        'related_contact' => $ids['related_contact'] ?? NULL,
         'participant' => $ids['participant'] ?? NULL,
         'contributionRecur' => $ids['contributionRecur'] ?? NULL,
       ], $contribution, FALSE, FALSE);