From cd3bc1627733b427352feba1f4a8c8ed01a3bc96 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 18 Apr 2016 03:01:11 +1200 Subject: [PATCH] CRM-18426 pay later receipts not going out --- CRM/Contribute/BAO/Contribution/Utils.php | 35 ++++++++++++++--------- CRM/Core/Payment.php | 9 ++++++ CRM/Core/Payment/Manual.php | 9 ++++++ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index f99f910511..01356aef8a 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -141,6 +141,18 @@ class CRM_Contribute_BAO_Contribution_Utils { if ($form->_values['is_recur'] && $contribution->contribution_recur_id) { $paymentParams['contributionRecurID'] = $contribution->contribution_recur_id; } + if (isset($paymentParams['contribution_source'])) { + $form->_params['source'] = $paymentParams['contribution_source']; + } + + // get the price set values for receipt. + if ($form->_priceSetId && $form->_lineItem) { + $form->_values['lineItem'] = $form->_lineItem; + $form->_values['priceSetID'] = $form->_priceSetId; + } + + $form->_values['contribution_id'] = $contribution->id; + $form->_values['contribution_page_id'] = $contribution->contribution_page_id; if (!empty($form->_paymentProcessor)) { try { @@ -160,6 +172,13 @@ class CRM_Contribute_BAO_Contribution_Utils { $contribution->payment_status_id = $result['payment_status_id']; } $result['contribution'] = $contribution; + if ($contribution->payment_status_id == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', + 'status_id', 'Pending') && $payment->isSendReceiptForPending()) { + CRM_Contribute_BAO_ContributionPage::sendMail($contactID, + $form->_values, + $contribution->is_test + ); + } return $result; } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { @@ -179,22 +198,10 @@ class CRM_Contribute_BAO_Contribution_Utils { } } - // Only pay later or unpaid should reach this point. The theory is that paylater should get a receipt now & - // processor - // transaction receipts should be outcome driven. + // Only pay later or unpaid should reach this point, although pay later likely does not & is handled via the + // manual processor, so it's unclear what this set is for and whether the following send ever fires. $form->set('params', $form->_params); - if (isset($paymentParams['contribution_source'])) { - $form->_params['source'] = $paymentParams['contribution_source']; - } - - // get the price set values for receipt. - if ($form->_priceSetId && $form->_lineItem) { - $form->_values['lineItem'] = $form->_lineItem; - $form->_values['priceSetID'] = $form->_priceSetId; - } - $form->_values['contribution_id'] = $contribution->id; - $form->_values['contribution_page_id'] = $contribution->contribution_page_id; if ($form->_params['amount'] == 0) { // This is kind of a back-up for pay-later $0 transactions. // In other flows they pick up the manual processor & get dealt with above (I diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 69a831f620..dcec384ee3 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -1336,4 +1336,13 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id ) return FALSE; } + /** + * Should a receipt be sent out for a pending payment. + * + * e.g for traditional pay later & ones with a delayed settlement a pending receipt makes sense. + */ + public function isSendReceiptForPending() { + return FALSE; + } + } diff --git a/CRM/Core/Payment/Manual.php b/CRM/Core/Payment/Manual.php index 1072f34010..ecc3c92520 100644 --- a/CRM/Core/Payment/Manual.php +++ b/CRM/Core/Payment/Manual.php @@ -192,4 +192,13 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { return $result; } + /** + * Should a receipt be sent out for a pending payment. + * + * e.g for traditional pay later & ones with a delayed settlement a pending receipt makes sense. + */ + public function isSendReceiptForPending() { + return TRUE; + } + } -- 2.25.1