Commit 7a43c996 authored by JonGold's avatar JonGold Committed by mattwire
Browse files

Send receipts on one-time payment notifications

parent c193a7e1
......@@ -67,13 +67,14 @@ trait CRM_Core_Payment_MJWIPNTrait {
}
/**
* Get the value of is_email_receipt to use when a new contribution is received for a recurring contribution
* If not set, we respect the value set on the ContributionRecur entity.
* Get the value of is_email_receipt to use when a new contribution is received.
* If not set, we respect the value set on the ContributionRecur entity (for recurring contributions)
* or the value set on the ContributionPage entity (for non-recurring contributions).
*
* @return int
* @throws \CiviCRM_API3_Exception
*/
public function getSendEmailReceipt() {
public function getSendEmailReceipt($contributionId) {
if (isset($this->is_email_receipt)) {
return (int) $this->is_email_receipt;
}
......@@ -88,6 +89,19 @@ trait CRM_Core_Payment_MJWIPNTrait {
$this->is_email_receipt = 0;
}
}
// Non-recurring contribution.
else {
try {
$this->is_email_receipt = \Civi\Api4\Contribution::get(FALSE)
->addSelect('contribution_page.is_email_receipt')
->addWhere('id', '=', $contributionId)
->execute()
->first()['contribution_page.is_email_receipt'] ?? 0;
}
catch (Exception $e) {
$this->is_email_receipt = 0;
}
}
return (int) $this->is_email_receipt;
}
......@@ -327,7 +341,7 @@ trait CRM_Core_Payment_MJWIPNTrait {
];
CRM_Core_DAO::executeQuery($sql, $queryParams);
}
$paymentParams['is_send_contribution_notification'] = $this->getSendEmailReceipt();
$paymentParams['is_send_contribution_notification'] = $this->getSendEmailReceipt($paymentParams['contribution_id']);
$paymentParams['skipCleanMoney'] = TRUE;
$paymentParams['payment_processor_id'] = $this->_paymentProcessor->getID();
civicrm_api3('Mjwpayment', 'create_payment', $paymentParams);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment