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/core#521: PCP Send notification after successful contribution payment #19096

Closed
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
16 changes: 16 additions & 0 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -4258,6 +4258,22 @@ public static function completeOrder($input, $recurringContributionID, $contribu
$transaction->commit();
\Civi::log()->info("Contribution {$contributionParams['id']} updated successfully");

$result = civicrm_api4('ContributionSoft', 'get', [
'where' => [
['contribution_id', '=', $contributionID],
],
'checkPermissions' => FALSE,
]);
$contributionSoft = $result->first();

if ($contributionSoft && $contributionSoft['pcp_id']) {
//Send notification to owner for PCP
$contributionDetails = $contributionResult['values'][$contributionResult['id']];
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->copyValues($contributionDetails);
CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only called from one place in the code so we can easily change it to receive an array rather than cast to an object

}

// @todo - check if Contribution::create does this, test, remove.
CRM_Contribute_BAO_ContributionRecur::updateRecurLinkedPledge($contributionID, $recurringContributionID,
$contributionParams['contribution_status_id'], $input['amount']);
Expand Down
5 changes: 3 additions & 2 deletions CRM/Contribute/BAO/ContributionSoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,9 @@ protected static function processPCP($pcp, $contribution) {
$softParams['pcp_personal_note'] = $pcp['pcp_personal_note'] ?? NULL;
$softParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp');
$contributionSoft = self::add($softParams);
//Send notification to owner for PCP
if ($contributionSoft->pcp_id && empty($pcpId)) {
// Send notification to owner for PCP.
$completedStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
if ($contributionSoft->pcp_id && empty($pcpId) && empty($contribution->contribution_page_id) && $contribution->contribution_status_id == $completedStatusID) {
CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, (array) $contributionSoft);
}
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ public static function processOnBehalfOrganization(&$behalfOrganization, &$conta
*
* @param object $contribution
* @param array $contributionSoft
* Contribution object.
* Contribution array.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
Expand Down