}
//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.
}
}
+ /**
+ * 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();
+ }
+
}