* @param bool $isTest
* @param array $lineItems
*
- * @throws Exception
- * @return CRM_Contribute_DAO_Contribution
+ * @param int $billingLocationID
+ * ID of billing location type.
+ *
+ * @return \CRM_Contribute_DAO_Contribution
+ * @throws \Exception
*/
public static function processContribution(
&$form,
$pending,
$online,
$isTest,
- $lineItems
+ $lineItems,
+ $billingLocationID
) {
$transaction = new CRM_Core_Transaction();
$contribSoftContactId = $addressID = NULL;
+ $contributeMode = $form->_contributeMode;
+ $isMonetary = !empty($form->_values['is_monetary']);
+ $isEmailReceipt = !empty($form->_values['is_email_receipt']);
// add these values for the recurringContrib function ,CRM-10188
$params['financial_type_id'] = $financialType->id;
//create an contribution address
- if ($form->_contributeMode != 'notify' && empty($params['is_pay_later']) && !empty($form->_values['is_monetary'])) {
- $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $form->_bltID);
+ if ($contributeMode != 'notify' && empty($params['is_pay_later']) && $isMonetary) {
+ $addressID = CRM_Contribute_BAO_Contribution::createAddress($params, $billingLocationID);
}
//@todo - this is being set from the form to resolve CRM-10188 - an
// a better fix would be to set the values in the respective forms rather than require
// a function being shared by two forms to deal with their respective values
// moving it to the BAO & not taking the $form as a param would make sense here.
- if (!isset($params['is_email_receipt']) && !empty($form->_values['is_email_receipt'])) {
- $params['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $form->_values);
+ if (!isset($params['is_email_receipt']) && $isEmailReceipt) {
+ $params['is_email_receipt'] = $isEmailReceipt;
}
$recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType, $online);
$nonDeductibleAmount = self::getNonDeductibleAmount($params, $financialType, $online);
$now = date('YmdHis');
$receiptDate = CRM_Utils_Array::value('receipt_date', $params);
- if (!empty($form->_values['is_email_receipt'])) {
+ if ($isEmailReceipt) {
$receiptDate = $now;
}
}
if (isset($params['amount'])) {
- $isMonetary = NULL;
- if (!empty($form->_values['is_monetary'])) {
- $isMonetary = $form->_values['is_monetary'];
- }
$contribParams = self::getContributionParams(
$params, $contactID, $financialType->id, $online, $contributionPageId, $nonDeductibleAmount, $campaignId, $isMonetary, $pending, $result, $receiptDate,
$recurringContributionID, $isTest, $addressID, $contribSoftContactId, $lineItems
// is not appropriate to delete a valid contribution if a user create problem occurs
CRM_Contribute_BAO_Contribution_Utils::createCMSUser($params,
$contactID,
- 'email-' . $form->_bltID
+ 'email-' . $billingLocationID
);
return $contribution;
}