Merge pull request #2845 from elcapo/activity-contact-api
[civicrm-core.git] / api / v3 / examples / Contribution / Get.php
1 <?php
2 /**
3 * Test Generated example of using contribution get API
4 * *
5 */
6 function contribution_get_example(){
7 $params = array(
8 'contribution_id' => 1,
9 );
10
11 try{
12 $result = civicrm_api3('contribution', 'get', $params);
13 }
14 catch (CiviCRM_API3_Exception $e) {
15 // handle error here
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
20 }
21
22 return $result;
23 }
24
25 /**
26 * Function returns array of result expected from previous function
27 */
28 function contribution_get_expectedresult(){
29
30 $expectedResult = array(
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 1,
34 'id' => 1,
35 'values' => array(
36 '1' => array(
37 'contact_id' => '1',
38 'contact_type' => 'Individual',
39 'contact_sub_type' => '',
40 'sort_name' => 'Anderson, Anthony',
41 'display_name' => 'Mr. Anthony Anderson II',
42 'contribution_id' => '1',
43 'currency' => 'USD',
44 'receive_date' => '2010-01-20 00:00:00',
45 'non_deductible_amount' => '10.00',
46 'total_amount' => '100.00',
47 'fee_amount' => '5.00',
48 'net_amount' => '95.00',
49 'trxn_id' => '23456',
50 'invoice_id' => '78910',
51 'cancel_date' => '',
52 'cancel_reason' => '',
53 'receipt_date' => '',
54 'thankyou_date' => '',
55 'contribution_source' => 'SSF',
56 'amount_level' => '',
57 'is_test' => 0,
58 'is_pay_later' => 0,
59 'contribution_status_id' => '1',
60 'check_number' => '',
61 'contribution_campaign_id' => '',
62 'financial_type_id' => '1',
63 'financial_type' => 'Donation',
64 'instrument_id' => '84',
65 'payment_instrument' => 'Check',
66 'product_id' => '',
67 'product_name' => '',
68 'sku' => '',
69 'contribution_product_id' => '',
70 'product_option' => '',
71 'fulfilled_date' => '',
72 'contribution_start_date' => '',
73 'contribution_end_date' => '',
74 'contribution_recur_id' => '',
75 'financial_account_id' => '1',
76 'accounting_code' => '4200',
77 'contribution_note' => '',
78 'contribution_batch' => '',
79 'contribution_status' => 'Completed',
80 'contribution_payment_instrument' => 'Check',
81 'contribution_check_number' => '',
82 'id' => '1',
83 'contribution_type_id' => '1',
84 ),
85 ),
86 );
87
88 return $expectedResult;
89 }
90
91
92 /*
93 * This example has been generated from the API test suite. The test that created it is called
94 *
95 * testGetContributionLegacyBehaviour and can be found in
96 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.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
105 * http://MYSITE.ORG/path/to/civicrm/api/explorer
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 */