3 * Test Generated example demonstrating the Contribution.create API.
5 * Demonstrates creating contribution with Soft Credit defaults for amount and type.
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,
21 'soft_credit_to' => 27,
25 $result = civicrm_api3('Contribution', 'create', $params);
27 catch (CiviCRM_API3_Exception
$e) {
29 $errorMessage = $e->getMessage();
30 $errorCode = $e->getErrorCode();
31 $errorData = $e->getExtraParams();
34 'error_message' => $errorMessage,
35 'error_code' => $errorCode,
36 'error_data' => $errorData,
44 * Function returns array of result expected from previous function.
49 function contribution_create_expectedresult() {
51 $expectedResult = array(
60 'financial_type_id' => '1',
61 'contribution_page_id' => '',
62 'payment_instrument_id' => '4',
63 'receive_date' => '20120511000000',
64 'non_deductible_amount' => '10',
65 'total_amount' => '100',
72 'cancel_reason' => '',
74 'thankyou_date' => '',
77 'contribution_recur_id' => '',
80 'contribution_status_id' => '1',
84 'creditnote_id' => '',
86 'revenue_recognition_date' => '',
87 'contribution_type_id' => '1',
92 return $expectedResult;
96 * This example has been generated from the API test suite.
97 * The test that created it is called "testCreateContributionWithSoftCreditDefaults"
98 * and can be found at:
99 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
101 * You can see the outcome of the API tests at
102 * https://test.civicrm.org/job/CiviCRM-master-git/
104 * To Learn about the API read
105 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
107 * Browse the api on your own site with the api explorer
108 * http://MYSITE.ORG/path/to/civicrm/api
110 * Read more about testing here
111 * http://wiki.civicrm.org/confluence/display/CRM/Testing
113 * API Standards documentation:
114 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards