CRM-16926 fix up patch for 4.7
authoreileenmcnaugton <eileen@fuzion.co.nz>
Mon, 3 Aug 2015 12:39:08 +0000 (00:39 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Mon, 3 Aug 2015 12:39:08 +0000 (00:39 +1200)
CRM/Contribute/Form/Contribution/Confirm.php

index a8e4da5e0ded51d0b6aecda104ed9d322777238e..23e4bc5e30ed8f773e2fc6c64435cd80096133cc 100644 (file)
@@ -2307,12 +2307,21 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       // @todo move premium processing to complete transaction if it truly is an 'after' action.
       $this->postProcessPremium($premiumParams, $result['contribution']);
       if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
-        civicrm_api3('contribution', 'completetransaction', array(
-          'id' => $result['contribution']->id,
-          'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
-          'payment_processor_id' => $this->_paymentProcessor['id'],
-          )
-        );
+        try {
+          civicrm_api3('contribution', 'completetransaction', array(
+              'id' => $result['contribution']->id,
+              'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
+              'payment_processor_id' => $this->_paymentProcessor['id'],
+              'is_transactional' => FALSE,
+            )
+          );
+        }
+        catch (CiviCRM_API3_Exception $e) {
+          if ($e->getErrorCode() != 'contribution_completed') {
+            throw new CRM_Core_Exception('Failed to update contribution in database');
+          }
+        }
+
       }
       return $result;
     }