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,
21 'soft_credit' => array(
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() {
57 $expectedResult = array(
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',
78 'cancel_reason' => '',
80 'thankyou_date' => '',
83 'contribution_recur_id' => '',
86 'contribution_status_id' => '1',
90 'creditnote_id' => '',
92 'revenue_recognition_date' => '',
93 'contribution_type_id' => '1',
98 return $expectedResult;
102 * This example has been generated from the API test suite.
103 * The test that created it is called "testCreateContributionWithSoftCredit"
104 * and can be found at:
105 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
107 * You can see the outcome of the API tests at
108 * https://test.civicrm.org/job/CiviCRM-master-git/
110 * To Learn about the API read
111 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
113 * Browse the api on your own site with the api explorer
114 * http://MYSITE.ORG/path/to/civicrm/api
116 * Read more about testing here
117 * http://wiki.civicrm.org/confluence/display/CRM/Testing
119 * API Standards documentation:
120 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards