Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / Payment / UpdatePayment.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Payment.create API.
4 *
5 * Update Payment
6 *
7 * @return array
8 * API result array
9 */
10 function payment_create_example() {
11 $params = [
12 'contribution_id' => 1,
13 'total_amount' => 100,
14 'id' => 3,
15 'check_permissions' => TRUE,
16 ];
17
18 try{
19 $result = civicrm_api3('Payment', 'create', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return [
27 'is_error' => 1,
28 'error_message' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 ];
32 }
33
34 return $result;
35 }
36
37 /**
38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
42 */
43 function payment_create_expectedresult() {
44
45 $expectedResult = [
46 'is_error' => 0,
47 'version' => 3,
48 'count' => 1,
49 'id' => 5,
50 'values' => [
51 '5' => [
52 'id' => '5',
53 'from_financial_account_id' => '7',
54 'to_financial_account_id' => '6',
55 'trxn_date' => '20170207024653',
56 'total_amount' => '100',
57 'fee_amount' => '',
58 'net_amount' => '100',
59 'currency' => 'USD',
60 'is_payment' => '1',
61 'trxn_id' => '',
62 'trxn_result_code' => '',
63 'status_id' => '1',
64 'payment_processor_id' => '',
65 ],
66 ],
67 ];
68
69 return $expectedResult;
70 }
71
72 /*
73 * This example has been generated from the API test suite.
74 * The test that created it is called "testUpdatePayment"
75 * and can be found at:
76 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentTest.php
77 *
78 * You can see the outcome of the API tests at
79 * https://test.civicrm.org/job/CiviCRM-master-git/
80 *
81 * To Learn about the API read
82 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
83 *
84 * Browse the api on your own site with the api explorer
85 * http://MYSITE.ORG/path/to/civicrm/api
86 *
87 * Read more about testing here
88 * http://wiki.civicrm.org/confluence/display/CRM/Testing
89 *
90 * API Standards documentation:
91 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
92 */