Merge pull request #3679 from yashodha/CRM-14951
[civicrm-core.git] / api / v3 / Contribution.php
index 5ef18c90869468810db3b2aeec937bf6253901e4..0b5b5acc2b164a06082acf14b132d08ec3097846 100644 (file)
@@ -384,6 +384,9 @@ function civicrm_api3_contribution_completetransaction(&$params) {
     if(!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)){
       throw new API_Exception('failed to load related objects');
     }
+    elseif ($contribution->contribution_status_id == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
+      throw new API_Exception(ts('Contribution already completed'));
+    }
     $objects = $contribution->_relatedObjects;
     $objects['contribution'] = &$contribution;
     $input['component'] = $contribution->_component;