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' => array(
21 'soft_credit_type_id' => 3,
27 $result = civicrm_api3('contribution', 'create', $params);
29 catch (CiviCRM_API3_Exception
$e) {
31 $errorMessage = $e->getMessage();
32 $errorCode = $e->getErrorCode();
33 $errorData = $e->getExtraParams();
34 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
41 * Function returns array of result expected from previous function
43 function contribution_create_expectedresult(){
45 $expectedResult = array(
54 'financial_type_id' => '1',
55 'contribution_page_id' => '',
56 'payment_instrument_id' => '4',
57 'receive_date' => '20120511000000',
58 'non_deductible_amount' => '10',
59 'total_amount' => '100',
66 'cancel_reason' => '',
68 'thankyou_date' => '',
71 'contribution_recur_id' => '',
74 'contribution_status_id' => '1',
78 'creditnote_id' => '',
80 'contribution_type_id' => '1',
85 return $expectedResult;
90 * This example has been generated from the API test suite. The test that created it is called
92 * testCreateContributionWithSoftCredt and can be found in
93 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
95 * You can see the outcome of the API tests at
96 * https://test.civicrm.org/job/CiviCRM-master-git/
98 * To Learn about the API read
99 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
101 * Browse the api on your own site with the api explorer
102 * http://MYSITE.ORG/path/to/civicrm/api/explorer
104 * Read more about testing here
105 * http://wiki.civicrm.org/confluence/display/CRM/Testing
107 * API Standards documentation:
108 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards