$params['discountAmount'] = $this->_params[0]['discountAmount'];
$params['discountMessage'] = $this->_params[0]['discountMessage'];
}
- if (!empty($this->_params[0]['amount_priceset_level_radio'])) {
- $params['amount_priceset_level_radio'] = $this->_params[0]['amount_priceset_level_radio'];
- }
+
$params['amount_level'] = $this->_params[0]['amount_level'];
$params['currencyID'] = $this->_params[0]['currencyID'];
}
//passing contribution id is already registered.
- $contribution = self::processContribution($this, $value, $result, $contactID, $pending, $isAdditionalAmount);
+ $contribution = self::processContribution($this, $value, $result, $contactID, $pending, $isAdditionalAmount, $this->_paymentProcessor);
$value['contributionID'] = $contribution->id;
$value['contributionTypeID'] = $contribution->financial_type_id;
$value['receive_date'] = $contribution->receive_date;
*/
public static function processContribution(
&$form, $params, $result, $contactID,
- $pending = FALSE, $isAdditionalAmount = FALSE
+ $pending = FALSE, $isAdditionalAmount = FALSE,
+ $paymentProcessor = NULL
) {
$transaction = new CRM_Core_Transaction();
'campaign_id' => CRM_Utils_Array::value('campaign_id', $params),
);
- if (empty($params['is_pay_later'])) {
- $contribParams['payment_instrument_id'] = 1;
+ if ($paymentProcessor) {
+ $contribParams['payment_instrument_id'] = $paymentProcessor['payment_instrument_id'];
}
if (!$pending && $result) {
$contribParams['id'] = $contribID;
}
+ if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+ $eventStartDate = CRM_Utils_Array::value(
+ 'start_date',
+ CRM_Utils_Array::value(
+ 'event',
+ $form->_values
+ )
+ );
+ if ($eventStartDate) {
+ $contribParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
+ }
+ }
//create an contribution address
// The concept of contributeMode is deprecated. Elsewhere we use the function processBillingAddress() - although
// currently that is only inherited by back-office forms.
// create contribution record
$contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
// CRM-11124
- CRM_Event_BAO_Participant::createDiscountTrxn($form->_eventId, $contribParams, CRM_Utils_Array::value('amount_priceset_level_radio', $params, NULL));
+ CRM_Event_BAO_Participant::createDiscountTrxn($form->_eventId, $contribParams, NULL, CRM_Price_BAO_PriceSet::parseFirstPriceSetValueIDFromParams($params));
// process soft credit / pcp pages
if (!empty($params['pcp_made_through_id'])) {
/**
* Fix the Location Fields.
*
+ * @todo Reconcile with the contribution method formatParamsForPaymentProcessor
+ * rather than adding different logic to check when to keep the billing
+ * fields. There might be a difference in handling guest/multiple
+ * participants though.
+ *
* @param array $params
* @param array $fields
* @param CRM_Core_Form $form
}
}
+ // If there's no 'first_name' in the profile then overwrite the names from
+ // the billing fields (if they are set)
if (is_array($fields)) {
if (!array_key_exists('first_name', $fields)) {
$nameFields = array('first_name', 'middle_name', 'last_name');
}
}
- // also add location name to the array
- if ($form->_values['event']['is_monetary']) {
+ // Add the billing names to the billing address, if a billing name is set
+ if (!empty($params['billing_first_name'])) {
$params["address_name-{$form->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$fields["address_name-{$form->_bltID}"] = 1;
}
+
$fields["email-{$form->_bltID}"] = 1;
$fields['email-Primary'] = 1;
}
}
+ /**
+ * Submit in test mode.
+ *
+ * @param $params
+ */
+ public static function testSubmit($params) {
+ $form = new CRM_Event_Form_Registration_Confirm();
+ // This way the mocked up controller ignores the session stuff.
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_REQUEST['id'] = $form->_eventId = $params['id'];
+ $form->controller = new CRM_Event_Controller_Registration();
+ $form->_params = $params['params'];
+ $form->set('params', $params['params']);
+ $form->_values['custom_pre_id'] = array();
+ $form->_values['custom_post_id'] = array();
+ $form->_contributeMode = $params['contributeMode'];
+ $eventParams = array('id' => $params['id']);
+ CRM_Event_BAO_Event::retrieve($eventParams, $form->_values['event']);
+ $form->set('registerByID', $params['registerByID']);
+ $form->postProcess();
+ }
+
}