Merge pull request #14577 from mattwire/type_consolidation
[civicrm-core.git] / api / v3 / examples / TaxContributionPage / Create.ex.php
CommitLineData
50fb255d 1<?php
50fb255d 2/**
3 * Test Generated example of using tax_contribution_page create API.
4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function tax_contribution_page_create_example() {
cf8f0fff 9 $params = [
50fb255d 10 'contact_id' => 1,
11 'receive_date' => '20120511',
12 'total_amount' => '100',
13 'financial_type_id' => 11,
14 'contribution_page_id' => 1,
15 'trxn_id' => 12345,
16 'invoice_id' => 67890,
17 'source' => 'SSF',
18 'contribution_status_id' => 2,
cf8f0fff 19 ];
50fb255d 20
21 try{
22 $result = civicrm_api3('tax_contribution_page', 'create', $params);
23 }
24 catch (CiviCRM_API3_Exception $e) {
25 // Handle error here.
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
cf8f0fff 29 return [
50fb255d 30 'error' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
cf8f0fff 33 ];
50fb255d 34 }
35
36 return $result;
37}
38
39/**
40 * Function returns array of result expected from previous function.
41 *
42 * @return array
43 * API result array
44 */
45function tax_contribution_page_create_expectedresult() {
46
cf8f0fff 47 $expectedResult = [
50fb255d 48 'is_error' => 0,
49 'version' => 3,
50 'count' => 1,
51 'id' => 1,
cf8f0fff
CW
52 'values' => [
53 '1' => [
50fb255d 54 'id' => '1',
55 'contact_id' => '1',
56 'financial_type_id' => '11',
57 'contribution_page_id' => '1',
58 'payment_instrument_id' => '4',
59 'receive_date' => '20120511000000',
60 'non_deductible_amount' => '',
61 'total_amount' => '120',
62 'fee_amount' => 0,
63 'net_amount' => '120',
64 'trxn_id' => '12345',
65 'invoice_id' => '67890',
66 'currency' => 'USD',
67 'cancel_date' => '',
68 'cancel_reason' => '',
69 'receipt_date' => '',
70 'thankyou_date' => '',
71 'source' => 'SSF',
72 'amount_level' => '',
73 'contribution_recur_id' => '',
74 'is_test' => '',
75 'is_pay_later' => '',
76 'contribution_status_id' => '2',
77 'address_id' => '',
78 'check_number' => '',
79 'campaign_id' => '',
80 'creditnote_id' => '',
81 'tax_amount' => '20',
82 'contribution_type_id' => '11',
cf8f0fff
CW
83 ],
84 ],
85 ];
50fb255d 86
87 return $expectedResult;
88}
89
90/**
91* This example has been generated from the API test suite.
92* The test that created it is called
93* testCreateContributionPendingOnline
94* and can be found in
95* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
96*
97* You can see the outcome of the API tests at
98* https://test.civicrm.org/job/CiviCRM-master-git/
99*
100* To Learn about the API read
101* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
102*
103* Browse the api on your own site with the api explorer
41d4d31f 104* http://MYSITE.ORG/path/to/civicrm/api
50fb255d 105*
106* Read more about testing here
107* http://wiki.civicrm.org/confluence/display/CRM/Testing
108*
109* API Standards documentation:
110* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
111*/