From 46366f162a2dad23ed6b1e749c38fa9d44f52aa5 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Wed, 31 Jul 2019 08:02:39 +1000 Subject: [PATCH] Catch Payment Processor Exception if thrown when registering via back office participant registration Make changes as per Matt's and Eileen's comments --- CRM/Event/Form/Participant.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index fca8bbf342..bc1d548dee 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1256,10 +1256,14 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment // 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}" )); -- 2.25.1