Skip to content

Commit

Permalink
CRM-19213 fix payment_instrument_id on event & add first test (shell …
Browse files Browse the repository at this point in the history
…really)
  • Loading branch information
eileenmcnaughton committed Nov 16, 2016
1 parent 16f3bd0 commit 604f8ea
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions CRM/Event/Form/Registration/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public function postProcess() {
}

//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;
Expand Down Expand Up @@ -943,7 +943,8 @@ public function postProcess() {
*/
public static function processContribution(
&$form, $params, $result, $contactID,
$pending = FALSE, $isAdditionalAmount = FALSE
$pending = FALSE, $isAdditionalAmount = FALSE,
$paymentProcessor = NULL
) {
$transaction = new CRM_Core_Transaction();

Expand Down Expand Up @@ -972,8 +973,8 @@ public static function processContribution(
'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) {
Expand Down Expand Up @@ -1277,4 +1278,26 @@ public static function assignProfiles(&$form) {
}
}

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

}

0 comments on commit 604f8ea

Please sign in to comment.