Merge branch '4.6' of https://github.com/civicrm/civicrm-core
[civicrm-core.git] / api / v3 / Contribution.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * This api exposes CiviCRM Contribution records.
30 *
31 * @package CiviCRM_APIv3
32 */
33
34 /**
35 * Add or update a Contribution.
36 *
37 * @param array $params
38 * Input parameters.
39 *
40 * @throws API_Exception
41 * @return array
42 * Api result array
43 */
44 function civicrm_api3_contribution_create(&$params) {
45 $values = array();
46 _civicrm_api3_custom_format_params($params, $values, 'Contribution');
47 $params = array_merge($params, $values);
48
49 if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
50 if (empty($params['id'])) {
51 $op = 'add';
52 }
53 else {
54 if (empty($params['financial_type_id'])) {
55 $params['financial_type_id'] = civicrm_api3('Contribution', 'getvalue', array(
56 'id' => $params['id'],
57 'return' => 'financial_type_id',
58 ));
59 }
60 $op = 'edit';
61 }
62 CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
63 if (!in_array($params['financial_type_id'], array_keys($types))) {
64 return civicrm_api3_create_error('You do not have permission to create this contribution');
65 }
66 }
67 if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
68 $error = array();
69 //throw error for invalid status change such as setting completed back to pending
70 //@todo this sort of validation belongs in the BAO not the API - if it is not an OK
71 // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
72 CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error);
73 if (array_key_exists('contribution_status_id', $error)) {
74 throw new API_Exception($error['contribution_status_id']);
75 }
76 }
77 if (!empty($params['id']) && !empty($params['financial_type_id'])) {
78 $error = array();
79 CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
80 if (array_key_exists('financial_type_id', $error)) {
81 throw new API_Exception($error['financial_type_id']);
82 }
83 }
84 _civicrm_api3_contribution_create_legacy_support_45($params);
85
86 // Make sure tax calculation is handled via api.
87 $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
88
89 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
90 }
91
92 /**
93 * Adjust Metadata for Create action.
94 *
95 * The metadata is used for setting defaults, documentation & validation.
96 *
97 * @param array $params
98 * Array of parameters determined by getfields.
99 */
100 function _civicrm_api3_contribution_create_spec(&$params) {
101 $params['contact_id']['api.required'] = 1;
102 $params['total_amount']['api.required'] = 1;
103 $params['payment_instrument_id']['api.aliases'] = array('payment_instrument');
104 $params['receive_date']['api.default'] = 'now';
105 $params['payment_processor'] = array(
106 'name' => 'payment_processor',
107 'title' => 'Payment Processor ID',
108 'description' => 'ID of payment processor used for this contribution',
109 // field is called payment processor - not payment processor id but can only be one id so
110 // it seems likely someone will fix it up one day to be more consistent - lets alias it from the start
111 'api.aliases' => array('payment_processor_id'),
112 'type' => CRM_Utils_Type::T_INT,
113 );
114 $params['financial_type_id']['api.aliases'] = array('contribution_type_id', 'contribution_type');
115 $params['financial_type_id']['api.required'] = 1;
116 $params['note'] = array(
117 'name' => 'note',
118 'uniqueName' => 'contribution_note',
119 'title' => 'note',
120 'type' => 2,
121 'description' => 'Associated Note in the notes table',
122 );
123 $params['soft_credit_to'] = array(
124 'name' => 'soft_credit_to',
125 'title' => 'Soft Credit contact ID (legacy)',
126 'type' => 1,
127 'description' => 'ID of Contact to be Soft credited to (deprecated - use contribution_soft api)',
128 'FKClassName' => 'CRM_Contact_DAO_Contact',
129 );
130 $params['honor_contact_id'] = array(
131 'name' => 'honor_contact_id',
132 'title' => 'Honoree contact ID (legacy)',
133 'type' => 1,
134 'description' => 'ID of honoree contact (deprecated - use contribution_soft api)',
135 'FKClassName' => 'CRM_Contact_DAO_Contact',
136 );
137 $params['honor_type_id'] = array(
138 'name' => 'honor_type_id',
139 'title' => 'Honoree Type (legacy)',
140 'type' => 1,
141 'description' => 'Type of honoree contact (deprecated - use contribution_soft api)',
142 'pseudoconstant' => TRUE,
143 );
144 // note this is a recommended option but not adding as a default to avoid
145 // creating unnecessary changes for the dev
146 $params['skipRecentView'] = array(
147 'name' => 'skipRecentView',
148 'title' => 'Skip adding to recent view',
149 'type' => CRM_Utils_Type::T_BOOLEAN,
150 'description' => 'Do not add to recent view (setting this improves performance)',
151 );
152 $params['skipLineItem'] = array(
153 'name' => 'skipLineItem',
154 'title' => 'Skip adding line items',
155 'type' => CRM_Utils_Type::T_BOOLEAN,
156 'api.default' => 0,
157 'description' => 'Do not add line items by default (if you wish to add your own)',
158 );
159 $params['batch_id'] = array(
160 'title' => 'Batch',
161 'type' => 1,
162 'description' => 'Batch which relevant transactions should be added to',
163 );
164 }
165
166 /**
167 * Support for schema changes made in 4.5.
168 *
169 * The main purpose of the API is to provide integrators a level of stability not provided by
170 * the core code or schema - this means we have to provide support for api calls (where possible)
171 * across schema changes.
172 *
173 * @param array $params
174 */
175 function _civicrm_api3_contribution_create_legacy_support_45(&$params) {
176 //legacy soft credit handling - recommended approach is chaining
177 if (!empty($params['soft_credit_to'])) {
178 $params['soft_credit'][] = array(
179 'contact_id' => $params['soft_credit_to'],
180 'amount' => $params['total_amount'],
181 'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"),
182 );
183 }
184 if (!empty($params['honor_contact_id'])) {
185 $params['soft_credit'][] = array(
186 'contact_id' => $params['honor_contact_id'],
187 'amount' => $params['total_amount'],
188 'soft_credit_type_id' => CRM_Utils_Array::value('honor_type_id', $params, CRM_Core_OptionGroup::getValue('soft_credit_type', 'in_honor_of', 'name')),
189 );
190 }
191 }
192
193 /**
194 * Delete a Contribution.
195 *
196 * @param array $params
197 * Input parameters.
198 *
199 * @return array
200 */
201 function civicrm_api3_contribution_delete($params) {
202
203 $contributionID = !empty($params['contribution_id']) ? $params['contribution_id'] : $params['id'];
204 // First check contribution financial type
205 $financialType = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionID, 'financial_type_id');
206 // Now check permissioned lineitems & permissioned contribution
207 if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()
208 && !CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($financialType)) ||
209 !CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributionID, 'delete', FALSE)
210 ) {
211 return civicrm_api3_create_error('You do not have permission to delete this contribution');
212 }
213 if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionID)) {
214 return civicrm_api3_create_success(array($contributionID => 1));
215 }
216 else {
217 return civicrm_api3_create_error('Could not delete contribution');
218 }
219 }
220
221 /**
222 * Modify metadata for delete action.
223 *
224 * Legacy support for contribution_id.
225 *
226 * @param array $params
227 */
228 function _civicrm_api3_contribution_delete_spec(&$params) {
229 $params['id']['api.aliases'] = array('contribution_id');
230 }
231
232 /**
233 * Retrieve a set of contributions.
234 *
235 * @param array $params
236 * Input parameters.
237 *
238 * @return array
239 * Array of contributions, if error an array with an error id and error message
240 */
241 function civicrm_api3_contribution_get($params) {
242
243 $mode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
244 list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Contribution');
245
246 $contribution = array();
247 while ($dao->fetch()) {
248 //CRM-8662
249 $contribution_details = $query->store($dao);
250 $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE);
251 $contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution);
252 // format soft credit for backward compatibility
253 _civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]);
254 }
255 return civicrm_api3_create_success($contribution, $params, 'Contribution', 'get', $dao);
256 }
257
258 /**
259 * This function is used to format the soft credit for backward compatibility.
260 *
261 * As of v4.4 we support multiple soft credit, so now contribution returns array with 'soft_credit' as key
262 * but we still return first soft credit as a part of contribution array
263 *
264 * @param $contribution
265 */
266 function _civicrm_api3_format_soft_credit(&$contribution) {
267 if (!empty($contribution['soft_credit'])) {
268 $contribution['soft_credit_to'] = $contribution['soft_credit'][1]['contact_id'];
269 $contribution['soft_credit_id'] = $contribution['soft_credit'][1]['soft_credit_id'];
270 }
271 }
272
273 /**
274 * Adjust Metadata for Get action.
275 *
276 * The metadata is used for setting defaults, documentation & validation.
277 *
278 * @param array $params
279 * Array of parameters determined by getfields.
280 */
281 function _civicrm_api3_contribution_get_spec(&$params) {
282 $params['contribution_test'] = array(
283 'api.default' => 0,
284 'type' => CRM_Utils_Type::T_BOOLEAN,
285 'title' => 'Get Test Contributions?',
286 'api.aliases' => array('is_test'),
287 );
288
289 $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
290 $params['payment_instrument_id']['api.aliases'] = array('contribution_payment_instrument', 'payment_instrument');
291 $params['contact_id'] = $params['contribution_contact_id'];
292 $params['contact_id']['api.aliases'] = array('contribution_contact_id');
293 unset($params['contribution_contact_id']);
294 }
295
296 /**
297 * Legacy handling for contribution parameters.
298 *
299 * Take the input parameter list as specified in the data model and
300 * convert it into the same format that we use in QF and BAO object.
301 *
302 * @param array $params
303 * property name/value pairs to insert in new contact.
304 * @param array $values
305 * The reformatted properties that we can use internally.
306 *
307 * @return array
308 */
309 function _civicrm_api3_contribute_format_params($params, &$values) {
310 //legacy way of formatting from v2 api - v3 way is to define metadata & do it in the api layer
311 _civicrm_api3_filter_fields_for_bao('Contribution', $params, $values);
312 return array();
313 }
314
315 /**
316 * Adjust Metadata for Transact action.
317 *
318 * The metadata is used for setting defaults, documentation & validation.
319 *
320 * @param array $params
321 * Array of parameters determined by getfields.
322 */
323 function _civicrm_api3_contribution_transact_spec(&$params) {
324 $fields = civicrm_api3('Contribution', 'getfields', array('action' => 'create'));
325 $params = array_merge($params, $fields['values']);
326 $params['receive_date']['api.default'] = 'now';
327 }
328
329 /**
330 * Process a transaction and record it against the contact.
331 *
332 * @param array $params
333 * Input parameters.
334 *
335 * @return array
336 * contribution of created or updated record (or a civicrm error)
337 */
338 function civicrm_api3_contribution_transact($params) {
339 // Set some params specific to payment processing
340 // @todo - fix this function - none of the results checked by civicrm_error would ever be an array with
341 // 'is_error' set
342 // also trxn_id is not saved.
343 // but since there is no test it's not desirable to jump in & make the obvious changes.
344 $params['payment_processor_mode'] = empty($params['is_test']) ? 'live' : 'test';
345 $params['amount'] = $params['total_amount'];
346 if (!isset($params['net_amount'])) {
347 $params['net_amount'] = $params['amount'];
348 }
349 if (!isset($params['invoiceID']) && isset($params['invoice_id'])) {
350 $params['invoiceID'] = $params['invoice_id'];
351 }
352
353 // Some payment processors expect a unique invoice_id - generate one if not supplied
354 $params['invoice_id'] = CRM_Utils_Array::value('invoice_id', $params, md5(uniqid(rand(), TRUE)));
355
356 $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($params['payment_processor'], $params['payment_processor_mode']);
357 $paymentProcessor['object']->doPayment($params);
358
359 $params['payment_instrument_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', $paymentProcessor['payment_processor_type_id'], 'payment_type') == 1 ? 'Credit Card' : 'Debit Card';
360 return civicrm_api('Contribution', 'create', $params);
361 }
362
363 /**
364 * Send a contribution confirmation (receipt or invoice).
365 *
366 * The appropriate online template will be used (the existence of related objects
367 * (e.g. memberships ) will affect this selection
368 *
369 * @param array $params
370 * Input parameters.
371 *
372 * @throws Exception
373 */
374 function civicrm_api3_contribution_sendconfirmation($params) {
375 $contribution = new CRM_Contribute_BAO_Contribution();
376 $contribution->id = $params['id'];
377 if (!$contribution->find(TRUE)) {
378 throw new Exception('Contribution does not exist');
379 }
380 $input = $ids = $cvalues = array('receipt_from_email' => $params['receipt_from_email']);
381 $contribution->loadRelatedObjects($input, $ids, TRUE);
382 $contribution->composeMessageArray($input, $ids, $cvalues, FALSE, FALSE);
383 }
384
385 /**
386 * Adjust Metadata for sendconfirmation action.
387 *
388 * The metadata is used for setting defaults, documentation & validation.
389 *
390 * @param array $params
391 * Array of parameters determined by getfields.
392 */
393 function _civicrm_api3_contribution_sendconfirmation_spec(&$params) {
394 $params['id'] = array(
395 'api.required' => 1,
396 'title' => 'Contribution ID',
397 'type' => CRM_Utils_Type::T_INT,
398 );
399 $params['receipt_from_email'] = array(
400 'api.required' => 1,
401 'title' => 'From Email address (string) required until someone provides a patch :-)',
402 'type' => CRM_Utils_Type::T_STRING,
403 );
404 $params['receipt_from_name'] = array(
405 'title' => 'From Name (string)',
406 'type' => CRM_Utils_Type::T_STRING,
407 );
408 $params['cc_receipt'] = array(
409 'title' => 'CC Email address (string)',
410 'type' => CRM_Utils_Type::T_STRING,
411 );
412 $params['bcc_receipt'] = array(
413 'title' => 'BCC Email address (string)',
414 'type' => CRM_Utils_Type::T_STRING,
415 );
416 $params['receipt_text'] = array(
417 'title' => 'Message (string)',
418 'type' => CRM_Utils_Type::T_STRING,
419 );
420 }
421
422 /**
423 * Complete an existing (pending) transaction.
424 *
425 * This will update related entities (participant, membership, pledge etc)
426 * and take any complete actions from the contribution page (e.g. send receipt).
427 *
428 * @todo - most of this should live in the BAO layer but as we want it to be an addition
429 * to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
430 *
431 * @param array $params
432 * Input parameters.
433 *
434 * @throws API_Exception
435 * Api result array.
436 */
437 function civicrm_api3_contribution_completetransaction(&$params) {
438
439 $input = $ids = array();
440 if (isset($params['payment_processor_id'])) {
441 $input['payment_processor_id'] = $params['payment_processor_id'];
442 }
443 $contribution = new CRM_Contribute_BAO_Contribution();
444 $contribution->id = $params['id'];
445 $contribution->find(TRUE);
446 if (!$contribution->id == $params['id']) {
447 throw new API_Exception('A valid contribution ID is required', 'invalid_data');
448 }
449
450 if (!$contribution->loadRelatedObjects($input, $ids, TRUE)) {
451 throw new API_Exception('failed to load related objects');
452 }
453 elseif ($contribution->contribution_status_id == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
454 throw new API_Exception(ts('Contribution already completed'), 'contribution_completed');
455 }
456 $input['trxn_id'] = !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id;
457 if (!empty($params['fee_amount'])) {
458 $input['fee_amount'] = $params['fee_amount'];
459 }
460 $params = _ipn_process_transaction($params, $contribution, $input, $ids);
461
462 }
463
464 /**
465 * Provide function metadata.
466 *
467 * @param array $params
468 */
469 function _civicrm_api3_contribution_completetransaction_spec(&$params) {
470 $params['id'] = array(
471 'title' => 'Contribution ID',
472 'type' => CRM_Utils_Type::T_INT,
473 'api.required' => TRUE,
474 );
475 $params['trxn_id'] = array(
476 'title' => 'Transaction ID',
477 'type' => CRM_Utils_Type::T_STRING,
478 );
479 $params['is_email_receipt'] = array(
480 'title' => 'Send email Receipt?',
481 'type' => CRM_Utils_Type::T_BOOLEAN,
482 );
483 $params['receipt_from_email'] = array(
484 'title' => 'Email to send receipt from.',
485 'description' => 'If not provided this will default to being based on domain mail or contribution page',
486 'type' => CRM_Utils_Type::T_EMAIL,
487 );
488 $params['receipt_from_name'] = array(
489 'title' => 'Name to send receipt from',
490 'description' => '. If not provided this will default to domain mail or contribution page',
491 'type' => CRM_Utils_Type::T_STRING,
492 );
493 $params['payment_processor_id'] = array(
494 'title' => 'Payment processor ID',
495 'description' => 'Providing this is strongly recommended, as not possible to calculate it accurately always',
496 'type' => CRM_Utils_Type::T_INT,
497 );
498 $params['fee_amount'] = array(
499 'title' => 'Fee charged on transaction',
500 'description' => 'If a fee has been charged then the amount',
501 'type' => CRM_Utils_Type::T_FLOAT,
502 );
503 $params['trxn_date'] = array(
504 'title' => 'Transaction Date',
505 'description' => 'Date this transaction occurred',
506 'type' => CRM_Utils_Type::T_DATE,
507 );
508 }
509
510 /**
511 * Complete an existing (pending) transaction.
512 *
513 * This will update related entities (participant, membership, pledge etc)
514 * and take any complete actions from the contribution page (e.g. send receipt).
515 *
516 * @todo - most of this should live in the BAO layer but as we want it to be an addition
517 * to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
518 *
519 * @param array $params
520 * Input parameters.
521 *
522 * @throws API_Exception
523 * Api result array.
524 */
525 function civicrm_api3_contribution_repeattransaction(&$params) {
526 $input = $ids = array();
527 $contribution = new CRM_Contribute_BAO_Contribution();
528 $contribution->id = $params['original_contribution_id'];
529 if (!$contribution->find(TRUE)) {
530 throw new API_Exception(
531 'A valid original contribution ID is required', 'invalid_data');
532 }
533 $original_contribution = clone $contribution;
534 try {
535 if (!$contribution->loadRelatedObjects($input, $ids, TRUE)) {
536 throw new API_Exception('failed to load related objects');
537 }
538
539 unset($contribution->id, $contribution->receive_date, $contribution->invoice_id);
540 $contribution->contribution_status_id = $params['contribution_status_id'];
541 $contribution->receive_date = $params['receive_date'];
542
543 $passThroughParams = array('trxn_id', 'total_amount', 'campaign_id', 'fee_amount');
544 $input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));
545
546 $params = _ipn_process_transaction($params, $contribution, $input, $ids, $original_contribution);
547 }
548 catch(Exception $e) {
549 throw new API_Exception('failed to load related objects' . $e->getMessage() . "\n" . $e->getTraceAsString());
550 }
551 }
552
553 /**
554 * Calls IPN complete transaction for completing or repeating a transaction.
555 *
556 * The IPN function is overloaded with two purposes - this is simply a wrapper for that
557 * when separating them in the api layer.
558 *
559 * @param array $params
560 * @param CRM_Contribute_BAO_Contribution $contribution
561 * @param array $input
562 *
563 * @param array $ids
564 *
565 * @param CRM_Contribute_BAO_Contribution $firstContribution
566 *
567 * @return mixed
568 */
569 function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstContribution = NULL) {
570 $objects = $contribution->_relatedObjects;
571 $objects['contribution'] = &$contribution;
572
573 if ($firstContribution) {
574 $objects['first_contribution'] = $firstContribution;
575 }
576 $input['component'] = $contribution->_component;
577 $input['is_test'] = $contribution->is_test;
578 $input['amount'] = empty($input['total_amount']) ? $contribution->total_amount : $input['total_amount'];
579
580 if (isset($params['is_email_receipt'])) {
581 $input['is_email_receipt'] = $params['is_email_receipt'];
582 }
583 if (!empty($params['trxn_date'])) {
584 $input['trxn_date'] = $params['trxn_date'];
585 }
586 if (empty($contribution->contribution_page_id)) {
587 static $domainFromName;
588 static $domainFromEmail;
589 if (empty($domainFromEmail) && (empty($params['receipt_from_name']) || empty($params['receipt_from_email']))) {
590 list($domainFromName, $domainFromEmail) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
591 }
592 $input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName);
593 $input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail);
594 }
595 $transaction = new CRM_Core_Transaction();
596 CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, !empty($contribution->contribution_recur_id), $contribution,
597 FALSE, FALSE);
598 return $params;
599 }
600
601 /**
602 * Provide function metadata.
603 *
604 * @param array $params
605 */
606 function _civicrm_api3_contribution_repeattransaction_spec(&$params) {
607 $params['original_contribution_id'] = array(
608 'title' => 'Original Contribution ID',
609 'type' => CRM_Utils_Type::T_INT,
610 'api.required' => TRUE,
611 );
612 $params['trxn_id'] = array(
613 'title' => 'Transaction ID',
614 'type' => CRM_Utils_Type::T_STRING,
615 );
616 $params['is_email_receipt'] = array(
617 'title' => 'Send email Receipt?',
618 'type' => CRM_Utils_Type::T_BOOLEAN,
619 );
620 $params['contribution_status_id'] = array(
621 'title' => 'Contribution Status ID',
622 'name' => 'contribution_status_id',
623 'type' => CRM_Utils_Type::T_INT,
624 'pseudoconstant' => array(
625 'optionGroupName' => 'contribution_status',
626 ),
627 'api.required' => TRUE,
628 );
629 $params['receive_date'] = array(
630 'title' => 'Contribution Receive Date',
631 'name' => 'receive_date',
632 'type' => CRM_Utils_Type::T_DATE,
633 'api.default' => 'now',
634 );
635 $params['trxn_id'] = array(
636 'title' => 'Transaction ID',
637 'name' => 'trxn_id',
638 'type' => CRM_Utils_Type::T_STRING,
639 );
640 $params['payment_processor_id'] = array(
641 'description' => ts('Payment processor ID, will be loaded from contribution_recur if not provided'),
642 'title' => 'Payment processor ID',
643 'name' => 'payment_processor_id',
644 'type' => CRM_Utils_Type::T_INT,
645 );
646 }