3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * This api exposes CiviCRM Contribution records.
15 * @package CiviCRM_APIv3
18 use Civi\Api4\Contribution
;
21 * Add or update a Contribution.
23 * @param array $params
26 * @throws API_Exception
30 function civicrm_api3_contribution_create($params) {
32 _civicrm_api3_custom_format_params($params, $values, 'Contribution');
33 $params = array_merge($params, $values);
34 // The BAO should not clean money - it should be done in the form layer & api wrapper
35 // (although arguably the api should expect pre-cleaned it seems to do some cleaning.)
36 if (empty($params['skipCleanMoney'])) {
37 foreach (['total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount'] as $field) {
38 if (isset($params[$field])) {
39 $params[$field] = CRM_Utils_Rule
::cleanMoney($params[$field]);
43 $params['skipCleanMoney'] = TRUE;
45 if (!empty($params['check_permissions'])) {
46 // Check acls on this entity. Note that we pass in financial type id, if we have it
47 // since we know this is checked by acls. In v4 we do something more generic.
48 if (!Contribution
::checkAccess()
49 ->setAction(empty($params['id']) ?
'create' : 'update')
50 ->addValue('id', $params['id'] ??
NULL)
51 ->addValue('financial_type_id', $params['financial_type_id'] ??
NULL)
52 ->execute()->first()['access']) {
53 throw new API_Exception('You do not have permission to create this contribution');
56 if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
58 //throw error for invalid status change such as setting completed back to pending
59 //@todo this sort of validation belongs in the BAO not the API - if it is not an OK
60 // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
61 CRM_Contribute_BAO_Contribution
::checkStatusValidation(NULL, $params, $error);
62 if (array_key_exists('contribution_status_id', $error)) {
63 throw new API_Exception($error['contribution_status_id']);
66 if (!empty($params['id']) && !empty($params['financial_type_id'])) {
68 CRM_Contribute_BAO_Contribution
::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
69 if (array_key_exists('financial_type_id', $error)) {
70 throw new API_Exception($error['financial_type_id']);
73 _civicrm_api3_contribution_create_legacy_support_45($params);
75 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'Contribution');
79 * Adjust Metadata for Create action.
81 * The metadata is used for setting defaults, documentation & validation.
83 * @param array $params
84 * Array of parameters determined by getfields.
86 function _civicrm_api3_contribution_create_spec(&$params) {
87 $params['contact_id']['api.required'] = 1;
88 $params['total_amount']['api.required'] = 1;
89 $params['payment_instrument_id']['api.aliases'] = ['payment_instrument'];
90 $params['receive_date']['api.default'] = 'now';
91 $params['receive_date']['api.required'] = TRUE;
92 $params['payment_processor'] = [
93 'name' => 'payment_processor',
94 'title' => 'Payment Processor ID',
95 'description' => 'ID of payment processor used for this contribution',
96 // field is called payment processor - not payment processor id but can only be one id so
97 // it seems likely someone will fix it up one day to be more consistent - lets alias it from the start
98 'api.aliases' => ['payment_processor_id'],
99 'type' => CRM_Utils_Type
::T_INT
,
101 $params['financial_type_id']['api.aliases'] = ['contribution_type_id', 'contribution_type'];
102 $params['financial_type_id']['api.required'] = 1;
105 'uniqueName' => 'contribution_note',
108 'description' => 'Associated Note in the notes table',
110 $params['soft_credit_to'] = [
111 'name' => 'soft_credit_to',
112 'title' => 'Soft Credit contact ID (legacy)',
113 'type' => CRM_Utils_Type
::T_INT
,
114 'description' => 'ID of Contact to be Soft credited to (deprecated - use contribution_soft api)',
115 'FKClassName' => 'CRM_Contact_DAO_Contact',
117 $params['honor_contact_id'] = [
118 'name' => 'honor_contact_id',
119 'title' => 'Honoree contact ID (legacy)',
120 'type' => CRM_Utils_Type
::T_INT
,
121 'description' => 'ID of honoree contact (deprecated - use contribution_soft api)',
122 'FKClassName' => 'CRM_Contact_DAO_Contact',
124 $params['honor_type_id'] = [
125 'name' => 'honor_type_id',
126 'title' => 'Honoree Type (legacy)',
127 'type' => CRM_Utils_Type
::T_INT
,
128 'description' => 'Type of honoree contact (deprecated - use contribution_soft api)',
129 'pseudoconstant' => TRUE,
131 // note this is a recommended option but not adding as a default to avoid
132 // creating unnecessary changes for the dev
133 $params['skipRecentView'] = [
134 'name' => 'skipRecentView',
135 'title' => 'Skip adding to recent view',
136 'type' => CRM_Utils_Type
::T_BOOLEAN
,
137 'description' => 'Do not add to recent view (setting this improves performance)',
139 $params['skipLineItem'] = [
140 'name' => 'skipLineItem',
141 'title' => 'Skip adding line items',
142 'type' => CRM_Utils_Type
::T_BOOLEAN
,
144 'description' => 'Do not add line items by default (if you wish to add your own)',
146 $params['batch_id'] = [
148 'type' => CRM_Utils_Type
::T_INT
,
149 'description' => 'Batch which relevant transactions should be added to',
151 $params['refund_trxn_id'] = [
152 'title' => 'Refund Transaction ID',
153 'type' => CRM_Utils_Type
::T_STRING
,
154 'description' => 'Transaction ID specific to the refund taking place',
156 $params['card_type_id'] = [
157 'title' => 'Card Type ID',
158 'description' => 'Providing Credit Card Type ID',
159 'type' => CRM_Utils_Type
::T_INT
,
160 'pseudoconstant' => [
161 'optionGroupName' => 'accept_creditcard',
167 * Support for schema changes made in 4.5.
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.
173 * @param array $params
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'][] = [
179 'contact_id' => $params['soft_credit_to'],
180 'amount' => $params['total_amount'],
181 'soft_credit_type_id' => CRM_Core_OptionGroup
::getDefaultValue("soft_credit_type"),
184 if (!empty($params['honor_contact_id'])) {
185 $params['soft_credit'][] = [
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_PseudoConstant
::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'in_honor_of')),
194 * Delete a Contribution.
196 * @param array $params
200 * @throws \API_Exception
202 function civicrm_api3_contribution_delete($params) {
204 $contributionID = !empty($params['contribution_id']) ?
$params['contribution_id'] : $params['id'];
205 if (!empty($params['check_permissions']) && !\Civi\Api4\Utils\CoreUtil
::checkAccessDelegated('Contribution', 'delete', ['id' => $contributionID], CRM_Core_Session
::getLoggedInContactID() ?
: 0)) {
206 throw new API_Exception('You do not have permission to delete this contribution');
208 if (CRM_Contribute_BAO_Contribution
::deleteContribution($contributionID)) {
209 return civicrm_api3_create_success([$contributionID => 1]);
211 throw new API_Exception('Could not delete contribution');
215 * Modify metadata for delete action.
217 * Legacy support for contribution_id.
219 * @param array $params
221 function _civicrm_api3_contribution_delete_spec(&$params) {
222 $params['id']['api.aliases'] = ['contribution_id'];
226 * Retrieve a set of contributions.
228 * @param array $params
232 * Array of contributions, if error an array with an error id and error message
234 function civicrm_api3_contribution_get($params) {
236 $mode = CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
;
237 $additionalOptions = _civicrm_api3_contribution_get_support_nonunique_returns($params);
238 $returnProperties = CRM_Contribute_BAO_Query
::defaultReturnProperties($mode);
240 // Get the contributions based on parameters passed in
241 $contributions = _civicrm_api3_get_using_query_object('Contribution', $params, $additionalOptions, NULL, $mode, $returnProperties);
242 if (!empty($contributions)) {
243 $softContributions = CRM_Contribute_BAO_ContributionSoft
::getSoftCreditContributionFields(array_keys($contributions), TRUE);
244 foreach ($contributions as $id => $contribution) {
245 $contributions[$id] = isset($softContributions[$id]) ?
array_merge($contribution, $softContributions[$id]) : $contribution;
246 // format soft credit for backward compatibility
247 _civicrm_api3_format_soft_credit($contributions[$id]);
248 _civicrm_api3_contribution_add_supported_fields($contributions[$id]);
251 return civicrm_api3_create_success($contributions, $params, 'Contribution', 'get');
255 * Fix the return values to reflect cases where the schema has been changed.
257 * At the query object level using uniquenames dismbiguates between tables.
259 * However, adding uniquename can change inputs accepted by the api, so we need
260 * to ensure we are asking for the unique name return fields.
262 * @param array $params
265 * @throws \API_Exception
267 function _civicrm_api3_contribution_get_support_nonunique_returns($params) {
268 $additionalOptions = [];
269 $options = _civicrm_api3_get_options_from_params($params, TRUE);
270 foreach (['check_number', 'address_id', 'cancel_date'] as $changedVariable) {
271 if (isset($options['return']) && !empty($options['return'][$changedVariable])) {
272 $additionalOptions['return']['contribution_' . $changedVariable] = 1;
275 return $additionalOptions;
279 * Support for supported output variables.
281 * @param $contribution
283 function _civicrm_api3_contribution_add_supported_fields(&$contribution) {
284 // These are output fields that are supported in our test contract.
285 // Arguably we should also do the same with 'campaign_id' &
286 // 'source' - which are also fields being rendered with unique names.
287 // That seems more consistent with other api where we output the actual field names.
289 'contribution_check_number' => 'check_number',
290 'contribution_address_id' => 'address_id',
291 'payment_instrument_id' => 'instrument_id',
292 'contribution_cancel_date' => 'cancel_date',
294 foreach ($outputAliases as $returnName => $copyTo) {
295 if (array_key_exists($returnName, $contribution)) {
296 $contribution[$copyTo] = $contribution[$returnName];
303 * Get number of contacts matching the supplied criteria.
305 * @param array $params
309 function civicrm_api3_contribution_getcount($params) {
310 $count = _civicrm_api3_get_using_query_object('Contribution', $params, [], TRUE, CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
);
315 * This function is used to format the soft credit for backward compatibility.
317 * As of v4.4 we support multiple soft credit, so now contribution returns array with 'soft_credit' as key
318 * but we still return first soft credit as a part of contribution array
320 * @param $contribution
322 function _civicrm_api3_format_soft_credit(&$contribution) {
323 if (!empty($contribution['soft_credit'])) {
324 $contribution['soft_credit_to'] = $contribution['soft_credit'][1]['contact_id'];
325 $contribution['soft_credit_id'] = $contribution['soft_credit'][1]['soft_credit_id'];
330 * Adjust Metadata for Get action.
332 * The metadata is used for setting defaults, documentation & validation.
334 * @param array $params
335 * Array of parameters determined by getfields.
337 function _civicrm_api3_contribution_get_spec(&$params) {
338 $params['contribution_test'] = [
340 'type' => CRM_Utils_Type
::T_BOOLEAN
,
341 'title' => 'Get Test Contributions?',
342 'api.aliases' => ['is_test'],
345 $params['financial_type_id']['api.aliases'] = ['contribution_type_id'];
346 $params['payment_instrument_id']['api.aliases'] = ['contribution_payment_instrument', 'payment_instrument'];
347 $params['contact_id'] = $params['contribution_contact_id'] ??
NULL;
348 $params['contact_id']['api.aliases'] = ['contribution_contact_id'];
349 $params['is_template']['api.default'] = 0;
350 unset($params['contribution_contact_id']);
354 * Legacy handling for contribution parameters.
356 * Take the input parameter list as specified in the data model and
357 * convert it into the same format that we use in QF and BAO object.
359 * @param array $params
360 * property name/value pairs to insert in new contact.
361 * @param array $values
362 * The reformatted properties that we can use internally.
366 function _civicrm_api3_contribute_format_params($params, &$values) {
367 //legacy way of formatting from v2 api - v3 way is to define metadata & do it in the api layer
368 _civicrm_api3_filter_fields_for_bao('Contribution', $params, $values);
373 * Send a contribution confirmation (receipt or invoice).
375 * The appropriate online template will be used (the existence of related objects
376 * (e.g. memberships ) will affect this selection
378 * @param array $params
383 function civicrm_api3_contribution_sendconfirmation($params) {
386 'receipt_from_email',
393 'payment_processor_id',
395 $input = array_intersect_key($params, array_flip($allowedParams));
396 CRM_Contribute_BAO_Contribution
::sendMail($input, $ids, $params['id']);
401 * Adjust Metadata for sendconfirmation action.
403 * The metadata is used for setting defaults, documentation & validation.
405 * @param array $params
406 * Array of parameters determined by getfields.
408 function _civicrm_api3_contribution_sendconfirmation_spec(&$params) {
411 'title' => ts('Contribution ID'),
412 'type' => CRM_Utils_Type
::T_INT
,
414 $params['receipt_from_email'] = [
415 'title' => ts('From Email address (string)'),
416 'type' => CRM_Utils_Type
::T_STRING
,
418 $params['receipt_from_name'] = [
419 'title' => ts('From Name (string)'),
420 'type' => CRM_Utils_Type
::T_STRING
,
422 $params['cc_receipt'] = [
423 'title' => ts('CC Email address (string)'),
424 'type' => CRM_Utils_Type
::T_STRING
,
426 $params['bcc_receipt'] = [
427 'title' => ts('BCC Email address (string)'),
428 'type' => CRM_Utils_Type
::T_STRING
,
430 $params['receipt_text'] = [
431 'title' => ts('Message (string)'),
432 'type' => CRM_Utils_Type
::T_STRING
,
434 $params['pay_later_receipt'] = [
435 'title' => ts('Pay Later Message (string)'),
436 'type' => CRM_Utils_Type
::T_STRING
,
438 $params['receipt_update'] = [
439 'title' => ts('Update the Receipt Date'),
440 'type' => CRM_Utils_Type
::T_BOOLEAN
,
441 'api.default' => TRUE,
443 $params['payment_processor_id'] = [
444 'title' => ts('Payment processor Id (avoids mis-guesses)'),
445 'type' => CRM_Utils_Type
::T_INT
,
450 * Complete an existing (pending) transaction.
452 * This will update related entities (participant, membership, pledge etc)
453 * and take any complete actions from the contribution page (e.g. send receipt).
455 * @todo - most of this should live in the BAO layer but as we want it to be an addition
456 * to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
458 * @param array $params
463 * @throws \API_Exception
464 * @throws \CRM_Core_Exception
467 function civicrm_api3_contribution_completetransaction($params) {
468 $contribution = new CRM_Contribute_BAO_Contribution();
469 $contribution->id
= $params['id'];
470 if (!$contribution->find(TRUE)) {
471 throw new API_Exception('A valid contribution ID is required', 'invalid_data');
473 if ($contribution->contribution_status_id
== CRM_Core_PseudoConstant
::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')) {
474 throw new API_Exception(ts('Contribution already completed'), 'contribution_completed');
477 $params['trxn_id'] = $params['trxn_id'] ??
$contribution->trxn_id
;
479 $passThroughParams = [
481 'payment_processor_id',
484 $input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));
487 if (!$contribution->loadRelatedObjects(['payment_processor_id' => $input['payment_processor_id'] ??
NULL], $ids, TRUE)) {
488 throw new API_Exception('failed to load related objects');
491 return _ipn_process_transaction($params, $contribution, $input, $ids);
495 * Provide function metadata.
497 * @param array $params
499 function _civicrm_api3_contribution_completetransaction_spec(&$params) {
501 'title' => 'Contribution ID',
502 'type' => CRM_Utils_Type
::T_INT
,
503 'api.required' => TRUE,
505 $params['trxn_id'] = [
506 'title' => 'Transaction ID',
507 'type' => CRM_Utils_Type
::T_STRING
,
509 $params['is_email_receipt'] = [
510 'title' => 'Send email Receipt?',
511 'type' => CRM_Utils_Type
::T_BOOLEAN
,
513 $params['receipt_from_email'] = [
514 'title' => 'Email to send receipt from.',
515 'description' => 'If not provided this will default to being based on domain mail or contribution page',
516 'type' => CRM_Utils_Type
::T_EMAIL
,
518 $params['receipt_from_name'] = [
519 'title' => 'Name to send receipt from',
520 'description' => '. If not provided this will default to domain mail or contribution page',
521 'type' => CRM_Utils_Type
::T_STRING
,
523 $params['payment_processor_id'] = [
524 'title' => 'Payment processor ID',
525 'description' => 'Providing this is strongly recommended, as not possible to calculate it accurately always',
526 'type' => CRM_Utils_Type
::T_INT
,
528 $params['fee_amount'] = [
529 'title' => 'Fee charged on transaction',
530 'description' => 'If a fee has been charged then the amount',
531 'type' => CRM_Utils_Type
::T_FLOAT
,
533 $params['trxn_date'] = [
534 'title' => 'Transaction Date',
535 'description' => 'Date this transaction occurred',
536 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
538 $params['card_type_id'] = [
539 'title' => 'Card Type ID',
540 'description' => 'Providing Credit Card Type ID',
541 'type' => CRM_Utils_Type
::T_INT
,
542 'pseudoconstant' => [
543 'optionGroupName' => 'accept_creditcard',
546 // At some point we will deprecate this api in favour of calling payment create which will in turn call this
547 // api if appropriate to transition related entities and send receipts - ie. financial responsibility should
548 // not exist in completetransaction. For now we just need to allow payment.create to force a bypass on the
549 // things it does itself.
550 $params['is_post_payment_create'] = [
551 'title' => 'Is this being called from payment create?',
552 'type' => CRM_Utils_Type
::T_BOOLEAN
,
553 'description' => 'The \'correct\' flow is to call payment.create for the financial side & for that to call completecontribution for the entity & receipt management. However, we need to still support completetransaction directly for legacy reasons',
558 * Complete an existing (pending) transaction.
560 * This will update related entities (participant, membership, pledge etc)
561 * and take any complete actions from the contribution page (e.g. send receipt).
563 * @todo - most of this should live in the BAO layer but as we want it to be an addition
564 * to 4.3 which is already stable we should add it to the api layer & re-factor into the BAO layer later
566 * @param array $params
571 * @throws API_Exception
573 function civicrm_api3_contribution_repeattransaction($params) {
574 civicrm_api3_verify_one_mandatory($params, NULL, ['contribution_recur_id', 'original_contribution_id']);
575 if (empty($params['original_contribution_id'])) {
576 // CRM-19873 call with test mode.
577 $params['original_contribution_id'] = civicrm_api3('contribution', 'getvalue', [
579 'contribution_status_id' => ['IN' => ['Completed']],
580 'contribution_recur_id' => $params['contribution_recur_id'],
581 'contribution_test' => CRM_Core_DAO
::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $params['contribution_recur_id'], 'is_test'),
582 'options' => ['limit' => 1, 'sort' => 'id DESC'],
585 $contribution = new CRM_Contribute_BAO_Contribution();
586 $contribution->id
= $params['original_contribution_id'];
587 if (!$contribution->find(TRUE)) {
588 throw new API_Exception(
589 'A valid original contribution ID is required', 'invalid_data');
591 // We don't support repeattransaction without a related recurring contribution.
592 if (empty($contribution->contribution_recur_id
)) {
593 throw new API_Exception(
594 'Repeattransaction API can only be used in the context of contributions that have a contribution_recur_id.',
599 $params['payment_processor_id'] = civicrm_api3('contributionRecur', 'getvalue', [
600 'return' => 'payment_processor_id',
601 'id' => $contribution->contribution_recur_id
,
604 $passThroughParams = [
610 'contribution_status_id',
612 'payment_processor_id',
614 $input = array_intersect_key($params, array_fill_keys($passThroughParams, NULL));
617 if (!$contribution->loadRelatedObjects(['payment_processor_id' => $input['payment_processor_id']], $ids, TRUE)) {
618 throw new API_Exception('failed to load related objects');
620 unset($contribution->id
, $contribution->receive_date
, $contribution->invoice_id
);
621 $contribution->receive_date
= $params['receive_date'];
623 return _ipn_process_transaction($params, $contribution, $input, $ids);
627 * Calls IPN complete transaction for completing or repeating a transaction.
629 * The IPN function is overloaded with two purposes - this is simply a wrapper for that
630 * when separating them in the api layer.
632 * @param array $params
633 * @param CRM_Contribute_BAO_Contribution $contribution
634 * @param array $input
639 * @throws \CRM_Core_Exception
640 * @throws \CiviCRM_API3_Exception
642 function _ipn_process_transaction($params, $contribution, $input, $ids) {
643 $objects = $contribution->_relatedObjects
;
644 $objects['contribution'] = &$contribution;
645 $input['component'] = $contribution->_component
;
646 $input['is_test'] = $contribution->is_test
;
647 $input['amount'] = empty($input['total_amount']) ?
$contribution->total_amount
: $input['total_amount'];
649 if (isset($params['is_email_receipt'])) {
650 $input['is_email_receipt'] = $params['is_email_receipt'];
652 if (!empty($params['trxn_date'])) {
653 $input['trxn_date'] = $params['trxn_date'];
655 if (!empty($params['receive_date'])) {
656 $input['receive_date'] = $params['receive_date'];
658 if (empty($contribution->contribution_page_id
)) {
659 static $domainFromName;
660 static $domainFromEmail;
661 if (empty($domainFromEmail) && (empty($params['receipt_from_name']) ||
empty($params['receipt_from_email']))) {
662 [$domainFromName, $domainFromEmail] = CRM_Core_BAO_Domain
::getNameAndEmail(TRUE);
664 $input['receipt_from_name'] = CRM_Utils_Array
::value('receipt_from_name', $params, $domainFromName);
665 $input['receipt_from_email'] = CRM_Utils_Array
::value('receipt_from_email', $params, $domainFromEmail);
667 $input['card_type_id'] = $params['card_type_id'] ??
NULL;
668 $input['pan_truncation'] = $params['pan_truncation'] ??
NULL;
669 if (!empty($params['payment_instrument_id'])) {
670 $input['payment_instrument_id'] = $params['payment_instrument_id'];
672 return CRM_Contribute_BAO_Contribution
::completeOrder($input,
673 !empty($objects['contributionRecur']) ?
$objects['contributionRecur']->id
: NULL,
674 $objects['contribution']->id ??
NULL,
675 $params['is_post_payment_create'] ??
NULL);
679 * Provide function metadata.
681 * @param array $params
683 function _civicrm_api3_contribution_repeattransaction_spec(&$params) {
684 $params['original_contribution_id'] = [
685 'title' => 'Original Contribution ID',
686 'description' => 'Contribution ID to copy (will be calculated from recurring contribution if not provided)',
687 'type' => CRM_Utils_Type
::T_INT
,
689 $params['contribution_recur_id'] = [
690 'title' => 'Recurring contribution ID',
691 'type' => CRM_Utils_Type
::T_INT
,
693 $params['trxn_id'] = [
694 'title' => 'Transaction ID',
695 'type' => CRM_Utils_Type
::T_STRING
,
697 $params['is_email_receipt'] = [
698 'title' => 'Send email Receipt?',
699 'type' => CRM_Utils_Type
::T_BOOLEAN
,
701 $params['contribution_status_id'] = [
702 'title' => 'Contribution Status ID',
703 'name' => 'contribution_status_id',
704 'type' => CRM_Utils_Type
::T_INT
,
705 'pseudoconstant' => [
706 'optionGroupName' => 'contribution_status',
708 'api.required' => TRUE,
709 'api.default' => 'Pending',
711 $params['receive_date'] = [
712 'title' => 'Contribution Receive Date',
713 'name' => 'receive_date',
714 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
715 'api.default' => 'now',
717 $params['trxn_id'] = [
718 'title' => 'Transaction ID',
720 'type' => CRM_Utils_Type
::T_STRING
,
722 $params['campaign_id'] = [
723 'title' => 'Campaign ID',
724 'name' => 'campaign_id',
725 'type' => CRM_Utils_Type
::T_INT
,
726 'pseudoconstant' => [
727 'table' => 'civicrm_campaign',
729 'labelColumn' => 'title',
732 $params['financial_type_id'] = [
733 'title' => 'Financial ID (ignored if more than one line item)',
734 'name' => 'financial_type_id',
735 'type' => CRM_Utils_Type
::T_INT
,
736 'pseudoconstant' => [
737 'table' => 'civicrm_financial_type',
739 'labelColumn' => 'name',
742 $params['payment_processor_id'] = [
743 'description' => ts('Payment processor ID, will be loaded from contribution_recur if not provided'),
744 'title' => 'Payment processor ID',
745 'name' => 'payment_processor_id',
746 'type' => CRM_Utils_Type
::T_INT
,
751 * Declare deprecated functions.
754 * Array of deprecated actions
756 function _civicrm_api3_contribution_deprecation() {
757 return ['transact' => 'Contribute.transact is ureliable & unsupported - see https://docs.civicrm.org/dev/en/latest/financial/OrderAPI/ for how to move on'];