From 31176a73acbcf16e079160f3c8e8667d45c115dc Mon Sep 17 00:00:00 2001 From: Sunil Pawar Date: Thu, 14 Dec 2017 16:30:16 +0530 Subject: [PATCH 1/2] Offline Credit Card Membership Renewal show not showing any error message on failure --- CRM/Core/Error.php | 3 +++ CRM/Member/Form/Membership.php | 6 +++--- CRM/Member/Form/MembershipRenewal.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) 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 acb14746d658..f3f5ac0f049a 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_Error::displaySessionError($e); 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..cadcbf5e5d81 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_Error::displaySessionError($e); 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}" )); From 63dd64f2eec0ddc7f78aeb0d4d8367e240a80bb8 Mon Sep 17 00:00:00 2001 From: Sunil Pawar Date: Fri, 5 Jan 2018 11:35:32 +0530 Subject: [PATCH 2/2] use setstatus directly to error message --- CRM/Member/Form/Membership.php | 2 +- CRM/Member/Form/MembershipRenewal.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index f3f5ac0f049a..19a97a4053be 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1426,7 +1426,7 @@ public function submit() { CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']); } - CRM_Core_Error::displaySessionError($e); + 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=membership&mode={$this->_mode}" )); diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index cadcbf5e5d81..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); + 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}" ));