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' => '',
95 'contribution_type_id' => '1',
100 return $expectedResult;
104 * This example has been generated from the API test suite.
105 * The test that created it is called "testCreateContributionWithSoftCredit"
106 * and can be found at:
107 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
109 * You can see the outcome of the API tests at
110 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
112 * To Learn about the API read
113 * https://docs.civicrm.org/dev/en/latest/api/
115 * Browse the API on your own site with the API Explorer. It is in the main
116 * CiviCRM menu, under: Support > Development > API Explorer.
118 * Read more about testing here
119 * https://docs.civicrm.org/dev/en/latest/testing/
121 * API Standards documentation:
122 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/