Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the PaymentProcessorType.create API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function payment_processor_type_create_example() { | |
9 | $params = array( | |
10 | 'sequential' => 1, | |
11 | 'name' => 'API_Test_PP', | |
12 | 'title' => 'API Test Payment Processor', | |
13 | 'class_name' => 'CRM_Core_Payment_APITest', | |
14 | 'billing_mode' => 'form', | |
15 | 'is_recur' => 0, | |
16 | ); | |
6a488035 | 17 | |
50fb255d | 18 | try{ |
a828d7b8 | 19 | $result = civicrm_api3('PaymentProcessorType', 'create', $params); |
50fb255d | 20 | } |
21 | catch (CiviCRM_API3_Exception $e) { | |
22 | // Handle error here. | |
23 | $errorMessage = $e->getMessage(); | |
24 | $errorCode = $e->getErrorCode(); | |
25 | $errorData = $e->getExtraParams(); | |
26 | return array( | |
27 | 'error' => $errorMessage, | |
28 | 'error_code' => $errorCode, | |
29 | 'error_data' => $errorData, | |
30 | ); | |
31 | } | |
32 | ||
33 | return $result; | |
6a488035 TO |
34 | } |
35 | ||
fb32de45 | 36 | /** |
50fb255d | 37 | * Function returns array of result expected from previous function. |
38 | * | |
39 | * @return array | |
40 | * API result array | |
6a488035 | 41 | */ |
50fb255d | 42 | function payment_processor_type_create_expectedresult() { |
6a488035 | 43 | |
53ca8fd7 | 44 | $expectedResult = array( |
50fb255d | 45 | 'is_error' => 0, |
46 | 'version' => 3, | |
47 | 'count' => 1, | |
48 | 'id' => 15, | |
49 | 'values' => array( | |
53ca8fd7 | 50 | '0' => array( |
50fb255d | 51 | 'id' => '15', |
52 | 'name' => 'API_Test_PP', | |
53 | 'title' => 'API Test Payment Processor', | |
54 | 'description' => '', | |
55 | 'is_active' => '1', | |
56 | 'is_default' => '', | |
57 | 'user_name_label' => '', | |
58 | 'password_label' => '', | |
59 | 'signature_label' => '', | |
60 | 'subject_label' => '', | |
61 | 'class_name' => 'CRM_Core_Payment_APITest', | |
62 | 'url_site_default' => '', | |
63 | 'url_api_default' => '', | |
64 | 'url_recur_default' => '', | |
65 | 'url_button_default' => '', | |
66 | 'url_site_test_default' => '', | |
67 | 'url_api_test_default' => '', | |
68 | 'url_recur_test_default' => '', | |
69 | 'url_button_test_default' => '', | |
70 | 'billing_mode' => '1', | |
71 | 'is_recur' => 0, | |
72 | 'payment_type' => '', | |
73 | ), | |
6a488035 | 74 | ), |
50fb255d | 75 | ); |
6a488035 | 76 | |
fb32de45 | 77 | return $expectedResult; |
6a488035 TO |
78 | } |
79 | ||
a828d7b8 | 80 | /* |
50fb255d | 81 | * This example has been generated from the API test suite. |
a828d7b8 CW |
82 | * The test that created it is called "testPaymentProcessorTypeCreate" |
83 | * and can be found at: | |
69d79249 | 84 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentProcessorTypeTest.php |
6a488035 TO |
85 | * |
86 | * You can see the outcome of the API tests at | |
69d79249 | 87 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
88 | * |
89 | * To Learn about the API read | |
69d79249 | 90 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 91 | * |
69d79249 | 92 | * Browse the api on your own site with the api explorer |
41d4d31f | 93 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
94 | * |
95 | * Read more about testing here | |
96 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
97 | * | |
98 | * API Standards documentation: | |
99 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 100 | */ |