Merge pull request #1048 from eileenmcnaughton/master
[civicrm-core.git] / api / v3 / examples / Contribution / ContributionCreateWithSoftCredit.php
1 <?php
2
3 /*
4 Demonstrates creating contribution with SoftCredit
5 */
6 function contribution_create_example(){
7 $params = array(
8 'contact_id' => 1,
9 'receive_date' => '20120511',
10 'total_amount' => '100',
11 'financial_type_id' => 1,
12 'non_deductible_amount' => '10',
13 'fee_amount' => '5',
14 'net_amount' => '95',
15 'source' => 'SSF',
16 'contribution_status_id' => 1,
17 'version' => 3,
18 'soft_credit_to' => 2,
19 );
20
21 $result = civicrm_api( 'contribution','create',$params );
22
23 return $result;
24 }
25
26 /*
27 * Function returns array of result expected from previous function
28 */
29 function contribution_create_expectedresult(){
30
31 $expectedResult = array(
32 'is_error' => 0,
33 'version' => 3,
34 'count' => 1,
35 'id' => 1,
36 'values' => array(
37 '1' => array(
38 'id' => '1',
39 'contact_id' => '1',
40 'financial_type_id' => '1',
41 'contribution_page_id' => '',
42 'payment_instrument_id' => '',
43 'receive_date' => '20120511000000',
44 'non_deductible_amount' => '10',
45 'total_amount' => '100',
46 'fee_amount' => '5',
47 'net_amount' => '95',
48 'trxn_id' => '',
49 'invoice_id' => '',
50 'currency' => 'USD',
51 'cancel_date' => '',
52 'cancel_reason' => '',
53 'receipt_date' => '',
54 'thankyou_date' => '',
55 'source' => 'SSF',
56 'amount_level' => '',
57 'contribution_recur_id' => '',
58 'honor_contact_id' => '',
59 'is_test' => '',
60 'is_pay_later' => '',
61 'contribution_status_id' => '1',
62 'honor_type_id' => '',
63 'address_id' => '',
64 'check_number' => '',
65 'campaign_id' => '',
66 'contribution_type_id' => '1',
67 ),
68 ),
69 );
70
71 return $expectedResult ;
72 }
73
74
75 /*
76 * This example has been generated from the API test suite. The test that created it is called
77 *
78 * testCreateContributionWithSoftCredt and can be found in
79 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionTest.php
80 *
81 * You can see the outcome of the API tests at
82 * http://tests.dev.civicrm.org/trunk/results-api_v3
83 *
84 * To Learn about the API read
85 * http://book.civicrm.org/developer/current/techniques/api/
86 *
87 * and review the wiki at
88 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
89 *
90 * Read more about testing here
91 * http://wiki.civicrm.org/confluence/display/CRM/Testing
92 *
93 * API Standards documentation:
94 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
95 */