3 * Test Generated example of using contribution create API.
9 function contribution_create_example() {
12 'receive_date' => '20120511',
13 'total_amount' => '100',
14 'financial_type_id' => 1,
15 'contribution_page_id' => 1,
17 'invoice_id' => 67890,
19 'contribution_status_id' => 2,
23 $result = civicrm_api3('contribution', 'create', $params);
25 catch (CiviCRM_API3_Exception
$e) {
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
41 * Function returns array of result expected from previous function.
46 function contribution_create_expectedresult() {
48 $expectedResult = array(
57 'financial_type_id' => '1',
58 'contribution_page_id' => '1',
59 'payment_instrument_id' => '4',
60 'receive_date' => '20120511000000',
61 'non_deductible_amount' => '',
62 'total_amount' => '100',
64 'net_amount' => '100',
66 'invoice_id' => '67890',
69 'cancel_reason' => '',
71 'thankyou_date' => '',
74 'contribution_recur_id' => '',
77 'contribution_status_id' => '2',
81 'creditnote_id' => '',
83 'contribution_type_id' => '1',
88 return $expectedResult;
92 * This example has been generated from the API test suite.
93 * The test that created it is called
94 * testCreateContributionPendingOnline
96 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
98 * You can see the outcome of the API tests at
99 * https://test.civicrm.org/job/CiviCRM-master-git/
101 * To Learn about the API read
102 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
104 * Browse the api on your own site with the api explorer
105 * http://MYSITE.ORG/path/to/civicrm/api
107 * Read more about testing here
108 * http://wiki.civicrm.org/confluence/display/CRM/Testing
110 * API Standards documentation:
111 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards