protected $fromEmailId = NULL;
- protected $_fromEmails = NULL;
-
protected $_view = NULL;
public $_action = NULL;
CRM_Utils_System::setTitle($title);
return;
}
- $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
-
$entityType = 'contribution';
if ($this->_component == 'event') {
$entityType = 'participant';
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
$eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
- $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
}
else {
$this->_contributionId = $this->_id;
- $this->_fromEmails['from_email_id'] = CRM_Core_BAO_Email::getFromEmail();
}
$paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, FALSE, TRUE);
//add receipt for offline contribution
$this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?'));
- $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']);
+ if ($this->_component === 'event') {
+ $eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
+ }
+
+ $this->add('select', 'from_email_address', ts('Receipt From'), CRM_Financial_BAO_Payment::getValidFromEmailsForPayment($eventID ?? NULL));
$this->add('textarea', 'receipt_text', ts('Confirmation Message'));
$this->addRule('net_amount', ts('Please enter a valid monetary value for Net Amount.'), 'money');
}
- $buttonName = $this->_refund ? 'Record Refund' : 'Record Payment';
+ $buttonName = $this->_refund ? ts('Record Refund') : ts('Record Payment');
$this->addButtons([
[
'type' => 'upload',
- 'name' => ts('%1', [1 => $buttonName]),
+ 'name' => $buttonName,
'js' => $js,
'isDefault' => TRUE,
],
/**
* Process Payments.
+ *
* @param array $submittedValues
*
+ * @throws \CiviCRM_API3_Exception
*/
public function submit($submittedValues) {
$this->_params = $submittedValues;
$statusMsg = ts('The payment record has been processed.');
// send email
if (!empty($paymentID) && !empty($this->_params['is_email_receipt'])) {
- $sendResult = civicrm_api3('Payment', 'sendconfirmation', ['id' => $paymentID])['values'][$paymentID];
+ $sendResult = civicrm_api3('Payment', 'sendconfirmation', ['id' => $paymentID, 'from' => $submittedValues['from_email_address']])['values'][$paymentID];
if ($sendResult['is_sent']) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
$this->assign('displayName', $this->userDisplayName);
}
- $this->formatParamsForPaymentProcessor($this->_params);
-
$this->_params['amount'] = $this->_params['total_amount'];
// @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
// function to get correct amount level consistently. Remove setting of the amount level in
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
Civi::log()->error('Payment processor exception: ' . $e->getMessage());
$urlParams = "action=add&cid={$this->_contactId}&id={$this->_contributionId}&component={$this->_component}&mode={$this->_mode}";
- CRM_Core_Error::statusBounce(CRM_Utils_System::url($e->getMessage(), 'civicrm/payment/add', $urlParams));
+ CRM_Core_Error::statusBounce($e->getMessage(), CRM_Utils_System::url('civicrm/payment/add', $urlParams));
}
}