Fix Payment edit form to use Payment.cancel & payment.create api
[civicrm-core.git] / api / v3 / PaymentProcessorType.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * This api exposes CiviCRM payment processor types.
14 *
15 * @package CiviCRM_APIv3
16 */
17
18 /**
19 * Create payment_processor type.
20 *
21 * @param array $params
22 * Associative array of property name/value pairs to insert in new payment_processor type.
23 *
24 * @return array
25 */
26 function civicrm_api3_payment_processor_type_create($params) {
27 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PaymentProcessorType');
28 }
29
30 /**
31 * Adjust Metadata for Create action.
32 *
33 * The metadata is used for setting defaults, documentation & validation.
34 *
35 * @param array $params
36 * Array of parameters determined by getfields.
37 */
38 function _civicrm_api3_payment_processor_type_create_spec(&$params) {
39 $params['billing_mode']['api.required'] = 1;
40 $params['class_name']['api.required'] = 1;
41 $params['is_active']['api.default'] = 1;
42 $params['is_recur']['api.default'] = FALSE;
43 $params['name']['api.required'] = 1;
44 $params['title']['api.required'] = 1;
45 $params['payment_instrument_id']['api.default'] = 'Credit Card';
46 }
47
48 /**
49 * Get all payment_processor types.
50 *
51 * @param array $params
52 *
53 * @return array
54 */
55 function civicrm_api3_payment_processor_type_get($params) {
56 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
57 }
58
59 /**
60 * Delete a payment_processor type delete.
61 *
62 * @param array $params
63 *
64 * @return array
65 * API Result Array
66 */
67 function civicrm_api3_payment_processor_type_delete($params) {
68 if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) {
69 return civicrm_api3_create_error('Invalid value for payment processor type ID');
70 }
71
72 $payProcTypeBAO = new CRM_Financial_BAO_PaymentProcessorType();
73 $result = $payProcTypeBAO->del($params['id']);
74 if (!$result) {
75 return civicrm_api3_create_error('Could not delete payment processor type');
76 }
77 return civicrm_api3_create_success($result, $params, 'PaymentProcessorType', 'delete', $payProcTypeBAO);
78 }