3 * Test Generated example of using tax_contribution_page create API.
5 * Create Contribution with Nested Line Items.
10 function tax_contribution_page_create_example() {
13 'receive_date' => '20120511',
14 'total_amount' => '400',
15 'financial_type_id' => 7,
17 'invoice_id' => 67890,
19 'contribution_status_id' => 1,
21 'api.line_item.create' => array(
23 'price_field_id' => array(
27 'line_total' => '100',
28 'unit_price' => '100',
29 'financial_type_id' => 7,
32 'price_field_id' => array(
36 'line_total' => '300',
37 'unit_price' => '300',
38 'financial_type_id' => 8,
44 $result = civicrm_api3('tax_contribution_page', 'create', $params);
46 catch (CiviCRM_API3_Exception
$e) {
48 $errorMessage = $e->getMessage();
49 $errorCode = $e->getErrorCode();
50 $errorData = $e->getExtraParams();
52 'error' => $errorMessage,
53 'error_code' => $errorCode,
54 'error_data' => $errorData,
62 * Function returns array of result expected from previous function.
67 function tax_contribution_page_create_expectedresult() {
69 $expectedResult = array(
78 'financial_type_id' => '7',
79 'contribution_page_id' => '',
80 'payment_instrument_id' => '4',
81 'receive_date' => '20120511000000',
82 'non_deductible_amount' => '',
83 'total_amount' => '435',
85 'net_amount' => '435',
87 'invoice_id' => '67890',
90 'cancel_reason' => '',
92 'thankyou_date' => '',
95 'contribution_recur_id' => '',
98 'contribution_status_id' => '1',
100 'check_number' => '',
102 'creditnote_id' => '',
103 'tax_amount' => '35',
104 'contribution_type_id' => '7',
105 'api.line_item.create' => array(
114 'entity_table' => 'civicrm_contribution',
116 'contribution_id' => '1',
117 'price_field_id' => array(
120 'label' => 'line item',
122 'unit_price' => '100',
123 'line_total' => '100',
124 'participant_count' => '',
125 'price_field_value_id' => '',
126 'financial_type_id' => '7',
127 'deductible_amount' => '',
128 'tax_amount' => '20',
140 'entity_table' => 'civicrm_contribution',
142 'contribution_id' => '1',
143 'price_field_id' => array(
146 'label' => 'line item',
148 'unit_price' => '300',
149 'line_total' => '300',
150 'participant_count' => '',
151 'price_field_value_id' => '',
152 'financial_type_id' => '8',
153 'deductible_amount' => '',
154 'tax_amount' => '15',
163 return $expectedResult;
167 * This example has been generated from the API test suite.
168 * The test that created it is called
169 * testCreateContributionChainedLineItems
170 * and can be found in
171 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
173 * You can see the outcome of the API tests at
174 * https://test.civicrm.org/job/CiviCRM-master-git/
176 * To Learn about the API read
177 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
179 * Browse the api on your own site with the api explorer
180 * http://MYSITE.ORG/path/to/civicrm/api
182 * Read more about testing here
183 * http://wiki.civicrm.org/confluence/display/CRM/Testing
185 * API Standards documentation:
186 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards