Remove redundant status seting in IPN
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 1 Apr 2022 04:26:52 +0000 (17:26 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 4 Apr 2022 23:20:04 +0000 (11:20 +1200)
CRM/Core/Payment/PayPalIPN.php
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php

index 4a23cacdd62520d7a8ad6bd78a5f141639ac2505..bbf874b2c864d5ad9f28a41a7cbc80c37121383a 100644 (file)
@@ -133,19 +133,6 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
       echo 'Failure: Invalid parameters<p>';
       return;
     }
-    if ($first) {
-      $recur->start_date = $now;
-    }
-    else {
-      $recur->modified_date = $now;
-    }
-
-    // make sure the contribution status is not done
-    // since order of ipn's is unknown
-    if ($recur->contribution_status_id != $contributionStatuses['Completed']) {
-      $recur->contribution_status_id = $contributionStatuses['In Progress'];
-    }
-    $recur->save();
 
     if (!$first) {
       // check if this contribution transaction is already processed
index f6075b1a988dfbdd30666c473034e9d41740af12..8a9ebb6920cd6e996434a6cde236c15fdbba7a91 100644 (file)
@@ -9,6 +9,8 @@
  +--------------------------------------------------------------------+
  */
 
+use Civi\Api4\ContributionRecur;
+
 /**
  * Class CRM_Core_Payment_PayPalProIPNTest
  * @group headless
@@ -123,6 +125,11 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
     $mut = new CiviMailUtils($this, TRUE);
     $paypalIPN = new CRM_Core_Payment_PayPalIPN($this->getPaypalRecurTransaction());
     $paypalIPN->main();
+    $recur = ContributionRecur::get()
+      ->addWhere('contact_id', '=', $this->_contactID)
+      ->addSelect('contribution_status_id:name')
+      ->execute()->first();
+    $this->assertEquals('In Progress', $recur['contribution_status_id:name']);
     $mut->checkMailLog(['https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_subscr-find'], ['civicrm/contribute/unsubscribe', 'civicrm/contribute/updatebilling']);
     $mut->stop();
     $contribution1 = $this->callAPISuccess('Contribution', 'getsingle', ['id' => $this->_contributionID]);