3 * Test Generated example of using contribution create API
4 * Demonstrates creating contribution with SoftCredit *
6 function contribution_create_example(){
9 'receive_date' => '20120511',
10 'total_amount' => '100',
11 'financial_type_id' => 1,
12 'non_deductible_amount' => '10',
16 'contribution_status_id' => 1,
17 'soft_credit_to' => 2,
21 $result = civicrm_api3('contribution', 'create', $params);
23 catch (CiviCRM_API3_Exception
$e) {
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
35 * Function returns array of result expected from previous function
37 function contribution_create_expectedresult(){
39 $expectedResult = array(
48 'financial_type_id' => '1',
49 'contribution_page_id' => '',
50 'payment_instrument_id' => '',
51 'receive_date' => '20120511000000',
52 'non_deductible_amount' => '10',
53 'total_amount' => '100',
60 'cancel_reason' => '',
62 'thankyou_date' => '',
65 'contribution_recur_id' => '',
66 'honor_contact_id' => '',
69 'contribution_status_id' => '1',
70 'honor_type_id' => '',
74 'contribution_type_id' => '1',
79 return $expectedResult;
84 * This example has been generated from the API test suite. The test that created it is called
86 * testCreateContributionWithSoftCredt and can be found in
87 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
89 * You can see the outcome of the API tests at
90 * http://tests.dev.civicrm.org/trunk/results-api_v3
92 * To Learn about the API read
93 * http://book.civicrm.org/developer/current/techniques/api/
95 * and review the wiki at
96 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
98 * Read more about testing here
99 * http://wiki.civicrm.org/confluence/display/CRM/Testing
101 * API Standards documentation:
102 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards