diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index cffb07980b6a..df1ab58a6155 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -149,6 +149,9 @@ static public function getMessages(&$error, $separator = '
') { $message = implode($separator, $message); return $message; } + elseif (is_a($error, 'Civi\Payment\Exception\PaymentProcessorException')) { + return $error->getMessage(); + } return NULL; } diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index cf84532b7291..cbe63ef234e5 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1417,7 +1417,7 @@ public function submit() { // Assign amount to template if payment was successful. $this->assign('amount', $params['total_amount']); } - catch (PaymentProcessorException $e) { + catch (\Civi\Payment\Exception\PaymentProcessorException $e) { if (!empty($paymentParams['contributionID'])) { CRM_Contribute_BAO_Contribution::failPayment($paymentParams['contributionID'], $this->_contactID, $e->getMessage()); @@ -1426,9 +1426,9 @@ public function submit() { CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']); } - CRM_Core_Error::displaySessionError($result); + CRM_Core_Session::singleton()->setStatus($e->getMessage()); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', - "reset=1&action=add&cid={$this->_contactID}&context=&mode={$this->_mode}" + "reset=1&action=add&cid={$this->_contactID}&context=membership&mode={$this->_mode}" )); } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 6734e5a71650..8edc1701093e 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -469,7 +469,7 @@ public function postProcess() { return $statusMsg; } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { - CRM_Core_Error::displaySessionError($e->getMessage()); + CRM_Core_Session::singleton()->setStatus($e->getMessage()); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}" ));