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