├── .gitignore ├── LICENSE ├── README.md ├── autoload.php ├── composer.json └── lib ├── ApiClient.php ├── ApiException.php ├── Client ├── BanksApi.php ├── PaymentMethodsApi.php ├── PaymentsApi.php └── ReceiversApi.php ├── Configuration.php ├── Model ├── AuthorizationError.php ├── BankItem.php ├── BanksResponse.php ├── ErrorItem.php ├── PaymentMethodItem.php ├── PaymentMethodsResponse.php ├── PaymentsCreateResponse.php ├── PaymentsResponse.php ├── ReceiversCreateResponse.php ├── ServiceError.php ├── SuccessResponse.php └── ValidationError.php └── ObjectSerializer.php /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Instalation 2 | 3 | Add the dependency _khipu/khipu-api-client_ to _composer.json_ and run 4 | 5 | ``` 6 | composer install 7 | ``` 8 | 9 | 10 | ## Usage 11 | 12 | ### Basic usage 13 | ```php 14 | setSecret("abc123"); 19 | $c->setReceiverId(1234); 20 | $c->setDebug(true); 21 | 22 | $cl = new Khipu\ApiClient($c); 23 | 24 | $exp = new DateTime(); 25 | $exp->setDate(2020, 11, 3); 26 | 27 | $kh = new Khipu\Client\PaymentsApi($cl); 28 | 29 | try { 30 | $opts = array( 31 | "expires_date" => $exp, 32 | "body" => "test body" 33 | ); 34 | $resp = $kh->paymentsPost("Test de api", "CLP", 1570, $opts); 35 | print_r($resp); 36 | $r2 = $kh->paymentsIdGet($resp->getPaymentId()); 37 | print_r($r2); 38 | } catch(Exception $e) { 39 | echo $e->getMessage(); 40 | } 41 | ?> 42 | ``` 43 | -------------------------------------------------------------------------------- /autoload.php: -------------------------------------------------------------------------------- 1 | =5.3.3", 21 | "ext-curl": "*", 22 | "ext-json": "*", 23 | "ext-mbstring": "*" 24 | }, 25 | "require-dev": { 26 | "phpunit/phpunit": "~4.0", 27 | "satooshi/php-coveralls": "~0.6.1", 28 | "squizlabs/php_codesniffer": "~2.0" 29 | }, 30 | "autoload": { 31 | "psr-4": { "Khipu\\" : "lib/" } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/ApiClient.php: -------------------------------------------------------------------------------- 1 | config = $config; 79 | $this->serializer = new ObjectSerializer(); 80 | } 81 | 82 | /** 83 | * Get the config 84 | * @return Configuration 85 | */ 86 | public function getConfig() 87 | { 88 | return $this->config; 89 | } 90 | 91 | /** 92 | * Get the serializer 93 | * @return ObjectSerializer 94 | */ 95 | public function getSerializer() 96 | { 97 | return $this->serializer; 98 | } 99 | 100 | /** 101 | * Get API key (with prefix if set) 102 | * @param string $apiKeyIdentifier name of apikey 103 | * @return string API key with the prefix 104 | */ 105 | public function getApiKeyWithPrefix($apiKeyIdentifier) 106 | { 107 | $prefix = $this->config->getApiKeyPrefix($apiKeyIdentifier); 108 | $apiKey = $this->config->getApiKey($apiKeyIdentifier); 109 | 110 | if (!isset($apiKey)) { 111 | return null; 112 | } 113 | 114 | if (isset($prefix)) { 115 | $keyWithPrefix = $prefix." ".$apiKey; 116 | } else { 117 | $keyWithPrefix = $apiKey; 118 | } 119 | 120 | return $keyWithPrefix; 121 | } 122 | 123 | /** 124 | * Make the HTTP call (Sync) 125 | * @param string $resourcePath path to method endpoint 126 | * @param string $method method to call 127 | * @param array $queryParams parameters to be place in query URL 128 | * @param array $postData parameters to be placed in POST body 129 | * @param array $headerParams parameters to be place in request header 130 | * @param string $responseType expected response type of the endpoint 131 | * @throws \Khipu\ApiException on a non 2xx response 132 | * @return mixed 133 | */ 134 | public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null) 135 | { 136 | 137 | $headers = array(); 138 | 139 | // construct the http header 140 | $headerParams = array_merge( 141 | (array)$this->config->getDefaultHeaders(), 142 | (array)$headerParams 143 | ); 144 | 145 | foreach ($headerParams as $key => $val) { 146 | $headers[] = "$key: $val"; 147 | } 148 | 149 | // form data 150 | if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { 151 | $postData = http_build_query($postData); 152 | } else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model 153 | $postData = json_encode($this->serializer->sanitizeForSerialization($postData)); 154 | } 155 | 156 | $url = $this->config->getHost() . $resourcePath; 157 | 158 | $curl = curl_init(); 159 | // set timeout, if needed 160 | if ($this->config->getCurlTimeout() != 0) { 161 | curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout()); 162 | } 163 | // return the result on success, rather than just TRUE 164 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 165 | 166 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); 167 | 168 | // disable SSL verification, if needed 169 | if ($this->config->getSSLVerification() == false) { 170 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); 171 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); 172 | } 173 | 174 | if (! empty($queryParams)) { 175 | $url = ($url . '?' . http_build_query($queryParams)); 176 | } 177 | 178 | if ($method == self::$POST) { 179 | curl_setopt($curl, CURLOPT_POST, true); 180 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); 181 | } else if ($method == self::$HEAD) { 182 | curl_setopt($curl, CURLOPT_NOBODY, true); 183 | } else if ($method == self::$OPTIONS) { 184 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); 185 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); 186 | } else if ($method == self::$PATCH) { 187 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); 188 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); 189 | } else if ($method == self::$PUT) { 190 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); 191 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); 192 | } else if ($method == self::$DELETE) { 193 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); 194 | curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); 195 | } else if ($method != self::$GET) { 196 | throw new ApiException('Method ' . $method . ' is not recognized.'); 197 | } 198 | curl_setopt($curl, CURLOPT_URL, $url); 199 | 200 | // Set user agent 201 | curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent()); 202 | 203 | // debugging for curl 204 | if ($this->config->getDebug()) { 205 | error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, $this->config->getDebugFile()); 206 | 207 | curl_setopt($curl, CURLOPT_VERBOSE, 1); 208 | curl_setopt($curl, CURLOPT_STDERR, fopen($this->config->getDebugFile(), 'a')); 209 | } else { 210 | curl_setopt($curl, CURLOPT_VERBOSE, 0); 211 | } 212 | 213 | // obtain the HTTP response headers 214 | curl_setopt($curl, CURLOPT_HEADER, 1); 215 | 216 | // Make the request 217 | $response = curl_exec($curl); 218 | $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); 219 | $http_header = substr($response, 0, $http_header_size); 220 | $http_body = substr($response, $http_header_size); 221 | $response_info = curl_getinfo($curl); 222 | 223 | // debug HTTP response body 224 | if ($this->config->getDebug()) { 225 | error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, $this->config->getDebugFile()); 226 | } 227 | 228 | // Handle the response 229 | if ($response_info['http_code'] == 0) { 230 | throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); 231 | } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { 232 | // return raw body if response is a file 233 | if ($responseType == '\SplFileObject') { 234 | return array($http_body, $http_header); 235 | } 236 | 237 | $data = json_decode($http_body); 238 | if (json_last_error() > 0) { // if response is a string 239 | $data = $http_body; 240 | } 241 | } else { 242 | $data = json_decode($http_body); 243 | if (json_last_error() > 0) { // if response is a string 244 | $data = $http_body; 245 | } 246 | 247 | throw new ApiException( 248 | "[".$response_info['http_code']."] Error connecting to the API ($url)", 249 | $response_info['http_code'], $http_header, $data 250 | ); 251 | } 252 | return array($data, $http_header); 253 | } 254 | 255 | /** 256 | * Return the header 'Accept' based on an array of Accept provided 257 | * 258 | * @param string[] $accept Array of header 259 | * 260 | * @return string Accept (e.g. application/json) 261 | */ 262 | public static function selectHeaderAccept($accept) 263 | { 264 | if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { 265 | return null; 266 | } elseif (preg_grep("/application\/json/i", $accept)) { 267 | return 'application/json'; 268 | } else { 269 | return implode(',', $accept); 270 | } 271 | } 272 | 273 | /** 274 | * Return the content type based on an array of content-type provided 275 | * 276 | * @param string[] $content_type Array fo content-type 277 | * 278 | * @return string Content-Type (e.g. application/json) 279 | */ 280 | public static function selectHeaderContentType($content_type) 281 | { 282 | if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { 283 | return 'application/json'; 284 | } elseif (preg_grep("/application\/json/i", $content_type)) { 285 | return 'application/json'; 286 | } else { 287 | return implode(',', $content_type); 288 | } 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /lib/ApiException.php: -------------------------------------------------------------------------------- 1 | responseHeaders = $responseHeaders; 78 | $this->responseBody = $responseBody; 79 | } 80 | 81 | /** 82 | * Gets the HTTP response header 83 | * 84 | * @return string HTTP response header 85 | */ 86 | public function getResponseHeaders() 87 | { 88 | return $this->responseHeaders; 89 | } 90 | 91 | /** 92 | * Gets the HTTP body of the server response either as Json or string 93 | * 94 | * @return mixed HTTP body of the server response either as Json or string 95 | */ 96 | public function getResponseBody() 97 | { 98 | return $this->responseBody; 99 | } 100 | 101 | /** 102 | * Sets the deseralized response object (during deserialization) 103 | * @param mixed $obj Deserialized response object 104 | * @return void 105 | */ 106 | public function setResponseObject($obj) 107 | { 108 | $this->responseObject = $obj; 109 | } 110 | 111 | /** 112 | * Gets the deseralized response object (during deserialization) 113 | * 114 | * @return mixed the deserialized response object 115 | */ 116 | public function getResponseObject() 117 | { 118 | return $this->responseObject; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /lib/Client/BanksApi.php: -------------------------------------------------------------------------------- 1 | getConfig()->setHost('https://khipu.com/api/2.0'); 68 | } 69 | 70 | $this->apiClient = $apiClient; 71 | } 72 | 73 | /** 74 | * Get API client 75 | * @return \Khipu\ApiClient get the API client 76 | */ 77 | public function getApiClient() 78 | { 79 | return $this->apiClient; 80 | } 81 | 82 | /** 83 | * Set the API client 84 | * @param \Khipu\ApiClient $apiClient set the API client 85 | * @return BanksApi 86 | */ 87 | public function setApiClient(ApiClient $apiClient) 88 | { 89 | $this->apiClient = $apiClient; 90 | return $this; 91 | } 92 | 93 | 94 | /** 95 | * banksGet 96 | * 97 | * Obtener listado de bancos 98 | * 99 | * @param array $options Arreglo de par��metros opcionales (opcional) 100 | * @return \Khipu\Model\BanksResponse 101 | * @throws \Khipu\ApiException on non-2xx response 102 | */ 103 | public function banksGet($options = null) 104 | { 105 | 106 | 107 | // parse inputs 108 | $resourcePath = "/banks"; 109 | $resourcePath = str_replace("{format}", "json", $resourcePath); 110 | $method = "GET"; 111 | $httpBody = ''; 112 | $queryParams = array(); 113 | $headerParams = array(); 114 | $formParams = array(); 115 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 116 | if (!is_null($_header_accept)) { 117 | $headerParams['Accept'] = $_header_accept; 118 | } 119 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 120 | 121 | 122 | 123 | if( $options != null ) { 124 | 125 | } 126 | 127 | 128 | 129 | 130 | if( $options != null ) { 131 | 132 | } 133 | 134 | 135 | 136 | 137 | if( $options != null ) { 138 | 139 | } 140 | 141 | 142 | 143 | if( $options != null ) { 144 | 145 | } 146 | 147 | 148 | 149 | if( $options != null ) { 150 | 151 | } 152 | 153 | // for model (json/xml) 154 | if (isset($_tempBody)) { 155 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 156 | } else if (count($formParams) > 0) { 157 | $httpBody = $formParams; // for HTTP post (form) 158 | } 159 | 160 | 161 | 162 | 163 | $encoded = array(); 164 | 165 | foreach ($formParams as $key => $value) { 166 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 167 | } 168 | foreach ($queryParams as $key => $value) { 169 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 170 | } 171 | 172 | $keys = array_keys($encoded); 173 | sort($keys); 174 | 175 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 176 | 177 | $toSign = "$method&" . rawurlencode($url); 178 | foreach ($keys as $key) { 179 | $toSign .= "&$key=" . $encoded[$key]; 180 | } 181 | if (isset($_tempBody)){ 182 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 183 | $toSign .="&".$json_body; 184 | } 185 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 186 | 187 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 188 | 189 | 190 | 191 | // make the API Call 192 | try 193 | { 194 | list($response, $httpHeader) = $this->apiClient->callApi( 195 | $resourcePath, $method, 196 | $queryParams, $httpBody, 197 | $headerParams, '\Khipu\Model\BanksResponse' 198 | ); 199 | 200 | if (!$response) { 201 | return null; 202 | } 203 | 204 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\BanksResponse', $httpHeader); 205 | 206 | } catch (ApiException $e) { 207 | switch ($e->getCode()) { 208 | case 200: 209 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\BanksResponse', $e->getResponseHeaders()); 210 | $e->setResponseObject($data); 211 | break; 212 | case 400: 213 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 214 | $e->setResponseObject($data); 215 | break; 216 | case 403: 217 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 218 | $e->setResponseObject($data); 219 | break; 220 | case 503: 221 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 222 | $e->setResponseObject($data); 223 | break; 224 | } 225 | 226 | throw $e; 227 | } 228 | 229 | return null; 230 | 231 | } 232 | 233 | } 234 | -------------------------------------------------------------------------------- /lib/Client/PaymentMethodsApi.php: -------------------------------------------------------------------------------- 1 | getConfig()->setHost('https://khipu.com/api/2.0'); 68 | } 69 | 70 | $this->apiClient = $apiClient; 71 | } 72 | 73 | /** 74 | * Get API client 75 | * @return \Khipu\ApiClient get the API client 76 | */ 77 | public function getApiClient() 78 | { 79 | return $this->apiClient; 80 | } 81 | 82 | /** 83 | * Set the API client 84 | * @param \Khipu\ApiClient $apiClient set the API client 85 | * @return PaymentMethodsApi 86 | */ 87 | public function setApiClient(ApiClient $apiClient) 88 | { 89 | $this->apiClient = $apiClient; 90 | return $this; 91 | } 92 | 93 | 94 | /** 95 | * merchantsIdPaymentMethodsGet 96 | * 97 | * Obtener listado de medios de pago disponible para una cuenta de cobrador 98 | * 99 | * @param string $id Identificador del merchant (requerido) 100 | * @param array $options Arreglo de par��metros opcionales (opcional) 101 | * @return \Khipu\Model\PaymentMethodsResponse 102 | * @throws \Khipu\ApiException on non-2xx response 103 | */ 104 | public function merchantsIdPaymentMethodsGet($id, $options = null) 105 | { 106 | 107 | // verify the required parameter 'id' is set 108 | if ($id === null) { 109 | throw new \InvalidArgumentException('Missing the required parameter $id when calling merchantsIdPaymentMethodsGet'); 110 | } 111 | 112 | // parse inputs 113 | $resourcePath = "/merchants/{id}/paymentMethods"; 114 | $resourcePath = str_replace("{format}", "json", $resourcePath); 115 | $method = "GET"; 116 | $httpBody = ''; 117 | $queryParams = array(); 118 | $headerParams = array(); 119 | $formParams = array(); 120 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 121 | if (!is_null($_header_accept)) { 122 | $headerParams['Accept'] = $_header_accept; 123 | } 124 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 125 | 126 | 127 | 128 | if( $options != null ) { 129 | 130 | } 131 | 132 | 133 | 134 | 135 | if( $options != null ) { 136 | 137 | } 138 | 139 | 140 | // path params 141 | $resourcePath = str_replace( 142 | "{" . "id" . "}", 143 | $this->apiClient->getSerializer()->toPathValue($id), 144 | $resourcePath 145 | ); 146 | 147 | 148 | if( $options != null ) { 149 | 150 | } 151 | 152 | 153 | 154 | if( $options != null ) { 155 | 156 | } 157 | 158 | 159 | 160 | if( $options != null ) { 161 | 162 | } 163 | 164 | // for model (json/xml) 165 | if (isset($_tempBody)) { 166 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 167 | } else if (count($formParams) > 0) { 168 | $httpBody = $formParams; // for HTTP post (form) 169 | } 170 | 171 | 172 | 173 | 174 | $encoded = array(); 175 | 176 | foreach ($formParams as $key => $value) { 177 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 178 | } 179 | foreach ($queryParams as $key => $value) { 180 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 181 | } 182 | 183 | $keys = array_keys($encoded); 184 | sort($keys); 185 | 186 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 187 | 188 | $toSign = "$method&" . rawurlencode($url); 189 | foreach ($keys as $key) { 190 | $toSign .= "&$key=" . $encoded[$key]; 191 | } 192 | if (isset($_tempBody)){ 193 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 194 | $toSign .="&".$json_body; 195 | } 196 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 197 | 198 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 199 | 200 | 201 | 202 | // make the API Call 203 | try 204 | { 205 | list($response, $httpHeader) = $this->apiClient->callApi( 206 | $resourcePath, $method, 207 | $queryParams, $httpBody, 208 | $headerParams, '\Khipu\Model\PaymentMethodsResponse' 209 | ); 210 | 211 | if (!$response) { 212 | return null; 213 | } 214 | 215 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\PaymentMethodsResponse', $httpHeader); 216 | 217 | } catch (ApiException $e) { 218 | switch ($e->getCode()) { 219 | case 200: 220 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\PaymentMethodsResponse', $e->getResponseHeaders()); 221 | $e->setResponseObject($data); 222 | break; 223 | case 400: 224 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 225 | $e->setResponseObject($data); 226 | break; 227 | case 403: 228 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 229 | $e->setResponseObject($data); 230 | break; 231 | case 503: 232 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 233 | $e->setResponseObject($data); 234 | break; 235 | } 236 | 237 | throw $e; 238 | } 239 | 240 | return null; 241 | 242 | } 243 | 244 | } 245 | -------------------------------------------------------------------------------- /lib/Client/PaymentsApi.php: -------------------------------------------------------------------------------- 1 | getConfig()->setHost('https://khipu.com/api/2.0'); 68 | } 69 | 70 | $this->apiClient = $apiClient; 71 | } 72 | 73 | /** 74 | * Get API client 75 | * @return \Khipu\ApiClient get the API client 76 | */ 77 | public function getApiClient() 78 | { 79 | return $this->apiClient; 80 | } 81 | 82 | /** 83 | * Set the API client 84 | * @param \Khipu\ApiClient $apiClient set the API client 85 | * @return PaymentsApi 86 | */ 87 | public function setApiClient(ApiClient $apiClient) 88 | { 89 | $this->apiClient = $apiClient; 90 | return $this; 91 | } 92 | 93 | 94 | /** 95 | * paymentsGet 96 | * 97 | * Obtener información de un pago 98 | * 99 | * @param string $notification_token Token de notifiación recibido usando la API de notificaiones 1.3 o superior. (requerido) 100 | * @param array $options Arreglo de par��metros opcionales (opcional) 101 | * @return \Khipu\Model\PaymentsResponse 102 | * @throws \Khipu\ApiException on non-2xx response 103 | */ 104 | public function paymentsGet($notification_token, $options = null) 105 | { 106 | 107 | // verify the required parameter 'notification_token' is set 108 | if ($notification_token === null) { 109 | throw new \InvalidArgumentException('Missing the required parameter $notification_token when calling paymentsGet'); 110 | } 111 | 112 | // parse inputs 113 | $resourcePath = "/payments"; 114 | $resourcePath = str_replace("{format}", "json", $resourcePath); 115 | $method = "GET"; 116 | $httpBody = ''; 117 | $queryParams = array(); 118 | $headerParams = array(); 119 | $formParams = array(); 120 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 121 | if (!is_null($_header_accept)) { 122 | $headerParams['Accept'] = $_header_accept; 123 | } 124 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 125 | 126 | // query params 127 | $queryParams['notification_token'] = $this->apiClient->getSerializer()->toQueryValue($notification_token); 128 | 129 | 130 | if( $options != null ) { 131 | 132 | } 133 | 134 | 135 | 136 | 137 | if( $options != null ) { 138 | 139 | } 140 | 141 | 142 | 143 | 144 | if( $options != null ) { 145 | 146 | } 147 | 148 | 149 | 150 | if( $options != null ) { 151 | 152 | } 153 | 154 | 155 | 156 | if( $options != null ) { 157 | 158 | } 159 | 160 | // for model (json/xml) 161 | if (isset($_tempBody)) { 162 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 163 | } else if (count($formParams) > 0) { 164 | $httpBody = $formParams; // for HTTP post (form) 165 | } 166 | 167 | 168 | 169 | 170 | $encoded = array(); 171 | 172 | foreach ($formParams as $key => $value) { 173 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 174 | } 175 | foreach ($queryParams as $key => $value) { 176 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 177 | } 178 | 179 | $keys = array_keys($encoded); 180 | sort($keys); 181 | 182 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 183 | 184 | $toSign = "$method&" . rawurlencode($url); 185 | foreach ($keys as $key) { 186 | $toSign .= "&$key=" . $encoded[$key]; 187 | } 188 | if (isset($_tempBody)){ 189 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 190 | $toSign .="&".$json_body; 191 | } 192 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 193 | 194 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 195 | 196 | 197 | 198 | // make the API Call 199 | try 200 | { 201 | list($response, $httpHeader) = $this->apiClient->callApi( 202 | $resourcePath, $method, 203 | $queryParams, $httpBody, 204 | $headerParams, '\Khipu\Model\PaymentsResponse' 205 | ); 206 | 207 | if (!$response) { 208 | return null; 209 | } 210 | 211 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\PaymentsResponse', $httpHeader); 212 | 213 | } catch (ApiException $e) { 214 | switch ($e->getCode()) { 215 | case 200: 216 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\PaymentsResponse', $e->getResponseHeaders()); 217 | $e->setResponseObject($data); 218 | break; 219 | case 400: 220 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 221 | $e->setResponseObject($data); 222 | break; 223 | case 403: 224 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 225 | $e->setResponseObject($data); 226 | break; 227 | case 503: 228 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 229 | $e->setResponseObject($data); 230 | break; 231 | } 232 | 233 | throw $e; 234 | } 235 | 236 | return null; 237 | 238 | } 239 | 240 | /** 241 | * paymentsPost 242 | * 243 | * Crear un pago 244 | * 245 | * @param string $subject Motivo (requerido) 246 | * @param string $currency El código de moneda en formato ISO-4217 (requerido) 247 | * @param double $amount El monto del cobro. Sin separador de miles y usando '.' como separador de decimales. Hasta 4 lugares decimales, dependiendo de la moneda (requerido) 248 | * @param array $options Arreglo de par��metros opcionales (opcional) 249 | * - string 'transaction_id' Identificador propio de la transacción. Ej: número de factura u orden de compra (opcional) 250 | * - string 'custom' Parámetro para enviar información personalizada de la transacción. Ej: documento XML con el detalle del carro de compra (opcional) 251 | * - string 'body' Descripción del cobro (opcional) 252 | * - string 'bank_id' Identificador del banco para usar en el pago (opcional) 253 | * - string 'return_url' La dirección URL a donde enviar al cliente mientras el pago está siendo verificado (opcional) 254 | * - string 'cancel_url' La dirección URL a donde enviar al cliente si decide no hacer hacer la transacción (opcional) 255 | * - string 'picture_url' Una dirección URL de una foto de tu producto o servicio (opcional) 256 | * - string 'notify_url' La dirección del web-service que utilizará khipu para notificar cuando el pago esté conciliado (opcional) 257 | * - string 'contract_url' La dirección URL del archivo PDF con el contrato a firmar mediante este pago. El cobrador debe estar habilitado para este servicio y el campo 'fixed_payer_personal_identifier' es obgligatorio (opcional) 258 | * - string 'notify_api_version' Versión de la API de notifiaciones para recibir avisos por web-service (opcional) 259 | * - \DateTime 'expires_date' Fecha de expiración del cobro. Pasada esta fecha el cobro es inválido. Formato ISO-8601. Ej: 2017-03-01T13:00:00Z (opcional) 260 | * - bool 'send_email' Si es 'true', se enviará una solicitud de cobro al correo especificado en 'payer_email' (opcional) 261 | * - string 'payer_name' Nombre del pagador. Es obligatorio cuando send_email es 'true' (opcional) 262 | * - string 'payer_email' Correo del pagador. Es obligatorio cuando send_email es 'true' (opcional) 263 | * - bool 'send_reminders' Si es 'true', se enviarán recordatorios de cobro. (opcional) 264 | * - string 'responsible_user_email' Correo electrónico del responsable de este cobro, debe corresponder a un usuario khipu con permisos para cobrar usando esta cuenta de cobro (opcional) 265 | * - string 'fixed_payer_personal_identifier' Identificador personal. Si se especifica, solo podrá ser pagado usando ese identificador (opcional) 266 | * - double 'integrator_fee' Comisión para el integrador. Sólo es válido si la cuenta de cobro tiene una cuenta de integrador asociada (opcional) 267 | * - bool 'collect_account_uuid' Para cuentas de cobro con más cuenta propia. Permite elegir la cuenta donde debe ocurrir la transferencia. (opcional) 268 | * - string 'confirm_timeout_date' Fecha de rendición del cobro. Es también la fecha final para poder reembolsar el cobro. Formato ISO-8601. Ej: 2017-03-01T13:00:00Z (opcional) 269 | * - string 'mandatory_payment_method' Si se especifica, el cobro sólo se podrá pagar utilizando ese medio de pago. El valor para el campo de obtiene consultando el endpoint 'Consulta medios de pago disponibles'. (opcional) 270 | * @return \Khipu\Model\PaymentsCreateResponse 271 | * @throws \Khipu\ApiException on non-2xx response 272 | */ 273 | public function paymentsPost($subject, $currency, $amount, $options = null) 274 | { 275 | 276 | // verify the required parameter 'subject' is set 277 | if ($subject === null) { 278 | throw new \InvalidArgumentException('Missing the required parameter $subject when calling paymentsPost'); 279 | } 280 | // verify the required parameter 'currency' is set 281 | if ($currency === null) { 282 | throw new \InvalidArgumentException('Missing the required parameter $currency when calling paymentsPost'); 283 | } 284 | // verify the required parameter 'amount' is set 285 | if ($amount === null) { 286 | throw new \InvalidArgumentException('Missing the required parameter $amount when calling paymentsPost'); 287 | } 288 | 289 | // parse inputs 290 | $resourcePath = "/payments"; 291 | $resourcePath = str_replace("{format}", "json", $resourcePath); 292 | $method = "POST"; 293 | $httpBody = ''; 294 | $queryParams = array(); 295 | $headerParams = array(); 296 | $formParams = array(); 297 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 298 | if (!is_null($_header_accept)) { 299 | $headerParams['Accept'] = $_header_accept; 300 | } 301 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 302 | 303 | 304 | 305 | if( $options != null ) { 306 | 307 | } 308 | 309 | 310 | 311 | 312 | if( $options != null ) { 313 | 314 | } 315 | 316 | 317 | 318 | 319 | if( $options != null ) { 320 | 321 | } 322 | 323 | // form params 324 | $formParams['subject'] = $this->apiClient->getSerializer()->toFormValue($subject); 325 | // form params 326 | $formParams['currency'] = $this->apiClient->getSerializer()->toFormValue($currency); 327 | // form params 328 | $formParams['amount'] = $this->apiClient->getSerializer()->toFormValue($amount); 329 | 330 | 331 | if( $options != null ) { 332 | // form params 333 | if (array_key_exists("transaction_id", $options) && $options["transaction_id"] != null) { 334 | $formParams['transaction_id'] = $this->apiClient->getSerializer()->toFormValue($options["transaction_id"]); 335 | }// form params 336 | if (array_key_exists("custom", $options) && $options["custom"] != null) { 337 | $formParams['custom'] = $this->apiClient->getSerializer()->toFormValue($options["custom"]); 338 | }// form params 339 | if (array_key_exists("body", $options) && $options["body"] != null) { 340 | $formParams['body'] = $this->apiClient->getSerializer()->toFormValue($options["body"]); 341 | }// form params 342 | if (array_key_exists("bank_id", $options) && $options["bank_id"] != null) { 343 | $formParams['bank_id'] = $this->apiClient->getSerializer()->toFormValue($options["bank_id"]); 344 | }// form params 345 | if (array_key_exists("return_url", $options) && $options["return_url"] != null) { 346 | $formParams['return_url'] = $this->apiClient->getSerializer()->toFormValue($options["return_url"]); 347 | }// form params 348 | if (array_key_exists("cancel_url", $options) && $options["cancel_url"] != null) { 349 | $formParams['cancel_url'] = $this->apiClient->getSerializer()->toFormValue($options["cancel_url"]); 350 | }// form params 351 | if (array_key_exists("picture_url", $options) && $options["picture_url"] != null) { 352 | $formParams['picture_url'] = $this->apiClient->getSerializer()->toFormValue($options["picture_url"]); 353 | }// form params 354 | if (array_key_exists("notify_url", $options) && $options["notify_url"] != null) { 355 | $formParams['notify_url'] = $this->apiClient->getSerializer()->toFormValue($options["notify_url"]); 356 | }// form params 357 | if (array_key_exists("contract_url", $options) && $options["contract_url"] != null) { 358 | $formParams['contract_url'] = $this->apiClient->getSerializer()->toFormValue($options["contract_url"]); 359 | }// form params 360 | if (array_key_exists("notify_api_version", $options) && $options["notify_api_version"] != null) { 361 | $formParams['notify_api_version'] = $this->apiClient->getSerializer()->toFormValue($options["notify_api_version"]); 362 | }// form params 363 | if (array_key_exists("expires_date", $options) && $options["expires_date"] != null) { 364 | $formParams['expires_date'] = $this->apiClient->getSerializer()->toFormValue($options["expires_date"]); 365 | }// form params 366 | if (array_key_exists("send_email", $options) && $options["send_email"] != null) { 367 | $formParams['send_email'] = $this->apiClient->getSerializer()->toFormValue($options["send_email"]); 368 | }// form params 369 | if (array_key_exists("payer_name", $options) && $options["payer_name"] != null) { 370 | $formParams['payer_name'] = $this->apiClient->getSerializer()->toFormValue($options["payer_name"]); 371 | }// form params 372 | if (array_key_exists("payer_email", $options) && $options["payer_email"] != null) { 373 | $formParams['payer_email'] = $this->apiClient->getSerializer()->toFormValue($options["payer_email"]); 374 | }// form params 375 | if (array_key_exists("send_reminders", $options) && $options["send_reminders"] != null) { 376 | $formParams['send_reminders'] = $this->apiClient->getSerializer()->toFormValue($options["send_reminders"]); 377 | }// form params 378 | if (array_key_exists("responsible_user_email", $options) && $options["responsible_user_email"] != null) { 379 | $formParams['responsible_user_email'] = $this->apiClient->getSerializer()->toFormValue($options["responsible_user_email"]); 380 | }// form params 381 | if (array_key_exists("fixed_payer_personal_identifier", $options) && $options["fixed_payer_personal_identifier"] != null) { 382 | $formParams['fixed_payer_personal_identifier'] = $this->apiClient->getSerializer()->toFormValue($options["fixed_payer_personal_identifier"]); 383 | }// form params 384 | if (array_key_exists("integrator_fee", $options) && $options["integrator_fee"] != null) { 385 | $formParams['integrator_fee'] = $this->apiClient->getSerializer()->toFormValue($options["integrator_fee"]); 386 | }// form params 387 | if (array_key_exists("collect_account_uuid", $options) && $options["collect_account_uuid"] != null) { 388 | $formParams['collect_account_uuid'] = $this->apiClient->getSerializer()->toFormValue($options["collect_account_uuid"]); 389 | }// form params 390 | if (array_key_exists("confirm_timeout_date", $options) && $options["confirm_timeout_date"] != null) { 391 | $formParams['confirm_timeout_date'] = $this->apiClient->getSerializer()->toFormValue($options["confirm_timeout_date"]); 392 | }// form params 393 | if (array_key_exists("mandatory_payment_method", $options) && $options["mandatory_payment_method"] != null) { 394 | $formParams['mandatory_payment_method'] = $this->apiClient->getSerializer()->toFormValue($options["mandatory_payment_method"]); 395 | } 396 | } 397 | 398 | 399 | 400 | if( $options != null ) { 401 | 402 | } 403 | 404 | // for model (json/xml) 405 | if (isset($_tempBody)) { 406 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 407 | } else if (count($formParams) > 0) { 408 | $httpBody = $formParams; // for HTTP post (form) 409 | } 410 | 411 | 412 | 413 | 414 | $encoded = array(); 415 | 416 | foreach ($formParams as $key => $value) { 417 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 418 | } 419 | foreach ($queryParams as $key => $value) { 420 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 421 | } 422 | 423 | $keys = array_keys($encoded); 424 | sort($keys); 425 | 426 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 427 | 428 | $toSign = "$method&" . rawurlencode($url); 429 | foreach ($keys as $key) { 430 | $toSign .= "&$key=" . $encoded[$key]; 431 | } 432 | if (isset($_tempBody)){ 433 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 434 | $toSign .="&".$json_body; 435 | } 436 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 437 | 438 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 439 | 440 | 441 | 442 | // make the API Call 443 | try 444 | { 445 | list($response, $httpHeader) = $this->apiClient->callApi( 446 | $resourcePath, $method, 447 | $queryParams, $httpBody, 448 | $headerParams, '\Khipu\Model\PaymentsCreateResponse' 449 | ); 450 | 451 | if (!$response) { 452 | return null; 453 | } 454 | 455 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\PaymentsCreateResponse', $httpHeader); 456 | 457 | } catch (ApiException $e) { 458 | switch ($e->getCode()) { 459 | case 200: 460 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\PaymentsCreateResponse', $e->getResponseHeaders()); 461 | $e->setResponseObject($data); 462 | break; 463 | case 400: 464 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 465 | $e->setResponseObject($data); 466 | break; 467 | case 403: 468 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 469 | $e->setResponseObject($data); 470 | break; 471 | case 503: 472 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 473 | $e->setResponseObject($data); 474 | break; 475 | } 476 | 477 | throw $e; 478 | } 479 | 480 | return null; 481 | 482 | } 483 | 484 | /** 485 | * paymentsIdGet 486 | * 487 | * Obtener información de un pago 488 | * 489 | * @param string $id Identificador del pago (requerido) 490 | * @param array $options Arreglo de par��metros opcionales (opcional) 491 | * @return \Khipu\Model\PaymentsResponse 492 | * @throws \Khipu\ApiException on non-2xx response 493 | */ 494 | public function paymentsIdGet($id, $options = null) 495 | { 496 | 497 | // verify the required parameter 'id' is set 498 | if ($id === null) { 499 | throw new \InvalidArgumentException('Missing the required parameter $id when calling paymentsIdGet'); 500 | } 501 | 502 | // parse inputs 503 | $resourcePath = "/payments/{id}"; 504 | $resourcePath = str_replace("{format}", "json", $resourcePath); 505 | $method = "GET"; 506 | $httpBody = ''; 507 | $queryParams = array(); 508 | $headerParams = array(); 509 | $formParams = array(); 510 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 511 | if (!is_null($_header_accept)) { 512 | $headerParams['Accept'] = $_header_accept; 513 | } 514 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 515 | 516 | 517 | 518 | if( $options != null ) { 519 | 520 | } 521 | 522 | 523 | 524 | 525 | if( $options != null ) { 526 | 527 | } 528 | 529 | 530 | // path params 531 | $resourcePath = str_replace( 532 | "{" . "id" . "}", 533 | $this->apiClient->getSerializer()->toPathValue($id), 534 | $resourcePath 535 | ); 536 | 537 | 538 | if( $options != null ) { 539 | 540 | } 541 | 542 | 543 | 544 | if( $options != null ) { 545 | 546 | } 547 | 548 | 549 | 550 | if( $options != null ) { 551 | 552 | } 553 | 554 | // for model (json/xml) 555 | if (isset($_tempBody)) { 556 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 557 | } else if (count($formParams) > 0) { 558 | $httpBody = $formParams; // for HTTP post (form) 559 | } 560 | 561 | 562 | 563 | 564 | $encoded = array(); 565 | 566 | foreach ($formParams as $key => $value) { 567 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 568 | } 569 | foreach ($queryParams as $key => $value) { 570 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 571 | } 572 | 573 | $keys = array_keys($encoded); 574 | sort($keys); 575 | 576 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 577 | 578 | $toSign = "$method&" . rawurlencode($url); 579 | foreach ($keys as $key) { 580 | $toSign .= "&$key=" . $encoded[$key]; 581 | } 582 | if (isset($_tempBody)){ 583 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 584 | $toSign .="&".$json_body; 585 | } 586 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 587 | 588 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 589 | 590 | 591 | 592 | // make the API Call 593 | try 594 | { 595 | list($response, $httpHeader) = $this->apiClient->callApi( 596 | $resourcePath, $method, 597 | $queryParams, $httpBody, 598 | $headerParams, '\Khipu\Model\PaymentsResponse' 599 | ); 600 | 601 | if (!$response) { 602 | return null; 603 | } 604 | 605 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\PaymentsResponse', $httpHeader); 606 | 607 | } catch (ApiException $e) { 608 | switch ($e->getCode()) { 609 | case 200: 610 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\PaymentsResponse', $e->getResponseHeaders()); 611 | $e->setResponseObject($data); 612 | break; 613 | case 400: 614 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 615 | $e->setResponseObject($data); 616 | break; 617 | case 403: 618 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 619 | $e->setResponseObject($data); 620 | break; 621 | case 503: 622 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 623 | $e->setResponseObject($data); 624 | break; 625 | } 626 | 627 | throw $e; 628 | } 629 | 630 | return null; 631 | 632 | } 633 | 634 | /** 635 | * paymentsIdDelete 636 | * 637 | * Borrar un pago 638 | * 639 | * @param string $id Identificador del pago (requerido) 640 | * @param array $options Arreglo de par��metros opcionales (opcional) 641 | * @return \Khipu\Model\SuccessResponse 642 | * @throws \Khipu\ApiException on non-2xx response 643 | */ 644 | public function paymentsIdDelete($id, $options = null) 645 | { 646 | 647 | // verify the required parameter 'id' is set 648 | if ($id === null) { 649 | throw new \InvalidArgumentException('Missing the required parameter $id when calling paymentsIdDelete'); 650 | } 651 | 652 | // parse inputs 653 | $resourcePath = "/payments/{id}"; 654 | $resourcePath = str_replace("{format}", "json", $resourcePath); 655 | $method = "DELETE"; 656 | $httpBody = ''; 657 | $queryParams = array(); 658 | $headerParams = array(); 659 | $formParams = array(); 660 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 661 | if (!is_null($_header_accept)) { 662 | $headerParams['Accept'] = $_header_accept; 663 | } 664 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 665 | 666 | 667 | 668 | if( $options != null ) { 669 | 670 | } 671 | 672 | 673 | 674 | 675 | if( $options != null ) { 676 | 677 | } 678 | 679 | 680 | // path params 681 | $resourcePath = str_replace( 682 | "{" . "id" . "}", 683 | $this->apiClient->getSerializer()->toPathValue($id), 684 | $resourcePath 685 | ); 686 | 687 | 688 | if( $options != null ) { 689 | 690 | } 691 | 692 | 693 | 694 | if( $options != null ) { 695 | 696 | } 697 | 698 | 699 | 700 | if( $options != null ) { 701 | 702 | } 703 | 704 | // for model (json/xml) 705 | if (isset($_tempBody)) { 706 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 707 | } else if (count($formParams) > 0) { 708 | $httpBody = $formParams; // for HTTP post (form) 709 | } 710 | 711 | 712 | 713 | 714 | $encoded = array(); 715 | 716 | foreach ($formParams as $key => $value) { 717 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 718 | } 719 | foreach ($queryParams as $key => $value) { 720 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 721 | } 722 | 723 | $keys = array_keys($encoded); 724 | sort($keys); 725 | 726 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 727 | 728 | $toSign = "$method&" . rawurlencode($url); 729 | foreach ($keys as $key) { 730 | $toSign .= "&$key=" . $encoded[$key]; 731 | } 732 | if (isset($_tempBody)){ 733 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 734 | $toSign .="&".$json_body; 735 | } 736 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 737 | 738 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 739 | 740 | 741 | 742 | // make the API Call 743 | try 744 | { 745 | list($response, $httpHeader) = $this->apiClient->callApi( 746 | $resourcePath, $method, 747 | $queryParams, $httpBody, 748 | $headerParams, '\Khipu\Model\SuccessResponse' 749 | ); 750 | 751 | if (!$response) { 752 | return null; 753 | } 754 | 755 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\SuccessResponse', $httpHeader); 756 | 757 | } catch (ApiException $e) { 758 | switch ($e->getCode()) { 759 | case 200: 760 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\SuccessResponse', $e->getResponseHeaders()); 761 | $e->setResponseObject($data); 762 | break; 763 | case 400: 764 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 765 | $e->setResponseObject($data); 766 | break; 767 | case 403: 768 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 769 | $e->setResponseObject($data); 770 | break; 771 | case 503: 772 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 773 | $e->setResponseObject($data); 774 | break; 775 | } 776 | 777 | throw $e; 778 | } 779 | 780 | return null; 781 | 782 | } 783 | 784 | /** 785 | * paymentsIdConfirmPost 786 | * 787 | * Confirmar el pago. 788 | * 789 | * @param string $id Identificador del pago (requerido) 790 | * @param array $options Arreglo de par��metros opcionales (opcional) 791 | * @return \Khipu\Model\SuccessResponse 792 | * @throws \Khipu\ApiException on non-2xx response 793 | */ 794 | public function paymentsIdConfirmPost($id, $options = null) 795 | { 796 | 797 | // verify the required parameter 'id' is set 798 | if ($id === null) { 799 | throw new \InvalidArgumentException('Missing the required parameter $id when calling paymentsIdConfirmPost'); 800 | } 801 | 802 | // parse inputs 803 | $resourcePath = "/payments/{id}/confirm"; 804 | $resourcePath = str_replace("{format}", "json", $resourcePath); 805 | $method = "POST"; 806 | $httpBody = ''; 807 | $queryParams = array(); 808 | $headerParams = array(); 809 | $formParams = array(); 810 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 811 | if (!is_null($_header_accept)) { 812 | $headerParams['Accept'] = $_header_accept; 813 | } 814 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 815 | 816 | 817 | 818 | if( $options != null ) { 819 | 820 | } 821 | 822 | 823 | 824 | 825 | if( $options != null ) { 826 | 827 | } 828 | 829 | 830 | // path params 831 | $resourcePath = str_replace( 832 | "{" . "id" . "}", 833 | $this->apiClient->getSerializer()->toPathValue($id), 834 | $resourcePath 835 | ); 836 | 837 | 838 | if( $options != null ) { 839 | 840 | } 841 | 842 | 843 | 844 | if( $options != null ) { 845 | 846 | } 847 | 848 | 849 | 850 | if( $options != null ) { 851 | 852 | } 853 | 854 | // for model (json/xml) 855 | if (isset($_tempBody)) { 856 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 857 | } else if (count($formParams) > 0) { 858 | $httpBody = $formParams; // for HTTP post (form) 859 | } 860 | 861 | 862 | 863 | 864 | $encoded = array(); 865 | 866 | foreach ($formParams as $key => $value) { 867 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 868 | } 869 | foreach ($queryParams as $key => $value) { 870 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 871 | } 872 | 873 | $keys = array_keys($encoded); 874 | sort($keys); 875 | 876 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 877 | 878 | $toSign = "$method&" . rawurlencode($url); 879 | foreach ($keys as $key) { 880 | $toSign .= "&$key=" . $encoded[$key]; 881 | } 882 | if (isset($_tempBody)){ 883 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 884 | $toSign .="&".$json_body; 885 | } 886 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 887 | 888 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 889 | 890 | 891 | 892 | // make the API Call 893 | try 894 | { 895 | list($response, $httpHeader) = $this->apiClient->callApi( 896 | $resourcePath, $method, 897 | $queryParams, $httpBody, 898 | $headerParams, '\Khipu\Model\SuccessResponse' 899 | ); 900 | 901 | if (!$response) { 902 | return null; 903 | } 904 | 905 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\SuccessResponse', $httpHeader); 906 | 907 | } catch (ApiException $e) { 908 | switch ($e->getCode()) { 909 | case 200: 910 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\SuccessResponse', $e->getResponseHeaders()); 911 | $e->setResponseObject($data); 912 | break; 913 | case 400: 914 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 915 | $e->setResponseObject($data); 916 | break; 917 | case 403: 918 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 919 | $e->setResponseObject($data); 920 | break; 921 | case 503: 922 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 923 | $e->setResponseObject($data); 924 | break; 925 | } 926 | 927 | throw $e; 928 | } 929 | 930 | return null; 931 | 932 | } 933 | 934 | /** 935 | * paymentsIdRefundsPost 936 | * 937 | * Reembolsar total o parcialmente un pago 938 | * 939 | * @param string $id Identificador del pago (requerido) 940 | * @param array $options Arreglo de par��metros opcionales (opcional) 941 | * - double 'amount' El monto a devolver. Sin separador de miles y usando '.' como separador de decimales. Hasta 4 lugares decimales, dependiendo de la moneda. Si se omite el reembolso se hará por el total del monto del pago. (opcional) 942 | * @return \Khipu\Model\SuccessResponse 943 | * @throws \Khipu\ApiException on non-2xx response 944 | */ 945 | public function paymentsIdRefundsPost($id, $options = null) 946 | { 947 | 948 | // verify the required parameter 'id' is set 949 | if ($id === null) { 950 | throw new \InvalidArgumentException('Missing the required parameter $id when calling paymentsIdRefundsPost'); 951 | } 952 | 953 | // parse inputs 954 | $resourcePath = "/payments/{id}/refunds"; 955 | $resourcePath = str_replace("{format}", "json", $resourcePath); 956 | $method = "POST"; 957 | $httpBody = ''; 958 | $queryParams = array(); 959 | $headerParams = array(); 960 | $formParams = array(); 961 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 962 | if (!is_null($_header_accept)) { 963 | $headerParams['Accept'] = $_header_accept; 964 | } 965 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 966 | 967 | 968 | 969 | if( $options != null ) { 970 | 971 | } 972 | 973 | 974 | 975 | 976 | if( $options != null ) { 977 | 978 | } 979 | 980 | 981 | // path params 982 | $resourcePath = str_replace( 983 | "{" . "id" . "}", 984 | $this->apiClient->getSerializer()->toPathValue($id), 985 | $resourcePath 986 | ); 987 | 988 | 989 | if( $options != null ) { 990 | 991 | } 992 | 993 | 994 | 995 | if( $options != null ) { 996 | // form params 997 | if (array_key_exists("amount", $options) && $options["amount"] != null) { 998 | $formParams['amount'] = $this->apiClient->getSerializer()->toFormValue($options["amount"]); 999 | } 1000 | } 1001 | 1002 | 1003 | 1004 | if( $options != null ) { 1005 | 1006 | } 1007 | 1008 | // for model (json/xml) 1009 | if (isset($_tempBody)) { 1010 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 1011 | } else if (count($formParams) > 0) { 1012 | $httpBody = $formParams; // for HTTP post (form) 1013 | } 1014 | 1015 | 1016 | 1017 | 1018 | $encoded = array(); 1019 | 1020 | foreach ($formParams as $key => $value) { 1021 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 1022 | } 1023 | foreach ($queryParams as $key => $value) { 1024 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 1025 | } 1026 | 1027 | $keys = array_keys($encoded); 1028 | sort($keys); 1029 | 1030 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 1031 | 1032 | $toSign = "$method&" . rawurlencode($url); 1033 | foreach ($keys as $key) { 1034 | $toSign .= "&$key=" . $encoded[$key]; 1035 | } 1036 | if (isset($_tempBody)){ 1037 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 1038 | $toSign .="&".$json_body; 1039 | } 1040 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 1041 | 1042 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 1043 | 1044 | 1045 | 1046 | // make the API Call 1047 | try 1048 | { 1049 | list($response, $httpHeader) = $this->apiClient->callApi( 1050 | $resourcePath, $method, 1051 | $queryParams, $httpBody, 1052 | $headerParams, '\Khipu\Model\SuccessResponse' 1053 | ); 1054 | 1055 | if (!$response) { 1056 | return null; 1057 | } 1058 | 1059 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\SuccessResponse', $httpHeader); 1060 | 1061 | } catch (ApiException $e) { 1062 | switch ($e->getCode()) { 1063 | case 200: 1064 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\SuccessResponse', $e->getResponseHeaders()); 1065 | $e->setResponseObject($data); 1066 | break; 1067 | case 400: 1068 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 1069 | $e->setResponseObject($data); 1070 | break; 1071 | case 403: 1072 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 1073 | $e->setResponseObject($data); 1074 | break; 1075 | case 503: 1076 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 1077 | $e->setResponseObject($data); 1078 | break; 1079 | } 1080 | 1081 | throw $e; 1082 | } 1083 | 1084 | return null; 1085 | 1086 | } 1087 | 1088 | } 1089 | -------------------------------------------------------------------------------- /lib/Client/ReceiversApi.php: -------------------------------------------------------------------------------- 1 | getConfig()->setHost('https://khipu.com/api/2.0'); 68 | } 69 | 70 | $this->apiClient = $apiClient; 71 | } 72 | 73 | /** 74 | * Get API client 75 | * @return \Khipu\ApiClient get the API client 76 | */ 77 | public function getApiClient() 78 | { 79 | return $this->apiClient; 80 | } 81 | 82 | /** 83 | * Set the API client 84 | * @param \Khipu\ApiClient $apiClient set the API client 85 | * @return ReceiversApi 86 | */ 87 | public function setApiClient(ApiClient $apiClient) 88 | { 89 | $this->apiClient = $apiClient; 90 | return $this; 91 | } 92 | 93 | 94 | /** 95 | * receiversPost 96 | * 97 | * Crear una nueva cuenta de cobro 98 | * 99 | * @param string $admin_first_name Nombre de pila del administrador de la cuenta de cobro a crear. (requerido) 100 | * @param string $admin_last_name Apellido del administrador de la cuenta de cobro a crear. (requerido) 101 | * @param string $admin_email Correo electrónico del administrador de la cuenta de cobro a crear. (requerido) 102 | * @param string $country_code Código alfanumérico de dos caractéres ISO 3166-1 del país de la cuenta de cobro a crear. (requerido) 103 | * @param string $business_identifier Identificador tributario del cobrador asociado a la cuenta de cobro a crear. (requerido) 104 | * @param string $business_category Categoría tributaria o rubro tributario del cobrador asociado a la cuenta de cobro a crear. (requerido) 105 | * @param string $business_name Nombre tributario del cobrador asociado a la cuenta de cobro a crear. (requerido) 106 | * @param string $business_phone Teléfono del cobrador asociado a la cuenta de cobro a crear. (requerido) 107 | * @param string $business_address_line_1 Dirección del cobrador de la cuenta de cobro a crear. (requerido) 108 | * @param string $business_address_line_2 Segunda línea de la dirección del cobrador de la cuenta de cobro a crear. (requerido) 109 | * @param string $business_address_line_3 Tercera línea de la dirección del cobrador de la cuenta de cobro a crear. (requerido) 110 | * @param string $contact_full_name Nombre del contacto del cobrador. (requerido) 111 | * @param string $contact_job_title Cargo del contacto del cobrador. (requerido) 112 | * @param string $contact_email Correo electrónico del contacto del cobrador. (requerido) 113 | * @param string $contact_phone Teléfono del contacto del cobrador. (requerido) 114 | * @param array $options Arreglo de par��metros opcionales (opcional) 115 | * - string 'bank_account_bank_id' Identificador del banco. (opcional) 116 | * - string 'bank_account_identifier' Identificador personal del dueño de la cuenta de banco. (opcional) 117 | * - string 'bank_account_name' Nombre de la cuenta de banco. (opcional) 118 | * - string 'bank_account_number' Número de la cuenta en el banco. (opcional) 119 | * - string 'notify_url' URL por omisión para el webservice donde se notificará el pago. (opcional) 120 | * - string 'rendition_url' URL para el webservice donde se notificará la rendición. (opcional) 121 | * @return \Khipu\Model\ReceiversCreateResponse 122 | * @throws \Khipu\ApiException on non-2xx response 123 | */ 124 | public function receiversPost($admin_first_name, $admin_last_name, $admin_email, $country_code, $business_identifier, $business_category, $business_name, $business_phone, $business_address_line_1, $business_address_line_2, $business_address_line_3, $contact_full_name, $contact_job_title, $contact_email, $contact_phone, $options = null) 125 | { 126 | 127 | // verify the required parameter 'admin_first_name' is set 128 | if ($admin_first_name === null) { 129 | throw new \InvalidArgumentException('Missing the required parameter $admin_first_name when calling receiversPost'); 130 | } 131 | // verify the required parameter 'admin_last_name' is set 132 | if ($admin_last_name === null) { 133 | throw new \InvalidArgumentException('Missing the required parameter $admin_last_name when calling receiversPost'); 134 | } 135 | // verify the required parameter 'admin_email' is set 136 | if ($admin_email === null) { 137 | throw new \InvalidArgumentException('Missing the required parameter $admin_email when calling receiversPost'); 138 | } 139 | // verify the required parameter 'country_code' is set 140 | if ($country_code === null) { 141 | throw new \InvalidArgumentException('Missing the required parameter $country_code when calling receiversPost'); 142 | } 143 | // verify the required parameter 'business_identifier' is set 144 | if ($business_identifier === null) { 145 | throw new \InvalidArgumentException('Missing the required parameter $business_identifier when calling receiversPost'); 146 | } 147 | // verify the required parameter 'business_category' is set 148 | if ($business_category === null) { 149 | throw new \InvalidArgumentException('Missing the required parameter $business_category when calling receiversPost'); 150 | } 151 | // verify the required parameter 'business_name' is set 152 | if ($business_name === null) { 153 | throw new \InvalidArgumentException('Missing the required parameter $business_name when calling receiversPost'); 154 | } 155 | // verify the required parameter 'business_phone' is set 156 | if ($business_phone === null) { 157 | throw new \InvalidArgumentException('Missing the required parameter $business_phone when calling receiversPost'); 158 | } 159 | // verify the required parameter 'business_address_line_1' is set 160 | if ($business_address_line_1 === null) { 161 | throw new \InvalidArgumentException('Missing the required parameter $business_address_line_1 when calling receiversPost'); 162 | } 163 | // verify the required parameter 'business_address_line_2' is set 164 | if ($business_address_line_2 === null) { 165 | throw new \InvalidArgumentException('Missing the required parameter $business_address_line_2 when calling receiversPost'); 166 | } 167 | // verify the required parameter 'business_address_line_3' is set 168 | if ($business_address_line_3 === null) { 169 | throw new \InvalidArgumentException('Missing the required parameter $business_address_line_3 when calling receiversPost'); 170 | } 171 | // verify the required parameter 'contact_full_name' is set 172 | if ($contact_full_name === null) { 173 | throw new \InvalidArgumentException('Missing the required parameter $contact_full_name when calling receiversPost'); 174 | } 175 | // verify the required parameter 'contact_job_title' is set 176 | if ($contact_job_title === null) { 177 | throw new \InvalidArgumentException('Missing the required parameter $contact_job_title when calling receiversPost'); 178 | } 179 | // verify the required parameter 'contact_email' is set 180 | if ($contact_email === null) { 181 | throw new \InvalidArgumentException('Missing the required parameter $contact_email when calling receiversPost'); 182 | } 183 | // verify the required parameter 'contact_phone' is set 184 | if ($contact_phone === null) { 185 | throw new \InvalidArgumentException('Missing the required parameter $contact_phone when calling receiversPost'); 186 | } 187 | 188 | // parse inputs 189 | $resourcePath = "/receivers"; 190 | $resourcePath = str_replace("{format}", "json", $resourcePath); 191 | $method = "POST"; 192 | $httpBody = ''; 193 | $queryParams = array(); 194 | $headerParams = array(); 195 | $formParams = array(); 196 | $_header_accept = ApiClient::selectHeaderAccept(array('application/json')); 197 | if (!is_null($_header_accept)) { 198 | $headerParams['Accept'] = $_header_accept; 199 | } 200 | $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); 201 | 202 | 203 | 204 | if( $options != null ) { 205 | 206 | } 207 | 208 | 209 | 210 | 211 | if( $options != null ) { 212 | 213 | } 214 | 215 | 216 | 217 | 218 | if( $options != null ) { 219 | 220 | } 221 | 222 | // form params 223 | $formParams['admin_first_name'] = $this->apiClient->getSerializer()->toFormValue($admin_first_name); 224 | // form params 225 | $formParams['admin_last_name'] = $this->apiClient->getSerializer()->toFormValue($admin_last_name); 226 | // form params 227 | $formParams['admin_email'] = $this->apiClient->getSerializer()->toFormValue($admin_email); 228 | // form params 229 | $formParams['country_code'] = $this->apiClient->getSerializer()->toFormValue($country_code); 230 | // form params 231 | $formParams['business_identifier'] = $this->apiClient->getSerializer()->toFormValue($business_identifier); 232 | // form params 233 | $formParams['business_category'] = $this->apiClient->getSerializer()->toFormValue($business_category); 234 | // form params 235 | $formParams['business_name'] = $this->apiClient->getSerializer()->toFormValue($business_name); 236 | // form params 237 | $formParams['business_phone'] = $this->apiClient->getSerializer()->toFormValue($business_phone); 238 | // form params 239 | $formParams['business_address_line_1'] = $this->apiClient->getSerializer()->toFormValue($business_address_line_1); 240 | // form params 241 | $formParams['business_address_line_2'] = $this->apiClient->getSerializer()->toFormValue($business_address_line_2); 242 | // form params 243 | $formParams['business_address_line_3'] = $this->apiClient->getSerializer()->toFormValue($business_address_line_3); 244 | // form params 245 | $formParams['contact_full_name'] = $this->apiClient->getSerializer()->toFormValue($contact_full_name); 246 | // form params 247 | $formParams['contact_job_title'] = $this->apiClient->getSerializer()->toFormValue($contact_job_title); 248 | // form params 249 | $formParams['contact_email'] = $this->apiClient->getSerializer()->toFormValue($contact_email); 250 | // form params 251 | $formParams['contact_phone'] = $this->apiClient->getSerializer()->toFormValue($contact_phone); 252 | 253 | 254 | if( $options != null ) { 255 | // form params 256 | if (array_key_exists("bank_account_bank_id", $options) && $options["bank_account_bank_id"] != null) { 257 | $formParams['bank_account_bank_id'] = $this->apiClient->getSerializer()->toFormValue($options["bank_account_bank_id"]); 258 | }// form params 259 | if (array_key_exists("bank_account_identifier", $options) && $options["bank_account_identifier"] != null) { 260 | $formParams['bank_account_identifier'] = $this->apiClient->getSerializer()->toFormValue($options["bank_account_identifier"]); 261 | }// form params 262 | if (array_key_exists("bank_account_name", $options) && $options["bank_account_name"] != null) { 263 | $formParams['bank_account_name'] = $this->apiClient->getSerializer()->toFormValue($options["bank_account_name"]); 264 | }// form params 265 | if (array_key_exists("bank_account_number", $options) && $options["bank_account_number"] != null) { 266 | $formParams['bank_account_number'] = $this->apiClient->getSerializer()->toFormValue($options["bank_account_number"]); 267 | }// form params 268 | if (array_key_exists("notify_url", $options) && $options["notify_url"] != null) { 269 | $formParams['notify_url'] = $this->apiClient->getSerializer()->toFormValue($options["notify_url"]); 270 | }// form params 271 | if (array_key_exists("rendition_url", $options) && $options["rendition_url"] != null) { 272 | $formParams['rendition_url'] = $this->apiClient->getSerializer()->toFormValue($options["rendition_url"]); 273 | } 274 | } 275 | 276 | 277 | 278 | if( $options != null ) { 279 | 280 | } 281 | 282 | // for model (json/xml) 283 | if (isset($_tempBody)) { 284 | $httpBody = $_tempBody; // $_tempBody is the method argument, if present 285 | } else if (count($formParams) > 0) { 286 | $httpBody = $formParams; // for HTTP post (form) 287 | } 288 | 289 | 290 | 291 | 292 | $encoded = array(); 293 | 294 | foreach ($formParams as $key => $value) { 295 | $encoded[rawurlencode($key)] = rawurlencode($formParams[$key]); 296 | } 297 | foreach ($queryParams as $key => $value) { 298 | $encoded[rawurlencode($key)] = rawurlencode($queryParams[$key]); 299 | } 300 | 301 | $keys = array_keys($encoded); 302 | sort($keys); 303 | 304 | $url = $this->apiClient->getConfig()->getHost() . $resourcePath; 305 | 306 | $toSign = "$method&" . rawurlencode($url); 307 | foreach ($keys as $key) { 308 | $toSign .= "&$key=" . $encoded[$key]; 309 | } 310 | if (isset($_tempBody)){ 311 | $json_body = json_encode($this->apiClient->getSerializer()->sanitizeForSerialization($_tempBody)); 312 | $toSign .="&".$json_body; 313 | } 314 | $hash = hash_hmac('sha256', $toSign , $this->apiClient->getConfig()->getSecret()); //sha1($concatenated . "&secret=" . $secret) . "\n"; 315 | 316 | $headerParams['Authorization'] = $this->apiClient->getConfig()->getReceiverId() . ":" . $hash; 317 | 318 | 319 | 320 | // make the API Call 321 | try 322 | { 323 | list($response, $httpHeader) = $this->apiClient->callApi( 324 | $resourcePath, $method, 325 | $queryParams, $httpBody, 326 | $headerParams, '\Khipu\Model\ReceiversCreateResponse' 327 | ); 328 | 329 | if (!$response) { 330 | return null; 331 | } 332 | 333 | return $this->apiClient->getSerializer()->deserialize($response, '\Khipu\Model\ReceiversCreateResponse', $httpHeader); 334 | 335 | } catch (ApiException $e) { 336 | switch ($e->getCode()) { 337 | case 200: 338 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ReceiversCreateResponse', $e->getResponseHeaders()); 339 | $e->setResponseObject($data); 340 | break; 341 | case 400: 342 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ValidationError', $e->getResponseHeaders()); 343 | $e->setResponseObject($data); 344 | break; 345 | case 403: 346 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\AuthorizationError', $e->getResponseHeaders()); 347 | $e->setResponseObject($data); 348 | break; 349 | case 503: 350 | $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Khipu\Model\ServiceError', $e->getResponseHeaders()); 351 | $e->setResponseObject($data); 352 | break; 353 | } 354 | 355 | throw $e; 356 | } 357 | 358 | return null; 359 | 360 | } 361 | 362 | } 363 | -------------------------------------------------------------------------------- /lib/Configuration.php: -------------------------------------------------------------------------------- 1 | tempFolderPath = sys_get_temp_dir(); 147 | } 148 | 149 | /** 150 | * Sets API key 151 | * 152 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) 153 | * @param string $key API key or token 154 | * 155 | * @return Configuration 156 | */ 157 | public function setApiKey($apiKeyIdentifier, $key) 158 | { 159 | $this->apiKeys[$apiKeyIdentifier] = $key; 160 | return $this; 161 | } 162 | 163 | public function setReceiverId($receiverId) 164 | { 165 | $this->receiverId = $receiverId; 166 | return $this; 167 | } 168 | 169 | public function setSecret($secret) 170 | { 171 | $this->secret = $secret; 172 | return $this; 173 | } 174 | 175 | public function getReceiverId() { 176 | return $this->receiverId; 177 | } 178 | 179 | public function getSecret() { 180 | return $this->secret; 181 | } 182 | 183 | /** 184 | * Gets API key 185 | * 186 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) 187 | * 188 | * @return string API key or token 189 | */ 190 | public function getApiKey($apiKeyIdentifier) 191 | { 192 | return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; 193 | } 194 | 195 | /** 196 | * Sets the prefix for API key (e.g. Bearer) 197 | * 198 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) 199 | * @param string $prefix API key prefix, e.g. Bearer 200 | * 201 | * @return Configuration 202 | */ 203 | public function setApiKeyPrefix($apiKeyIdentifier, $prefix) 204 | { 205 | $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; 206 | return $this; 207 | } 208 | 209 | /** 210 | * Gets API key prefix 211 | * 212 | * @param string $apiKeyIdentifier API key identifier (authentication scheme) 213 | * 214 | * @return string 215 | */ 216 | public function getApiKeyPrefix($apiKeyIdentifier) 217 | { 218 | return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; 219 | } 220 | 221 | /** 222 | * Sets the username for HTTP basic authentication 223 | * 224 | * @param string $username Username for HTTP basic authentication 225 | * 226 | * @return Configuration 227 | */ 228 | public function setUsername($username) 229 | { 230 | $this->username = $username; 231 | return $this; 232 | } 233 | 234 | /** 235 | * Gets the username for HTTP basic authentication 236 | * 237 | * @return string Username for HTTP basic authentication 238 | */ 239 | public function getUsername() 240 | { 241 | return $this->username; 242 | } 243 | 244 | /** 245 | * Sets the password for HTTP basic authentication 246 | * 247 | * @param string $password Password for HTTP basic authentication 248 | * 249 | * @return Configuration 250 | */ 251 | public function setPassword($password) 252 | { 253 | $this->password = $password; 254 | return $this; 255 | } 256 | 257 | /** 258 | * Gets the password for HTTP basic authentication 259 | * 260 | * @return string Password for HTTP basic authentication 261 | */ 262 | public function getPassword() 263 | { 264 | return $this->password; 265 | } 266 | 267 | /** 268 | * Adds a default header 269 | * 270 | * @param string $headerName header name (e.g. Token) 271 | * @param string $headerValue header value (e.g. 1z8wp3) 272 | * 273 | * @return ApiClient 274 | */ 275 | public function addDefaultHeader($headerName, $headerValue) 276 | { 277 | if (!is_string($headerName)) { 278 | throw new \InvalidArgumentException('Header name must be a string.'); 279 | } 280 | 281 | $this->defaultHeaders[$headerName] = $headerValue; 282 | return $this; 283 | } 284 | 285 | /** 286 | * Gets the default header 287 | * 288 | * @return array An array of default header(s) 289 | */ 290 | public function getDefaultHeaders() 291 | { 292 | return $this->defaultHeaders; 293 | } 294 | 295 | /** 296 | * Deletes a default header 297 | * 298 | * @param string $headerName the header to delete 299 | * 300 | * @return Configuration 301 | */ 302 | public function deleteDefaultHeader($headerName) 303 | { 304 | unset($this->defaultHeaders[$headerName]); 305 | } 306 | 307 | /** 308 | * Sets the host 309 | * 310 | * @param string $host Host 311 | * 312 | * @return Configuration 313 | */ 314 | public function setHost($host) 315 | { 316 | $this->host = $host; 317 | return $this; 318 | } 319 | 320 | /** 321 | * Gets the host 322 | * 323 | * @return string Host 324 | */ 325 | public function getHost() 326 | { 327 | return $this->host; 328 | } 329 | 330 | /** 331 | * Sets the user agent of the api client 332 | * 333 | * @param string $userAgent the user agent of the api client 334 | * 335 | * @return ApiClient 336 | */ 337 | public function setUserAgent($userAgent) 338 | { 339 | if (!is_string($userAgent)) { 340 | throw new \InvalidArgumentException('User-agent must be a string.'); 341 | } 342 | 343 | $this->userAgent = $userAgent; 344 | return $this; 345 | } 346 | 347 | public function setPlatform($name, $version) 348 | { 349 | $this->userAgent = "khipu-api-php-client/1.0.0|".$name."/".$version; 350 | } 351 | 352 | /** 353 | * Gets the user agent of the api client 354 | * 355 | * @return string user agent 356 | */ 357 | public function getUserAgent() 358 | { 359 | return $this->userAgent; 360 | } 361 | 362 | /** 363 | * Sets the HTTP timeout value 364 | * 365 | * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] 366 | * 367 | * @return ApiClient 368 | */ 369 | public function setCurlTimeout($seconds) 370 | { 371 | if (!is_numeric($seconds) || $seconds < 0) { 372 | throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); 373 | } 374 | 375 | $this->curlTimeout = $seconds; 376 | return $this; 377 | } 378 | 379 | /** 380 | * Gets the HTTP timeout value 381 | * 382 | * @return string HTTP timeout value 383 | */ 384 | public function getCurlTimeout() 385 | { 386 | return $this->curlTimeout; 387 | } 388 | 389 | /** 390 | * Sets debug flag 391 | * 392 | * @param bool $debug Debug flag 393 | * 394 | * @return Configuration 395 | */ 396 | public function setDebug($debug) 397 | { 398 | $this->debug = $debug; 399 | return $this; 400 | } 401 | 402 | /** 403 | * Gets the debug flag 404 | * 405 | * @return bool 406 | */ 407 | public function getDebug() 408 | { 409 | return $this->debug; 410 | } 411 | 412 | /** 413 | * Sets the debug file 414 | * 415 | * @param string $debugFile Debug file 416 | * 417 | * @return Configuration 418 | */ 419 | public function setDebugFile($debugFile) 420 | { 421 | $this->debugFile = $debugFile; 422 | return $this; 423 | } 424 | 425 | /** 426 | * Gets the debug file 427 | * 428 | * @return string 429 | */ 430 | public function getDebugFile() 431 | { 432 | return $this->debugFile; 433 | } 434 | 435 | /** 436 | * Sets the temp folder path 437 | * 438 | * @param string $tempFolderPath Temp folder path 439 | * 440 | * @return Configuration 441 | */ 442 | public function setTempFolderPath($tempFolderPath) 443 | { 444 | $this->tempFolderPath = $tempFolderPath; 445 | return $this; 446 | } 447 | 448 | /** 449 | * Gets the temp folder path 450 | * 451 | * @return string Temp folder path 452 | */ 453 | public function getTempFolderPath() 454 | { 455 | return $this->tempFolderPath; 456 | } 457 | 458 | /** 459 | * Sets if SSL verification should be enabled or disabled 460 | * 461 | * @param boolean $sslVerification True if the certificate should be validated, false otherwise 462 | * 463 | * @return Configuration 464 | */ 465 | public function setSSLVerification($sslVerification) 466 | { 467 | $this->sslVerification = $sslVerification; 468 | return $this; 469 | } 470 | 471 | /** 472 | * Gets if SSL verification should be enabled or disabled 473 | * 474 | * @return boolean True if the certificate should be validated, false otherwise 475 | */ 476 | public function getSSLVerification() 477 | { 478 | return $this->sslVerification; 479 | } 480 | 481 | /** 482 | * Gets the default configuration instance 483 | * 484 | * @return Configuration 485 | */ 486 | public static function getDefaultConfiguration() 487 | { 488 | if (self::$_defaultConfiguration == null) { 489 | self::$_defaultConfiguration = new Configuration(); 490 | } 491 | 492 | return self::$_defaultConfiguration; 493 | } 494 | 495 | /** 496 | * Sets the detault configuration instance 497 | * 498 | * @param Configuration $config An instance of the Configuration Object 499 | * 500 | * @return void 501 | */ 502 | public static function setDefaultConfiguration(Configuration $config) 503 | { 504 | self::$_defaultConfiguration = $config; 505 | } 506 | 507 | /** 508 | * Gets the essential information for debugging 509 | * 510 | * @return string The report for debugging 511 | */ 512 | public static function toDebugReport() 513 | { 514 | $report = "PHP SDK (Khipu) Debug Report:\n"; 515 | $report .= " OS: ".php_uname()."\n"; 516 | $report .= " PHP Version: ".phpversion()."\n"; 517 | $report .= " Swagger Spec Version: 2.9.1\n"; 518 | $report .= " SDK Package Version: 1.0.0\n"; 519 | $report .= " Temp Folder Path: ".self::getDefaultConfiguration()->getTempFolderPath()."\n"; 520 | 521 | return $report; 522 | } 523 | 524 | } 525 | -------------------------------------------------------------------------------- /lib/Model/AuthorizationError.php: -------------------------------------------------------------------------------- 1 | 'int', 55 | 'message' => 'string' 56 | ); 57 | 58 | /** 59 | * Array of attributes where the key is the local name, and the value is the original name 60 | * @var string[] 61 | */ 62 | static $attributeMap = array( 63 | 'status' => 'status', 64 | 'message' => 'message' 65 | ); 66 | 67 | /** 68 | * Array of attributes to setter functions (for deserialization of responses) 69 | * @var string[] 70 | */ 71 | static $setters = array( 72 | 'status' => 'setStatus', 73 | 'message' => 'setMessage' 74 | ); 75 | 76 | /** 77 | * Array of attributes to getter functions (for serialization of requests) 78 | * @var string[] 79 | */ 80 | static $getters = array( 81 | 'status' => 'getStatus', 82 | 'message' => 'getMessage' 83 | ); 84 | 85 | 86 | /** 87 | * $status Código del error 88 | * @var int 89 | */ 90 | protected $status; 91 | 92 | /** 93 | * $message Mensaje del error 94 | * @var string 95 | */ 96 | protected $message; 97 | 98 | 99 | /** 100 | * Constructor 101 | * @param mixed[] $data Associated array of property value initalizing the model 102 | */ 103 | public function __construct(array $data = null) 104 | { 105 | if ($data != null) { 106 | $this->status = $data["status"]; 107 | $this->message = $data["message"]; 108 | } 109 | } 110 | 111 | /** 112 | * Gets status 113 | * @return int 114 | */ 115 | public function getStatus() 116 | { 117 | return $this->status; 118 | } 119 | 120 | /** 121 | * Sets status 122 | * @param int $status Código del error 123 | * @return $this 124 | */ 125 | public function setStatus($status) 126 | { 127 | 128 | $this->status = $status; 129 | return $this; 130 | } 131 | 132 | /** 133 | * Gets message 134 | * @return string 135 | */ 136 | public function getMessage() 137 | { 138 | return $this->message; 139 | } 140 | 141 | /** 142 | * Sets message 143 | * @param string $message Mensaje del error 144 | * @return $this 145 | */ 146 | public function setMessage($message) 147 | { 148 | 149 | $this->message = $message; 150 | return $this; 151 | } 152 | 153 | /** 154 | * Returns true if offset exists. False otherwise. 155 | * @param integer $offset Offset 156 | * @return boolean 157 | */ 158 | public function offsetExists($offset) 159 | { 160 | return isset($this->$offset); 161 | } 162 | 163 | /** 164 | * Gets offset. 165 | * @param integer $offset Offset 166 | * @return mixed 167 | */ 168 | public function offsetGet($offset) 169 | { 170 | return $this->$offset; 171 | } 172 | 173 | /** 174 | * Sets value based on offset. 175 | * @param integer $offset Offset 176 | * @param mixed $value Value to be set 177 | * @return void 178 | */ 179 | public function offsetSet($offset, $value) 180 | { 181 | $this->$offset = $value; 182 | } 183 | 184 | /** 185 | * Unsets offset. 186 | * @param integer $offset Offset 187 | * @return void 188 | */ 189 | public function offsetUnset($offset) 190 | { 191 | unset($this->$offset); 192 | } 193 | 194 | /** 195 | * Gets the string presentation of the object 196 | * @return string 197 | */ 198 | public function __toString() 199 | { 200 | if (defined('JSON_PRETTY_PRINT')) { 201 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 202 | } else { 203 | return json_encode(get_object_vars($this)); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/Model/BankItem.php: -------------------------------------------------------------------------------- 1 | 'string', 55 | 'name' => 'string', 56 | 'message' => 'string', 57 | 'min_amount' => 'double', 58 | 'type' => 'string', 59 | 'parent' => 'string' 60 | ); 61 | 62 | /** 63 | * Array of attributes where the key is the local name, and the value is the original name 64 | * @var string[] 65 | */ 66 | static $attributeMap = array( 67 | 'bank_id' => 'bank_id', 68 | 'name' => 'name', 69 | 'message' => 'message', 70 | 'min_amount' => 'min_amount', 71 | 'type' => 'type', 72 | 'parent' => 'parent' 73 | ); 74 | 75 | /** 76 | * Array of attributes to setter functions (for deserialization of responses) 77 | * @var string[] 78 | */ 79 | static $setters = array( 80 | 'bank_id' => 'setBankId', 81 | 'name' => 'setName', 82 | 'message' => 'setMessage', 83 | 'min_amount' => 'setMinAmount', 84 | 'type' => 'setType', 85 | 'parent' => 'setParent' 86 | ); 87 | 88 | /** 89 | * Array of attributes to getter functions (for serialization of requests) 90 | * @var string[] 91 | */ 92 | static $getters = array( 93 | 'bank_id' => 'getBankId', 94 | 'name' => 'getName', 95 | 'message' => 'getMessage', 96 | 'min_amount' => 'getMinAmount', 97 | 'type' => 'getType', 98 | 'parent' => 'getParent' 99 | ); 100 | 101 | 102 | /** 103 | * $bank_id Identificador del banco 104 | * @var string 105 | */ 106 | protected $bank_id; 107 | 108 | /** 109 | * $name Nombre del banco 110 | * @var string 111 | */ 112 | protected $name; 113 | 114 | /** 115 | * $message Mensaje con particularidades del banco 116 | * @var string 117 | */ 118 | protected $message; 119 | 120 | /** 121 | * $min_amount Monto mínimo que acepta el banco en un pago 122 | * @var double 123 | */ 124 | protected $min_amount; 125 | 126 | /** 127 | * $type Tipo de banco 128 | * @var string 129 | */ 130 | protected $type; 131 | 132 | /** 133 | * $parent Identificador del banco padre (si un banco tiene banca personas y empresas, el primero será el padre del segundo) 134 | * @var string 135 | */ 136 | protected $parent; 137 | 138 | 139 | /** 140 | * Constructor 141 | * @param mixed[] $data Associated array of property value initalizing the model 142 | */ 143 | public function __construct(array $data = null) 144 | { 145 | if ($data != null) { 146 | $this->bank_id = $data["bank_id"]; 147 | $this->name = $data["name"]; 148 | $this->message = $data["message"]; 149 | $this->min_amount = $data["min_amount"]; 150 | $this->type = $data["type"]; 151 | $this->parent = $data["parent"]; 152 | } 153 | } 154 | 155 | /** 156 | * Gets bank_id 157 | * @return string 158 | */ 159 | public function getBankId() 160 | { 161 | return $this->bank_id; 162 | } 163 | 164 | /** 165 | * Sets bank_id 166 | * @param string $bank_id Identificador del banco 167 | * @return $this 168 | */ 169 | public function setBankId($bank_id) 170 | { 171 | 172 | $this->bank_id = $bank_id; 173 | return $this; 174 | } 175 | 176 | /** 177 | * Gets name 178 | * @return string 179 | */ 180 | public function getName() 181 | { 182 | return $this->name; 183 | } 184 | 185 | /** 186 | * Sets name 187 | * @param string $name Nombre del banco 188 | * @return $this 189 | */ 190 | public function setName($name) 191 | { 192 | 193 | $this->name = $name; 194 | return $this; 195 | } 196 | 197 | /** 198 | * Gets message 199 | * @return string 200 | */ 201 | public function getMessage() 202 | { 203 | return $this->message; 204 | } 205 | 206 | /** 207 | * Sets message 208 | * @param string $message Mensaje con particularidades del banco 209 | * @return $this 210 | */ 211 | public function setMessage($message) 212 | { 213 | 214 | $this->message = $message; 215 | return $this; 216 | } 217 | 218 | /** 219 | * Gets min_amount 220 | * @return double 221 | */ 222 | public function getMinAmount() 223 | { 224 | return $this->min_amount; 225 | } 226 | 227 | /** 228 | * Sets min_amount 229 | * @param double $min_amount Monto mínimo que acepta el banco en un pago 230 | * @return $this 231 | */ 232 | public function setMinAmount($min_amount) 233 | { 234 | 235 | $this->min_amount = $min_amount; 236 | return $this; 237 | } 238 | 239 | /** 240 | * Gets type 241 | * @return string 242 | */ 243 | public function getType() 244 | { 245 | return $this->type; 246 | } 247 | 248 | /** 249 | * Sets type 250 | * @param string $type Tipo de banco 251 | * @return $this 252 | */ 253 | public function setType($type) 254 | { 255 | 256 | $this->type = $type; 257 | return $this; 258 | } 259 | 260 | /** 261 | * Gets parent 262 | * @return string 263 | */ 264 | public function getParent() 265 | { 266 | return $this->parent; 267 | } 268 | 269 | /** 270 | * Sets parent 271 | * @param string $parent Identificador del banco padre (si un banco tiene banca personas y empresas, el primero será el padre del segundo) 272 | * @return $this 273 | */ 274 | public function setParent($parent) 275 | { 276 | 277 | $this->parent = $parent; 278 | return $this; 279 | } 280 | 281 | /** 282 | * Returns true if offset exists. False otherwise. 283 | * @param integer $offset Offset 284 | * @return boolean 285 | */ 286 | public function offsetExists($offset) 287 | { 288 | return isset($this->$offset); 289 | } 290 | 291 | /** 292 | * Gets offset. 293 | * @param integer $offset Offset 294 | * @return mixed 295 | */ 296 | public function offsetGet($offset) 297 | { 298 | return $this->$offset; 299 | } 300 | 301 | /** 302 | * Sets value based on offset. 303 | * @param integer $offset Offset 304 | * @param mixed $value Value to be set 305 | * @return void 306 | */ 307 | public function offsetSet($offset, $value) 308 | { 309 | $this->$offset = $value; 310 | } 311 | 312 | /** 313 | * Unsets offset. 314 | * @param integer $offset Offset 315 | * @return void 316 | */ 317 | public function offsetUnset($offset) 318 | { 319 | unset($this->$offset); 320 | } 321 | 322 | /** 323 | * Gets the string presentation of the object 324 | * @return string 325 | */ 326 | public function __toString() 327 | { 328 | if (defined('JSON_PRETTY_PRINT')) { 329 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 330 | } else { 331 | return json_encode(get_object_vars($this)); 332 | } 333 | } 334 | } 335 | -------------------------------------------------------------------------------- /lib/Model/BanksResponse.php: -------------------------------------------------------------------------------- 1 | '\Khipu\Model\BankItem[]' 55 | ); 56 | 57 | /** 58 | * Array of attributes where the key is the local name, and the value is the original name 59 | * @var string[] 60 | */ 61 | static $attributeMap = array( 62 | 'banks' => 'banks' 63 | ); 64 | 65 | /** 66 | * Array of attributes to setter functions (for deserialization of responses) 67 | * @var string[] 68 | */ 69 | static $setters = array( 70 | 'banks' => 'setBanks' 71 | ); 72 | 73 | /** 74 | * Array of attributes to getter functions (for serialization of requests) 75 | * @var string[] 76 | */ 77 | static $getters = array( 78 | 'banks' => 'getBanks' 79 | ); 80 | 81 | 82 | /** 83 | * $banks 84 | * @var \Khipu\Model\BankItem[] 85 | */ 86 | protected $banks; 87 | 88 | 89 | /** 90 | * Constructor 91 | * @param mixed[] $data Associated array of property value initalizing the model 92 | */ 93 | public function __construct(array $data = null) 94 | { 95 | if ($data != null) { 96 | $this->banks = $data["banks"]; 97 | } 98 | } 99 | 100 | /** 101 | * Gets banks 102 | * @return \Khipu\Model\BankItem[] 103 | */ 104 | public function getBanks() 105 | { 106 | return $this->banks; 107 | } 108 | 109 | /** 110 | * Sets banks 111 | * @param \Khipu\Model\BankItem[] $banks 112 | * @return $this 113 | */ 114 | public function setBanks($banks) 115 | { 116 | 117 | $this->banks = $banks; 118 | return $this; 119 | } 120 | 121 | /** 122 | * Returns true if offset exists. False otherwise. 123 | * @param integer $offset Offset 124 | * @return boolean 125 | */ 126 | public function offsetExists($offset) 127 | { 128 | return isset($this->$offset); 129 | } 130 | 131 | /** 132 | * Gets offset. 133 | * @param integer $offset Offset 134 | * @return mixed 135 | */ 136 | public function offsetGet($offset) 137 | { 138 | return $this->$offset; 139 | } 140 | 141 | /** 142 | * Sets value based on offset. 143 | * @param integer $offset Offset 144 | * @param mixed $value Value to be set 145 | * @return void 146 | */ 147 | public function offsetSet($offset, $value) 148 | { 149 | $this->$offset = $value; 150 | } 151 | 152 | /** 153 | * Unsets offset. 154 | * @param integer $offset Offset 155 | * @return void 156 | */ 157 | public function offsetUnset($offset) 158 | { 159 | unset($this->$offset); 160 | } 161 | 162 | /** 163 | * Gets the string presentation of the object 164 | * @return string 165 | */ 166 | public function __toString() 167 | { 168 | if (defined('JSON_PRETTY_PRINT')) { 169 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 170 | } else { 171 | return json_encode(get_object_vars($this)); 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /lib/Model/ErrorItem.php: -------------------------------------------------------------------------------- 1 | 'string', 55 | 'message' => 'string' 56 | ); 57 | 58 | /** 59 | * Array of attributes where the key is the local name, and the value is the original name 60 | * @var string[] 61 | */ 62 | static $attributeMap = array( 63 | 'field' => 'field', 64 | 'message' => 'message' 65 | ); 66 | 67 | /** 68 | * Array of attributes to setter functions (for deserialization of responses) 69 | * @var string[] 70 | */ 71 | static $setters = array( 72 | 'field' => 'setField', 73 | 'message' => 'setMessage' 74 | ); 75 | 76 | /** 77 | * Array of attributes to getter functions (for serialization of requests) 78 | * @var string[] 79 | */ 80 | static $getters = array( 81 | 'field' => 'getField', 82 | 'message' => 'getMessage' 83 | ); 84 | 85 | 86 | /** 87 | * $field Campo que tiene el error de validación 88 | * @var string 89 | */ 90 | protected $field; 91 | 92 | /** 93 | * $message Motivo del error de validación 94 | * @var string 95 | */ 96 | protected $message; 97 | 98 | 99 | /** 100 | * Constructor 101 | * @param mixed[] $data Associated array of property value initalizing the model 102 | */ 103 | public function __construct(array $data = null) 104 | { 105 | if ($data != null) { 106 | $this->field = $data["field"]; 107 | $this->message = $data["message"]; 108 | } 109 | } 110 | 111 | /** 112 | * Gets field 113 | * @return string 114 | */ 115 | public function getField() 116 | { 117 | return $this->field; 118 | } 119 | 120 | /** 121 | * Sets field 122 | * @param string $field Campo que tiene el error de validación 123 | * @return $this 124 | */ 125 | public function setField($field) 126 | { 127 | 128 | $this->field = $field; 129 | return $this; 130 | } 131 | 132 | /** 133 | * Gets message 134 | * @return string 135 | */ 136 | public function getMessage() 137 | { 138 | return $this->message; 139 | } 140 | 141 | /** 142 | * Sets message 143 | * @param string $message Motivo del error de validación 144 | * @return $this 145 | */ 146 | public function setMessage($message) 147 | { 148 | 149 | $this->message = $message; 150 | return $this; 151 | } 152 | 153 | /** 154 | * Returns true if offset exists. False otherwise. 155 | * @param integer $offset Offset 156 | * @return boolean 157 | */ 158 | public function offsetExists($offset) 159 | { 160 | return isset($this->$offset); 161 | } 162 | 163 | /** 164 | * Gets offset. 165 | * @param integer $offset Offset 166 | * @return mixed 167 | */ 168 | public function offsetGet($offset) 169 | { 170 | return $this->$offset; 171 | } 172 | 173 | /** 174 | * Sets value based on offset. 175 | * @param integer $offset Offset 176 | * @param mixed $value Value to be set 177 | * @return void 178 | */ 179 | public function offsetSet($offset, $value) 180 | { 181 | $this->$offset = $value; 182 | } 183 | 184 | /** 185 | * Unsets offset. 186 | * @param integer $offset Offset 187 | * @return void 188 | */ 189 | public function offsetUnset($offset) 190 | { 191 | unset($this->$offset); 192 | } 193 | 194 | /** 195 | * Gets the string presentation of the object 196 | * @return string 197 | */ 198 | public function __toString() 199 | { 200 | if (defined('JSON_PRETTY_PRINT')) { 201 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 202 | } else { 203 | return json_encode(get_object_vars($this)); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/Model/PaymentMethodItem.php: -------------------------------------------------------------------------------- 1 | 'string', 55 | 'name' => 'string', 56 | 'logo_url' => 'string' 57 | ); 58 | 59 | /** 60 | * Array of attributes where the key is the local name, and the value is the original name 61 | * @var string[] 62 | */ 63 | static $attributeMap = array( 64 | 'id' => 'id', 65 | 'name' => 'name', 66 | 'logo_url' => 'logo_url' 67 | ); 68 | 69 | /** 70 | * Array of attributes to setter functions (for deserialization of responses) 71 | * @var string[] 72 | */ 73 | static $setters = array( 74 | 'id' => 'setId', 75 | 'name' => 'setName', 76 | 'logo_url' => 'setLogoUrl' 77 | ); 78 | 79 | /** 80 | * Array of attributes to getter functions (for serialization of requests) 81 | * @var string[] 82 | */ 83 | static $getters = array( 84 | 'id' => 'getId', 85 | 'name' => 'getName', 86 | 'logo_url' => 'getLogoUrl' 87 | ); 88 | 89 | 90 | /** 91 | * $id Identificador del medio de pago 92 | * @var string 93 | */ 94 | protected $id; 95 | 96 | /** 97 | * $name Nombre del medio de pago 98 | * @var string 99 | */ 100 | protected $name; 101 | 102 | /** 103 | * $logo_url URL del logo sugerido para mostrar 104 | * @var string 105 | */ 106 | protected $logo_url; 107 | 108 | 109 | /** 110 | * Constructor 111 | * @param mixed[] $data Associated array of property value initalizing the model 112 | */ 113 | public function __construct(array $data = null) 114 | { 115 | if ($data != null) { 116 | $this->id = $data["id"]; 117 | $this->name = $data["name"]; 118 | $this->logo_url = $data["logo_url"]; 119 | } 120 | } 121 | 122 | /** 123 | * Gets id 124 | * @return string 125 | */ 126 | public function getId() 127 | { 128 | return $this->id; 129 | } 130 | 131 | /** 132 | * Sets id 133 | * @param string $id Identificador del medio de pago 134 | * @return $this 135 | */ 136 | public function setId($id) 137 | { 138 | 139 | $this->id = $id; 140 | return $this; 141 | } 142 | 143 | /** 144 | * Gets name 145 | * @return string 146 | */ 147 | public function getName() 148 | { 149 | return $this->name; 150 | } 151 | 152 | /** 153 | * Sets name 154 | * @param string $name Nombre del medio de pago 155 | * @return $this 156 | */ 157 | public function setName($name) 158 | { 159 | 160 | $this->name = $name; 161 | return $this; 162 | } 163 | 164 | /** 165 | * Gets logo_url 166 | * @return string 167 | */ 168 | public function getLogoUrl() 169 | { 170 | return $this->logo_url; 171 | } 172 | 173 | /** 174 | * Sets logo_url 175 | * @param string $logo_url URL del logo sugerido para mostrar 176 | * @return $this 177 | */ 178 | public function setLogoUrl($logo_url) 179 | { 180 | 181 | $this->logo_url = $logo_url; 182 | return $this; 183 | } 184 | 185 | /** 186 | * Returns true if offset exists. False otherwise. 187 | * @param integer $offset Offset 188 | * @return boolean 189 | */ 190 | public function offsetExists($offset) 191 | { 192 | return isset($this->$offset); 193 | } 194 | 195 | /** 196 | * Gets offset. 197 | * @param integer $offset Offset 198 | * @return mixed 199 | */ 200 | public function offsetGet($offset) 201 | { 202 | return $this->$offset; 203 | } 204 | 205 | /** 206 | * Sets value based on offset. 207 | * @param integer $offset Offset 208 | * @param mixed $value Value to be set 209 | * @return void 210 | */ 211 | public function offsetSet($offset, $value) 212 | { 213 | $this->$offset = $value; 214 | } 215 | 216 | /** 217 | * Unsets offset. 218 | * @param integer $offset Offset 219 | * @return void 220 | */ 221 | public function offsetUnset($offset) 222 | { 223 | unset($this->$offset); 224 | } 225 | 226 | /** 227 | * Gets the string presentation of the object 228 | * @return string 229 | */ 230 | public function __toString() 231 | { 232 | if (defined('JSON_PRETTY_PRINT')) { 233 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 234 | } else { 235 | return json_encode(get_object_vars($this)); 236 | } 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /lib/Model/PaymentMethodsResponse.php: -------------------------------------------------------------------------------- 1 | '\Khipu\Model\PaymentMethodItem[]' 55 | ); 56 | 57 | /** 58 | * Array of attributes where the key is the local name, and the value is the original name 59 | * @var string[] 60 | */ 61 | static $attributeMap = array( 62 | 'payment_methods' => 'paymentMethods' 63 | ); 64 | 65 | /** 66 | * Array of attributes to setter functions (for deserialization of responses) 67 | * @var string[] 68 | */ 69 | static $setters = array( 70 | 'payment_methods' => 'setPaymentMethods' 71 | ); 72 | 73 | /** 74 | * Array of attributes to getter functions (for serialization of requests) 75 | * @var string[] 76 | */ 77 | static $getters = array( 78 | 'payment_methods' => 'getPaymentMethods' 79 | ); 80 | 81 | 82 | /** 83 | * $payment_methods 84 | * @var \Khipu\Model\PaymentMethodItem[] 85 | */ 86 | protected $payment_methods; 87 | 88 | 89 | /** 90 | * Constructor 91 | * @param mixed[] $data Associated array of property value initalizing the model 92 | */ 93 | public function __construct(array $data = null) 94 | { 95 | if ($data != null) { 96 | $this->payment_methods = $data["payment_methods"]; 97 | } 98 | } 99 | 100 | /** 101 | * Gets payment_methods 102 | * @return \Khipu\Model\PaymentMethodItem[] 103 | */ 104 | public function getPaymentMethods() 105 | { 106 | return $this->payment_methods; 107 | } 108 | 109 | /** 110 | * Sets payment_methods 111 | * @param \Khipu\Model\PaymentMethodItem[] $payment_methods 112 | * @return $this 113 | */ 114 | public function setPaymentMethods($payment_methods) 115 | { 116 | 117 | $this->payment_methods = $payment_methods; 118 | return $this; 119 | } 120 | 121 | /** 122 | * Returns true if offset exists. False otherwise. 123 | * @param integer $offset Offset 124 | * @return boolean 125 | */ 126 | public function offsetExists($offset) 127 | { 128 | return isset($this->$offset); 129 | } 130 | 131 | /** 132 | * Gets offset. 133 | * @param integer $offset Offset 134 | * @return mixed 135 | */ 136 | public function offsetGet($offset) 137 | { 138 | return $this->$offset; 139 | } 140 | 141 | /** 142 | * Sets value based on offset. 143 | * @param integer $offset Offset 144 | * @param mixed $value Value to be set 145 | * @return void 146 | */ 147 | public function offsetSet($offset, $value) 148 | { 149 | $this->$offset = $value; 150 | } 151 | 152 | /** 153 | * Unsets offset. 154 | * @param integer $offset Offset 155 | * @return void 156 | */ 157 | public function offsetUnset($offset) 158 | { 159 | unset($this->$offset); 160 | } 161 | 162 | /** 163 | * Gets the string presentation of the object 164 | * @return string 165 | */ 166 | public function __toString() 167 | { 168 | if (defined('JSON_PRETTY_PRINT')) { 169 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 170 | } else { 171 | return json_encode(get_object_vars($this)); 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /lib/Model/PaymentsCreateResponse.php: -------------------------------------------------------------------------------- 1 | 'string', 55 | 'payment_url' => 'string', 56 | 'simplified_transfer_url' => 'string', 57 | 'transfer_url' => 'string', 58 | 'webpay_url' => 'string', 59 | 'hites_url' => 'string', 60 | 'payme_url' => 'string', 61 | 'app_url' => 'string', 62 | 'ready_for_terminal' => 'bool' 63 | ); 64 | 65 | /** 66 | * Array of attributes where the key is the local name, and the value is the original name 67 | * @var string[] 68 | */ 69 | static $attributeMap = array( 70 | 'payment_id' => 'payment_id', 71 | 'payment_url' => 'payment_url', 72 | 'simplified_transfer_url' => 'simplified_transfer_url', 73 | 'transfer_url' => 'transfer_url', 74 | 'webpay_url' => 'webpay_url', 75 | 'hites_url' => 'hites_url', 76 | 'payme_url' => 'payme_url', 77 | 'app_url' => 'app_url', 78 | 'ready_for_terminal' => 'ready_for_terminal' 79 | ); 80 | 81 | /** 82 | * Array of attributes to setter functions (for deserialization of responses) 83 | * @var string[] 84 | */ 85 | static $setters = array( 86 | 'payment_id' => 'setPaymentId', 87 | 'payment_url' => 'setPaymentUrl', 88 | 'simplified_transfer_url' => 'setSimplifiedTransferUrl', 89 | 'transfer_url' => 'setTransferUrl', 90 | 'webpay_url' => 'setWebpayUrl', 91 | 'hites_url' => 'setHitesUrl', 92 | 'payme_url' => 'setPaymeUrl', 93 | 'app_url' => 'setAppUrl', 94 | 'ready_for_terminal' => 'setReadyForTerminal' 95 | ); 96 | 97 | /** 98 | * Array of attributes to getter functions (for serialization of requests) 99 | * @var string[] 100 | */ 101 | static $getters = array( 102 | 'payment_id' => 'getPaymentId', 103 | 'payment_url' => 'getPaymentUrl', 104 | 'simplified_transfer_url' => 'getSimplifiedTransferUrl', 105 | 'transfer_url' => 'getTransferUrl', 106 | 'webpay_url' => 'getWebpayUrl', 107 | 'hites_url' => 'getHitesUrl', 108 | 'payme_url' => 'getPaymeUrl', 109 | 'app_url' => 'getAppUrl', 110 | 'ready_for_terminal' => 'getReadyForTerminal' 111 | ); 112 | 113 | 114 | /** 115 | * $payment_id Identificador único del pago, es una cadena alfanumérica de 12 caracteres. Cómo este identificador es único, se puede usar, por ejemplo, para evitar procesar una notificación repetida. (Khipu espera un código 200 al notificar un pago, si esto no ocurre se reintenta hasta por dos días). 116 | * @var string 117 | */ 118 | protected $payment_id; 119 | 120 | /** 121 | * $payment_url URL principal del pago, si el usuario no ha elegido previamente un método de pago se le muestran las opciones 122 | * @var string 123 | */ 124 | protected $payment_url; 125 | 126 | /** 127 | * $simplified_transfer_url URL de pago simplificado 128 | * @var string 129 | */ 130 | protected $simplified_transfer_url; 131 | 132 | /** 133 | * $transfer_url URL de pago normal 134 | * @var string 135 | */ 136 | protected $transfer_url; 137 | 138 | /** 139 | * $webpay_url URL de pago usando Webpay 140 | * @var string 141 | */ 142 | protected $webpay_url; 143 | 144 | /** 145 | * $hites_url URL de pago usando Hites 146 | * @var string 147 | */ 148 | protected $hites_url; 149 | 150 | /** 151 | * $payme_url URL de pago usando Hites 152 | * @var string 153 | */ 154 | protected $payme_url; 155 | 156 | /** 157 | * $app_url URL para invocar el pago desde un dispositivo móvil usando la APP de khipu 158 | * @var string 159 | */ 160 | protected $app_url; 161 | 162 | /** 163 | * $ready_for_terminal Es 'true' si el pago ya cuenta con todos los datos necesarios para abrir directamente la aplicación de pagos khipu 164 | * @var bool 165 | */ 166 | protected $ready_for_terminal; 167 | 168 | 169 | /** 170 | * Constructor 171 | * @param mixed[] $data Associated array of property value initalizing the model 172 | */ 173 | public function __construct(array $data = null) 174 | { 175 | if ($data != null) { 176 | $this->payment_id = $data["payment_id"]; 177 | $this->payment_url = $data["payment_url"]; 178 | $this->simplified_transfer_url = $data["simplified_transfer_url"]; 179 | $this->transfer_url = $data["transfer_url"]; 180 | $this->webpay_url = $data["webpay_url"]; 181 | $this->hites_url = $data["hites_url"]; 182 | $this->payme_url = $data["payme_url"]; 183 | $this->app_url = $data["app_url"]; 184 | $this->ready_for_terminal = $data["ready_for_terminal"]; 185 | } 186 | } 187 | 188 | /** 189 | * Gets payment_id 190 | * @return string 191 | */ 192 | public function getPaymentId() 193 | { 194 | return $this->payment_id; 195 | } 196 | 197 | /** 198 | * Sets payment_id 199 | * @param string $payment_id Identificador único del pago, es una cadena alfanumérica de 12 caracteres. Cómo este identificador es único, se puede usar, por ejemplo, para evitar procesar una notificación repetida. (Khipu espera un código 200 al notificar un pago, si esto no ocurre se reintenta hasta por dos días). 200 | * @return $this 201 | */ 202 | public function setPaymentId($payment_id) 203 | { 204 | 205 | $this->payment_id = $payment_id; 206 | return $this; 207 | } 208 | 209 | /** 210 | * Gets payment_url 211 | * @return string 212 | */ 213 | public function getPaymentUrl() 214 | { 215 | return $this->payment_url; 216 | } 217 | 218 | /** 219 | * Sets payment_url 220 | * @param string $payment_url URL principal del pago, si el usuario no ha elegido previamente un método de pago se le muestran las opciones 221 | * @return $this 222 | */ 223 | public function setPaymentUrl($payment_url) 224 | { 225 | 226 | $this->payment_url = $payment_url; 227 | return $this; 228 | } 229 | 230 | /** 231 | * Gets simplified_transfer_url 232 | * @return string 233 | */ 234 | public function getSimplifiedTransferUrl() 235 | { 236 | return $this->simplified_transfer_url; 237 | } 238 | 239 | /** 240 | * Sets simplified_transfer_url 241 | * @param string $simplified_transfer_url URL de pago simplificado 242 | * @return $this 243 | */ 244 | public function setSimplifiedTransferUrl($simplified_transfer_url) 245 | { 246 | 247 | $this->simplified_transfer_url = $simplified_transfer_url; 248 | return $this; 249 | } 250 | 251 | /** 252 | * Gets transfer_url 253 | * @return string 254 | */ 255 | public function getTransferUrl() 256 | { 257 | return $this->transfer_url; 258 | } 259 | 260 | /** 261 | * Sets transfer_url 262 | * @param string $transfer_url URL de pago normal 263 | * @return $this 264 | */ 265 | public function setTransferUrl($transfer_url) 266 | { 267 | 268 | $this->transfer_url = $transfer_url; 269 | return $this; 270 | } 271 | 272 | /** 273 | * Gets webpay_url 274 | * @return string 275 | */ 276 | public function getWebpayUrl() 277 | { 278 | return $this->webpay_url; 279 | } 280 | 281 | /** 282 | * Sets webpay_url 283 | * @param string $webpay_url URL de pago usando Webpay 284 | * @return $this 285 | */ 286 | public function setWebpayUrl($webpay_url) 287 | { 288 | 289 | $this->webpay_url = $webpay_url; 290 | return $this; 291 | } 292 | 293 | /** 294 | * Gets hites_url 295 | * @return string 296 | */ 297 | public function getHitesUrl() 298 | { 299 | return $this->hites_url; 300 | } 301 | 302 | /** 303 | * Sets hites_url 304 | * @param string $hites_url URL de pago usando Hites 305 | * @return $this 306 | */ 307 | public function setHitesUrl($hites_url) 308 | { 309 | 310 | $this->hites_url = $hites_url; 311 | return $this; 312 | } 313 | 314 | /** 315 | * Gets payme_url 316 | * @return string 317 | */ 318 | public function getPaymeUrl() 319 | { 320 | return $this->payme_url; 321 | } 322 | 323 | /** 324 | * Sets payme_url 325 | * @param string $payme_url URL de pago usando Hites 326 | * @return $this 327 | */ 328 | public function setPaymeUrl($payme_url) 329 | { 330 | 331 | $this->payme_url = $payme_url; 332 | return $this; 333 | } 334 | 335 | /** 336 | * Gets app_url 337 | * @return string 338 | */ 339 | public function getAppUrl() 340 | { 341 | return $this->app_url; 342 | } 343 | 344 | /** 345 | * Sets app_url 346 | * @param string $app_url URL para invocar el pago desde un dispositivo móvil usando la APP de khipu 347 | * @return $this 348 | */ 349 | public function setAppUrl($app_url) 350 | { 351 | 352 | $this->app_url = $app_url; 353 | return $this; 354 | } 355 | 356 | /** 357 | * Gets ready_for_terminal 358 | * @return bool 359 | */ 360 | public function getReadyForTerminal() 361 | { 362 | return $this->ready_for_terminal; 363 | } 364 | 365 | /** 366 | * Sets ready_for_terminal 367 | * @param bool $ready_for_terminal Es 'true' si el pago ya cuenta con todos los datos necesarios para abrir directamente la aplicación de pagos khipu 368 | * @return $this 369 | */ 370 | public function setReadyForTerminal($ready_for_terminal) 371 | { 372 | 373 | $this->ready_for_terminal = $ready_for_terminal; 374 | return $this; 375 | } 376 | 377 | /** 378 | * Returns true if offset exists. False otherwise. 379 | * @param integer $offset Offset 380 | * @return boolean 381 | */ 382 | public function offsetExists($offset) 383 | { 384 | return isset($this->$offset); 385 | } 386 | 387 | /** 388 | * Gets offset. 389 | * @param integer $offset Offset 390 | * @return mixed 391 | */ 392 | public function offsetGet($offset) 393 | { 394 | return $this->$offset; 395 | } 396 | 397 | /** 398 | * Sets value based on offset. 399 | * @param integer $offset Offset 400 | * @param mixed $value Value to be set 401 | * @return void 402 | */ 403 | public function offsetSet($offset, $value) 404 | { 405 | $this->$offset = $value; 406 | } 407 | 408 | /** 409 | * Unsets offset. 410 | * @param integer $offset Offset 411 | * @return void 412 | */ 413 | public function offsetUnset($offset) 414 | { 415 | unset($this->$offset); 416 | } 417 | 418 | /** 419 | * Gets the string presentation of the object 420 | * @return string 421 | */ 422 | public function __toString() 423 | { 424 | if (defined('JSON_PRETTY_PRINT')) { 425 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 426 | } else { 427 | return json_encode(get_object_vars($this)); 428 | } 429 | } 430 | } 431 | -------------------------------------------------------------------------------- /lib/Model/ReceiversCreateResponse.php: -------------------------------------------------------------------------------- 1 | 'string', 55 | 'secret' => 'string' 56 | ); 57 | 58 | /** 59 | * Array of attributes where the key is the local name, and the value is the original name 60 | * @var string[] 61 | */ 62 | static $attributeMap = array( 63 | 'receiver_id' => 'receiver_id', 64 | 'secret' => 'secret' 65 | ); 66 | 67 | /** 68 | * Array of attributes to setter functions (for deserialization of responses) 69 | * @var string[] 70 | */ 71 | static $setters = array( 72 | 'receiver_id' => 'setReceiverId', 73 | 'secret' => 'setSecret' 74 | ); 75 | 76 | /** 77 | * Array of attributes to getter functions (for serialization of requests) 78 | * @var string[] 79 | */ 80 | static $getters = array( 81 | 'receiver_id' => 'getReceiverId', 82 | 'secret' => 'getSecret' 83 | ); 84 | 85 | 86 | /** 87 | * $receiver_id Identificador único de la cuenta de cobro 88 | * @var string 89 | */ 90 | protected $receiver_id; 91 | 92 | /** 93 | * $secret Llave secreta de la cuenta de cobro, se usa para firmar todas las peticiones 94 | * @var string 95 | */ 96 | protected $secret; 97 | 98 | 99 | /** 100 | * Constructor 101 | * @param mixed[] $data Associated array of property value initalizing the model 102 | */ 103 | public function __construct(array $data = null) 104 | { 105 | if ($data != null) { 106 | $this->receiver_id = $data["receiver_id"]; 107 | $this->secret = $data["secret"]; 108 | } 109 | } 110 | 111 | /** 112 | * Gets receiver_id 113 | * @return string 114 | */ 115 | public function getReceiverId() 116 | { 117 | return $this->receiver_id; 118 | } 119 | 120 | /** 121 | * Sets receiver_id 122 | * @param string $receiver_id Identificador único de la cuenta de cobro 123 | * @return $this 124 | */ 125 | public function setReceiverId($receiver_id) 126 | { 127 | 128 | $this->receiver_id = $receiver_id; 129 | return $this; 130 | } 131 | 132 | /** 133 | * Gets secret 134 | * @return string 135 | */ 136 | public function getSecret() 137 | { 138 | return $this->secret; 139 | } 140 | 141 | /** 142 | * Sets secret 143 | * @param string $secret Llave secreta de la cuenta de cobro, se usa para firmar todas las peticiones 144 | * @return $this 145 | */ 146 | public function setSecret($secret) 147 | { 148 | 149 | $this->secret = $secret; 150 | return $this; 151 | } 152 | 153 | /** 154 | * Returns true if offset exists. False otherwise. 155 | * @param integer $offset Offset 156 | * @return boolean 157 | */ 158 | public function offsetExists($offset) 159 | { 160 | return isset($this->$offset); 161 | } 162 | 163 | /** 164 | * Gets offset. 165 | * @param integer $offset Offset 166 | * @return mixed 167 | */ 168 | public function offsetGet($offset) 169 | { 170 | return $this->$offset; 171 | } 172 | 173 | /** 174 | * Sets value based on offset. 175 | * @param integer $offset Offset 176 | * @param mixed $value Value to be set 177 | * @return void 178 | */ 179 | public function offsetSet($offset, $value) 180 | { 181 | $this->$offset = $value; 182 | } 183 | 184 | /** 185 | * Unsets offset. 186 | * @param integer $offset Offset 187 | * @return void 188 | */ 189 | public function offsetUnset($offset) 190 | { 191 | unset($this->$offset); 192 | } 193 | 194 | /** 195 | * Gets the string presentation of the object 196 | * @return string 197 | */ 198 | public function __toString() 199 | { 200 | if (defined('JSON_PRETTY_PRINT')) { 201 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 202 | } else { 203 | return json_encode(get_object_vars($this)); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/Model/ServiceError.php: -------------------------------------------------------------------------------- 1 | 'int', 55 | 'message' => 'string' 56 | ); 57 | 58 | /** 59 | * Array of attributes where the key is the local name, and the value is the original name 60 | * @var string[] 61 | */ 62 | static $attributeMap = array( 63 | 'status' => 'status', 64 | 'message' => 'message' 65 | ); 66 | 67 | /** 68 | * Array of attributes to setter functions (for deserialization of responses) 69 | * @var string[] 70 | */ 71 | static $setters = array( 72 | 'status' => 'setStatus', 73 | 'message' => 'setMessage' 74 | ); 75 | 76 | /** 77 | * Array of attributes to getter functions (for serialization of requests) 78 | * @var string[] 79 | */ 80 | static $getters = array( 81 | 'status' => 'getStatus', 82 | 'message' => 'getMessage' 83 | ); 84 | 85 | 86 | /** 87 | * $status Código del error 88 | * @var int 89 | */ 90 | protected $status; 91 | 92 | /** 93 | * $message Mensaje del error 94 | * @var string 95 | */ 96 | protected $message; 97 | 98 | 99 | /** 100 | * Constructor 101 | * @param mixed[] $data Associated array of property value initalizing the model 102 | */ 103 | public function __construct(array $data = null) 104 | { 105 | if ($data != null) { 106 | $this->status = $data["status"]; 107 | $this->message = $data["message"]; 108 | } 109 | } 110 | 111 | /** 112 | * Gets status 113 | * @return int 114 | */ 115 | public function getStatus() 116 | { 117 | return $this->status; 118 | } 119 | 120 | /** 121 | * Sets status 122 | * @param int $status Código del error 123 | * @return $this 124 | */ 125 | public function setStatus($status) 126 | { 127 | 128 | $this->status = $status; 129 | return $this; 130 | } 131 | 132 | /** 133 | * Gets message 134 | * @return string 135 | */ 136 | public function getMessage() 137 | { 138 | return $this->message; 139 | } 140 | 141 | /** 142 | * Sets message 143 | * @param string $message Mensaje del error 144 | * @return $this 145 | */ 146 | public function setMessage($message) 147 | { 148 | 149 | $this->message = $message; 150 | return $this; 151 | } 152 | 153 | /** 154 | * Returns true if offset exists. False otherwise. 155 | * @param integer $offset Offset 156 | * @return boolean 157 | */ 158 | public function offsetExists($offset) 159 | { 160 | return isset($this->$offset); 161 | } 162 | 163 | /** 164 | * Gets offset. 165 | * @param integer $offset Offset 166 | * @return mixed 167 | */ 168 | public function offsetGet($offset) 169 | { 170 | return $this->$offset; 171 | } 172 | 173 | /** 174 | * Sets value based on offset. 175 | * @param integer $offset Offset 176 | * @param mixed $value Value to be set 177 | * @return void 178 | */ 179 | public function offsetSet($offset, $value) 180 | { 181 | $this->$offset = $value; 182 | } 183 | 184 | /** 185 | * Unsets offset. 186 | * @param integer $offset Offset 187 | * @return void 188 | */ 189 | public function offsetUnset($offset) 190 | { 191 | unset($this->$offset); 192 | } 193 | 194 | /** 195 | * Gets the string presentation of the object 196 | * @return string 197 | */ 198 | public function __toString() 199 | { 200 | if (defined('JSON_PRETTY_PRINT')) { 201 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 202 | } else { 203 | return json_encode(get_object_vars($this)); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /lib/Model/SuccessResponse.php: -------------------------------------------------------------------------------- 1 | 'string' 55 | ); 56 | 57 | /** 58 | * Array of attributes where the key is the local name, and the value is the original name 59 | * @var string[] 60 | */ 61 | static $attributeMap = array( 62 | 'message' => 'message' 63 | ); 64 | 65 | /** 66 | * Array of attributes to setter functions (for deserialization of responses) 67 | * @var string[] 68 | */ 69 | static $setters = array( 70 | 'message' => 'setMessage' 71 | ); 72 | 73 | /** 74 | * Array of attributes to getter functions (for serialization of requests) 75 | * @var string[] 76 | */ 77 | static $getters = array( 78 | 'message' => 'getMessage' 79 | ); 80 | 81 | 82 | /** 83 | * $message Mensaje a desplegar al usuario 84 | * @var string 85 | */ 86 | protected $message; 87 | 88 | 89 | /** 90 | * Constructor 91 | * @param mixed[] $data Associated array of property value initalizing the model 92 | */ 93 | public function __construct(array $data = null) 94 | { 95 | if ($data != null) { 96 | $this->message = $data["message"]; 97 | } 98 | } 99 | 100 | /** 101 | * Gets message 102 | * @return string 103 | */ 104 | public function getMessage() 105 | { 106 | return $this->message; 107 | } 108 | 109 | /** 110 | * Sets message 111 | * @param string $message Mensaje a desplegar al usuario 112 | * @return $this 113 | */ 114 | public function setMessage($message) 115 | { 116 | 117 | $this->message = $message; 118 | return $this; 119 | } 120 | 121 | /** 122 | * Returns true if offset exists. False otherwise. 123 | * @param integer $offset Offset 124 | * @return boolean 125 | */ 126 | public function offsetExists($offset) 127 | { 128 | return isset($this->$offset); 129 | } 130 | 131 | /** 132 | * Gets offset. 133 | * @param integer $offset Offset 134 | * @return mixed 135 | */ 136 | public function offsetGet($offset) 137 | { 138 | return $this->$offset; 139 | } 140 | 141 | /** 142 | * Sets value based on offset. 143 | * @param integer $offset Offset 144 | * @param mixed $value Value to be set 145 | * @return void 146 | */ 147 | public function offsetSet($offset, $value) 148 | { 149 | $this->$offset = $value; 150 | } 151 | 152 | /** 153 | * Unsets offset. 154 | * @param integer $offset Offset 155 | * @return void 156 | */ 157 | public function offsetUnset($offset) 158 | { 159 | unset($this->$offset); 160 | } 161 | 162 | /** 163 | * Gets the string presentation of the object 164 | * @return string 165 | */ 166 | public function __toString() 167 | { 168 | if (defined('JSON_PRETTY_PRINT')) { 169 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 170 | } else { 171 | return json_encode(get_object_vars($this)); 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /lib/Model/ValidationError.php: -------------------------------------------------------------------------------- 1 | 'int', 55 | 'message' => 'string', 56 | 'errors' => '\Khipu\Model\ErrorItem[]' 57 | ); 58 | 59 | /** 60 | * Array of attributes where the key is the local name, and the value is the original name 61 | * @var string[] 62 | */ 63 | static $attributeMap = array( 64 | 'status' => 'status', 65 | 'message' => 'message', 66 | 'errors' => 'errors' 67 | ); 68 | 69 | /** 70 | * Array of attributes to setter functions (for deserialization of responses) 71 | * @var string[] 72 | */ 73 | static $setters = array( 74 | 'status' => 'setStatus', 75 | 'message' => 'setMessage', 76 | 'errors' => 'setErrors' 77 | ); 78 | 79 | /** 80 | * Array of attributes to getter functions (for serialization of requests) 81 | * @var string[] 82 | */ 83 | static $getters = array( 84 | 'status' => 'getStatus', 85 | 'message' => 'getMessage', 86 | 'errors' => 'getErrors' 87 | ); 88 | 89 | 90 | /** 91 | * $status Código del error 92 | * @var int 93 | */ 94 | protected $status; 95 | 96 | /** 97 | * $message Mensaje del error 98 | * @var string 99 | */ 100 | protected $message; 101 | 102 | /** 103 | * $errors 104 | * @var \Khipu\Model\ErrorItem[] 105 | */ 106 | protected $errors; 107 | 108 | 109 | /** 110 | * Constructor 111 | * @param mixed[] $data Associated array of property value initalizing the model 112 | */ 113 | public function __construct(array $data = null) 114 | { 115 | if ($data != null) { 116 | $this->status = $data["status"]; 117 | $this->message = $data["message"]; 118 | $this->errors = $data["errors"]; 119 | } 120 | } 121 | 122 | /** 123 | * Gets status 124 | * @return int 125 | */ 126 | public function getStatus() 127 | { 128 | return $this->status; 129 | } 130 | 131 | /** 132 | * Sets status 133 | * @param int $status Código del error 134 | * @return $this 135 | */ 136 | public function setStatus($status) 137 | { 138 | 139 | $this->status = $status; 140 | return $this; 141 | } 142 | 143 | /** 144 | * Gets message 145 | * @return string 146 | */ 147 | public function getMessage() 148 | { 149 | return $this->message; 150 | } 151 | 152 | /** 153 | * Sets message 154 | * @param string $message Mensaje del error 155 | * @return $this 156 | */ 157 | public function setMessage($message) 158 | { 159 | 160 | $this->message = $message; 161 | return $this; 162 | } 163 | 164 | /** 165 | * Gets errors 166 | * @return \Khipu\Model\ErrorItem[] 167 | */ 168 | public function getErrors() 169 | { 170 | return $this->errors; 171 | } 172 | 173 | /** 174 | * Sets errors 175 | * @param \Khipu\Model\ErrorItem[] $errors 176 | * @return $this 177 | */ 178 | public function setErrors($errors) 179 | { 180 | 181 | $this->errors = $errors; 182 | return $this; 183 | } 184 | 185 | /** 186 | * Returns true if offset exists. False otherwise. 187 | * @param integer $offset Offset 188 | * @return boolean 189 | */ 190 | public function offsetExists($offset) 191 | { 192 | return isset($this->$offset); 193 | } 194 | 195 | /** 196 | * Gets offset. 197 | * @param integer $offset Offset 198 | * @return mixed 199 | */ 200 | public function offsetGet($offset) 201 | { 202 | return $this->$offset; 203 | } 204 | 205 | /** 206 | * Sets value based on offset. 207 | * @param integer $offset Offset 208 | * @param mixed $value Value to be set 209 | * @return void 210 | */ 211 | public function offsetSet($offset, $value) 212 | { 213 | $this->$offset = $value; 214 | } 215 | 216 | /** 217 | * Unsets offset. 218 | * @param integer $offset Offset 219 | * @return void 220 | */ 221 | public function offsetUnset($offset) 222 | { 223 | unset($this->$offset); 224 | } 225 | 226 | /** 227 | * Gets the string presentation of the object 228 | * @return string 229 | */ 230 | public function __toString() 231 | { 232 | if (defined('JSON_PRETTY_PRINT')) { 233 | return json_encode(get_object_vars($this), JSON_PRETTY_PRINT); 234 | } else { 235 | return json_encode(get_object_vars($this)); 236 | } 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /lib/ObjectSerializer.php: -------------------------------------------------------------------------------- 1 | format(\DateTime::ISO8601); 61 | } else if (is_array($data)) { 62 | foreach ($data as $property => $value) { 63 | $data[$property] = $this->sanitizeForSerialization($value); 64 | } 65 | $sanitized = $data; 66 | } else if (is_object($data)) { 67 | $values = array(); 68 | foreach (array_keys($data::$swaggerTypes) as $property) { 69 | $getter = $data::$getters[$property]; 70 | if ($data->$getter() !== null) { 71 | $values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$getter()); 72 | } 73 | } 74 | ksort($values); 75 | $sanitized = $values; 76 | } else { 77 | $sanitized = (string)$data; 78 | } 79 | 80 | return $sanitized; 81 | } 82 | 83 | /** 84 | * Take value and turn it into a string suitable for inclusion in 85 | * the path, by url-encoding. 86 | * 87 | * @param string $value a string which will be part of the path 88 | * 89 | * @return string the serialized object 90 | */ 91 | public function toPathValue($value) 92 | { 93 | return rawurlencode($this->toString($value)); 94 | } 95 | 96 | /** 97 | * Take value and turn it into a string suitable for inclusion in 98 | * the query, by imploding comma-separated if it's an object. 99 | * If it's a string, pass through unchanged. It will be url-encoded 100 | * later. 101 | * 102 | * @param object $object an object to be serialized to a string 103 | * 104 | * @return string the serialized object 105 | */ 106 | public function toQueryValue($object) 107 | { 108 | if (is_array($object)) { 109 | return implode(',', $object); 110 | } else { 111 | return $this->toString($object); 112 | } 113 | } 114 | 115 | /** 116 | * Take value and turn it into a string suitable for inclusion in 117 | * the header. If it's a string, pass through unchanged 118 | * If it's a datetime object, format it in ISO8601 119 | * 120 | * @param string $value a string which will be part of the header 121 | * 122 | * @return string the header string 123 | */ 124 | public function toHeaderValue($value) 125 | { 126 | return $this->toString($value); 127 | } 128 | 129 | /** 130 | * Take value and turn it into a string suitable for inclusion in 131 | * the http body (form parameter). If it's a string, pass through unchanged 132 | * If it's a datetime object, format it in ISO8601 133 | * 134 | * @param string $value the value of the form parameter 135 | * 136 | * @return string the form string 137 | */ 138 | public function toFormValue($value) 139 | { 140 | if ($value instanceof SplFileObject) { 141 | return $value->getRealPath(); 142 | } else { 143 | return $this->toString($value); 144 | } 145 | } 146 | 147 | /** 148 | * Take value and turn it into a string suitable for inclusion in 149 | * the parameter. If it's a string, pass through unchanged 150 | * If it's a datetime object, format it in ISO8601 151 | * 152 | * @param string $value the value of the parameter 153 | * 154 | * @return string the header string 155 | */ 156 | public function toString($value) 157 | { 158 | if ($value instanceof \DateTime) { // datetime in ISO8601 format 159 | return $value->format(\DateTime::ISO8601); 160 | } else if (is_bool($value)) { 161 | return $value ? 1 : 0; 162 | } else { 163 | return $value; 164 | } 165 | } 166 | 167 | /** 168 | * Deserialize a JSON string into an object 169 | * 170 | * @param mixed $data object or primitive to be deserialized 171 | * @param string $class class name is passed as a string 172 | * @param string $httpHeader HTTP headers 173 | * 174 | * @return object an instance of $class 175 | */ 176 | public function deserialize($data, $class, $httpHeader=null) 177 | { 178 | if (null === $data) { 179 | $deserialized = null; 180 | } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] 181 | $inner = substr($class, 4, -1); 182 | $deserialized = array(); 183 | if (strrpos($inner, ",") !== false) { 184 | $subClass_array = explode(',', $inner, 2); 185 | $subClass = $subClass_array[1]; 186 | foreach ($data as $key => $value) { 187 | $deserialized[$key] = $this->deserialize($value, $subClass); 188 | } 189 | } 190 | } elseif (strcasecmp(substr($class, -2), '[]') == 0) { 191 | $subClass = substr($class, 0, -2); 192 | $values = array(); 193 | foreach ($data as $key => $value) { 194 | $values[] = $this->deserialize($value, $subClass); 195 | } 196 | $deserialized = $values; 197 | } elseif ($class === '\DateTime') { 198 | $deserialized = new \DateTime($data); 199 | } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { 200 | settype($data, $class); 201 | $deserialized = $data; 202 | } elseif ($class === '\SplFileObject') { 203 | // determine file name 204 | if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) { 205 | $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1]; 206 | } else { 207 | $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); 208 | } 209 | $deserialized = new \SplFileObject($filename, "w"); 210 | $byte_written = $deserialized->fwrite($data); 211 | error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile()); 212 | 213 | } else { 214 | $instance = new $class(); 215 | foreach ($instance::$swaggerTypes as $property => $type) { 216 | $propertySetter = $instance::$setters[$property]; 217 | 218 | if (!isset($propertySetter) || !isset($data->{$instance::$attributeMap[$property]})) { 219 | continue; 220 | } 221 | 222 | $propertyValue = $data->{$instance::$attributeMap[$property]}; 223 | if (isset($propertyValue)) { 224 | $instance->$propertySetter($this->deserialize($propertyValue, $type)); 225 | } 226 | } 227 | $deserialized = $instance; 228 | } 229 | 230 | return $deserialized; 231 | } 232 | } 233 | --------------------------------------------------------------------------------