4a19762036ba1bc554ec2c46587aa2fe201b9b6c
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();
36 'error' => $errorMessage,
37 'error_code' => $errorCode,
38 'error_data' => $errorData,
46 * Function returns array of result expected from previous function.
51 function contribution_create_expectedresult() {
53 $expectedResult = array(
62 'financial_type_id' => '1',
63 'contribution_page_id' => '',
64 'payment_instrument_id' => '1',
65 'receive_date' => '20120101000000',
66 'non_deductible_amount' => '10',
67 'total_amount' => '100',
71 'invoice_id' => '67890',
74 'cancel_reason' => '',
76 'thankyou_date' => '',
79 'contribution_recur_id' => '',
82 'contribution_status_id' => '1',
86 'creditnote_id' => '',
88 'contribution_type_id' => '1',
93 return $expectedResult;
97 * This example has been generated from the API test suite.
98 * The test that created it is called "testCreateContributionWithNote"
99 * and can be found at:
100 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
102 * You can see the outcome of the API tests at
103 * https://test.civicrm.org/job/CiviCRM-master-git/
105 * To Learn about the API read
106 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
108 * Browse the api on your own site with the api explorer
109 * http://MYSITE.ORG/path/to/civicrm/api
111 * Read more about testing here
112 * http://wiki.civicrm.org/confluence/display/CRM/Testing
114 * API Standards documentation:
115 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards