if (!empty($result) && !empty($this->_params['is_email_receipt'])) {
$this->_params['contact_id'] = $this->_contactId;
$this->_params['contribution_id'] = $this->_contributionId;
- // to get 'from email id' for send receipt
- $this->fromEmailId = $this->_params['from_email_address'];
+
$sendReceipt = $this->emailReceipt($this->_params);
if ($sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
public function emailReceipt(&$params) {
$templateEngine = CRM_Core_Smarty::singleton();
// email receipt sending
+ list($contributorDisplayName, $contributorEmail, $doNotMail) = CRM_Contact_BAO_Contact::getContactDetails($params['contact_id']);
+ if (!$contributorEmail || $doNotMail) {
+ return FALSE;
+ }
+ $templateEngine->assign('contactDisplayName', $contributorDisplayName);
// send message template
if ($this->_component == 'event') {
$templateEngine->assign('paymentAmount', $params['total_amount']);
$templateEngine->assign('paymentsComplete', $paymentsComplete);
}
- $templateEngine->assign('contactDisplayName', $this->_contributorDisplayName);
// assign trxn details
$templateEngine->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $params));
$sendTemplateParams = array(
'groupName' => 'msg_tpl_workflow_contribution',
'valueName' => 'payment_or_refund_notification',
- 'contactId' => $this->_contactId,
+ 'contactId' => $params['contact_id'],
'PDFFilename' => ts('notification') . '.pdf',
);
- // try to send emails only if email id is present
- // and the do-not-email option is not checked for that contact
- if ($this->_contributorEmail && !$this->_toDoNotEmail) {
- if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) {
- $receiptFrom = $params['from_email_address'];
- }
+ $sendTemplateParams['from'] = $params['from_email_address'];
+ $sendTemplateParams['toName'] = $contributorDisplayName;
+ $sendTemplateParams['toEmail'] = $contributorEmail;
- $sendTemplateParams['from'] = $receiptFrom;
- $sendTemplateParams['toName'] = $this->_contributorDisplayName;
- $sendTemplateParams['toEmail'] = $this->_contributorEmail;
- }
- list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
+ list($mailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
return $mailSent;
}
* Test the submit function that completes the partially paid Contribution using Credit Card.
*/
public function testAddPaymentUsingCreditCardForPartialyPaidContribution() {
+ $mut = new CiviMailUtils($this, TRUE);
$this->createContribution('Partially paid');
// pay additional amount by using Credit Card
- $this->submitPayment(70, 'live');
+ $this->submitPayment(70, 'live', TRUE);
$this->checkResults(array(30, 70), 2);
+ $mut->assertSubjects(['Payment Receipt -']);
+ $mut->checkMailLog([
+ 'Dear Anthony Anderson',
+ 'Payment Details',
+ 'Total Fees: $ 100.00',
+ 'This Payment Amount: $ 70.00',
+ 'Balance Owed: $ 0.00 ',
+ ]);
+
+ $mut->stop();
}
/**
* Payment Amount
* @param string $mode
* Mode of Payment
- *
+ * @param bool $isEmailReceipt
*/
- public function submitPayment($amount, $mode = NULL) {
+ public function submitPayment($amount, $mode = NULL, $isEmailReceipt = FALSE) {
$form = new CRM_Contribute_Form_AdditionalPayment();
$submitParams = array(
'receive_date_time' => '11:27PM',
'trxn_date' => '2017-04-11 13:05:11',
'payment_processor_id' => 0,
+ 'is_email_receipt' => $isEmailReceipt,
+ 'from_email_address' => 'site@something.com',
);
if ($mode) {
$submitParams += array(
- 'payment_instrument_id' => array_search('Credit card', $this->paymentInstruments),
+ 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
'payment_processor_id' => $this->paymentProcessorID,
'credit_card_exp_date' => array('M' => 5, 'Y' => 2025),
'credit_card_number' => '411111111111111',