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