3 * Test Generated example demonstrating the Contribution.create API.
5 * Demonstrates creating contribution with SoftCredit.
10 function contribution_create_example() {
13 'receive_date' => '20120511',
14 'total_amount' => '100',
15 'financial_type_id' => 1,
16 'non_deductible_amount' => '10',
20 'contribution_status_id' => 1,
25 'soft_credit_type_id' => 3,
31 $result = civicrm_api3('Contribution', 'create', $params);
33 catch (CiviCRM_API3_Exception
$e) {
35 $errorMessage = $e->getMessage();
36 $errorCode = $e->getErrorCode();
37 $errorData = $e->getExtraParams();
40 'error_message' => $errorMessage,
41 'error_code' => $errorCode,
42 'error_data' => $errorData,
50 * Function returns array of result expected from previous function.
55 function contribution_create_expectedresult() {
66 'financial_type_id' => '1',
67 'contribution_page_id' => '',
68 'payment_instrument_id' => '4',
69 'receive_date' => '20120511000000',
70 'non_deductible_amount' => '10',
71 'total_amount' => '100',
76 'invoice_number' => '',
79 'cancel_reason' => '',
81 'thankyou_date' => '',
84 'contribution_recur_id' => '',
87 'contribution_status_id' => '1',
91 'creditnote_id' => '',
93 'revenue_recognition_date' => '',
94 'contribution_type_id' => '1',
99 return $expectedResult;
103 * This example has been generated from the API test suite.
104 * The test that created it is called "testCreateContributionWithSoftCredit"
105 * and can be found at:
106 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
108 * You can see the outcome of the API tests at
109 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
111 * To Learn about the API read
112 * https://docs.civicrm.org/dev/en/latest/api/
114 * Browse the API on your own site with the API Explorer. It is in the main
115 * CiviCRM menu, under: Support > Development > API Explorer.
117 * Read more about testing here
118 * https://docs.civicrm.org/dev/en/latest/testing/
120 * API Standards documentation:
121 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/