-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
Conversation
(Standard links)
|
Are the failing tests related? |
CRM/Contribute/BAO/Contribution.php
Outdated
@@ -4340,6 +4340,16 @@ public static function completeOrder($input, $ids, $contribution, $isPostPayment | |||
$contribution->contribution_status_id = $contributionParams['contribution_status_id']; | |||
|
|||
CRM_Core_Error::debug_log_message('Contribution record updated successfully'); | |||
$contributionSoft = civicrm_api3('ContributionSoft', 'get', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the v4 api for ContributionSoft is about to be merged let's use that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @eileenmcnaughton
I will update the code to use api4 then :)
$contributionSoft = (object) $contributionSoft['values'][0]; | ||
//Send notification to owner for PCP | ||
if ($contributionSoft->pcp_id) { | ||
CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft); |
There was a problem hiding this comment.
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
Test fails are enotices as |
Also - I should say - I think this is the right thing in terms of moving the code to a more appropriate location. I am trying to find out if there is any test cover in #19113 |
Hey @yashodha @eileenmcnaughton
Please let me know if we need any other changes? |
I wound up adding PcpBlock v4 api to write the test In support of civicrm#19096
I wound up adding PcpBlock v4 api to write the test In support of civicrm#19096
@nishant-bhorodia that sounds right - might need to pull #19083 in or wait for it to be merged first I added a test here #19117 |
Many Thanks @eileenmcnaughton :) |
the soft credit api is merged now |
I wound up adding PcpBlock v4 api to write the test In support of civicrm#19096
I wound up adding PcpBlock v4 api to write the test In support of civicrm#19096
fbba50e
to
d185010
Compare
Thanks @eileenmcnaughton 😄 |
thanks @nishant-bhorodia - still test fails :-( |
oh :( checking! |
This is a partial of civicrm#19096 which requires contributionSoft to be an array & just simplifies that commit (which is still failing tests
923d84b
to
ab5f980
Compare
da706e9
to
ea8190f
Compare
@nishant-bhorodia ideally completeOrder should be hit in both flows. The problem I see in create is that an unrelated edit could trigger it too |
b6038fc
to
731c3be
Compare
Hello @eileenmcnaughton |
gentle reminder @eileenmcnaughton :) |
test this please |
//Send notification to owner for PCP | ||
if ($contributionSoft->pcp_id && empty($pcpId)) { | ||
// Send notification to owner for PCP. | ||
if ($contributionSoft->pcp_id && empty($pcpId) && empty($contribution->contribution_page_id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nishant-bhorodia I feel like this might be the wrong extra criteria to add. Does it work if instead we change the contribution status? (if it's still pending we should not send)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @eileenmcnaughton
thanks for reviewing!
I have added another condition to check if the status is completed
.
The two conditions I added does the following:
- Check if the contribution is made without contribution page i.e., from the admin area.
- Check if the status is completed.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @eileenmcnaughton ,
Hope you are well!!
Please can I ask if the change looks fine?
thanks!!
731c3be
to
d5bd28f
Compare
There is a test failure CRM_Core_Payment_AuthorizeNetIPNTest::testIPNPaymentMembershipRecurSuccessNoLeakage /home/jenkins/bknix-dfl/build/core-19096-8dde/web/sites/all/modules/civicrm/CRM/Contribute/BAO/Contribution.php:4290 |
d5bd28f
to
09e3798
Compare
09e3798
to
9fb8ac2
Compare
Updated the PR to pass the failing tests which includes :
$transaction->commit();
\Civi::log()->info("Contribution {$contributionParams['id']} updated successfully");
- $contributionSoft = civicrm_api4('ContributionSoft', 'get', [
+ $result = civicrm_api4('ContributionSoft', 'get', [
...
+ $contributionSoft = $result->first();
- if (!empty($contributionSoft)) {
+ if ($contributionSoft && $contributionSoft['pcp_id']) {
//Send notification to owner for PCP
- if ($contributionSoft->column('pcp_id')) {
- CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft[0]);
- }
+ $contributionDetails = $contributionResult['values'][$contributionResult['id']];
+ $contribution = new CRM_Contribute_BAO_Contribution();
+ $contribution->copyValues($contributionDetails);
+ CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner($contribution, $contributionSoft);
} |
This is cleanup towards civicrm#19096 in that it gets the function out of the form layer and also makes it so it does not require a BAO. This does add one extra db lookup in some cases but I think it's pretty low volume and will mean this is not required https://github.com/civicrm/civicrm-core/pull/19096/files#diff-4c9d0b1abe07057a4eea2b47bc627eecb95face8ed8d86c1c005312a52cca811R4271-R4273
This is cleanup towards civicrm#19096 in that it gets the function out of the form layer and also makes it so it does not require a BAO. This does add one extra db lookup in some cases but I think it's pretty low volume and will mean this is not required https://github.com/civicrm/civicrm-core/pull/19096/files#diff-4c9d0b1abe07057a4eea2b47bc627eecb95face8ed8d86c1c005312a52cca811R4271-R4273
This is cleanup towards civicrm#19096 in that it gets the function out of the form layer and also makes it so it does not require a BAO. This does add one extra db lookup in some cases but I think it's pretty low volume and will mean this is not required https://github.com/civicrm/civicrm-core/pull/19096/files#diff-4c9d0b1abe07057a4eea2b47bc627eecb95face8ed8d86c1c005312a52cca811R4271-R4273
This is a reviewer's cut of civicrm#19096 the only substantive difference is the check around the contribution_status_id in this line https://github.com/civicrm/civicrm-core/pull/19096/files#diff-9f33a2073e9f844dbb842e0737b7df4bce13db31eabe13b9bdd10e1035dbf6d3R612 has had the empty(->contribution_page_id) bit removed - I can 't think why that would be added in & I think it was discussed out but not removed
This is cleanup towards civicrm#19096 in that it gets the function out of the form layer and also makes it so it does not require a BAO. This does add one extra db lookup in some cases but I think it's pretty low volume and will mean this is not required https://github.com/civicrm/civicrm-core/pull/19096/files#diff-4c9d0b1abe07057a4eea2b47bc627eecb95face8ed8d86c1c005312a52cca811R4271-R4273
This is a reviewer's cut of civicrm#19096 the only substantive difference is the check around the contribution_status_id in this line https://github.com/civicrm/civicrm-core/pull/19096/files#diff-9f33a2073e9f844dbb842e0737b7df4bce13db31eabe13b9bdd10e1035dbf6d3R612 has had the empty(->contribution_page_id) bit removed - I can 't think why that would be added in & I think it was discussed out but not removed
This is cleanup towards civicrm#19096 in that it gets the function out of the form layer and also makes it so it does not require a BAO. This does add one extra db lookup in some cases but I think it's pretty low volume and will mean this is not required https://github.com/civicrm/civicrm-core/pull/19096/files#diff-4c9d0b1abe07057a4eea2b47bc627eecb95face8ed8d86c1c005312a52cca811R4271-R4273
This is a reviewer's cut of civicrm#19096 the only substantive difference is the check around the contribution_status_id in this line https://github.com/civicrm/civicrm-core/pull/19096/files#diff-9f33a2073e9f844dbb842e0737b7df4bce13db31eabe13b9bdd10e1035dbf6d3R612 has had the empty(->contribution_page_id) bit removed - I can 't think why that would be added in & I think it was discussed out but not removed
@nishant-bhorodia @ahed-compucorp This now has file conflicts. |
I'm pretty sure this has been otherwise fixed |
Yes, you have created pull request #20523 and merged it. |
yay |
Overview
Owner notification email sending before payment. When you are the owner of a fundraising page, you are supposed to receive a notification email after a successful donation has been made to your fundraising page. However when you are using a payment processor that navigates you out from civicrm to its own payment page (like sagepay, or paypal standard) the owner notification is sent before the payment has been made.
Core issue: https://lab.civicrm.org/dev/core/-/issues/521
Before
PCP Owner received notification for contribution before the payment was done.
After
PCP Owner receives notification only after successful contribution payment is done.
Technical Details
CRM_Contribute_Form_Contribution_Confirm::pcpNotifyOwner
function will be called at two places now.protected static function processPCP($pcp, $contribution)
for backend pcp contributions.public static function completeOrder
for contributions made by using PCP page.