Merge pull request #7860 from monishdeb/CRM-18079
[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 'error' => $errorMessage,
23 'error_code' => $errorCode,
24 'error_data' => $errorData,
25 );
26 }
27
28 return $result;
29 }
30
31 /**
32 * Function returns array of result expected from previous function.
33 *
34 * @return array
35 * API result array
36 */
37 function order_get_expectedresult() {
38
39 $expectedResult = array(
40 'is_error' => 0,
41 'version' => 3,
42 'count' => 1,
43 'id' => 1,
44 'values' => array(
45 '1' => array(
46 'contact_id' => '3',
47 'contact_type' => 'Individual',
48 'contact_sub_type' => '',
49 'sort_name' => 'Anderson, Anthony',
50 'display_name' => 'Mr. Anthony Anderson II',
51 'contribution_id' => '1',
52 'currency' => 'USD',
53 'receive_date' => '2010-01-20 00:00:00',
54 'non_deductible_amount' => '0.00',
55 'total_amount' => '100.00',
56 'fee_amount' => '0.00',
57 'net_amount' => '100.00',
58 'trxn_id' => '',
59 'invoice_id' => '',
60 'cancel_date' => '',
61 'cancel_reason' => '',
62 'receipt_date' => '',
63 'thankyou_date' => '',
64 'contribution_source' => '',
65 'amount_level' => '',
66 'is_test' => 0,
67 'is_pay_later' => 0,
68 'contribution_status_id' => '1',
69 'check_number' => '',
70 'contribution_campaign_id' => '',
71 'financial_type_id' => '1',
72 'financial_type' => 'Donation',
73 'product_id' => '',
74 'product_name' => '',
75 'sku' => '',
76 'contribution_product_id' => '',
77 'product_option' => '',
78 'fulfilled_date' => '',
79 'contribution_start_date' => '',
80 'contribution_end_date' => '',
81 'contribution_recur_id' => '',
82 'financial_account_id' => '1',
83 'accounting_code' => '4200',
84 'campaign_id' => '',
85 'contribution_campaign_title' => '',
86 'contribution_note' => '',
87 'contribution_batch' => '',
88 'contribution_status' => 'Completed',
89 'payment_instrument' => 'Check',
90 'payment_instrument_id' => '4',
91 'instrument_id' => '4',
92 'contribution_check_number' => '',
93 'id' => '1',
94 'contribution_type_id' => '1',
95 'line_items' => array(
96 '0' => array(
97 'id' => '1',
98 'entity_table' => 'civicrm_contribution',
99 'entity_id' => '1',
100 'contribution_id' => '1',
101 'price_field_id' => '1',
102 'label' => 'Contribution Amount',
103 'qty' => '1.00',
104 'unit_price' => '100.00',
105 'line_total' => '100.00',
106 'price_field_value_id' => '1',
107 'financial_type_id' => '1',
108 'deductible_amount' => '0.00',
109 ),
110 ),
111 ),
112 ),
113 );
114
115 return $expectedResult;
116 }
117
118 /*
119 * This example has been generated from the API test suite.
120 * The test that created it is called "testGetOrder"
121 * and can be found at:
122 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OrderTest.php
123 *
124 * You can see the outcome of the API tests at
125 * https://test.civicrm.org/job/CiviCRM-master-git/
126 *
127 * To Learn about the API read
128 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
129 *
130 * Browse the api on your own site with the api explorer
131 * http://MYSITE.ORG/path/to/civicrm/api
132 *
133 * Read more about testing here
134 * http://wiki.civicrm.org/confluence/display/CRM/Testing
135 *
136 * API Standards documentation:
137 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
138 */