CRM-16523 refactor completetransation to call hooks
[civicrm-core.git] / api / v3 / PaymentProcessor.php
index 54cdcabb8780933e2674f8f5017ca05bf038d4a9..54ff1db80e166b519e8b94f8505b9ac0ffc1a825 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  * @param array $params
  *
  * @return array
- *   Array of newly created PaymentProcessor property values.
  */
 function civicrm_api3_payment_processor_create($params) {
+  if (empty($params['id']) && empty($params['payment_instrument_id'])) {
+    $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', array(
+      'id' => $params['payment_processor_type_id'],
+      'return' => 'payment_instrument_id',
+    ));
+  }
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
@@ -81,3 +86,26 @@ function civicrm_api3_payment_processor_delete($params) {
 function civicrm_api3_payment_processor_get($params) {
   return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
+
+
+/**
+ * Set default getlist parameters.
+ *
+ * @see _civicrm_api3_generic_getlist_defaults
+ *
+ * @param array $request
+ *
+ * @return array
+ */
+function _civicrm_api3_payment_processor_getlist_defaults(&$request) {
+  return array(
+    'description_field' => array(
+      'payment_processor_type_id',
+      'description',
+    ),
+    'params' => array(
+      'is_test' => 0,
+      'is_active' => 1,
+    ),
+  );
+}