4c9df79844e832e03dd1ee80f771c307bcca4614
[civicrm-core.git] / api / v3 / examples / Participant / CreateParticipantPayment.php
1 <?php
2
3 /*
4 single function to create contact w partipation & contribution. Note that in the
5 case of 'contribution' the 'create' is implied (api.contribution.create)
6 */
7 function participant_create_example(){
8 $params = array(
9 'contact_type' => 'Individual',
10 'display_name' => 'dlobo',
11 'version' => 3,
12 'api.participant' => array(
13 'event_id' => 38,
14 'status_id' => 1,
15 'role_id' => 1,
16 'format.only_id' => 1,
17 ),
18 'api.contribution.create' => array(
19 'financial_type_id' => 1,
20 'total_amount' => 100,
21 'format.only_id' => 1,
22 ),
23 'api.participant_payment.create' => array(
24 'contribution_id' => '$value.api.contribution.create',
25 'participant_id' => '$value.api.participant',
26 ),
27 );
28
29 $result = civicrm_api( 'participant','create',$params );
30
31 return $result;
32 }
33
34 /*
35 * Function returns array of result expected from previous function
36 */
37 function participant_create_expectedresult(){
38
39 $expectedResult = array(
40 'is_error' => 0,
41 'version' => 3,
42 'count' => 1,
43 'id' => 5,
44 'values' => array(
45 '5' => array(
46 'id' => '5',
47 'contact_type' => 'Individual',
48 'contact_sub_type' => '',
49 'do_not_email' => 0,
50 'do_not_phone' => 0,
51 'do_not_mail' => 0,
52 'do_not_sms' => 0,
53 'do_not_trade' => 0,
54 'is_opt_out' => 0,
55 'legal_identifier' => '',
56 'external_identifier' => '',
57 'sort_name' => '',
58 'display_name' => 'dlobo',
59 'nick_name' => '',
60 'legal_name' => '',
61 'image_URL' => '',
62 'preferred_communication_method' => '',
63 'preferred_language' => 'en_US',
64 'preferred_mail_format' => 'Both',
65 'hash' => '67eac7789eaee00',
66 'api_key' => '',
67 'first_name' => '',
68 'middle_name' => '',
69 'last_name' => '',
70 'prefix_id' => '',
71 'suffix_id' => '',
72 'email_greeting_id' => '1',
73 'email_greeting_custom' => '',
74 'email_greeting_display' => '',
75 'postal_greeting_id' => '1',
76 'postal_greeting_custom' => '',
77 'postal_greeting_display' => '',
78 'addressee_id' => '1',
79 'addressee_custom' => '',
80 'addressee_display' => '',
81 'job_title' => '',
82 'gender_id' => '',
83 'birth_date' => '',
84 'is_deceased' => 0,
85 'deceased_date' => '',
86 'household_name' => '',
87 'primary_contact_id' => '',
88 'organization_name' => '',
89 'sic_code' => '',
90 'user_unique_id' => '',
91 'created_date' => '20120130621222105',
92 'modified_date' => '2012-11-14 16:02:35',
93 'api.participant' => 4,
94 'api.contribution.create' => 1,
95 'api.participant_payment.create' => array(
96 'is_error' => 0,
97 'version' => 3,
98 'count' => 1,
99 'id' => 1,
100 'values' => array(
101 '0' => array(
102 'id' => '1',
103 'participant_id' => '4',
104 'contribution_id' => '1',
105 ),
106 ),
107 ),
108 ),
109 ),
110 );
111
112 return $expectedResult ;
113 }
114
115
116 /*
117 * This example has been generated from the API test suite. The test that created it is called
118 *
119 * testCreateParticipantWithPayment and can be found in
120 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ParticipantTest.php
121 *
122 * You can see the outcome of the API tests at
123 * http://tests.dev.civicrm.org/trunk/results-api_v3
124 *
125 * To Learn about the API read
126 * http://book.civicrm.org/developer/current/techniques/api/
127 *
128 * and review the wiki at
129 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
130 *
131 * Read more about testing here
132 * http://wiki.civicrm.org/confluence/display/CRM/Testing
133 *
134 * API Standards documentation:
135 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
136 */