3 * Test Generated example demonstrating the Contribution.create API.
5 * Demonstrates creating contribution with Note Entity.
10 function contribution_create_example() {
13 'receive_date' => '2012-01-01',
14 'total_amount' => '100',
15 'financial_type_id' => 1,
16 'payment_instrument_id' => 1,
17 'non_deductible_amount' => '10',
21 'invoice_id' => 67890,
23 'contribution_status_id' => 1,
24 'note' => 'my contribution note',
28 $result = civicrm_api3('Contribution', 'create', $params);
30 catch (CiviCRM_API3_Exception
$e) {
32 $errorMessage = $e->getMessage();
33 $errorCode = $e->getErrorCode();
34 $errorData = $e->getExtraParams();
37 'error_message' => $errorMessage,
38 'error_code' => $errorCode,
39 'error_data' => $errorData,
47 * Function returns array of result expected from previous function.
52 function contribution_create_expectedresult() {
63 'financial_type_id' => '1',
64 'contribution_page_id' => '',
65 'payment_instrument_id' => '1',
66 'receive_date' => '20120101000000',
67 'non_deductible_amount' => '10',
68 'total_amount' => '100',
72 'invoice_id' => '67890',
73 'invoice_number' => '',
76 'cancel_reason' => '',
78 'thankyou_date' => '',
81 'contribution_recur_id' => '',
84 'contribution_status_id' => '1',
88 'creditnote_id' => '',
90 'revenue_recognition_date' => '',
91 'contribution_type_id' => '1',
96 return $expectedResult;
100 * This example has been generated from the API test suite.
101 * The test that created it is called "testCreateContributionWithNote"
102 * and can be found at:
103 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
105 * You can see the outcome of the API tests at
106 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
108 * To Learn about the API read
109 * https://docs.civicrm.org/dev/en/latest/api/
111 * Browse the API on your own site with the API Explorer. It is in the main
112 * CiviCRM menu, under: Support > Development > API Explorer.
114 * Read more about testing here
115 * https://docs.civicrm.org/dev/en/latest/testing/
117 * API Standards documentation:
118 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/