fixes for CRM-14180, also notice fixes
authorkurund <kurund@civicrm.org>
Thu, 13 Mar 2014 15:42:24 +0000 (21:12 +0530)
committerkurund <kurund@civicrm.org>
Thu, 13 Mar 2014 15:42:24 +0000 (21:12 +0530)
----------------------------------------
* CRM-14180: Declined Credit card redirects user to wrong page.
  http://issues.civicrm.org/jira/browse/CRM-14180

CRM/Contribute/Form/Contribution/Confirm.php
CRM/Core/Error.php
CRM/Member/BAO/Membership.php

index 3363a49b0290e9956e9f2c0a03b5cc54454108cc..85aa0167ff76fa7d34db93dc73545eb9df8374da 100644 (file)
@@ -939,10 +939,15 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
           }
         }
 
-        CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
-          $this, $premiumParams, $customFieldsFormatted,
-          $fieldTypes
-        );
+        try {
+          CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
+            $this, $premiumParams, $customFieldsFormatted,
+            $fieldTypes
+          );
+        } 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']}"));
+        }
       }
     }
     else {
index ed6be358d103ec9d4dd5ef672e700a73d6bf99bc..251633afd02e6a81897ec0f5865014a72efb8c1b 100644 (file)
@@ -106,7 +106,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
     $this->setDefaultCallback(array($this, 'handlePES'));
   }
 
-  function getMessages(&$error, $separator = '<br />') {
+  static public function getMessages(&$error, $separator = '<br />') {
     if (is_a($error, 'CRM_Core_Error')) {
       $errors = $error->getErrors();
       $message = array();
index 8cee375460c8d9daadf812591736e9a58afb29ff..6f27098fd758162a9ef962f2168174ae4f99c6e8 100644 (file)
@@ -1436,14 +1436,7 @@ AND civicrm_membership.is_test = %2";
         }
       }
       $message = ts('Payment Processor Error message') . ': ' . implode('<br/>', $message);
-      // Redirect the form in case of error
-      // @todo this redirect in the BAO layer is really bad & should be moved to the form layer
-      // however since we have no idea how (if) this is triggered we can't safely move / remove it
-      $errorParams = array(
-        'legacy_redirect_path' => 'civicrm/contribute/transact',
-        'legacy_redirect_query' => "_qf_Main_display=true&qfKey={$form->_params['qfKey']}",
-      );
-      throw new CRM_Core_Exception($message, 0, $errorParams);
+      throw new CRM_Core_Exception($message);
     }
 
     // CRM-7851