Skip to content

Commit

Permalink
Merge pull request #19443 from eileenmcnaughton/ipn
Browse files Browse the repository at this point in the history
[REF] Move sendNotification out of recur, remove unused related_contact
  • Loading branch information
mattwire authored Feb 3, 2021
2 parents 6b47c46 + 3a317d6 commit 92912ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
24 changes: 10 additions & 14 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public function recur($input, $ids, $recur, $contribution, $first) {
// 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');
Expand Down Expand Up @@ -153,16 +152,6 @@ public function recur($input, $ids, $recur, $contribution, $first) {

$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;
}
Expand Down Expand Up @@ -193,7 +182,6 @@ public function recur($input, $ids, $recur, $contribution, $first) {
}

$this->single($input, [
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => $ids['participant'] ?? NULL,
'contributionRecur' => $recur->id,
], $contribution, TRUE);
Expand Down Expand Up @@ -358,6 +346,15 @@ public function main() {
$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;
}

Expand Down Expand Up @@ -387,7 +384,6 @@ public function main() {
return;
}
$this->single($input, [
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => $ids['participant'] ?? NULL,
'contributionRecur' => $contributionRecurID,
], $contribution);
Expand Down
2 changes: 0 additions & 2 deletions CRM/Core/Payment/PayPalProIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ public function recur($input, $ids, $recur, $contribution, $first) {
$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);
Expand Down Expand Up @@ -493,7 +492,6 @@ public function main() {
}

$this->single($input, [
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => $ids['participant'] ?? NULL,
'contributionRecur' => $ids['contributionRecur'] ?? NULL,
], $contribution, FALSE, FALSE);
Expand Down

0 comments on commit 92912ca

Please sign in to comment.