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