fix version in header
[civicrm-core.git] / api / v3 / Contribution.php
index 334ee342ea06ab07c28fd0b48aa7413dc95c150f..c553702a6889b3c9f58779e4777dac30723fbdb7 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -69,7 +69,7 @@ function civicrm_api3_contribution_create(&$params) {
 
   // make sure tax calculation is handled via api
   $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
-  
+
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
 }
 
@@ -103,18 +103,25 @@ function _civicrm_api3_contribution_create_spec(&$params) {
   );
   $params['soft_credit_to'] = array(
     'name' => 'soft_credit_to',
-    'title' => 'Soft Credit contact ID',
+    'title' => 'Soft Credit contact ID (legacy)',
     'type' => 1,
-    'description' => 'ID of Contact to be Soft credited to',
+    'description' => 'ID of Contact to be Soft credited to (deprecated - use contribution_soft api)',
     'FKClassName' => 'CRM_Contact_DAO_Contact',
   );
   $params['honor_contact_id'] = array(
     'name' => 'honor_contact_id',
-    'title' => 'Honoree contact ID',
+    'title' => 'Honoree contact ID (legacy)',
     'type' => 1,
-    'description' => 'ID of honoree contact',
+    'description' => 'ID of honoree contact (deprecated - use contribution_soft api)',
     'FKClassName' => 'CRM_Contact_DAO_Contact',
   );
+  $params['honor_type_id'] = array(
+    'name' => 'honor_type_id',
+    'title' => 'Honoree Type (legacy)',
+    'type' => 1,
+    'description' => 'Type of honoree contact (deprecated - use contribution_soft api)',
+    'pseudoconstant' => TRUE,
+  );
   // note this is a recommended option but not adding as a default to avoid
   // creating unnecessary changes for the dev
   $params['skipRecentView'] = array(
@@ -146,16 +153,18 @@ function _civicrm_api3_contribution_create_spec(&$params) {
 function _civicrm_api3_contribution_create_legacy_support_45(&$params){
   //legacy soft credit handling - recommended approach is chaining
   if(!empty($params['soft_credit_to'])){
-    $params['soft_credit'] = array(array(
+    $params['soft_credit'][] = array(
       'contact_id'          => $params['soft_credit_to'],
       'amount'              => $params['total_amount'],
-      'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type")));
+      'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type")
+    );
   }
   if(!empty($params['honor_contact_id'])){
-    $params['soft_credit'] = array(array(
+    $params['soft_credit'][] = array(
       'contact_id'          => $params['honor_contact_id'],
       'amount'              => $params['total_amount'],
-      'soft_credit_type_id' => CRM_Core_OptionGroup::getValue('soft_credit_type', 'in_honor_of', 'name')));
+      'soft_credit_type_id' => CRM_Utils_Array::value('honor_type_id', $params, CRM_Core_OptionGroup::getValue('soft_credit_type', 'in_honor_of', 'name'))
+    );
   }
 }
 
@@ -193,11 +202,7 @@ function _civicrm_api3_contribution_delete_spec(&$params) {
  *
  * @param  array $params (reference ) input parameters
  *
- * @internal param array $returnProperties Which properties should be included in the
- * returned Contribution object. If NULL, the default
- * set of properties will be included.
- *
- * @return array (reference )        array of contributions, if error an array with an error id and error message
+ * @return array of contributions, if error an array with an error id and error message
  * @static void
  * @access public
  * {@getfields Contribution_get}
@@ -428,7 +433,7 @@ function civicrm_api3_contribution_completetransaction(&$params) {
     // @todo required for base ipn but problematic as api layer handles this
     $transaction = new CRM_Core_Transaction();
     $ipn = new CRM_Core_Payment_BaseIPN();
-    $ipn->completeTransaction($input, $ids, $objects, $transaction);
+    $ipn->completeTransaction($input, $ids, $objects, $transaction, !empty($contribution->contribution_recur_id));
   }
   catch(Exception $e) {
     throw new API_Exception('failed to load related objects' . $e->getMessage() . "\n" . $e->getTraceAsString());
@@ -436,9 +441,10 @@ function civicrm_api3_contribution_completetransaction(&$params) {
 }
 
 /**
- * @param $params
+ * provide function metadata
+ * @param array $params
  */
-function _civicrm_api3_contribution_completetransaction(&$params) {
+function _civicrm_api3_contribution_completetransaction_spec(&$params) {
   $params['id'] = array(
     'title' => 'Contribution ID',
     'type' => CRM_Utils_Type::T_INT,