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,
39 $result = civicrm_api( 'contribution','create',$params );
45 * Function returns array of result expected from previous function
47 function contribution_create_expectedresult(){
49 $expectedResult = array(
58 'financial_type_id' => '1',
59 'contribution_page_id' => '',
60 'payment_instrument_id' => '1',
61 'receive_date' => '20120511000000',
62 'non_deductible_amount' => '10',
63 'total_amount' => '100',
67 'invoice_id' => '67890',
70 'cancel_reason' => '',
72 'thankyou_date' => '',
75 'contribution_recur_id' => '',
76 'honor_contact_id' => '',
79 'contribution_status_id' => '1',
80 'honor_type_id' => '',
82 'check_number' => 'null',
84 'contribution_type_id' => '1',
85 'api.line_item.create' => array(
94 'entity_table' => 'civicrm_contribution',
96 'price_field_id' => '1',
97 'label' => 'line item',
100 'line_total' => '20',
101 'participant_count' => '',
102 'price_field_value_id' => '',
103 'financial_type_id' => '',
104 'deductible_amount' => '',
116 'entity_table' => 'civicrm_contribution',
118 'price_field_id' => '1',
119 'label' => 'line item',
121 'unit_price' => '80',
122 'line_total' => '80',
123 'participant_count' => '',
124 'price_field_value_id' => '',
125 'financial_type_id' => '',
126 'deductible_amount' => '',
135 return $expectedResult ;
140 * This example has been generated from the API test suite. The test that created it is called
142 * testCreateContributionChainedLineItems and can be found in
143 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
145 * You can see the outcome of the API tests at
146 * http://tests.dev.civicrm.org/trunk/results-api_v3
148 * To Learn about the API read
149 * http://book.civicrm.org/developer/current/techniques/api/
151 * and review the wiki at
152 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
154 * Read more about testing here
155 * http://wiki.civicrm.org/confluence/display/CRM/Testing
157 * API Standards documentation:
158 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards