Commit | Line | Data |
---|---|---|
6094aad5 PN |
1 | <?php |
2 | /** | |
3 | * Test Generated example demonstrating the Payment.get API. | |
4 | * | |
5 | * @return array | |
6 | * API result array | |
7 | */ | |
8 | function payment_get_example() { | |
cf8f0fff | 9 | $params = [ |
6094aad5 PN |
10 | 'contribution_id' => 1, |
11 | 'check_permissions' => TRUE, | |
cf8f0fff | 12 | ]; |
6094aad5 PN |
13 | |
14 | try{ | |
15 | $result = civicrm_api3('Payment', '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(); | |
cf8f0fff | 22 | return [ |
1d8ee3d6 | 23 | 'is_error' => 1, |
24 | 'error_message' => $errorMessage, | |
6094aad5 PN |
25 | 'error_code' => $errorCode, |
26 | 'error_data' => $errorData, | |
cf8f0fff | 27 | ]; |
6094aad5 PN |
28 | } |
29 | ||
30 | return $result; | |
31 | } | |
32 | ||
33 | /** | |
34 | * Function returns array of result expected from previous function. | |
35 | * | |
36 | * @return array | |
37 | * API result array | |
38 | */ | |
39 | function payment_get_expectedresult() { | |
40 | ||
cf8f0fff | 41 | $expectedResult = [ |
6094aad5 PN |
42 | 'is_error' => 0, |
43 | 'version' => 3, | |
44 | 'count' => 1, | |
45 | 'id' => 1, | |
cf8f0fff CW |
46 | 'values' => [ |
47 | '1' => [ | |
6094aad5 PN |
48 | 'id' => '1', |
49 | 'to_financial_account_id' => '6', | |
50 | 'trxn_date' => '2010-01-20 00:00:00', | |
51 | 'total_amount' => '100.00', | |
52 | 'fee_amount' => '0.00', | |
53 | 'net_amount' => '100.00', | |
54 | 'currency' => 'USD', | |
55 | 'is_payment' => '1', | |
56 | 'trxn_id' => '23456', | |
57 | 'status_id' => '1', | |
58 | 'payment_instrument_id' => '4', | |
59 | 'contribution_id' => '1', | |
cf8f0fff CW |
60 | ], |
61 | ], | |
62 | ]; | |
6094aad5 PN |
63 | |
64 | return $expectedResult; | |
65 | } | |
66 | ||
67 | /* | |
68 | * This example has been generated from the API test suite. | |
69 | * The test that created it is called "testGetPayment" | |
70 | * and can be found at: | |
71 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentTest.php | |
72 | * | |
73 | * You can see the outcome of the API tests at | |
74 | * https://test.civicrm.org/job/CiviCRM-master-git/ | |
75 | * | |
76 | * To Learn about the API read | |
77 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API | |
78 | * | |
79 | * Browse the api on your own site with the api explorer | |
80 | * http://MYSITE.ORG/path/to/civicrm/api | |
81 | * | |
82 | * Read more about testing here | |
83 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
84 | * | |
85 | * API Standards documentation: | |
86 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
87 | */ |