Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the ContributionRecur.create API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function contribution_recur_create_example() { | |
9 | $params = array( | |
10 | 'contact_id' => 3, | |
11 | 'installments' => '12', | |
12 | 'frequency_interval' => '1', | |
13 | 'amount' => '500', | |
14 | 'contribution_status_id' => 1, | |
15 | 'start_date' => '2012-01-01 00:00:00', | |
16 | 'currency' => 'USD', | |
17 | 'frequency_unit' => 'day', | |
18 | ); | |
6a488035 | 19 | |
50fb255d | 20 | try{ |
a828d7b8 | 21 | $result = civicrm_api3('ContributionRecur', 'create', $params); |
50fb255d | 22 | } |
23 | catch (CiviCRM_API3_Exception $e) { | |
24 | // Handle error here. | |
25 | $errorMessage = $e->getMessage(); | |
26 | $errorCode = $e->getErrorCode(); | |
27 | $errorData = $e->getExtraParams(); | |
28 | return array( | |
5be22f39 | 29 | 'is_error' => 1, |
30 | 'error_message' => $errorMessage, | |
50fb255d | 31 | 'error_code' => $errorCode, |
32 | 'error_data' => $errorData, | |
33 | ); | |
34 | } | |
35 | ||
36 | return $result; | |
6a488035 TO |
37 | } |
38 | ||
fb32de45 | 39 | /** |
50fb255d | 40 | * Function returns array of result expected from previous function. |
41 | * | |
42 | * @return array | |
43 | * API result array | |
6a488035 | 44 | */ |
50fb255d | 45 | function contribution_recur_create_expectedresult() { |
6a488035 | 46 | |
edb0d67a | 47 | $expectedResult = array( |
50fb255d | 48 | 'is_error' => 0, |
49 | 'version' => 3, | |
50 | 'count' => 1, | |
51 | 'id' => 1, | |
52 | 'values' => array( | |
edb0d67a | 53 | '1' => array( |
50fb255d | 54 | 'id' => '1', |
55 | 'contact_id' => '3', | |
56 | 'amount' => '500', | |
57 | 'currency' => 'USD', | |
58 | 'frequency_unit' => 'day', | |
59 | 'frequency_interval' => '1', | |
60 | 'installments' => '12', | |
61 | 'start_date' => '2013-07-29 00:00:00', | |
62 | 'create_date' => '20120130621222105', | |
5be22f39 | 63 | 'modified_date' => '2012-11-14 16:02:35', |
50fb255d | 64 | 'cancel_date' => '', |
65 | 'end_date' => '', | |
66 | 'processor_id' => '', | |
5be22f39 | 67 | 'payment_token_id' => '', |
50fb255d | 68 | 'trxn_id' => '', |
69 | 'invoice_id' => '', | |
70 | 'contribution_status_id' => '1', | |
71 | 'is_test' => '', | |
72 | 'cycle_day' => '', | |
73 | 'next_sched_contribution_date' => '', | |
74 | 'failure_count' => '', | |
75 | 'failure_retry_date' => '', | |
76 | 'auto_renew' => '', | |
77 | 'payment_processor_id' => '', | |
78 | 'financial_type_id' => '', | |
79 | 'payment_instrument_id' => '', | |
80 | 'campaign_id' => '', | |
81 | 'is_email_receipt' => '', | |
82 | ), | |
6a488035 | 83 | ), |
50fb255d | 84 | ); |
6a488035 | 85 | |
fb32de45 | 86 | return $expectedResult; |
6a488035 TO |
87 | } |
88 | ||
a828d7b8 | 89 | /* |
50fb255d | 90 | * This example has been generated from the API test suite. |
a828d7b8 CW |
91 | * The test that created it is called "testCreateContributionRecur" |
92 | * and can be found at: | |
69d79249 | 93 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionRecurTest.php |
6a488035 TO |
94 | * |
95 | * You can see the outcome of the API tests at | |
69d79249 | 96 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
97 | * |
98 | * To Learn about the API read | |
69d79249 | 99 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 100 | * |
69d79249 | 101 | * Browse the api on your own site with the api explorer |
41d4d31f | 102 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
103 | * |
104 | * Read more about testing here | |
105 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
106 | * | |
107 | * API Standards documentation: | |
108 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 109 | */ |