Payment Notification sent wrongly
system recurring contribution is configured to NOT send Email notification, it is still triggered via PayPal hook, when a Expired notification is received.
Hard to reproduce, since it takes the recurring amount time to reproduce the issue. But the general procedure would be:
- Configure civicrm to not send emails on contributions start/end (civicrm_contribution_recur - is_email_receipt)
- Create a recurring Paypal donation
- Log the donation in the system
- Cancel recurring donation
- Paypal sends out a webhook event, the Contribution is expired, but an email is sent nevertheless.
An Email is sent even though CiviCRM is configured to not send emails for contributions.
On a cancelled contribution, if no emailing for contributions is configured, no mail should be sent.
- Happened in 5.19.4
- Code seems to be the same in current master.
- Relevant code pieces:
CRM/Core/Payment/PayPalProIPN.php:150 in case of a paypal notification
$sendNotificationis set to TRUE, not checking if emailing is configured or not.
Then in CRM/Contribute/BAO/ContributionPage.php:L544, if an id for the recurring BAO object is present,
$emailReceipe is set to TRUE. ID is set in case of a webhook event.
The code comment says
// This means we are coming from back-office - ie. no page ID, but recurring. // Ideally this information would be passed into the function clearly rather than guessing by convention.
But this will be accessed via paypal webhook. It should either be tested in PayPalProIPN.php, or the logic in ContributionPage needs to be adjusted. The check for the id seems flawed.
I'm having a hard time reproducing this, so I wanted to gather my findings and put them up for review! thanks for looking into this.