4 Create Contribution with Nested Line Items
6 function contribution_create_example(){
9 'receive_date' => '20120511',
10 'total_amount' => '100',
11 'financial_type_id' => 1,
12 'payment_instrument_id' => 1,
13 'non_deductible_amount' => '10',
17 'invoice_id' => 67890,
19 'contribution_status_id' => 1,
22 'api.line_item.create' => array(
24 'price_field_id' => 1,
30 'price_field_id' => 1,
38 $result = civicrm_api( 'contribution','create',$params );
44 * Function returns array of result expected from previous function
46 function contribution_create_expectedresult(){
48 $expectedResult = array(
57 'financial_type_id' => '1',
58 'contribution_page_id' => '',
59 'payment_instrument_id' => '1',
60 'receive_date' => '20120511000000',
61 'non_deductible_amount' => '10',
62 'total_amount' => '100',
66 'invoice_id' => '67890',
69 'cancel_reason' => '',
71 'thankyou_date' => '',
74 'contribution_recur_id' => '',
75 'honor_contact_id' => '',
78 'contribution_status_id' => '1',
79 'honor_type_id' => '',
81 'check_number' => 'null',
83 'contribution_type_id' => '1',
84 'api.line_item.create' => array(
87 'undefined_fields' => array(
90 '2' => 'entity_table',
91 '3' => 'contribution_id',
92 '4' => 'api.has_parent',
93 '5' => 'price_field_id',
104 'entity_table' => 'civicrm_contribution',
106 'price_field_id' => '1',
107 'label' => 'line item',
109 'unit_price' => '10',
110 'line_total' => '20',
111 'participant_count' => '',
112 'price_field_value_id' => '',
113 'financial_type_id' => '',
114 'deductible_amount' => '',
120 'undefined_fields' => array(
123 '2' => 'entity_table',
124 '3' => 'contribution_id',
125 '4' => 'api.has_parent',
126 '5' => 'price_field_id',
137 'entity_table' => 'civicrm_contribution',
139 'price_field_id' => '1',
140 'label' => 'line item',
142 'unit_price' => '80',
143 'line_total' => '80',
144 'participant_count' => '',
145 'price_field_value_id' => '',
146 'financial_type_id' => '',
147 'deductible_amount' => '',
156 return $expectedResult ;
161 * This example has been generated from the API test suite. The test that created it is called
163 * testCreateContributionChainedLineItems and can be found in
164 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
166 * You can see the outcome of the API tests at
167 * http://tests.dev.civicrm.org/trunk/results-api_v3
169 * To Learn about the API read
170 * http://book.civicrm.org/developer/current/techniques/api/
172 * and review the wiki at
173 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
175 * Read more about testing here
176 * http://wiki.civicrm.org/confluence/display/CRM/Testing
178 * API Standards documentation:
179 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards