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