5 +--------------------------------------------------------------------+
6 | CiviCRM version 4.3 |
7 +--------------------------------------------------------------------+
8 | Copyright CiviCRM LLC (c) 2004-2013 |
9 +--------------------------------------------------------------------+
10 | This file is a part of CiviCRM. |
12 | CiviCRM is free software; you can copy, modify, and distribute it |
13 | under the terms of the GNU Affero General Public License |
14 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
16 | CiviCRM is distributed in the hope that it will be useful, but |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
19 | See the GNU Affero General Public License for more details. |
21 | You should have received a copy of the GNU Affero General Public |
22 | License and the CiviCRM Licensing Exception along |
23 | with this program; if not, contact CiviCRM LLC |
24 | at info[AT]civicrm[DOT]org. If you have questions about the |
25 | GNU Affero General Public License or the licensing of CiviCRM, |
26 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
27 +--------------------------------------------------------------------+
31 * new version of civicrm apis. See blog post at
32 * http://civicrm.org/node/131
34 * @package CiviCRM_APIv3
35 * @subpackage API_Contact
36 * @copyright CiviCRM LLC (c) 2004-2013
37 * $Id: PaymentProcessorType.php 30415 2010-10-29 12:02:47Z shot $
42 * Include common API util functions
44 require_once 'CRM/Financial/BAO/PaymentProcessorType.php';
47 * Function to create payment_processor type
49 * @param array $params Associative array of property name/value pairs to insert in new payment_processor type.
51 * @return Newly created PaymentProcessor_type object
52 * {@getfields PaymentProcessorType_create}
54 * {@schema Core/PaymentProcessorType.xml}
56 function civicrm_api3_payment_processor_type_create($params) {
57 require_once 'CRM/Utils/Rule.php';
60 if (isset($params['id']) && !CRM_Utils_Rule
::integer($params['id'])) {
61 return civicrm_api3_create_error('Invalid value for payment_processor type ID');
64 $payProcType = new CRM_Financial_BAO_PaymentProcessorType();
65 $payProcType = CRM_Financial_BAO_PaymentProcessorType
::create($params);
69 _civicrm_api3_object_to_array($payProcType, $relType[$payProcType->id
]);
71 return civicrm_api3_create_success($relType, $params, 'payment_processor_type', 'create', $payProcType);
75 * Adjust Metadata for Create action
77 * The metadata is used for setting defaults, documentation & validation
78 * @param array $params array or parameters determined by getfields
80 function _civicrm_api3_payment_processor_type_create_spec(&$params) {
81 $params['billing_mode']['api.required'] = 1;
82 $params['class_name']['api.required'] = 1;
83 $params['is_active']['api.default'] = 1;
84 $params['is_recur']['api.default'] = FALSE;
85 // FIXME bool support // $params['is_recur']['api.required'] = 1;
86 $params['name']['api.required'] = 1;
87 $params['title']['api.required'] = 1;
91 * Function to get all payment_processor type
92 * retruns An array of PaymentProcessor_type
94 * {@getfields PaymentProcessorType_get}
95 * @example PaymentProcessorTypeGet.php
97 function civicrm_api3_payment_processor_type_get($params) {
98 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
102 * Delete a payment_processor type delete
104 * @param id of payment_processor type $id
106 * @return array API Result Array
107 * {@getfields PaymentProcessorType_delete}
111 function civicrm_api3_payment_processor_type_delete($params) {
113 require_once 'CRM/Utils/Rule.php';
114 if ($params['id'] != NULL && !CRM_Utils_Rule
::integer($params['id'])) {
115 return civicrm_api3_create_error('Invalid value for payment processor type ID');
118 $payProcTypeBAO = new CRM_Financial_BAO_PaymentProcessorType();
119 $result = $payProcTypeBAO->del($params['id']);
121 return civicrm_api3_create_error('Could not delete payment processor type');
123 return civicrm_api3_create_success($result, $params, 'payment_processor_type', 'delete', $payProcTypeBAO);