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