Skip to content

Commit

Permalink
Merge pull request #18735 from eileenmcnaughton/aipn
Browse files Browse the repository at this point in the history
dev/financial#152 simplify interaction with membership, deprecate function
  • Loading branch information
mattwire authored Oct 12, 2020
2 parents 5fa6284 + c3407e4 commit 6ba1f01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions CRM/Contribute/BAO/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ public static function validateRecurContribution($fields, $files, $self, &$error
* @param bool $isFirstOrLastRecurringPayment
*/
public static function sendRecurringStartOrEndNotification($ids, $recur, $isFirstOrLastRecurringPayment) {
CRM_Core_Error::deprecatedFunctionWarning('use CRM_Contribute_BAO_ContributionPage::recurringNotify');
if ($isFirstOrLastRecurringPayment) {
$autoRenewMembership = FALSE;
if ($recur->id &&
Expand Down
17 changes: 8 additions & 9 deletions CRM/Core/Payment/AuthorizeNetIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public function main($component = 'contribute') {
'related_contact' => $ids['related_contact'] ?? NULL,
'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL,
'contributionRecur' => !empty($objects['contributionRecur']) ? $objects['contributionRecur']->id : NULL,
'membership' => $ids['membership'] ?? NULL,
'contact' => $ids['contact'] ?? NULL,
'contributionPage' => $ids['contributionPage'] ?? NULL,
], $objects, $first);
Expand All @@ -165,6 +164,7 @@ public function main($component = 'contribute') {
*/
public function recur($input, $ids, $objects, $first) {
$recur = &$objects['contributionRecur'];
$contribution = &$objects['contribution'];

// do a subscription check
if ($recur->processor_id != $input['subscription_id']) {
Expand Down Expand Up @@ -225,15 +225,15 @@ public function recur($input, $ids, $objects, $first) {

CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects['contribution']);

// Only Authorize.net does this so it is on the a.net class. If there is a need for other processors
// to do this we should make it available via the api, e.g as a parameter, changing the nuance
// from isSentReceipt to an array of which receipts to send.
// Note that there is site-by-site opinions on which notifications are good to send.
if ($isFirstOrLastRecurringPayment) {
CRM_Contribute_BAO_ContributionRecur::sendRecurringStartOrEndNotification($ids, $recur,
$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)
);
}

}

/**
Expand Down Expand Up @@ -314,7 +314,6 @@ public function getIDs(&$ids, &$input) {
$log->error('payment_notification', ['message' => $message, 'ids' => $ids, 'input' => $input]);
throw new CRM_Core_Exception($message);
}
$ids['membership'] = $this->getMembershipID($ids['contribution'], $ids['contributionRecur']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function testIPNPaymentMembershipRecurSuccess() {
/**
* Test IPN response mails don't leak.
*
* @throws \CRM_Core_Exception
* @throws \CRM_Core_Exception|\CiviCRM_API3_Exception
*/
public function testIPNPaymentMembershipRecurSuccessNoLeakage() {
$mut = new CiviMailUtils($this, TRUE);
Expand Down

0 comments on commit 6ba1f01

Please sign in to comment.