3 * Test Generated example demonstrating the Contribution.create API.
8 function contribution_create_example() {
11 'receive_date' => '20120511',
12 'total_amount' => '100',
13 'financial_type_id' => 1,
14 'contribution_page_id' => 1,
16 'invoice_id' => 67890,
18 'contribution_status_id' => 2,
22 $result = civicrm_api3('Contribution', 'create', $params);
24 catch (CiviCRM_API3_Exception
$e) {
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
30 'error' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
40 * Function returns array of result expected from previous function.
45 function contribution_create_expectedresult() {
47 $expectedResult = array(
56 'financial_type_id' => '1',
57 'contribution_page_id' => '1',
58 'payment_instrument_id' => '4',
59 'receive_date' => '20120511000000',
60 'non_deductible_amount' => '',
61 'total_amount' => '100',
63 'net_amount' => '100',
65 'invoice_id' => '67890',
68 'cancel_reason' => '',
70 'thankyou_date' => '',
73 'contribution_recur_id' => '',
76 'contribution_status_id' => '2',
80 'creditnote_id' => '',
82 'contribution_type_id' => '1',
83 'revenue_recognition_date' => '',
88 return $expectedResult;
92 * This example has been generated from the API test suite.
93 * The test that created it is called "testCreateContributionPendingOnline"
94 * and can be found at:
95 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
97 * You can see the outcome of the API tests at
98 * https://test.civicrm.org/job/CiviCRM-master-git/
100 * To Learn about the API read
101 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
103 * Browse the api on your own site with the api explorer
104 * http://MYSITE.ORG/path/to/civicrm/api
106 * Read more about testing here
107 * http://wiki.civicrm.org/confluence/display/CRM/Testing
109 * API Standards documentation:
110 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards