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

dev/financial#152 simplify interaction with membership, deprecate function #18735

Merged
merged 1 commit into from
Oct 12, 2020
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
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