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(
93 'entity_table' => 'civicrm_contribution',
95 'price_field_id' => '1',
96 'label' => 'line item',
100 'participant_count' => '',
101 'price_field_value_id' => '',
102 'financial_type_id' => '',
103 'deductible_amount' => '',
115 'entity_table' => 'civicrm_contribution',
117 'price_field_id' => '1',
118 'label' => 'line item',
120 'unit_price' => '80',
121 'line_total' => '80',
122 'participant_count' => '',
123 'price_field_value_id' => '',
124 'financial_type_id' => '',
125 'deductible_amount' => '',
134 return $expectedResult ;
139 * This example has been generated from the API test suite. The test that created it is called
141 * testCreateContributionChainedLineItems and can be found in
142 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
144 * You can see the outcome of the API tests at
145 * http://tests.dev.civicrm.org/trunk/results-api_v3
147 * To Learn about the API read
148 * http://book.civicrm.org/developer/current/techniques/api/
150 * and review the wiki at
151 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
153 * Read more about testing here
154 * http://wiki.civicrm.org/confluence/display/CRM/Testing
156 * API Standards documentation:
157 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards