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