diff --git a/LICENSE b/LICENSE index 8f71f43fe..60eef4615 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,21 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - +MIT License + +Copyright (c) 2017 Adyen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/Adyen/ApiKeyAuthenticatedService.php b/src/Adyen/ApiKeyAuthenticatedService.php new file mode 100644 index 000000000..adc0bcaaf --- /dev/null +++ b/src/Adyen/ApiKeyAuthenticatedService.php @@ -0,0 +1,9 @@ +_config = new \Adyen\Config(); - }elseif ($config instanceof \Adyen\ConfigInterface) { + } elseif ($config instanceof \Adyen\ConfigInterface) { $this->_config = $config; } else { throw new \Adyen\AdyenException("This config object is not supported, you need to implement the ConfigInterface"); @@ -71,6 +77,16 @@ public function setPassword($password) $this->_config->set('password', $password); } + /** + * Set x-api-key for Web Service Client + * + * @param $xapikey + */ + public function setXApiKey($xApiKey) + { + $this->_config->set('x-api-key', $xApiKey); + } + /** * Set environment to connect to test or live platform of Adyen * @@ -79,17 +95,21 @@ public function setPassword($password) */ public function setEnvironment($environment) { - if($environment == \Adyen\Environment::TEST) { + if ($environment == \Adyen\Environment::TEST) { $this->_config->set('environment', \Adyen\Environment::TEST); $this->_config->set('endpoint', self::ENDPOINT_TEST); - $this->_config->set('endpointDirectorylookup', self::ENPOINT_TEST_DIRECTORY_LOOKUP); - } elseif($environment == \Adyen\Environment::LIVE) { + $this->_config->set('endpointDirectorylookup', self::ENDPOINT_TEST_DIRECTORY_LOOKUP); + $this->_config->set('endpointTerminalCloud', self::TERMINAL_CLOUD_TEST); + $this->_config->set('endpointCheckout', self::ENDPOINT_CHECKOUT_TEST); + } elseif ($environment == \Adyen\Environment::LIVE) { $this->_config->set('environment', \Adyen\Environment::LIVE); $this->_config->set('endpoint', self::ENDPOINT_LIVE); - $this->_config->set('endpointDirectorylookup', self::ENPOINT_LIVE_DIRECTORY_LOOKUP); + $this->_config->set('endpointDirectorylookup', self::ENDPOINT_LIVE_DIRECTORY_LOOKUP); + $this->_config->set('endpointTerminalCloud', self::TERMINAL_CLOUD_LIVE); + $this->_config->set('endpointCheckout', self::ENDPOINT_CHECKOUT_LIVE); } else { - // environment does not exists - $msg = "This environment does not exists use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; + // environment does not exist + $msg = "This environment does not exist, use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; throw new \Adyen\AdyenException($msg); } } @@ -119,7 +139,8 @@ public function setMerchantAccount($merchantAccount) $this->_config->set('merchantAccount', $merchantAccount); } - public function setApplicationName($applicationName) { + public function setApplicationName($applicationName) + { $this->_config->set('applicationName', $applicationName); } @@ -143,6 +164,11 @@ public function setOutputType($value) $this->_config->set('outputType', $value); } + public function setTimeout($value) + { + $this->_config->set('timeout', $value); + } + /** * Get the library version @@ -174,6 +200,25 @@ public function getApiRecurringVersion() return self::API_RECURRING_VERSION; } + /** + * Get the version of the Checkout API endpoint + * + * @return string + */ + public function getApiCheckoutVersion() + { + return self::API_CHECKOUT_VERSION; + } + + /** + * Get the version of the Checkout Utility API endpoint + * + * @return string + */ + public function getApiCheckoutUtilityVersion() + { + return self::API_CHECKOUT_UTILITY_VERSION; + } /** * @param HttpClient\ClientInterface $httpClient diff --git a/src/Adyen/Config.php b/src/Adyen/Config.php index 6f1e3709c..a807cc338 100644 --- a/src/Adyen/Config.php +++ b/src/Adyen/Config.php @@ -59,6 +59,16 @@ public function getPassword() return isset($this->data['password']) ? $this->data['password'] : null; } + /** + * Get the Checkout API Key from the Adyen Customer Area + * + * @return mixed|null + */ + public function getXApiKey() + { + return !empty($this->data['x-api-key']) ? $this->data['x-api-key'] : null; + } + public function getInputType() { if(isset($this->data['inputType']) && in_array($this->data['inputType'], $this->allowedInput)) { @@ -78,6 +88,11 @@ public function getOutputType() return $this->defaultOutput; } + public function getTimeout() + { + return !empty($this->data['timeout']) ? $this->data['timeout'] : null; + } + public function getMerchantAccount() { return isset($this->data['merchantAccount']) ? $this->data['merchantAccount'] : null; diff --git a/src/Adyen/ConfigInterface.php b/src/Adyen/ConfigInterface.php index 94bfd4463..0f0ef66fc 100644 --- a/src/Adyen/ConfigInterface.php +++ b/src/Adyen/ConfigInterface.php @@ -6,9 +6,10 @@ public function getUsername(); public function getPassword(); + public function getXApiKey(); public function get($param); public function getInputType(); public function getOutputType(); public function getMerchantAccount(); - + public function getTimeout(); } \ No newline at end of file diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index a38b6204d..9dc762f9c 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -21,6 +21,8 @@ public function requestJson(\Adyen\Service $service, $requestUrl, $params) $logger = $client->getLogger(); $username = $config->getUsername(); $password = $config->getPassword(); + $xApiKey = $config->getXApiKey(); + $jsonRequest = json_encode($params); // log the request @@ -32,14 +34,10 @@ public function requestJson(\Adyen\Service $service, $requestUrl, $params) //Tell cURL that we want to send a POST request. curl_setopt($ch, CURLOPT_POST, 1); - // set authorisation - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); - //Attach our encoded JSON string to the POST fields. curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonRequest); - // set a custom User-Agent + //create a custom User-Agent $userAgent = $config->get('applicationName') . " " . \Adyen\Client::USER_AGENT_SUFFIX . $client->getLibraryVersion(); //Set the content type to application/json and use the defined userAgent @@ -48,14 +46,33 @@ public function requestJson(\Adyen\Service $service, $requestUrl, $params) 'User-Agent: ' . $userAgent ); + // set authorisation credentials according to support & availability + if ($service->requiresApiKey() && !empty($xApiKey)) { + //Set the content type to application/json and use the defined userAgent along with the x-api-key + $headers[] = 'x-api-key: ' . $xApiKey; + } elseif ($service->requiresApiKey() && empty($xApiKey)) { + $msg = "Please provide a valid Checkout API Key"; + throw new \Adyen\AdyenException($msg); + } else { + + //Set the basic auth credentials + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); + } + + //Set the timeout + if($config->getTimeout() != null){ + curl_setopt($ch, CURLOPT_TIMEOUT, $config->getTimeout()); + } + + //Set the headers curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // return the result curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Execute the request - $result = curl_exec($ch); - $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); + list($result, $httpStatus) = $this->curlRequest($ch); // log the raw response $logger->info("JSON Response is: " . $result); @@ -64,8 +81,8 @@ public function requestJson(\Adyen\Service $service, $requestUrl, $params) if ($httpStatus != 200 && $result) { $this->handleResultError($result, $logger); } elseif (!$result) { - $errno = curl_errno($ch); - $message = curl_error($ch); + + list($errno, $message) = $this->curlError($ch); curl_close($ch); $this->handleCurlError($requestUrl, $errno, $message, $logger); @@ -218,7 +235,6 @@ protected function handleCurlError($url, $errno, $message, $logger) protected function handleResultError($result, $logger) { $decodeResult = json_decode($result, true); - if (isset($decodeResult['message']) && isset($decodeResult['errorCode'])) { $logger->error($decodeResult['errorCode'] . ': ' . $decodeResult['message']); throw new \Adyen\AdyenException($decodeResult['message'], $decodeResult['errorCode'], null, @@ -248,4 +264,19 @@ private function logRequest(\Psr\Log\LoggerInterface $logger, $requestUrl, $para } $logger->info('JSON Request to Adyen:' . json_encode($params)); } + + protected function curlRequest($ch) + { + $result = curl_exec($ch); + $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); + return array($result, $httpStatus); + } + + protected function curlError($ch) + { + $errno = curl_errno($ch); + $message = curl_error($ch); + return array($errno, $message); + } + } diff --git a/src/Adyen/Service.php b/src/Adyen/Service.php index 880c1dfcb..ada85ecea 100644 --- a/src/Adyen/Service.php +++ b/src/Adyen/Service.php @@ -5,6 +5,7 @@ class Service { private $client; + protected $_requiresApiKey = false; public function __construct(\Adyen\Client $client) { @@ -13,7 +14,7 @@ public function __construct(\Adyen\Client $client) // validate if client has all the configuration we need if(!$client->getConfig()->get('environment')) { // throw exception - $msg = "The Client does not have a corect environment. use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; + $msg = "The Client does not have a correct environment, use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; throw new \Adyen\AdyenException($msg); } @@ -25,4 +26,9 @@ public function getClient() return $this->client; } + public function requiresApiKey() + { + return $this->_requiresApiKey; + } + } \ No newline at end of file diff --git a/src/Adyen/Service/AbstractResource.php b/src/Adyen/Service/AbstractResource.php index 8fafb2358..9c67a01ac 100644 --- a/src/Adyen/Service/AbstractResource.php +++ b/src/Adyen/Service/AbstractResource.php @@ -7,13 +7,11 @@ class AbstractResource protected $_service; protected $_endpoint; - protected $_requiredFields; - public function __construct(\Adyen\Service $service, $endpoint, $requiredFields) + public function __construct(\Adyen\Service $service, $endpoint) { $this->_service = $service; $this->_endpoint = $endpoint; - $this->_requiredFields = $requiredFields; } /** @@ -35,9 +33,6 @@ public function request($params) $params['merchantAccount'] = $this->_service->getClient()->getConfig()->getMerchantAccount(); } - // validate the request parameters - $this->_validate($params); - $curlClient = $this->_service->getClient()->getHttpClient(); return $curlClient->requestJson($this->_service, $this->_endpoint, $params); } @@ -51,75 +46,8 @@ public function requestPost($params) throw new \Adyen\AdyenException($msg); } - // validate the request parameters - $this->_validate($params); - $curlClient = $this->_service->getClient()->getHttpClient(); return $curlClient->requestPost($this->_service, $this->_endpoint, $params); } - /** - * Validate if all required fields are in the params - * - * @param $params - */ - protected function _validate($params) - { - $missingFields = array(); - $missingValues = array(); - - if(is_array($this->_requiredFields)) { - foreach($this->_requiredFields as $requiredField) { - - // if validation is two levels validate if parent and child is in the request - if(strpos($requiredField, ".") !== FALSE) { - $results = explode('.', $requiredField); - - // for validation only a depth for 2 levels is needed - $parent = $results[0]; - $child = $results[1]; - - if(!isset($params[$parent])) { - // missing the parent param in request - $missingFields[] = $requiredField; - continue; - } - if(!isset($params[$parent][$child])) { - // missing the child param in request - $missingFields[] = $requiredField; - continue; - } else { - // check if value is set - if($params[$parent][$child] === "") { - $missingValues[] = $requiredField; - } - } - - // the param is in the request so continue - continue; - } - - if(!array_key_exists($requiredField, $params)) { - $missingFields[] = $requiredField; - } else { - // check if value is set - if($params[$requiredField] === "") { - $missingValues[] = $requiredField; - } - } - } - } - - if(!empty($missingFields)) { - $msg = 'Missing the following fields: ' . implode($missingFields, ','); - $this->_service->getClient()->getLogger()->error($msg); - throw new \Adyen\AdyenException($msg); - } - - if(!empty($missingValues)) { - $msg = 'Missing the following values: ' . implode($missingValues, ','); - $this->_service->getClient()->getLogger()->error($msg); - throw new \Adyen\AdyenException($msg); - } - } } \ No newline at end of file diff --git a/src/Adyen/Service/Checkout.php b/src/Adyen/Service/Checkout.php new file mode 100644 index 000000000..a892db61d --- /dev/null +++ b/src/Adyen/Service/Checkout.php @@ -0,0 +1,57 @@ +_paymentSession = new \Adyen\Service\ResourceModel\Checkout\PaymentSession($this); + $this->_paymentsResult = new \Adyen\Service\ResourceModel\Checkout\PaymentsResult($this); + $this->_paymentMethods = new \Adyen\Service\ResourceModel\Checkout\PaymentMethods($this); + $this->_payments = new \Adyen\Service\ResourceModel\Checkout\Payments($this); + $this->_paymentsDetails = new \Adyen\Service\ResourceModel\Checkout\PaymentsDetails($this); + + } + + public function paymentSession($params) + { + $result = $this->_paymentSession->request($params); + return $result; + } + + public function paymentsResult($params) + { + $result = $this->_paymentsResult->request($params); + return $result; + } + + public function paymentMethods($params) + { + $result = $this->_paymentMethods->request($params); + return $result; + } + + public function payments($params) + { + $result = $this->_payments->request($params); + return $result; + } + + public function paymentsDetails($params) + { + $result = $this->_paymentsDetails->request($params); + return $result; + } + + +} \ No newline at end of file diff --git a/src/Adyen/Service/CheckoutUtility.php b/src/Adyen/Service/CheckoutUtility.php new file mode 100644 index 000000000..e4b75b783 --- /dev/null +++ b/src/Adyen/Service/CheckoutUtility.php @@ -0,0 +1,24 @@ +_originKeys = new \Adyen\Service\ResourceModel\CheckoutUtility\OriginKeys($this); + + } + + public function originKeys($params) + { + $result = $this->_originKeys->request($params); + return $result; + } + +} \ No newline at end of file diff --git a/src/Adyen/Service/Modification.php b/src/Adyen/Service/Modification.php index c3260053b..edb0cb543 100644 --- a/src/Adyen/Service/Modification.php +++ b/src/Adyen/Service/Modification.php @@ -9,6 +9,7 @@ class Modification extends \Adyen\Service protected $_cancelOrRefund; protected $_capture; protected $_refund; + protected $_adjustAuthorisation; public function __construct(\Adyen\Client $client) { @@ -18,6 +19,7 @@ public function __construct(\Adyen\Client $client) $this->_cancelOrRefund = new \Adyen\Service\ResourceModel\Modification\CancelOrRefund($this); $this->_capture = new \Adyen\Service\ResourceModel\Modification\Capture($this); $this->_refund = new \Adyen\Service\ResourceModel\Modification\Refund($this); + $this->_adjustAuthorisation = new \Adyen\Service\ResourceModel\Modification\AdjustAuthorisation($this); } public function cancel($params) @@ -44,4 +46,9 @@ public function refund($params) return $result; } + public function adjustAuthorisation($params) + { + $result = $this->_adjustAuthorisation->request($params); + return $result; + } } \ No newline at end of file diff --git a/src/Adyen/Service/PosPayment.php b/src/Adyen/Service/PosPayment.php new file mode 100644 index 000000000..9d3fe9390 --- /dev/null +++ b/src/Adyen/Service/PosPayment.php @@ -0,0 +1,40 @@ +_runTenderSync = new \Adyen\Service\ResourceModel\Payment\TerminalCloudAPI($this, false); + $this->_runTenderAsync = new \Adyen\Service\ResourceModel\Payment\TerminalCloudAPI($this, true); + } + + public function runTenderSync($params) + { + $result = $this->_runTenderSync->request($params); + return $result; + } + + public function runTenderAsync($params) + { + $result = $this->_runTenderAsync->request($params); + return $result; + } + + public function getServiceId($request) + { + if (isset($request['SaleToPOIRequest']['MessageHeader']['ServiceID'])) { + return $request['SaleToPOIRequest']['MessageHeader']['ServiceID']; + } + return null; + } + +} diff --git a/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php b/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php new file mode 100644 index 000000000..a9fbd7ecc --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php @@ -0,0 +1,15 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointCheckout') .'/'. $service->getClient()->getApiCheckoutVersion() . '/paymentMethods'; + parent::__construct($service, $this->_endpoint); + } + +} diff --git a/src/Adyen/Service/ResourceModel/Checkout/PaymentSession.php b/src/Adyen/Service/ResourceModel/Checkout/PaymentSession.php new file mode 100644 index 000000000..dcae56005 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentSession.php @@ -0,0 +1,15 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointCheckout') .'/'. $service->getClient()->getApiCheckoutVersion() . '/paymentSession'; + parent::__construct($service, $this->_endpoint); + } + +} diff --git a/src/Adyen/Service/ResourceModel/Checkout/Payments.php b/src/Adyen/Service/ResourceModel/Checkout/Payments.php new file mode 100644 index 000000000..aa4534867 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Checkout/Payments.php @@ -0,0 +1,16 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointCheckout') .'/'. $service->getClient()->getApiCheckoutVersion() . '/payments'; + parent::__construct($service, $this->_endpoint); + } + +} diff --git a/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php b/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php new file mode 100644 index 000000000..77672c447 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php @@ -0,0 +1,15 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointCheckout') .'/'. $service->getClient()->getApiCheckoutVersion() . '/payments/details'; + parent::__construct($service, $this->_endpoint); + } + +} diff --git a/src/Adyen/Service/ResourceModel/Checkout/PaymentsResult.php b/src/Adyen/Service/ResourceModel/Checkout/PaymentsResult.php new file mode 100644 index 000000000..09f808088 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentsResult.php @@ -0,0 +1,15 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointCheckout') .'/'. $service->getClient()->getApiCheckoutVersion() . '/payments/result'; + parent::__construct($service, $this->_endpoint); + } + +} diff --git a/src/Adyen/Service/ResourceModel/CheckoutUtility/OriginKeys.php b/src/Adyen/Service/ResourceModel/CheckoutUtility/OriginKeys.php new file mode 100644 index 000000000..f9ce3c607 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/CheckoutUtility/OriginKeys.php @@ -0,0 +1,15 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointCheckout') .'/'. $service->getClient()->getApiCheckoutUtilityVersion() . '/originKeys'; + parent::__construct($service, $this->_endpoint); + } + +} diff --git a/src/Adyen/Service/ResourceModel/DirectoryLookup/Directory.php b/src/Adyen/Service/ResourceModel/DirectoryLookup/Directory.php index fa6f48c7d..b139b2cf0 100644 --- a/src/Adyen/Service/ResourceModel/DirectoryLookup/Directory.php +++ b/src/Adyen/Service/ResourceModel/DirectoryLookup/Directory.php @@ -7,23 +7,12 @@ class Directory extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'paymentAmount', - 'currencyCode', - 'merchantReference', - 'skinCode', - 'merchantAccount', - 'sessionValidity', - 'shopperLocale', - 'merchantSig' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpointDirectorylookup'); - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php b/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php new file mode 100644 index 000000000..372595153 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php @@ -0,0 +1,15 @@ +_endpoint = $service->getClient()->getConfig()->get('endpoint').'/pal/servlet/Payment/'.$service->getClient()->getApiVersion().'/adjustAuthorisation'; + parent::__construct($service, $this->_endpoint); + } + +} \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Modification/Cancel.php b/src/Adyen/Service/ResourceModel/Modification/Cancel.php index 254da7e80..735444319 100644 --- a/src/Adyen/Service/ResourceModel/Modification/Cancel.php +++ b/src/Adyen/Service/ResourceModel/Modification/Cancel.php @@ -4,17 +4,12 @@ class Cancel extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/cancel'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php b/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php index b35681c6f..cf4c550b2 100644 --- a/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php +++ b/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php @@ -4,17 +4,12 @@ class CancelOrRefund extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'originalReference', - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/'. $service->getClient()->getApiVersion() . '/cancelOrRefund'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Modification/Capture.php b/src/Adyen/Service/ResourceModel/Modification/Capture.php index 955ff8eba..5287d8906 100644 --- a/src/Adyen/Service/ResourceModel/Modification/Capture.php +++ b/src/Adyen/Service/ResourceModel/Modification/Capture.php @@ -4,20 +4,12 @@ class Capture extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'modificationAmount', - 'modificationAmount.value', - 'modificationAmount.currency', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/capture'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Modification/Refund.php b/src/Adyen/Service/ResourceModel/Modification/Refund.php index 7d47a3aa2..95e91de85 100644 --- a/src/Adyen/Service/ResourceModel/Modification/Refund.php +++ b/src/Adyen/Service/ResourceModel/Modification/Refund.php @@ -4,20 +4,12 @@ class Refund extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'modificationAmount', - 'modificationAmount.value', - 'modificationAmount.currency', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/refund'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payment/Authorise.php b/src/Adyen/Service/ResourceModel/Payment/Authorise.php index 6c502bd94..09d649eac 100644 --- a/src/Adyen/Service/ResourceModel/Payment/Authorise.php +++ b/src/Adyen/Service/ResourceModel/Payment/Authorise.php @@ -4,19 +4,12 @@ class Authorise extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'amount.value', - 'amount.currency', - 'reference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/authorise'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php b/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php index 397725fb9..52d9fd103 100644 --- a/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php +++ b/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php @@ -4,19 +4,12 @@ class Authorise3D extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'browserInfo', - 'md', - 'paResponse' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/authorise3d'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php b/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php new file mode 100644 index 000000000..90b6095f9 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php @@ -0,0 +1,19 @@ +_endpoint = $service->getClient()->getConfig()->get('endpointTerminalCloud') . '/async'; + } else { + $this->_endpoint = $service->getClient()->getConfig()->get('endpointTerminalCloud') . '/sync'; + } + parent::__construct($service, $this->_endpoint); + } + +} \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/Confirm.php b/src/Adyen/Service/ResourceModel/Payout/Confirm.php index f1bec89d0..6e3a87aad 100644 --- a/src/Adyen/Service/ResourceModel/Payout/Confirm.php +++ b/src/Adyen/Service/ResourceModel/Payout/Confirm.php @@ -4,17 +4,12 @@ class Confirm extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/confirm'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/Decline.php b/src/Adyen/Service/ResourceModel/Payout/Decline.php index cfb64fb00..1ed095d25 100644 --- a/src/Adyen/Service/ResourceModel/Payout/Decline.php +++ b/src/Adyen/Service/ResourceModel/Payout/Decline.php @@ -4,17 +4,12 @@ class Decline extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/decline'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php b/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php index 5c777b2de..7d2dcbc30 100644 --- a/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php +++ b/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php @@ -4,22 +4,12 @@ class StoreDetailsAndSubmit extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'amount.currency', - 'amount.value', - 'merchantAccount', - 'recurring.contract', - 'reference', - 'shopperEmail', - 'shopperReference', - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetailAndSubmit'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/Submit.php b/src/Adyen/Service/ResourceModel/Payout/Submit.php index 97a5e6ba6..0d1268292 100644 --- a/src/Adyen/Service/ResourceModel/Payout/Submit.php +++ b/src/Adyen/Service/ResourceModel/Payout/Submit.php @@ -4,23 +4,12 @@ class Submit extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'amount.currency', - 'amount.value', - 'merchantAccount', - 'recurring.contract', - 'reference', - 'shopperEmail', - 'shopperReference', - 'selectedRecurringDetailReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/submit'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php index 7c37d1ada..37e19251b 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php @@ -4,17 +4,12 @@ class ConfirmThirdParty extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/confirmThirdParty'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php index d83c03179..07f681c02 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php @@ -4,17 +4,12 @@ class DeclineThirdParty extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'originalReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/declineThirdParty'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php index 1fd60b92d..aced34bb4 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php @@ -4,19 +4,12 @@ class StoreDetail extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'recurring.contract', - 'shopperEmail', - 'shopperReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetail'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php index f1f4166bd..f7cb4f86f 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php @@ -4,22 +4,12 @@ class StoreDetailsAndSubmitThirdParty extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'shopperEmail', - 'shopperReference', - 'reference', - 'recurring.contract', - 'amount.currency', - 'amount.value' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetailAndSubmitThirdParty'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php index 6319670ce..a49d5dcc2 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php @@ -4,23 +4,12 @@ class SubmitThirdParty extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'amount.currency', - 'amount.value', - 'merchantAccount', - 'recurring.contract', - 'reference', - 'shopperEmail', - 'shopperReference', - 'selectedRecurringDetailReference' - ); - protected $_endpoint; public function __construct($service) { $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/submitThirdParty'; - parent::__construct($service, $this->_endpoint, $this->_requiredFields); + parent::__construct($service, $this->_endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Recurring/Disable.php b/src/Adyen/Service/ResourceModel/Recurring/Disable.php index 0fe030647..3d86256c6 100644 --- a/src/Adyen/Service/ResourceModel/Recurring/Disable.php +++ b/src/Adyen/Service/ResourceModel/Recurring/Disable.php @@ -4,15 +4,10 @@ class Disable extends \Adyen\Service\AbstractResource { - protected $_requiredFields = array( - 'merchantAccount', - 'shopperReference' - ); - public function __construct($service) { $endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Recurring/' . $service->getClient()->getApiRecurringVersion() . '/disable'; - parent::__construct($service, $endpoint, $this->_requiredFields); + parent::__construct($service, $endpoint); } } \ No newline at end of file diff --git a/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php b/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php index 74a0ad6d7..0b2d1910a 100644 --- a/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php +++ b/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php @@ -4,16 +4,10 @@ class ListRecurringDetails extends \Adyen\Service\AbstractResource { - - protected $_requiredFields = array( - 'merchantAccount', - 'shopperReference' - ); - public function __construct($service) { $endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Recurring/' . $service->getClient()->getApiRecurringVersion() . '/listRecurringDetails'; - parent::__construct($service, $endpoint, $this->_requiredFields); + parent::__construct($service, $endpoint); } } \ No newline at end of file diff --git a/src/Adyen/TransactionType.php b/src/Adyen/TransactionType.php new file mode 100644 index 000000000..abd8e1a74 --- /dev/null +++ b/src/Adyen/TransactionType.php @@ -0,0 +1,12 @@ +createClient(); - - // initialize service - $service = new Service\Payment($client); - - $json = '{ - "card": { - "number": "4111111111111111", - "expiryMonth": "08", - "expiryYear": "2018", - "cvc": "737", - "holderName": "John Smith" - }, - "amount": { - "value": 1500, - "currency": "EUR" - }, - "reference": "", - "merchantAccount": "' . $this->_merchantAccount .'" - }'; - - $params = json_decode($json, true); - $e = null; - try { - $result = $service->authorise($params); - } catch (\Exception $e) { - $this->validateApiPermission($e); - } - - // check if exception is correct - $this->assertEquals('Adyen\AdyenException', get_class($e)); - $this->assertEquals('Missing the following values: reference', $e->getMessage()); - } - public function testCreatePaymentSuccess() { // initialize client diff --git a/tests/ExceptionTest.php b/tests/ExceptionTest.php index bac76c6a3..04f1e0b15 100644 --- a/tests/ExceptionTest.php +++ b/tests/ExceptionTest.php @@ -11,44 +11,6 @@ class ExceptionTest extends \Adyen\TestCase { - public function testExceptionMissingValuesToParams() - { - // initialize client - $client = $this->createClient(); - - // initialize service - $service = new Service\Payment($client); - - $json = '{ - "card": { - "number": "", - "expiryMonth": "", - "expiryYear": "", - "cvc": "", - "holderName": "" - }, - "amount": { - "value": "", - "currency": "" - }, - "reference": "", - "merchantAccount": "" - }'; - - $params = json_decode($json, true); - $e = null; - try { - $result = $service->authorise($params); - } catch (\Exception $e) { - - } - - $this->assertEquals('Adyen\AdyenException', get_class($e)); - $this->assertEquals('Missing the following values: merchantAccount,amount.value,amount.currency,reference', $e->getMessage()); - - - - } public function testExceptionMissingEnvironmentValue() { $client = new \Adyen\Client(); @@ -65,7 +27,7 @@ public function testExceptionMissingEnvironmentValue() // should have environment exception $this->assertEquals('Adyen\AdyenException', get_class($e)); - $this->assertEquals('The Client does not have a corect environment. use test or live', $e->getMessage()); + $this->assertEquals('The Client does not have a correct environment, use test or live', $e->getMessage()); } diff --git a/tests/MockTest/CheckoutTest.php b/tests/MockTest/CheckoutTest.php new file mode 100644 index 000000000..72a9e7430 --- /dev/null +++ b/tests/MockTest/CheckoutTest.php @@ -0,0 +1,279 @@ +createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array('merchantAccount' => "YourMerchantAccount"); + $result = $service->paymentMethods($params); + + $this->assertArrayHasKey('paymentMethods', $result); + + } + + public static function successPaymentMethodsProvider() + { + return array( + array('tests/Resources/Checkout/payment-methods-success.json', 200), + ); + } + + /** + * @param $jsonFile + * @param $httpStatus + * @param $expectedExceptionMessage + * @dataProvider failurePaymentMethodsProvider + * + */ + public function testPaymentMethodsFailure($jsonFile, $httpStatus, $expectedExceptionMessage) + { + // create Checkout client + $client = $this->createMockClient($jsonFile, $httpStatus); + + if ($expectedExceptionMessage == self::NO_CHECKOUT_KEY) { + $client->setXApiKey(""); + } + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array('merchantAccount' => "YourMerchantAccount"); + try { + $result = $service->paymentMethods($params); + $this->fail(); + } catch (\Exception $e) { + $this->assertInstanceOf('Adyen\AdyenException', $e); + $this->assertContains($expectedExceptionMessage, $e->getMessage()); + if ($httpStatus != null) { + $this->assertEquals($httpStatus, $e->getStatus()); + } + } + + } + + public static function failurePaymentMethodsProvider() + { + return array( + array('tests/Resources/Checkout/invalid-merchant-account.json', 403, "Invalid Merchant Account"), + array('tests/Resources/Checkout/payment-methods-forbidden.json', null, "Forbidden"), + array(null, null, self::NO_CHECKOUT_KEY) + ); + } + + /** + * @param $jsonFile + * @param $httpStatus + * + * @dataProvider successPaymentsProvider + * + */ + public function testPaymentsSuccess($jsonFile, $httpStatus) + { + // create Checkout client + $client = $this->createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array( + 'merchantAccount' => "YourMerchantAccount", + 'amount' => array('currency' => "EUR", 'value' => 1000), + 'paymentMethod' => array( + 'type' => "scheme", + 'number' => "4111111111111111", + 'expiryMonth' => "08", + 'expiryYear' => "2018", + 'holderName' => "John Smith", + 'cvc' => "737" + ), + 'reference' => "Your order number", + 'returnUrl' => "https://your-company.com/...", + 'additionalData' => array( + 'executeThreeD' => true + ) + ); + $result = $service->payments($params); + + $this->assertContains($result['resultCode'], array('Authorised', 'RedirectShopper')); + + } + + public static function successPaymentsProvider() + { + return array( + array('tests/Resources/Checkout/payments-success.json', 200), + array('tests/Resources/Checkout/payments-success-3D.json', 200) + ); + } + + /** + * @param $jsonFile + * @param $httpStatus + * @param $expectedExceptionMessage + * @dataProvider failurePaymentsProvider + * + */ + public function testPaymentsFailure($jsonFile, $httpStatus, $expectedExceptionMessage) + { + // create Checkout client + $client = $this->createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array( + 'merchantAccount' => "YourMerchantAccount", + 'amount' => array('currency' => "EUR", 'value' => 1000), + 'paymentMethod' => array( + 'type' => "scheme", + 'number' => "4111111111111111", + 'expiryMonth' => "08", + 'expiryYear' => "2018", + 'holderName' => "John Smith", + 'cvc' => "737" + ), + 'returnUrl' => "https://your-company.com/..." + ); + + $params['reference'] = 'yourownreference'; + + try { + $result = $service->payments($params); + $this->fail(); + } catch (\Exception $e) { + $this->assertInstanceOf('Adyen\AdyenException', $e); + $this->assertContains($expectedExceptionMessage, $e->getMessage()); + if ($httpStatus != null) { + $this->assertEquals($httpStatus, $e->getStatus()); + } + } + } + + + public static function failurePaymentsProvider() + { + return array( + array('tests/Resources/Checkout/invalid-merchant-account.json', 403, "Invalid Merchant Account"), + array('tests/Resources/Checkout/payments-forbidden.json', null, "Forbidden") + ); + } + + /** + * @param $jsonFile + * @param $httpStatus + * + * @dataProvider successPaymentsDetailsProvider + * + */ + public function testPaymentsDetailsSuccess($jsonFile, $httpStatus) + { + // create Checkout client + $client = $this->createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array( + 'merchantAccount' => "YourMerchantAccount", + 'paymentData' => 'Ab02b4c0!BQABAgCJN1wRZuGJmq8dMncmypvknj9s7l5Tj...', + 'details' => array( + 'MD' => 'sdfsdfsdf...', + 'PaRes' => 'sdkfhskdjfsdf...' + ), + ); + + $result = $service->paymentsDetails($params); + + $this->assertContains($result['resultCode'], array('Authorised')); + } + + public static function successPaymentsDetailsProvider() + { + return array( + array('tests/Resources/Checkout/payments-details-success.json', 200) + ); + } + + /** + * @param $jsonFile + * @param $httpStatus + * + * @dataProvider successPaymentSessionProvider + * + */ + public function testPaymentSessionSuccess($jsonFile, $httpStatus) + { + // create Checkout client + $client = $this->createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array( + 'merchantAccount' => "YourMerchantAccount", + 'amount' => array('currency' => "EUR", 'value' => 1000), + 'countryCode' => "NL", + 'reference' => "Your order number", + 'returnUrl' => "https://your-company.com/", + "sdkVersion" => "1.3.0" + ); + + $result = $service->paymentSession($params); + + $this->assertArrayHasKey("paymentSession", $result); + } + + public static function successPaymentSessionProvider() + { + return array( + array('tests/Resources/Checkout/payment-session-success.json', 200) + ); + } + + /** + * @param $jsonFile + * @param $httpStatus + * + * @dataProvider successPaymentsResultProvider + * + */ + public function testPaymentsResultSuccess($jsonFile, $httpStatus) + { + // create Checkout client + $client = $this->createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Checkout($client); + + $params = array( + 'payload' => "YourPayload" + ); + + $result = $service->paymentsResult($params); + + $this->assertContains($result['resultCode'], array('Authorised')); + } + + public static function successPaymentsResultProvider() + { + return array( + array('tests/Resources/Checkout/payments-result-success.json', 200) + ); + } + +} diff --git a/tests/MockTest/CheckoutUtilityTest.php b/tests/MockTest/CheckoutUtilityTest.php new file mode 100644 index 000000000..bc1e3a495 --- /dev/null +++ b/tests/MockTest/CheckoutUtilityTest.php @@ -0,0 +1,43 @@ +createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\CheckoutUtility($client); + + $params = array( + "originDomains" => array( + "https://www.your-domain1.com", + "https://www.your-domain2.com", + "https://www.your-domain3.com" + ) + ); + + $result = $service->originKeys($params); + + $this->assertArrayHasKey('originKeys', $result); + + } + + public static function successOriginKeysProvider() + { + return array( + array('tests/Resources/CheckoutUtility/origin-keys-success.json', 200) + ); + } +} \ No newline at end of file diff --git a/tests/MockTest/PaymentTest.php b/tests/MockTest/PaymentTest.php new file mode 100644 index 000000000..d771c7d01 --- /dev/null +++ b/tests/MockTest/PaymentTest.php @@ -0,0 +1,176 @@ +createMockClient($jsonFile, $httpStatus); + + // Stub Logger to prevent full card data being logged + $loggerMock = $this->getMockBuilder('\Monolog\Logger')->setMethods(array('info'))->disableOriginalConstructor()->getMock(); + $client->setLogger($loggerMock); + $loggerMock->expects($this->any()) + ->method('info') + ->with( + $this->logicalAnd( + $this->logicalNot($this->stringContains('4111')), + $this->logicalNot($this->stringContains('737')), + $this->logicalNot($this->stringContains('adyenjs....')) + ) + ); + + // initialize service + $service = new \Adyen\Service\Payment($client); + + $json = '{ + "card": { + "number": "4111111111111111", + "expiryMonth": "08", + "expiryYear": "2018", + "cvc": "737", + "holderName": "John Smith" + }, + "amount": { + "value": 1500, + "currency": "EUR" + }, + "reference": "payment-test", + "merchantAccount": "YourMerchantReference", + "additionalData": { + "card.encrypted.json" : "adyenjs...." + } + }'; + + $params = json_decode($json, true); + + $result = $service->authorise($params); + + $this->assertArrayHasKey('resultCode', $result); + $this->assertEquals('Authorised', $result['resultCode']); + } + + public static function successAuthoriseProvider() + { + return array( + array('tests/Resources/Payment/authorise-success.json', 200), + ); + } + + + /** + * @param $jsonFile Json file location + * @param $httpStatus expected http status code + * @param $errno + * @param $expectedExceptionMessage + * @dataProvider connectionFailureAuthoriseProvider + */ + public function testAuthoriseConnectionFailure($jsonFile, $httpStatus, $errno, $expectedExceptionMessage) + { + // create client + $client = $this->createMockClient($jsonFile, $httpStatus, $errno); + + // initialize service + $service = new \Adyen\Service\Payment($client); + + $json = '{ + "card": { + "number": "4111111111111111", + "expiryMonth": "08", + "expiryYear": "2018", + "cvc": "737", + "holderName": "John Smith" + }, + "amount": { + "value": 1500, + "currency": "EUR" + }, + "reference": "payment-test", + "merchantAccount": "YourMerchantReference" + }'; + + $params = json_decode($json, true); + + try { + $result = $service->authorise($params); + $this->fail(); + } catch (\Exception $e) { + $this->assertInstanceOf('Adyen\ConnectionException', $e); + $this->assertContains($expectedExceptionMessage, $e->getMessage()); + if ($httpStatus != null) { + $this->assertEquals($httpStatus, $e->getCode()); + } + } + } + + public static function connectionFailureAuthoriseProvider() + { + return array( + array(null, null, CURLE_OK, "Probably your Web Service username and/or password is incorrect"), + array(null, null, CURLE_OPERATION_TIMEOUTED, "Could not connect to Adyen"), + array(null, null, CURLE_SSL_CACERT, "Could not verify Adyen's SSL certificate"), + array(null, null, 12345, "Unexpected error communicating with Adyen.") + ); + } + + /** + * @param $jsonFile Json file location + * @param $httpStatus expected http status code + * @param $expectedExceptionMessage + * @dataProvider resultFailureAuthoriseProvider + */ + public function testAuthoriseResultFailure($jsonFile, $httpStatus, $expectedExceptionMessage) + { + // create client + $client = $this->createMockClient($jsonFile, $httpStatus); + + // initialize service + $service = new \Adyen\Service\Payment($client); + + $json = '{ + "card": { + "number": "4111111111111111", + "expiryMonth": "08", + "expiryYear": "2018", + "cvc": "737", + "holderName": "John Smith" + }, + "amount": { + "value": 1500, + "currency": "EUR" + }, + "reference": "payment-test", + "merchantAccount": "YourMerchantReference" + }'; + + $params = json_decode($json, true); + + try { + $result = $service->authorise($params); + $this->fail(); + } catch (\Exception $e) { + $this->assertInstanceOf('Adyen\AdyenException', $e); + $this->assertContains($expectedExceptionMessage, $e->getMessage()); + if ($httpStatus != null) { + $this->assertEquals($httpStatus, $e->getStatus()); + } + } + } + + public static function resultFailureAuthoriseProvider() + { + return array( + array('tests/Resources/Payment/invalid-merchant-account.json', 403, "Invalid Merchant Account") + ); + } +} \ No newline at end of file diff --git a/tests/MockTest/TestCaseMock.php b/tests/MockTest/TestCaseMock.php new file mode 100644 index 000000000..40da84c3d --- /dev/null +++ b/tests/MockTest/TestCaseMock.php @@ -0,0 +1,29 @@ +getMockBuilder(get_class(new \Adyen\HttpClient\CurlClient)) + ->setMethods(array('curlRequest', 'curlError')) + ->getMock(); + $curlClient->method('curlRequest') + ->willReturn(array($json, $httpStatus)); + $curlClient->method('curlError') + ->willReturn(array($errno, null)); + + $client = new \Adyen\Client(); + $client->setApplicationName("My Test Application"); + $client->setEnvironment(\Adyen\Environment::TEST); + $client->setXApiKey("MockAPIKey"); + $client->setHttpClient($curlClient); + return $client; + } +} \ No newline at end of file diff --git a/tests/ModificationTest.php b/tests/ModificationTest.php index fa5b54bd7..bd4fe0c53 100644 --- a/tests/ModificationTest.php +++ b/tests/ModificationTest.php @@ -15,7 +15,7 @@ class ModificationTest extends TestCase public function testCancelModification() { // create a payment - require_once __DIR__ . '/CreatePaymentRequestTest.php'; + require_once __DIR__.'/CreatePaymentRequestTest.php'; $test = new CreatePaymentRequestTest(); $result = $test->testCreatePaymentSuccess(); @@ -36,7 +36,7 @@ public function testCancelModification() public function testRefundModification() { // create a payment - require_once __DIR__ . '/CreatePaymentRequestTest.php'; + require_once __DIR__.'/CreatePaymentRequestTest.php'; $test = new CreatePaymentRequestTest(); $result = $test->testCreatePaymentSuccess(); @@ -53,7 +53,7 @@ public function testRefundModification() $params = array( "merchantAccount" => $this->_merchantAccount, "modificationAmount" => $modificationAmount, - "reference" => $pspReference . '_refund', + "reference" => $pspReference.'_refund', "originalReference" => $pspReference ); @@ -64,4 +64,61 @@ public function testRefundModification() } + public function testAdjustDecreaseModification() + { + // create a payment + require_once __DIR__.'/CreatePaymentRequestTest.php'; + $test = new CreatePaymentRequestTest(); + $result = $test->testCreatePaymentSuccess(); + + $pspReference = $result['pspReference']; + + // create modification + $client = $this->createClient(); + + // initialize service + $service = new Service\Modification($client); + + $params = array( + "merchantAccount" => $this->_merchantAccount, + "modificationAmount" => array('currency' => 'EUR', 'value' => '750'), + "reference" => $pspReference.'_adjustAuthorisation', + "originalReference" => $pspReference + ); + + $result = $service->adjustAuthorisation($params); + + $this->assertEquals('[adjustAuthorisation-received]', $result['response']); + + } + + public function testAdjustIncreaseModification() + { + // create a payment + require_once __DIR__.'/CreatePaymentRequestTest.php'; + $test = new CreatePaymentRequestTest(); + $result = $test->testCreatePaymentSuccess(); + + $pspReference = $result['pspReference']; + + // create modification + $client = $this->createClient(); + + // initialize service + $service = new Service\Modification($client); + + $params = array( + "merchantAccount" => $this->_merchantAccount, + "modificationAmount" => array('currency' => 'EUR', 'value' => '1600'), + "reference" => $pspReference.'_adjustAuthorisation', + "originalReference" => $pspReference + ); + + $result = $service->adjustAuthorisation($params); + + $this->assertEquals('[adjustAuthorisation-received]', $result['response']); + + } + + } diff --git a/tests/PosPaymentTest.php b/tests/PosPaymentTest.php new file mode 100644 index 000000000..568b3993b --- /dev/null +++ b/tests/PosPaymentTest.php @@ -0,0 +1,190 @@ +createTerminalCloudAPIClient(); + + // initialize service + $service = new Service\PosPayment($client); + + //Construct request + $transactionType = \Adyen\TransactionType::NORMAL; + $serviceID = date("dHis"); + $timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00"); + + $json = '{ + "SaleToPOIRequest": { + "MessageHeader": { + "MessageType": "Request", + "MessageClass": "Service", + "MessageCategory": "Payment", + "SaleID": "PosTestLibrary", + "POIID": "' . $this->getPOIID() . '", + "ProtocolVersion": "3.0", + "ServiceID": "' . $serviceID . '" + }, + "PaymentRequest": { + "SaleData": { + "SaleTransactionID": { + "TransactionID": "POSauth", + "TimeStamp": "' . $timeStamper . '" + }, + "TokenRequestedType": "Customer", + "SaleReferenceID": "SalesRefABC" + }, + "PaymentTransaction": { + "AmountsReq": { + "Currency": "EUR", + "RequestedAmount": ' . 14.91 . ' + } + }, + "PaymentData": { + "PaymentType": "' . $transactionType . '" + } + } + } + } + '; + + $params = json_decode($json, true); //Create associative array for passing along + + try { + $result = $service->runTenderSync($params); + } catch (\Exception $e) { + $this->validateApiPermission($e); + } + + $this->assertTrue(isset($result['SaleToPOIResponse'])); + $this->assertEquals('Success', $result['SaleToPOIResponse']['PaymentResponse']['Response']['Result']); + + } + + public function testCreatePosPaymentDeclined() + { + // initialize client + $client = $this->createTerminalCloudAPIClient(); + + // initialize service + $service = new Service\PosPayment($client); + + //Construct request + $transactionType = \Adyen\TransactionType::NORMAL; + $serviceID = date("dHis"); + $timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00"); + + $json = '{ + "SaleToPOIRequest": { + "MessageHeader": { + "MessageType": "Request", + "MessageClass": "Service", + "MessageCategory": "Payment", + "SaleID": "PosTestLibrary", + "POIID": "' . $this->getPOIID() . '", + "ProtocolVersion": "3.0", + "ServiceID": "' . $serviceID . '" + }, + "PaymentRequest": { + "SaleData": { + "SaleTransactionID": { + "TransactionID": "POSdeclined", + "TimeStamp": "' . $timeStamper . '" + }, + "TokenRequestedType": "Customer", + "SaleReferenceID": "SalesRefABC" + }, + "PaymentTransaction": { + "AmountsReq": { + "Currency": "EUR", + "RequestedAmount": ' . 1.49 . ' + } + }, + "PaymentData": { + "PaymentType": "' . $transactionType . '" + } + } + } + } + '; + + $params = json_decode($json, true); //Create associative array for passing along + + try { + $result = $service->runTenderSync($params); + } catch (\Exception $e) { + $this->validateApiPermission($e); + } + + $this->assertTrue(isset($result['SaleToPOIResponse']['PaymentResponse']['Response']['Result'])); + $this->assertEquals('Failure', $result['SaleToPOIResponse']['PaymentResponse']['Response']['Result']); + + } + + public function testCreatePosEMVRefundSuccess() + { + // initialize client + $client = $this->createTerminalCloudAPIClient(); + + // initialize service + $service = new Service\PosPayment($client); + + //Construct request + $transactionType = \Adyen\TransactionType::REFUND; + $serviceID = date("dHis"); + $timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00"); + + $json = '{ + "SaleToPOIRequest": { + "MessageHeader": { + "MessageType": "Request", + "MessageClass": "Service", + "MessageCategory": "Payment", + "SaleID": "PosTestLibrary", + "POIID": "' . $this->getPOIID() . '", + "ProtocolVersion": "3.0", + "ServiceID": "' . $serviceID . '" + }, + "PaymentRequest": { + "SaleData": { + "SaleTransactionID": { + "TransactionID": "POSrefund", + "TimeStamp": "' . $timeStamper . '" + }, + "TokenRequestedType": "Customer", + "SaleReferenceID": "SalesRefABC" + }, + "PaymentTransaction": { + "AmountsReq": { + "Currency": "EUR", + "RequestedAmount": ' . 14.91 . ' + } + }, + "PaymentData": { + "PaymentType": "' . $transactionType . '" + } + } + } + } + '; + + $params = json_decode($json, true); //Create associative array for passing along + + try { + $result = $service->runTenderSync($params); + } catch (\Exception $e) { + $this->validateApiPermission($e); + } + + $this->assertTrue(isset($result['SaleToPOIResponse'])); + $this->assertEquals('Success', $result['SaleToPOIResponse']['PaymentResponse']['Response']['Result']); + + } + +} \ No newline at end of file diff --git a/tests/Resources/Checkout/invalid-merchant-account.json b/tests/Resources/Checkout/invalid-merchant-account.json new file mode 100644 index 000000000..28afc9887 --- /dev/null +++ b/tests/Resources/Checkout/invalid-merchant-account.json @@ -0,0 +1,6 @@ +{ + "status": 403, + "errorCode": "901", + "message": "Invalid Merchant Account", + "errorType": "security" +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payment-methods-forbidden.json b/tests/Resources/Checkout/payment-methods-forbidden.json new file mode 100644 index 000000000..e80d3334e --- /dev/null +++ b/tests/Resources/Checkout/payment-methods-forbidden.json @@ -0,0 +1,7 @@ +{ + "error": { + "code": 403, + "message": "Forbidden", + "requested URI": "\/checkout\/\/v32\/paymentMethods" + } +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payment-methods-success.json b/tests/Resources/Checkout/payment-methods-success.json new file mode 100644 index 000000000..4159b2a78 --- /dev/null +++ b/tests/Resources/Checkout/payment-methods-success.json @@ -0,0 +1,278 @@ +{ + "paymentMethods": [{ + "name": "AliPay", + "type": "alipay" + }, { + "details": [{ + "key": "additionalData.card.encrypted.json", + "type": "cardToken" + }], + "name": "Credit Card", + "type": "scheme" + }, { + "name": "Bank Transfer (DE)", + "type": "bankTransfer_DE" + }, { + "name": "Bank Transfer (GB)", + "type": "bankTransfer_GB" + }, { + "name": "SEPA Bank Transfer", + "type": "bankTransfer_IBAN" + }, { + "name": "Bank Transfer (NL)", + "type": "bankTransfer_NL" + }, { + "name": "Bank Transfer (PL)", + "type": "bankTransfer_PL" + }, { + "name": "Bank Transfer (SE)", + "type": "bankTransfer_SE" + }, { + "details": [{ + "key": "additionalData.card.encrypted.json", + "type": "cardToken" + }], + "name": "Bancontact card", + "type": "bcmc" + }, { + "name": "Cash-Ticket", + "type": "cashticket" + }, { + "name": "DineroMail", + "type": "dineromail" + }, { + "name": "Online bank transfer.", + "type": "directEbanking" + }, { + "name": "Eenmalige machtiging", + "type": "directdebit_NL" + }, { + "details": [{ + "items": [{ + "id": "11", + "name": "Bank transfer \/ postal" + }, { + "id": "74", + "name": "Banki Sp\u00f3\u0142dzielcze" + }, { + "id": "73", + "name": "BLIK" + }, { + "id": "32", + "name": "BNP Paribas" + }, { + "id": "16", + "name": "Credit Agricole" + }, { + "id": "83", + "name": "EnveloBank" + }, { + "id": "55", + "name": "erata - dotpay installment" + }, { + "id": "93", + "name": "eSKOK" + }, { + "id": "56", + "name": "eurobank p\u0142atno\u015bci online" + }, { + "id": "76", + "name": "Getin Bank PBL" + }, { + "id": "81", + "name": "Idea Cloud" + }, { + "id": "7", + "name": "ING Corporate customers" + }, { + "id": "35", + "name": "Kantor Polski" + }, { + "id": "44", + "name": "Millennium - P\u0142atno\u015bci Internetowe" + }, { + "id": "10", + "name": "Millennium Corporate customers" + }, { + "id": "68", + "name": "mRaty" + }, { + "id": "1", + "name": "mTransfer" + }, { + "id": "80", + "name": "Noble Pay" + }, { + "id": "50", + "name": "Pay Way Toyota Bank" + }, { + "id": "45", + "name": "Pay with Alior Bank" + }, { + "id": "65", + "name": "Paylink Idea Bank" + }, { + "id": "36", + "name": "Pekao24Przelew" + }, { + "id": "70", + "name": "Pocztowy24" + }, { + "id": "6", + "name": "Przelew24" + }, { + "id": "46", + "name": "P\u0142ac\u0119 z Citi Handlowy" + }, { + "id": "38", + "name": "P\u0142ac\u0119 z ING" + }, { + "id": "2", + "name": "P\u0142ac\u0119 z Inteligo" + }, { + "id": "4", + "name": "P\u0142ac\u0119 z iPKO" + }, { + "id": "72", + "name": "P\u0142ac\u0119 z Orange" + }, { + "id": "66", + "name": "P\u0142ac\u0119 z PBS" + }, { + "id": "75", + "name": "P\u0142ac\u0119 z Plus Bank" + }, { + "id": "51", + "name": "P\u0142a\u0107 z BO\u015a" + }, { + "id": "48", + "name": "R-Przelew" + }, { + "id": "88", + "name": "Raiffeisen" + }, { + "id": "52", + "name": "SkyCash" + }, { + "id": "58", + "name": "Szybkie Platnosci Internetowe z Deutsche Bank PBC" + }, { + "id": "60", + "name": "T-Mobile us\u0142ugi bankowe" + }, { + "id": "21", + "name": "VIA - Moje Rachunki" + }, { + "id": "84", + "name": "Volkswagen Bank direct" + }, { + "id": "31", + "name": "Zaplac w Zabce i we Freshmarket" + }, { + "id": "24", + "name": "mPay" + }], + "key": "issuer", + "type": "select" + }], + "name": "Local Polish Payment Methods", + "type": "dotpay" + }, { + "name": "Finnish E-Banking", + "type": "ebanking_FI" + }, { + "name": "Lastschrift (ELV)", + "type": "elv" + }, { + "name": "Nationale Entertainment Card", + "type": "entertainmentcard" + }, { + "details": [{ + "key": "bic", + "type": "text" + }], + "name": "GiroPay", + "type": "giropay" + }, { + "details": [{ + "items": [{ + "id": "1121", + "name": "Test Issuer" + }, { + "id": "1154", + "name": "Test Issuer 5" + }, { + "id": "1153", + "name": "Test Issuer 4" + }, { + "id": "1152", + "name": "Test Issuer 3" + }, { + "id": "1151", + "name": "Test Issuer 2" + }, { + "id": "1162", + "name": "Test Issuer Cancelled" + }, { + "id": "1161", + "name": "Test Issuer Pending" + }, { + "id": "1160", + "name": "Test Issuer Refused" + }, { + "id": "1159", + "name": "Test Issuer 10" + }, { + "id": "1158", + "name": "Test Issuer 9" + }, { + "id": "1157", + "name": "Test Issuer 8" + }, { + "id": "1156", + "name": "Test Issuer 7" + }, { + "id": "1155", + "name": "Test Issuer 6" + }], + "key": "idealIssuer", + "type": "select" + }], + "name": "iDEAL", + "type": "ideal" + }, { + "name": "Phone Payment", + "type": "ivr" + }, { + "name": "Landline phone", + "type": "ivrLandline" + }, { + "name": "Mobile phone", + "type": "ivrMobile" + }, { + "name": "Moneybookers", + "type": "moneybookers" + }, { + "name": "Invoice", + "type": "openinvoice" + }, { + "name": "Paysafecard", + "type": "paysafecard" + }, { + "details": [{ + "key": "sepa.ownerName", + "type": "text" + }, { + "key": "sepa.ibanNumber", + "type": "text" + }], + "name": "SEPA Direct Debit", + "type": "sepadirectdebit" + }, { + "name": "Premium SMS", + "type": "sms" + }, { + "name": "Your Gift", + "type": "yourgift" + }] +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payment-session-success.json b/tests/Resources/Checkout/payment-session-success.json new file mode 100644 index 000000000..42446ad47 --- /dev/null +++ b/tests/Resources/Checkout/payment-session-success.json @@ -0,0 +1,3 @@ +{ + "paymentSession": "eyJjaGVja291dHNob3BwZXJCYXNlVXJsIjoiaHR0cHM6XC9cL2NoZWNrb3V0c2asdHBlci10ZXN0LmFkeWVuLmNvbVwvY2hlY2tvdXRzaG9wcGVyXC8iLCJkaXNhYmxlUmVjdXJyaW5nRGV0YWlsVXJsIjoiaHR0cHM6XC9cL2NoZWNrb3V0c2hvcHBlci10ZXN0LmFkeWVuLmNvbVwvY2hlY2tvdXRzaG9wcGVyXC9zZXJ2aWNlc1wvUGF5bWVudEluaXRpYXRpb25cL3YxXC9kaXNhYmxlUmVjdXJyaW5nRGV0YWlsIiwiZ2VuZXJhdGlvbnRpbWUiOiIyMDE4LTA2LTIyVDE0OjMxOjI1WiIsImluaXRpYXRpb25VcmwiOiJodHRwczpcL1wvY2hlY2tvdXRzaG9wcGVyLXRlc3QuYWR5ZW4uY29tXC9jaGVja291dHNob3BwZXJcL3NlcnZpY2VzXC9QYXltZW50SW5pdGlhdGlvblwvdjFcL2luaXRpYXRlIiwib3JpZ2luIjoiIiwicGF5bWVudCI6eyJhbW91bnQiOnsiY3VycmVuY3kiOiJFVVIiLCJ2YWx1ZSI6MTAwMH0sImNvdW50cnlDb2RlIjoiTkwiLCJyZWZlcmVuY2UiOiJZb3VyIG9yZGVyIG51bWJlciIsInJldHVyblVybCI6Imh0dHBzOlwvXC95b3VyLWNvbXBhbnkuY29tXC8iLCJzZXNzaW9uVmFsaWRpdHkiOiIyMDE4LTA2LTIyVDE1OjMxOjI1WiJ9LCJwYXltZW50RGF0YSI6I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RTIyNzNGODk4NDQ3M0U3NkVFNzM4N0ZFQzBFNzFCODM2ODQ0Qjg0MDZBQzkwNTk0OUZCODhGQzY4RThGMDE4NjYzMkYxRURCNEM5QjVCODg4RUY1QzU3RERFMTEzN0JCRjM2RjY1NEU0N0U1NzFGQkM4ODgyOENCRTk0MzhENzQyRjNDMDkyQUQ1RkYzRTYyQUNBRDI1MjQ2RUE0M0QyMkNGQzhBRTE0NDE5NzY3ODY3RDJDNjBEQ0JBNkFDOTIwMDhEMEQ4ODM0QkVBMTExN0FFMzQ3RjMxMkQ2QzAxQzU3Q0I0MkFERDNENEQ2MkUzNzI3QTNDRThBQTFGMDlCRjZCNzk2QTBBMzc0MUJDNDgxMTEifQ==" +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payments-details-success.json b/tests/Resources/Checkout/payments-details-success.json new file mode 100644 index 000000000..50d146635 --- /dev/null +++ b/tests/Resources/Checkout/payments-details-success.json @@ -0,0 +1,8 @@ +{ + "pspReference":"8515232733321252", + "resultCode":"Authorised", + "additionalData":{ + "liabilityShift":"true", + "refusalReasonRaw":"AUTHORISED" + } +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payments-forbidden.json b/tests/Resources/Checkout/payments-forbidden.json new file mode 100644 index 000000000..d4f790bc7 --- /dev/null +++ b/tests/Resources/Checkout/payments-forbidden.json @@ -0,0 +1,7 @@ +{ + "error": { + "code": 403, + "message": "Forbidden", + "requested URI": "\/checkout\/\/v32\/payments" + } +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payments-result-success.json b/tests/Resources/Checkout/payments-result-success.json new file mode 100644 index 000000000..9ee3775ce --- /dev/null +++ b/tests/Resources/Checkout/payments-result-success.json @@ -0,0 +1,4 @@ +{ + "pspReference": "8535253563623704", + "resultCode": "Authorised" +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payments-success-3D.json b/tests/Resources/Checkout/payments-success-3D.json new file mode 100644 index 000000000..96ee11563 --- /dev/null +++ b/tests/Resources/Checkout/payments-success-3D.json @@ -0,0 +1,20 @@ +{ + "resultCode": "RedirectShopper", + "details": [{ + "key": "MD", + "type": "text" + }, { + "key": "PaRes", + "type": "text" + }], + "paymentData": "Ab02b4c0!BQABAgBnicwOBkouhPP08Qjg5E5clc0bGyemR...", + "redirect": { + "data": { + "PaReq": "eNpVUttygjAU\/BXbDyAXQZE5ZoZKZ+oD1lp97jDhjNKR...", + "TermUrl": "https:\/\/your-company.com\/...", + "MD": "djIhd29JYnByWUlsYkRuWndGakdkd0F5dz09IWSjFITvzeJZYp37u..." + }, + "method": "POST", + "url": "https:\/\/test.adyen.com\/hpp\/3d\/validate.shtml" + } +} \ No newline at end of file diff --git a/tests/Resources/Checkout/payments-success.json b/tests/Resources/Checkout/payments-success.json new file mode 100644 index 000000000..2f5ab1ad8 --- /dev/null +++ b/tests/Resources/Checkout/payments-success.json @@ -0,0 +1,91 @@ +{ + "additionalData": { + "expiryDate": "8\/2018", + "fraudResultType": "GREEN", + "cardBin": "411111", + "cardSummary": "1111", + "fraudManualReview": "false", + "aliasType": "Default", + "alias": "H167852639363479", + "cardPaymentMethod": "visa", + "cardIssuingCountry": "NL" + }, + "fraudResult": { + "accountScore": 50, + "results": [{ + "FraudCheckResult": { + "accountScore": 0, + "checkId": 2, + "name": "CardChunkUsage" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 3, + "name": "PaymentDetailUsage" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 4, + "name": "HolderNameUsage" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 1, + "name": "PaymentDetailRefCheck" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 13, + "name": "IssuerRefCheck" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 15, + "name": "IssuingCountryReferral" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 27, + "name": "PmOwnerRefCheck" + } + }, { + "FraudCheckResult": { + "accountScore": 50, + "checkId": 41, + "name": "PaymentDetailNonFraudRefCheck" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 10, + "name": "HolderNameContainsNumber" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 11, + "name": "HolderNameIsOneWord" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 82, + "name": "CustomFieldCheck" + } + }, { + "FraudCheckResult": { + "accountScore": 0, + "checkId": 25, + "name": "CVCAuthResultCheck" + } + }] + }, + "pspReference": "8535253563623704", + "resultCode": "Authorised" +} \ No newline at end of file diff --git a/tests/Resources/CheckoutUtility/origin-keys-success.json b/tests/Resources/CheckoutUtility/origin-keys-success.json new file mode 100644 index 000000000..12908762a --- /dev/null +++ b/tests/Resources/CheckoutUtility/origin-keys-success.json @@ -0,0 +1,7 @@ +{ + "originKeys": { + "https://www.your-domain1.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4xLmNvbQ.UEwIBmW9-c_uXo5wSEr2w8Hz8hVIpujXPHjpcEse3xI", + "https://www.your-domain3.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4zLmNvbQ.fUvflu-YIdZSsLEH8Qqmr7ksE4ag_NYiiMXK0s6aq_4", + "https://www.your-domain2.com": "pub.v2.7814286629520534.aHR0cHM6Ly93d3cueW91ci1kb21haW4yLmNvbQ.EP6eXBJKk0t7-QIUl6e_b1qMuMHGepxG_SlUqxAYrfY" + } +} \ No newline at end of file diff --git a/tests/Resources/Payment/authorise-success.json b/tests/Resources/Payment/authorise-success.json new file mode 100644 index 000000000..bca90b0b0 --- /dev/null +++ b/tests/Resources/Payment/authorise-success.json @@ -0,0 +1,5 @@ +{ + "pspReference": "8815281183344931", + "resultCode": "Authorised", + "authCode": "99310" +} \ No newline at end of file diff --git a/tests/Resources/Payment/invalid-merchant-account.json b/tests/Resources/Payment/invalid-merchant-account.json new file mode 100644 index 000000000..28afc9887 --- /dev/null +++ b/tests/Resources/Payment/invalid-merchant-account.json @@ -0,0 +1,6 @@ +{ + "status": 403, + "errorCode": "901", + "message": "Invalid Merchant Account", + "errorType": "security" +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index ab6c93e53..ccfc194d6 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,9 +11,11 @@ class TestCase extends \PHPUnit_Framework_TestCase public function __construct() { + $this->_merchantAccount = $this->getMerchantAccount(); $this->_skinCode = $this->getSkinCode(); $this->_hmacSignature = $this->getHmacSignature(); + } @@ -128,6 +130,23 @@ protected function createReviewPayoutClient() } } + protected function createTerminalCloudAPIClient() + { + // load settings from .ini file + $settings = $this->_loadConfigIni(); + + if(!isset($settings['x-api-key']) || !isset($settings['POIID']) || $settings['x-api-key'] == 'YOUR X-API KEY' || $settings['POIID'] == 'UNIQUETERMINALID'){ + $this->_skipTest("Skipped the test. Configure your x-api-key and POIID in the config"); + }else{ + + $client = new \Adyen\Client(); + $client->setApplicationName("My Test Terminal API App"); + $client->setEnvironment(\Adyen\Environment::TEST); + $client->setXApiKey($settings['x-api-key']); + return $client; + + } + } protected function createClientWithMerchantAccount() { @@ -178,6 +197,17 @@ protected function getHmacSignature() return $settings['hmacSignature']; } + protected function getPOIID() + { + $settings = $this->_loadConfigIni(); + + if(!isset($settings['POIID']) || $settings['POIID'] == 'MODEL-SERIALNUMBER') { + return null; + } + + return $settings['POIID']; + } + protected function _loadConfigIni() { return parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'test.ini', true); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9a5a40d97..7880d07bb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,3 +1,4 @@