From: Sunil Pawar Date: Thu, 5 Oct 2017 10:14:18 +0000 (+0530) Subject: CRM-21265 , update payment status to Failed if membership transaction is declined X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d23860d80c01681390d10696385a0335b51fbcea;p=civicrm-core.git CRM-21265 , update payment status to Failed if membership transaction is declined --- 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']}"));