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