Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / PaymentProcessor / Create.php
1 <?php
2 /**
3 * Test Generated example demonstrating the PaymentProcessor.create API.
4 *
5 * @return array
6 * API result array
7 */
8 function payment_processor_create_example() {
9 $params = [
10 'name' => 'API Test PP',
11 'payment_processor_type_id' => 1,
12 'class_name' => 'CRM_Core_Payment_APITest',
13 'is_recur' => 0,
14 'domain_id' => 1,
15 ];
16
17 try{
18 $result = civicrm_api3('PaymentProcessor', 'create', $params);
19 }
20 catch (CiviCRM_API3_Exception $e) {
21 // Handle error here.
22 $errorMessage = $e->getMessage();
23 $errorCode = $e->getErrorCode();
24 $errorData = $e->getExtraParams();
25 return [
26 'is_error' => 1,
27 'error_message' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 ];
31 }
32
33 return $result;
34 }
35
36 /**
37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
41 */
42 function payment_processor_create_expectedresult() {
43
44 $expectedResult = [
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 2,
49 'values' => [
50 '2' => [
51 'id' => '2',
52 'domain_id' => '1',
53 'name' => 'API Test PP',
54 'description' => '',
55 'payment_processor_type_id' => '1',
56 'is_active' => '',
57 'is_default' => 0,
58 'is_test' => 0,
59 'user_name' => '',
60 'password' => '',
61 'signature' => '',
62 'url_site' => '',
63 'url_api' => '',
64 'url_recur' => '',
65 'url_button' => '',
66 'subject' => '',
67 'class_name' => 'CRM_Core_Payment_APITest',
68 'billing_mode' => '1',
69 'is_recur' => 0,
70 'payment_type' => '1',
71 'payment_instrument_id' => '1',
72 'accepted_credit_cards' => '',
73 ],
74 ],
75 ];
76
77 return $expectedResult;
78 }
79
80 /*
81 * This example has been generated from the API test suite.
82 * The test that created it is called "testPaymentProcessorCreate"
83 * and can be found at:
84 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentProcessorTest.php
85 *
86 * You can see the outcome of the API tests at
87 * https://test.civicrm.org/job/CiviCRM-master-git/
88 *
89 * To Learn about the API read
90 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
91 *
92 * Browse the api on your own site with the api explorer
93 * http://MYSITE.ORG/path/to/civicrm/api
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
100 */