Merge pull request #5046 from totten/master-resolver
[civicrm-core.git] / api / v3 / examples / Contribution / Get.php
1 <?php
2 /**
3 * Test Generated example of using contribution get API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9 function contribution_get_example() {
10 $params = array(
11 'contribution_id' => 1,
12 );
13
14 try{
15 $result = civicrm_api3('contribution', 'get', $params);
16 }
17 catch (CiviCRM_API3_Exception $e) {
18 // Handle error here.
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array(
23 'error' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 );
27 }
28
29 return $result;
30 }
31
32 /**
33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
37 */
38 function contribution_get_expectedresult() {
39
40 $expectedResult = array(
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 1,
44 'id' => 1,
45 'values' => array(
46 '1' => array(
47 'contact_id' => '4',
48 'contact_type' => 'Individual',
49 'contact_sub_type' => '',
50 'sort_name' => 'Anderson, Anthony',
51 'display_name' => 'Mr. Anthony Anderson II',
52 'contribution_id' => '1',
53 'currency' => 'USD',
54 'receive_date' => '2010-01-20 00:00:00',
55 'non_deductible_amount' => '10.00',
56 'total_amount' => '100.00',
57 'fee_amount' => '5.00',
58 'net_amount' => '95.00',
59 'trxn_id' => '23456',
60 'invoice_id' => '78910',
61 'cancel_date' => '',
62 'cancel_reason' => '',
63 'receipt_date' => '',
64 'thankyou_date' => '',
65 'contribution_source' => 'SSF',
66 'amount_level' => '',
67 'is_test' => 0,
68 'is_pay_later' => 0,
69 'contribution_status_id' => '1',
70 'check_number' => '',
71 'contribution_campaign_id' => '',
72 'financial_type_id' => '1',
73 'financial_type' => 'Donation',
74 'instrument_id' => '89',
75 'payment_instrument' => 'Check',
76 'product_id' => '',
77 'product_name' => '',
78 'sku' => '',
79 'contribution_product_id' => '',
80 'product_option' => '',
81 'fulfilled_date' => '',
82 'contribution_start_date' => '',
83 'contribution_end_date' => '',
84 'contribution_recur_id' => '',
85 'financial_account_id' => '1',
86 'accounting_code' => '4200',
87 'contribution_note' => '',
88 'contribution_batch' => '',
89 'contribution_status' => 'Completed',
90 'contribution_payment_instrument' => 'Check',
91 'contribution_check_number' => '',
92 'id' => '1',
93 'contribution_type_id' => '1',
94 ),
95 ),
96 );
97
98 return $expectedResult;
99 }
100
101 /**
102 * This example has been generated from the API test suite.
103 * The test that created it is called
104 * testGetContributionLegacyBehaviour
105 * and can be found in
106 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
107 *
108 * You can see the outcome of the API tests at
109 * https://test.civicrm.org/job/CiviCRM-master-git/
110 *
111 * To Learn about the API read
112 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
113 *
114 * Browse the api on your own site with the api explorer
115 * http://MYSITE.ORG/path/to/civicrm/api
116 *
117 * Read more about testing here
118 * http://wiki.civicrm.org/confluence/display/CRM/Testing
119 *
120 * API Standards documentation:
121 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
122 */