| 1 | <?php |
| 2 | /** |
| 3 | * Test Generated example demonstrating the PaymentProcessorType.create API. |
| 4 | * |
| 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 | ); |
| 17 | |
| 18 | try{ |
| 19 | $result = civicrm_api3('PaymentProcessorType', 'create', $params); |
| 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; |
| 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_type_create_expectedresult() { |
| 43 | |
| 44 | $expectedResult = array( |
| 45 | 'is_error' => 0, |
| 46 | 'version' => 3, |
| 47 | 'count' => 1, |
| 48 | 'id' => 15, |
| 49 | 'values' => array( |
| 50 | '0' => array( |
| 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 | ), |
| 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 "testPaymentProcessorTypeCreate" |
| 83 | * and can be found at: |
| 84 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentProcessorTypeTest.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 | */ |