3 * Test Generated example of using contribution create API
6 function contribution_create_example(){
9 'receive_date' => '20120511',
10 'total_amount' => '100',
11 'financial_type_id' => 1,
12 'contribution_page_id' => 1,
14 'invoice_id' => 67890,
16 'contribution_status_id' => 2,
20 $result = civicrm_api3('contribution', 'create', $params);
22 catch (CiviCRM_API3_Exception
$e) {
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
34 * Function returns array of result expected from previous function
36 function contribution_create_expectedresult(){
38 $expectedResult = array(
47 'financial_type_id' => '1',
48 'contribution_page_id' => '1',
49 'payment_instrument_id' => '4',
50 'receive_date' => '20120511000000',
51 'non_deductible_amount' => '',
52 'total_amount' => '100',
56 'invoice_id' => '67890',
59 'cancel_reason' => '',
61 'thankyou_date' => '',
64 'contribution_recur_id' => '',
65 'honor_contact_id' => '',
68 'contribution_status_id' => '2',
69 'honor_type_id' => '',
73 'contribution_type_id' => '1',
78 return $expectedResult;
83 * This example has been generated from the API test suite. The test that created it is called
85 * testCreateContributionPendingOnline and can be found in
86 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
88 * You can see the outcome of the API tests at
89 * http://tests.dev.civicrm.org/trunk/results-api_v3
91 * To Learn about the API read
92 * http://book.civicrm.org/developer/current/techniques/api/
94 * and review the wiki at
95 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
97 * Read more about testing here
98 * http://wiki.civicrm.org/confluence/display/CRM/Testing
100 * API Standards documentation:
101 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards