Merge pull request #8525 from twomice/CRM-18251b
[civicrm-core.git] / api / v3 / examples / Order / Get.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Order.get API.
4 *
5 * @return array
6 * API result array
7 */
8 function order_get_example() {
9 $params = array(
10 'contribution_id' => 1,
11 );
12
13 try{
14 $result = civicrm_api3('Order', 'get', $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(
22 'is_error' => 1,
23 'error_message' => $errorMessage,
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_get_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 'contact_id' => '3',
48 'contact_type' => 'Individual',
49 'contact_sub_type' => '',
50 'sort_name' => 'Anderson, Anthony',
51 'display_name' => 'Mr. Anthony Anderson II',
52 'contribution_id' => '1',
53 'currency' => 'USD',
54 'receive_date' => '2010-01-20 00:00:00',
55 'non_deductible_amount' => '0.00',
56 'total_amount' => '100.00',
57 'fee_amount' => '0.00',
58 'net_amount' => '100.00',
59 'trxn_id' => '',
60 'invoice_id' => '',
61 'cancel_date' => '',
62 'cancel_reason' => '',
63 'receipt_date' => '',
64 'thankyou_date' => '',
65 'contribution_source' => '',
66 'amount_level' => '',
67 'contribution_recur_id' => '',
68 'is_test' => 0,
69 'is_pay_later' => 0,
70 'contribution_status_id' => '1',
71 'contribution_check_number' => '',
72 'contribution_campaign_id' => '',
73 'financial_type_id' => '1',
74 'financial_type' => 'Donation',
75 'product_id' => '',
76 'product_name' => '',
77 'sku' => '',
78 'contribution_product_id' => '',
79 'product_option' => '',
80 'fulfilled_date' => '',
81 'contribution_start_date' => '',
82 'contribution_end_date' => '',
83 'financial_account_id' => '1',
84 'accounting_code' => '4200',
85 'campaign_id' => '',
86 'contribution_campaign_title' => '',
87 'contribution_note' => '',
88 'contribution_batch' => '',
89 'contribution_status' => 'Completed',
90 'payment_instrument' => 'Check',
91 'payment_instrument_id' => '4',
92 'instrument_id' => '4',
93 'check_number' => '',
94 'id' => '1',
95 'contribution_type_id' => '1',
96 'line_items' => array(
97 '0' => array(
98 'id' => '1',
99 'entity_table' => 'civicrm_contribution',
100 'entity_id' => '1',
101 'contribution_id' => '1',
102 'price_field_id' => '1',
103 'label' => 'Contribution Amount',
104 'qty' => '1.00',
105 'unit_price' => '100.00',
106 'line_total' => '100.00',
107 'price_field_value_id' => '1',
108 'financial_type_id' => '1',
109 'non_deductible_amount' => '0.00',
110 'contribution_type_id' => '1',
111 ),
112 ),
113 ),
114 ),
115 );
116
117 return $expectedResult;
118 }
119
120 /*
121 * This example has been generated from the API test suite.
122 * The test that created it is called "testGetOrder"
123 * and can be found at:
124 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OrderTest.php
125 *
126 * You can see the outcome of the API tests at
127 * https://test.civicrm.org/job/CiviCRM-master-git/
128 *
129 * To Learn about the API read
130 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
131 *
132 * Browse the api on your own site with the api explorer
133 * http://MYSITE.ORG/path/to/civicrm/api
134 *
135 * Read more about testing here
136 * http://wiki.civicrm.org/confluence/display/CRM/Testing
137 *
138 * API Standards documentation:
139 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
140 */