Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First recurring payment (paypal ipn) - remove redundant status set, start_date change #23081

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,6 @@ public function recur($input, $recur, $contribution, $first) {
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
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/

use Civi\Api4\ContributionRecur;

/**
* Class CRM_Core_Payment_PayPalProIPNTest
* @group headless
Expand Down Expand Up @@ -123,6 +125,11 @@ public function testIPNPaymentRecurSuccess(): void {
$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]);
Expand Down