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