Commit | Line | Data |
---|---|---|
54a54e15 PN |
1 | <?php |
2 | /** | |
3 | * Test Generated example demonstrating the Order.cancel API. | |
4 | * | |
5 | * @return array | |
6 | * API result array | |
7 | */ | |
8 | function order_cancel_example() { | |
9 | $params = array( | |
10 | 'contribution_id' => 1, | |
11 | ); | |
12 | ||
13 | try{ | |
14 | $result = civicrm_api3('Order', 'cancel', $params); | |
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( | |
5be22f39 | 22 | 'is_error' => 1, |
23 | 'error_message' => $errorMessage, | |
54a54e15 PN |
24 | 'error_code' => $errorCode, |
25 | 'error_data' => $errorData, | |
26 | ); | |
27 | } | |
28 | ||
29 | return $result; | |
30 | } | |
31 | ||
32 | /** | |
33 | * Function returns array of result expected from previous function. | |
34 | * | |
35 | * @return array | |
36 | * API result array | |
37 | */ | |
38 | function order_cancel_expectedresult() { | |
39 | ||
40 | $expectedResult = array( | |
41 | 'is_error' => 0, | |
42 | 'version' => 3, | |
43 | 'count' => 1, | |
44 | 'id' => 1, | |
45 | 'values' => array( | |
46 | '1' => array( | |
47 | 'id' => '1', | |
1d8ee3d6 | 48 | 'contact_id' => '16', |
54a54e15 PN |
49 | 'financial_type_id' => '1', |
50 | 'contribution_page_id' => '', | |
51 | 'payment_instrument_id' => '4', | |
52 | 'receive_date' => '2010-01-20 00:00:00', | |
53 | 'non_deductible_amount' => '0.00', | |
54 | 'total_amount' => '100.00', | |
55 | 'fee_amount' => '0.00', | |
56 | 'net_amount' => '100.00', | |
57 | 'trxn_id' => '', | |
58 | 'invoice_id' => '', | |
59 | 'currency' => 'USD', | |
60 | 'cancel_date' => '', | |
61 | 'cancel_reason' => '', | |
62 | 'receipt_date' => '', | |
63 | 'thankyou_date' => '', | |
64 | 'source' => '', | |
65 | 'amount_level' => '', | |
66 | 'contribution_recur_id' => '', | |
67 | 'is_test' => 0, | |
68 | 'is_pay_later' => 0, | |
69 | 'contribution_status_id' => '3', | |
70 | 'address_id' => '', | |
71 | 'check_number' => '', | |
72 | 'campaign_id' => '', | |
73 | 'creditnote_id' => 'CN_1', | |
74 | 'tax_amount' => '', | |
5be22f39 | 75 | 'revenue_recognition_date' => '', |
54a54e15 PN |
76 | 'contribution_type_id' => '1', |
77 | ), | |
78 | ), | |
79 | ); | |
80 | ||
81 | return $expectedResult; | |
82 | } | |
83 | ||
84 | /* | |
85 | * This example has been generated from the API test suite. | |
86 | * The test that created it is called "testCancelOrder" | |
87 | * and can be found at: | |
88 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OrderTest.php | |
89 | * | |
90 | * You can see the outcome of the API tests at | |
91 | * https://test.civicrm.org/job/CiviCRM-master-git/ | |
92 | * | |
93 | * To Learn about the API read | |
94 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API | |
95 | * | |
96 | * Browse the api on your own site with the api explorer | |
97 | * http://MYSITE.ORG/path/to/civicrm/api | |
98 | * | |
99 | * Read more about testing here | |
100 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
101 | * | |
102 | * API Standards documentation: | |
103 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
104 | */ |