89bf81b4 |
1 | <?php |
50fb255d |
2 | /** |
a828d7b8 |
3 | * Test Generated example demonstrating the ContributionPage.submit API. |
50fb255d |
4 | * |
5 | * submit contribution page |
6 | * |
7 | * @return array |
8 | * API result array |
9 | */ |
10 | function contribution_page_submit_example() { |
11 | $params = array( |
12 | 'price_3' => '', |
13 | 'id' => 1, |
14 | 'amount' => 10, |
15 | 'billing_first_name' => 'Billy', |
16 | 'billing_middle_name' => 'Goat', |
17 | 'billing_last_name' => 'Gruff', |
18 | 'email' => 'billy@goat.gruff', |
19 | 'selectMembership' => array( |
89bf81b4 |
20 | '0' => 1, |
21 | ), |
b396c447 |
22 | 'payment_processor_id' => 1, |
50fb255d |
23 | 'credit_card_number' => '4111111111111111', |
24 | 'credit_card_type' => 'Visa', |
25 | 'credit_card_exp_date' => array( |
89bf81b4 |
26 | 'M' => 9, |
27 | 'Y' => 2040, |
28 | ), |
50fb255d |
29 | 'cvv2' => 123, |
30 | 'is_recur' => 1, |
31 | 'frequency_interval' => 1, |
32 | 'frequency_unit' => 'month', |
33 | ); |
89bf81b4 |
34 | |
50fb255d |
35 | try{ |
a828d7b8 |
36 | $result = civicrm_api3('ContributionPage', 'submit', $params); |
50fb255d |
37 | } |
38 | catch (CiviCRM_API3_Exception $e) { |
39 | // Handle error here. |
40 | $errorMessage = $e->getMessage(); |
41 | $errorCode = $e->getErrorCode(); |
42 | $errorData = $e->getExtraParams(); |
43 | return array( |
44 | 'error' => $errorMessage, |
45 | 'error_code' => $errorCode, |
46 | 'error_data' => $errorData, |
47 | ); |
48 | } |
89bf81b4 |
49 | |
50fb255d |
50 | return $result; |
89bf81b4 |
51 | } |
52 | |
53 | /** |
50fb255d |
54 | * Function returns array of result expected from previous function. |
55 | * |
56 | * @return array |
57 | * API result array |
89bf81b4 |
58 | */ |
50fb255d |
59 | function contribution_page_submit_expectedresult() { |
89bf81b4 |
60 | |
61 | $expectedResult = array( |
50fb255d |
62 | 'is_error' => 0, |
63 | 'version' => 3, |
64 | 'count' => 0, |
65 | 'values' => '', |
66 | ); |
89bf81b4 |
67 | |
68 | return $expectedResult; |
69 | } |
70 | |
a828d7b8 |
71 | /* |
50fb255d |
72 | * This example has been generated from the API test suite. |
d27635dc |
73 | * The test that created it is called "testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed" |
a828d7b8 |
74 | * and can be found at: |
89bf81b4 |
75 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php |
76 | * |
77 | * You can see the outcome of the API tests at |
78 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
79 | * |
80 | * To Learn about the API read |
81 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
82 | * |
83 | * Browse the api on your own site with the api explorer |
41d4d31f |
84 | * http://MYSITE.ORG/path/to/civicrm/api |
89bf81b4 |
85 | * |
86 | * Read more about testing here |
87 | * http://wiki.civicrm.org/confluence/display/CRM/Testing |
88 | * |
89 | * API Standards documentation: |
90 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards |
91 | */ |