Merge pull request #19683 from colemanw/searchDisplayFixes
[civicrm-core.git] / api / v3 / PaymentProcessorType.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
a30c801b 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
a30c801b
TO
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 |
6a488035
TO
9 +--------------------------------------------------------------------+
10 */
11
12/**
c28e1768 13 * This api exposes CiviCRM payment processor types.
6a488035
TO
14 *
15 * @package CiviCRM_APIv3
6a488035 16 */
6a488035
TO
17
18/**
22242c87 19 * Create payment_processor type.
6a488035 20 *
cf470720
TO
21 * @param array $params
22 * Associative array of property name/value pairs to insert in new payment_processor type.
6a488035 23 *
72b3a70c 24 * @return array
6a488035
TO
25 */
26function civicrm_api3_payment_processor_type_create($params) {
da2dec3a 27 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PaymentProcessorType');
6a488035
TO
28}
29
30/**
0aa0303c
EM
31 * Adjust Metadata for Create action.
32 *
33 * The metadata is used for setting defaults, documentation & validation.
6a488035 34 *
cf470720 35 * @param array $params
b081365f 36 * Array of parameters determined by getfields.
6a488035
TO
37 */
38function _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;
6a488035
TO
43 $params['name']['api.required'] = 1;
44 $params['title']['api.required'] = 1;
a1936a29 45 $params['payment_instrument_id']['api.default'] = 'Credit Card';
6a488035
TO
46}
47
48/**
d1b0d05e
EM
49 * Get all payment_processor types.
50 *
d0997921 51 * @param array $params
d1b0d05e 52 *
645ee340 53 * @return array
6a488035
TO
54 */
55function civicrm_api3_payment_processor_type_get($params) {
56 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
57}
58
59/**
22242c87 60 * Delete a payment_processor type delete.
6a488035 61 *
c23f45d3 62 * @param array $params
6a488035 63 *
a6c01b45 64 * @return array
72b3a70c 65 * API Result Array
6a488035
TO
66 */
67function civicrm_api3_payment_processor_type_delete($params) {
6a488035
TO
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 }
244bbdd8 77 return civicrm_api3_create_success($result, $params, 'PaymentProcessorType', 'delete', $payProcTypeBAO);
6a488035 78}