Skip to content

Commit

Permalink
Move sending the emaill back out of the recur function
Browse files Browse the repository at this point in the history
This allows us not to pass in extra ids that are only required for that use and
steps us closer to not loading them
  • Loading branch information
eileenmcnaughton committed Oct 26, 2020
1 parent 7606941 commit 0aed28f
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions CRM/Core/Payment/AuthorizeNetIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,21 @@ public function main($component = 'contribute') {
$objects['contribution'] = &$contribution;
}
$input['payment_processor_id'] = $paymentProcessorID;
return $this->recur($input, [
$isFirstOrLastRecurringPayment = $this->recur($input, [
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
'contributionRecur' => $contributionRecur->id,
'contact' => $ids['contact'] ?? NULL,
'contributionPage' => $ids['contributionPage'] ?? NULL,
], $objects['contributionRecur'], $objects['contribution'], $first);
], $contributionRecur, $objects['contribution'], $first);

if ($isFirstOrLastRecurringPayment) {
//send recurring Notification email for user
CRM_Contribute_BAO_ContributionPage::recurringNotify(TRUE,
$ids['contact'],
$ids['contributionPage'],
$contributionRecur,
(bool) $this->getMembershipID($contribution->id, $contributionRecur->id)
);
}
}

return TRUE;
Expand Down Expand Up @@ -189,27 +197,18 @@ public function recur($input, $ids, $recur, $contribution, $first) {
// so we just fix the recurring contribution and not change any of
// the existing contributions
// CRM-9036
return TRUE;
return FALSE;
}

// check if contribution is already completed, if so we ignore this ipn
if ($contribution->contribution_status_id == 1) {
CRM_Core_Error::debug_log_message("Returning since contribution has already been handled.");
echo 'Success: Contribution has already been handled<p>';
return TRUE;
return FALSE;
}

CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $contribution);

if ($isFirstOrLastRecurringPayment) {
//send recurring Notification email for user
CRM_Contribute_BAO_ContributionPage::recurringNotify(TRUE,
$ids['contact'],
$ids['contributionPage'],
$recur,
(bool) $this->getMembershipID($contribution->id, $recur->id)
);
}
return $isFirstOrLastRecurringPayment;
}

/**
Expand Down

0 comments on commit 0aed28f

Please sign in to comment.