3 * Test Generated example of using contribution create API
4 * Demonstrates creating contribution with Note Entity *
6 function contribution_create_example(){
9 'receive_date' => '2012-01-01',
10 'total_amount' => '100',
11 'financial_type_id' => 1,
12 'payment_instrument_id' => 1,
13 'non_deductible_amount' => '10',
17 'invoice_id' => 67890,
19 'contribution_status_id' => 1,
20 'note' => 'my contribution note',
24 $result = civicrm_api3('contribution', 'create', $params);
26 catch (CiviCRM_API3_Exception
$e) {
28 $errorMessage = $e->getMessage();
29 $errorCode = $e->getErrorCode();
30 $errorData = $e->getExtraParams();
31 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
38 * Function returns array of result expected from previous function
40 function contribution_create_expectedresult(){
42 $expectedResult = array(
51 'financial_type_id' => '1',
52 'contribution_page_id' => '',
53 'payment_instrument_id' => '1',
54 'receive_date' => '20120101000000',
55 'non_deductible_amount' => '10',
56 'total_amount' => '100',
60 'invoice_id' => '67890',
63 'cancel_reason' => '',
65 'thankyou_date' => '',
68 'contribution_recur_id' => '',
69 'honor_contact_id' => '',
72 'contribution_status_id' => '1',
73 'honor_type_id' => '',
77 'contribution_type_id' => '1',
82 return $expectedResult;
87 * This example has been generated from the API test suite. The test that created it is called
89 * testCreateContributionWithNote and can be found in
90 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
92 * You can see the outcome of the API tests at
93 * http://tests.dev.civicrm.org/trunk/results-api_v3
95 * To Learn about the API read
96 * http://book.civicrm.org/developer/current/techniques/api/
98 * and review the wiki at
99 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
101 * Read more about testing here
102 * http://wiki.civicrm.org/confluence/display/CRM/Testing
104 * API Standards documentation:
105 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards