diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index fca8bbf34230..bc1d548deea1 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1256,10 +1256,14 @@ public function submit($params) { // CRM-15622: fix for incorrect contribution.fee_amount $paymentParams['fee_amount'] = NULL; - $result = $payment->doPayment($paymentParams); - - if (is_a($result, 'CRM_Core_Error')) { - CRM_Core_Error::displaySessionError($result); + try { + $result = $payment->doPayment($paymentParams); + } + catch (\Civi\Payment\Exception\PaymentProcessorException $e) { + // @todo un comment the following line out when we are creating a contribution before we get to this point + // see dev/financial#53 about ensuring we create a pending contribution before we try processing payment + // CRM_Contribute_BAO_Contribution::failPayment($contributionID); + CRM_Core_Session::singleton()->setStatus($e->getMessage()); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action=add&cid={$this->_contactId}&context=participant&mode={$this->_mode}" ));