Merge pull request #18852 from eileenmcnaughton/aip
[civicrm-core.git] / api / v3 / ParticipantPayment.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 participant payments.
14 *
15 * @package CiviCRM_APIv3
16 */
17
18 /**
19 * Create a Event Participant Payment.
20 *
21 * This API is used for creating a Participant Payment of Event.
22 * Required parameters: participant_id, contribution_id.
23 *
24 * @param array $params
25 * An associative array of name/value property values of civicrm_participant_payment.
26 *
27 * @return array
28 */
29 function civicrm_api3_participant_payment_create($params) {
30 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ParticipantPayment');
31 }
32
33 /**
34 * Adjust Metadata for Create action.
35 *
36 * The metadata is used for setting defaults, documentation & validation.
37 *
38 * @param array $params
39 * Array of parameters determined by getfields.
40 */
41 function _civicrm_api3_participant_payment_create_spec(&$params) {
42 $params['participant_id']['api.required'] = 1;
43 $params['contribution_id']['api.required'] = 1;
44 }
45
46 /**
47 * Deletes an existing Participant Payment.
48 *
49 * @param array $params
50 *
51 * @return array
52 * API result
53 */
54 function civicrm_api3_participant_payment_delete($params) {
55 $participant = new CRM_Event_BAO_ParticipantPayment();
56 return $participant->deleteParticipantPayment($params) ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting participantPayment');
57 }
58
59 /**
60 * Retrieve one or more participant payment records.
61 *
62 * @param array $params
63 * Input parameters.
64 *
65 * @return array
66 * array of properties, if error an array with an error id and error message
67 */
68 function civicrm_api3_participant_payment_get($params) {
69 return _civicrm_api3_basic_get('CRM_Event_DAO_ParticipantPayment', $params);
70 }