Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the ContributionPage.create API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function contribution_page_create_example() { | |
9 | $params = array( | |
10 | 'title' => 'Test Contribution Page', | |
11 | 'financial_type_id' => 1, | |
12 | 'currency' => 'NZD', | |
13 | 'goal_amount' => 34567, | |
14 | 'is_pay_later' => 1, | |
15 | 'is_monetary' => TRUE, | |
1d8ee3d6 | 16 | 'is_email_receipt' => TRUE, |
17 | 'receipt_from_email' => 'yourconscience@donate.com', | |
18 | 'receipt_from_name' => 'Ego Freud', | |
50fb255d | 19 | ); |
6a488035 | 20 | |
50fb255d | 21 | try{ |
a828d7b8 | 22 | $result = civicrm_api3('ContributionPage', 'create', $params); |
50fb255d | 23 | } |
24 | catch (CiviCRM_API3_Exception $e) { | |
25 | // Handle error here. | |
26 | $errorMessage = $e->getMessage(); | |
27 | $errorCode = $e->getErrorCode(); | |
28 | $errorData = $e->getExtraParams(); | |
29 | return array( | |
5be22f39 | 30 | 'is_error' => 1, |
31 | 'error_message' => $errorMessage, | |
50fb255d | 32 | 'error_code' => $errorCode, |
33 | 'error_data' => $errorData, | |
34 | ); | |
35 | } | |
36 | ||
37 | return $result; | |
6a488035 TO |
38 | } |
39 | ||
fb32de45 | 40 | /** |
50fb255d | 41 | * Function returns array of result expected from previous function. |
42 | * | |
43 | * @return array | |
44 | * API result array | |
6a488035 | 45 | */ |
50fb255d | 46 | function contribution_page_create_expectedresult() { |
6a488035 | 47 | |
edb0d67a | 48 | $expectedResult = array( |
50fb255d | 49 | 'is_error' => 0, |
50 | 'version' => 3, | |
51 | 'count' => 1, | |
52 | 'id' => 1, | |
53 | 'values' => array( | |
edb0d67a | 54 | '1' => array( |
50fb255d | 55 | 'id' => '1', |
56 | 'title' => 'Test Contribution Page', | |
57 | 'intro_text' => '', | |
58 | 'financial_type_id' => '1', | |
59 | 'payment_processor' => '', | |
60 | 'is_credit_card_only' => '', | |
61 | 'is_monetary' => '1', | |
62 | 'is_recur' => '', | |
63 | 'is_confirm_enabled' => '', | |
64 | 'recur_frequency_unit' => '', | |
65 | 'is_recur_interval' => '', | |
66 | 'is_recur_installments' => '', | |
5be22f39 | 67 | 'adjust_recur_start_date' => '', |
50fb255d | 68 | 'is_pay_later' => '1', |
69 | 'pay_later_text' => '', | |
70 | 'pay_later_receipt' => '', | |
71 | 'is_partial_payment' => '', | |
72 | 'initial_amount_label' => '', | |
73 | 'initial_amount_help_text' => '', | |
74 | 'min_initial_amount' => '', | |
75 | 'is_allow_other_amount' => '', | |
76 | 'default_amount_id' => '', | |
77 | 'min_amount' => '', | |
78 | 'max_amount' => '', | |
79 | 'goal_amount' => '34567', | |
80 | 'thankyou_title' => '', | |
81 | 'thankyou_text' => '', | |
82 | 'thankyou_footer' => '', | |
1d8ee3d6 | 83 | 'is_email_receipt' => '1', |
84 | 'receipt_from_name' => 'Ego Freud', | |
85 | 'receipt_from_email' => 'yourconscience@donate.com', | |
50fb255d | 86 | 'cc_receipt' => '', |
87 | 'bcc_receipt' => '', | |
88 | 'receipt_text' => '', | |
89 | 'is_active' => '1', | |
90 | 'footer_text' => '', | |
91 | 'amount_block_is_active' => '', | |
92 | 'start_date' => '', | |
93 | 'end_date' => '', | |
94 | 'created_id' => '', | |
95 | 'created_date' => '', | |
96 | 'currency' => 'NZD', | |
97 | 'campaign_id' => '', | |
98 | 'is_share' => '', | |
99 | 'is_billing_required' => '', | |
100 | ), | |
6a488035 | 101 | ), |
50fb255d | 102 | ); |
6a488035 | 103 | |
fb32de45 | 104 | return $expectedResult; |
6a488035 TO |
105 | } |
106 | ||
a828d7b8 | 107 | /* |
50fb255d | 108 | * This example has been generated from the API test suite. |
a828d7b8 CW |
109 | * The test that created it is called "testCreateContributionPage" |
110 | * and can be found at: | |
69d79249 | 111 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php |
6a488035 TO |
112 | * |
113 | * You can see the outcome of the API tests at | |
69d79249 | 114 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
115 | * |
116 | * To Learn about the API read | |
69d79249 | 117 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 118 | * |
69d79249 | 119 | * Browse the api on your own site with the api explorer |
41d4d31f | 120 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
121 | * |
122 | * Read more about testing here | |
123 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
124 | * | |
125 | * API Standards documentation: | |
126 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 127 | */ |