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