4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using tax_contribution_page create API.
11 * Create Contribution with Nested Line Items
16 function tax_contribution_page_create_example() {
19 'receive_date' => '20120511',
20 'total_amount' => '400',
21 'financial_type_id' => 7,
23 'invoice_id' => 67890,
25 'contribution_status_id' => 1,
27 'api.line_item.create' => array(
29 'price_field_id' => array(
33 'line_total' => '100',
34 'unit_price' => '100',
35 'financial_type_id' => 7,
38 'price_field_id' => array(
42 'line_total' => '300',
43 'unit_price' => '300',
44 'financial_type_id' => 8,
50 $result = civicrm_api3('tax_contribution_page', 'create', $params);
52 catch (CiviCRM_API3_Exception
$e) {
54 $errorMessage = $e->getMessage();
55 $errorCode = $e->getErrorCode();
56 $errorData = $e->getExtraParams();
58 'error' => $errorMessage,
59 'error_code' => $errorCode,
60 'error_data' => $errorData,
68 * Function returns array of result expected from previous function.
73 function tax_contribution_page_create_expectedresult() {
75 $expectedResult = array(
84 'financial_type_id' => '7',
85 'contribution_page_id' => '',
86 'payment_instrument_id' => '4',
87 'receive_date' => '20120511000000',
88 'non_deductible_amount' => '',
89 'total_amount' => '435',
91 'net_amount' => '435',
93 'invoice_id' => '67890',
96 'cancel_reason' => '',
98 'thankyou_date' => '',
100 'amount_level' => '',
101 'contribution_recur_id' => '',
103 'is_pay_later' => '',
104 'contribution_status_id' => '1',
106 'check_number' => '',
108 'creditnote_id' => '',
109 'tax_amount' => '35',
110 'contribution_type_id' => '7',
111 'api.line_item.create' => array(
120 'entity_table' => 'civicrm_contribution',
122 'contribution_id' => '1',
123 'price_field_id' => array(
126 'label' => 'line item',
128 'unit_price' => '100',
129 'line_total' => '100',
130 'participant_count' => '',
131 'price_field_value_id' => '',
132 'financial_type_id' => '7',
133 'deductible_amount' => '',
134 'tax_amount' => '20',
146 'entity_table' => 'civicrm_contribution',
148 'contribution_id' => '1',
149 'price_field_id' => array(
152 'label' => 'line item',
154 'unit_price' => '300',
155 'line_total' => '300',
156 'participant_count' => '',
157 'price_field_value_id' => '',
158 'financial_type_id' => '8',
159 'deductible_amount' => '',
160 'tax_amount' => '15',
169 return $expectedResult;
173 * This example has been generated from the API test suite.
174 * The test that created it is called
175 * testCreateContributionChainedLineItems
176 * and can be found in
177 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
179 * You can see the outcome of the API tests at
180 * https://test.civicrm.org/job/CiviCRM-master-git/
182 * To Learn about the API read
183 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
185 * Browse the api on your own site with the api explorer
186 * http://MYSITE.ORG/path/to/civicrm/api/explorer
188 * Read more about testing here
189 * http://wiki.civicrm.org/confluence/display/CRM/Testing
191 * API Standards documentation:
192 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards