4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contribution create API.
11 * Demonstrates creating contribution with Soft Credit defaults for amount and type
16 function contribution_create_example() {
19 'receive_date' => '20120511',
20 'total_amount' => '100',
21 'financial_type_id' => 1,
22 'non_deductible_amount' => '10',
26 'contribution_status_id' => 1,
27 'soft_credit_to' => 23,
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();
39 'error' => $errorMessage,
40 'error_code' => $errorCode,
41 'error_data' => $errorData,
49 * Function returns array of result expected from previous function.
54 function contribution_create_expectedresult() {
56 $expectedResult = array(
65 'financial_type_id' => '1',
66 'contribution_page_id' => '',
67 'payment_instrument_id' => '4',
68 'receive_date' => '20120511000000',
69 'non_deductible_amount' => '10',
70 'total_amount' => '100',
77 'cancel_reason' => '',
79 'thankyou_date' => '',
82 'contribution_recur_id' => '',
85 'contribution_status_id' => '1',
89 'creditnote_id' => '',
91 'contribution_type_id' => '1',
96 return $expectedResult;
100 * This example has been generated from the API test suite.
101 * The test that created it is called
102 * testCreateContributionWithSoftCreditDefaults
103 * and can be found in
104 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
106 * You can see the outcome of the API tests at
107 * https://test.civicrm.org/job/CiviCRM-master-git/
109 * To Learn about the API read
110 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
112 * Browse the api on your own site with the api explorer
113 * http://MYSITE.ORG/path/to/civicrm/api/explorer
115 * Read more about testing here
116 * http://wiki.civicrm.org/confluence/display/CRM/Testing
118 * API Standards documentation:
119 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards