From d23860d80c01681390d10696385a0335b51fbcea Mon Sep 17 00:00:00 2001 From: Sunil Pawar Date: Thu, 5 Oct 2017 15:44:18 +0530 Subject: [PATCH] CRM-21265 , update payment status to Failed if membership transaction is declined --- CRM/Contribute/Form/Contribution/Confirm.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 04563c238d..02e9835d25 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -2433,6 +2433,14 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr try { $this->processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems); } + catch (\Civi\Payment\Exception\PaymentProcessorException $e) { + CRM_Core_Session::singleton()->setStatus($e->getMessage()); + if (!empty($this->_contributionID)) { + CRM_Contribute_BAO_Contribution::failPayment($this->_contributionID, + $contactID, $e->getMessage()); + } + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}")); + } catch (CRM_Core_Exception $e) { CRM_Core_Session::singleton()->setStatus($e->getMessage()); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}")); -- 2.25.1