/** * Submit function. * * @param array $params * * @throws CiviCRM_API3_Exception */ public static function submit($params) { $form = new CRM_Contribute_Form_Contribution_Confirm(); $form->_id = $params['id']; CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values); $form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id); //this way the mocked up controller ignores the session stuff $_SERVER['REQUEST_METHOD'] = 'GET'; $form->controller = new CRM_Contribute_Controller_Contribution(); $params['invoiceID'] = md5(uniqid(rand(), TRUE)); $paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params); $form->_amount = $params['amount']; // hack these in for test support. $form->_fields['billing_first_name'] = 1; $form->_fields['billing_last_name'] = 1; $priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id']; $priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID); $priceSetFields = reset($priceFields); $form->_values['fee'] = $priceSetFields['fields']; $form->_priceSetId = $priceSetID; $form->setFormAmountFields($priceSetID); if (!empty($params['payment_processor_id'])) { $form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor_id'])); // The concept of contributeMode is deprecated as is the billing_mode concept. if ($form->_paymentProcessor['billing_mode'] == 1) { $form->_contributeMode = 'direct'; } else { $form->_contributeMode = 'notify'; } } else { $form->_params['payment_processor_id'] = 0; } $priceFields = $priceFields[$priceSetID]['fields']; CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution'); $form->_lineItem = array($priceSetID => $lineItems); $form->processFormSubmission(CRM_Utils_Array::value('contact_id', $params)); }