Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using contribution get API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function contribution_get_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 | 8 | 'contribution_id' => 1, |
6a488035 TO |
9 | ); |
10 | ||
fb32de45 | 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 | } | |
6a488035 | 21 | |
fb32de45 | 22 | return $result; |
6a488035 TO |
23 | } |
24 | ||
fb32de45 | 25 | /** |
6a488035 TO |
26 | * Function returns array of result expected from previous function |
27 | */ | |
28 | function contribution_get_expectedresult(){ | |
29 | ||
53ca8fd7 | 30 | $expectedResult = array( |
6a488035 TO |
31 | 'is_error' => 0, |
32 | 'version' => 3, | |
33 | 'count' => 1, | |
34 | 'id' => 1, | |
53ca8fd7 | 35 | 'values' => array( |
36 | '1' => array( | |
6a488035 TO |
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' => '', | |
65 | 'payment_instrument' => '', | |
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' => '', | |
81 | 'contribution_check_number' => '', | |
82 | 'id' => '1', | |
a1c68fd2 | 83 | 'contribution_type_id' => '1', |
6a488035 TO |
84 | ), |
85 | ), | |
86 | ); | |
87 | ||
fb32de45 | 88 | return $expectedResult; |
6a488035 TO |
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 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php | |
97 | * | |
98 | * You can see the outcome of the API tests at | |
99 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
100 | * | |
101 | * To Learn about the API read | |
102 | * http://book.civicrm.org/developer/current/techniques/api/ | |
103 | * | |
104 | * and review the wiki at | |
105 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
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 | */ |