24
24
*
25
25
* @return array
26
26
* Array of Order, if error an array with an error id and error message
27
+ * @throws \CiviCRM_API3_Exception
27
28
*/
28
- function civicrm_api3_order_get ($ params ) {
29
+ function civicrm_api3_order_get (array $ params ): array {
29
30
$ contributions = [];
30
31
$ params ['api.line_item.get ' ] = ['qty ' => ['<> ' => 0 ]];
31
32
$ isSequential = FALSE ;
@@ -53,7 +54,7 @@ function civicrm_api3_order_get($params) {
53
54
* @param array $params
54
55
* Array of parameters determined by getfields.
55
56
*/
56
- function _civicrm_api3_order_get_spec (&$ params ) {
57
+ function _civicrm_api3_order_get_spec (array &$ params ) {
57
58
$ params ['id ' ]['api.aliases ' ] = ['order_id ' ];
58
59
$ params ['id ' ]['title ' ] = ts ('Contribution / Order ID ' );
59
60
}
@@ -70,7 +71,7 @@ function _civicrm_api3_order_get_spec(&$params) {
70
71
* @throws \CiviCRM_API3_Exception
71
72
* @throws API_Exception
72
73
*/
73
- function civicrm_api3_order_create ($ params ) {
74
+ function civicrm_api3_order_create (array $ params ): array {
74
75
civicrm_api3_verify_one_mandatory ($ params , NULL , ['line_items ' , 'total_amount ' ]);
75
76
$ entity = NULL ;
76
77
$ entityIds = [];
@@ -156,10 +157,10 @@ function civicrm_api3_order_create($params) {
156
157
$ entity . '_id ' => $ entityId ,
157
158
];
158
159
// if entity is pledge then build pledge param
159
- if ($ entity == 'pledge ' ) {
160
+ if ($ entity === 'pledge ' ) {
160
161
$ paymentParams += $ entityParams ;
161
162
}
162
- elseif ($ entity == 'membership ' ) {
163
+ elseif ($ entity === 'membership ' ) {
163
164
$ contribution ['values ' ][$ contribution ['id ' ]]['membership_id ' ][] = $ entityId ;
164
165
$ paymentParams ['isSkipLineItem ' ] = TRUE ;
165
166
}
@@ -174,11 +175,12 @@ function civicrm_api3_order_create($params) {
174
175
*
175
176
* @param array $params
176
177
* Input parameters.
178
+ *
177
179
* @return array
178
180
* @throws API_Exception
179
181
* @throws CiviCRM_API3_Exception
180
182
*/
181
- function civicrm_api3_order_delete ($ params ) {
183
+ function civicrm_api3_order_delete (array $ params ): array {
182
184
$ contribution = civicrm_api3 ('Contribution ' , 'get ' , [
183
185
'return ' => ['is_test ' ],
184
186
'id ' => $ params ['id ' ],
@@ -199,8 +201,9 @@ function civicrm_api3_order_delete($params) {
199
201
* Input parameters.
200
202
*
201
203
* @return array
204
+ * @throws \CiviCRM_API3_Exception
202
205
*/
203
- function civicrm_api3_order_cancel ($ params ) {
206
+ function civicrm_api3_order_cancel (array $ params ) {
204
207
$ contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus (NULL , 'name ' );
205
208
$ params ['contribution_status_id ' ] = array_search ('Cancelled ' , $ contributionStatuses );
206
209
$ result = civicrm_api3 ('Contribution ' , 'create ' , $ params );
@@ -215,7 +218,7 @@ function civicrm_api3_order_cancel($params) {
215
218
* @param array $params
216
219
* Array of parameters determined by getfields.
217
220
*/
218
- function _civicrm_api3_order_cancel_spec (&$ params ) {
221
+ function _civicrm_api3_order_cancel_spec (array &$ params ) {
219
222
$ params ['contribution_id ' ] = [
220
223
'api.required ' => 1 ,
221
224
'title ' => 'Contribution ID ' ,
@@ -231,7 +234,7 @@ function _civicrm_api3_order_cancel_spec(&$params) {
231
234
* @param array $params
232
235
* Array of parameters determined by getfields.
233
236
*/
234
- function _civicrm_api3_order_create_spec (&$ params ) {
237
+ function _civicrm_api3_order_create_spec (array &$ params ) {
235
238
$ params ['contact_id ' ] = [
236
239
'name ' => 'contact_id ' ,
237
240
'title ' => 'Contact ID ' ,
@@ -271,7 +274,7 @@ function _civicrm_api3_order_create_spec(&$params) {
271
274
* @param array $params
272
275
* Array of parameters determined by getfields.
273
276
*/
274
- function _civicrm_api3_order_delete_spec (&$ params ) {
277
+ function _civicrm_api3_order_delete_spec (array &$ params ) {
275
278
$ params ['contribution_id ' ] = [
276
279
'api.required ' => TRUE ,
277
280
'title ' => 'Contribution ID ' ,
0 commit comments