5dab053aadbd1c62477717606240389e27e000bd
[civicrm-core.git] / api / v3 / examples / ContributionPage / Submit.php
1 <?php
2 /**
3 * Test Generated example of using contribution_page Submit API.
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(
20 '0' => 1,
21 ),
22 'payment_processor' => 1,
23 'credit_card_number' => '4111111111111111',
24 'credit_card_type' => 'Visa',
25 'credit_card_exp_date' => array(
26 'M' => 9,
27 'Y' => 2040,
28 ),
29 'cvv2' => 123,
30 'is_recur' => 1,
31 'frequency_interval' => 1,
32 'frequency_unit' => 'month',
33 );
34
35 try{
36 $result = civicrm_api3('contribution_page', 'Submit', $params);
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 }
49
50 return $result;
51 }
52
53 /**
54 * Function returns array of result expected from previous function.
55 *
56 * @return array
57 * API result array
58 */
59 function contribution_page_submit_expectedresult() {
60
61 $expectedResult = array(
62 'is_error' => 0,
63 'version' => 3,
64 'count' => 0,
65 'values' => '',
66 );
67
68 return $expectedResult;
69 }
70
71 /**
72 * This example has been generated from the API test suite.
73 * The test that created it is called
74 * testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed
75 * and can be found in
76 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
77 *
78 * You can see the outcome of the API tests at
79 * https://test.civicrm.org/job/CiviCRM-master-git/
80 *
81 * To Learn about the API read
82 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
83 *
84 * Browse the api on your own site with the api explorer
85 * http://MYSITE.ORG/path/to/civicrm/api
86 *
87 * Read more about testing here
88 * http://wiki.civicrm.org/confluence/display/CRM/Testing
89 *
90 * API Standards documentation:
91 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
92 */