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