CRM-21265 , update payment status to Failed if membership transaction is declined
authorSunil Pawar <sunil@cividesk.com>
Thu, 5 Oct 2017 10:14:18 +0000 (15:44 +0530)
committerSunil Pawar <sunil@cividesk.com>
Thu, 5 Oct 2017 10:14:18 +0000 (15:44 +0530)
CRM/Contribute/Form/Contribution/Confirm.php

index 04563c238d8e312b45beb1f364216973b9d79e21..02e9835d2537c74f765f52cd909686499bceb8de 100644 (file)
@@ -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']}"));