From 123fd86d3c5ec66ddb818362b642dd54e21c4e31 Mon Sep 17 00:00:00 2001 From: pauder Date: Wed, 28 Dec 2016 10:09:22 +0100 Subject: [PATCH 01/18] Add storeDetail resource and a test for bank account --- src/Adyen/Service/Payout.php | 8 +++- .../Payout/ThirdParty/StoreDetail.php | 22 ++++++++++ tests/PayoutThirdPartyTest.php | 41 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php diff --git a/src/Adyen/Service/Payout.php b/src/Adyen/Service/Payout.php index fc54291b1..244aef39d 100644 --- a/src/Adyen/Service/Payout.php +++ b/src/Adyen/Service/Payout.php @@ -13,6 +13,7 @@ class Payout extends \Adyen\Service protected $_declineThirdParty; protected $_storeDetailsAndSubmitThirdParty; protected $_submitThirdParty; + protected $_storeDetail; public function __construct(\Adyen\Client $client) { @@ -26,7 +27,7 @@ public function __construct(\Adyen\Client $client) $this->_declineThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\DeclineThirdParty($this); $this->_storeDetailsAndSubmitThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\StoreDetailsAndSubmitThirdParty($this); $this->_submitThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\SubmitThirdParty($this); - + $this->_storeDetail = new \Adyen\Service\ResourceModel\Payout\ThirdParty\StoreDetail($this); } public function confirm($params) { @@ -61,7 +62,10 @@ public function submitThirdParty($params) { $result = $this->_submitThirdParty->request($params); return $result; } - + public function storeDetail($params) { + $result = $this->_storeDetail->request($params); + return $result; + } } diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php new file mode 100644 index 000000000..1fd60b92d --- /dev/null +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php @@ -0,0 +1,22 @@ +_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetail'; + parent::__construct($service, $this->_endpoint, $this->_requiredFields); + } + +} \ No newline at end of file diff --git a/tests/PayoutThirdPartyTest.php b/tests/PayoutThirdPartyTest.php index d80e86fe8..7a15fb856 100644 --- a/tests/PayoutThirdPartyTest.php +++ b/tests/PayoutThirdPartyTest.php @@ -134,6 +134,47 @@ public function testStoreDetailAndSubmitPayoutThirdPartyInvalidIban() $this->assertEquals('Adyen\AdyenException', get_class($e)); $this->assertEquals('Invalid iban', $e->getMessage()); } + + public function testStoreDetailsBankSuccess() + { + // initialize client + $client = $this->createPayoutClient(); + + // initialize service + $service = new Service\Payout($client); + + $json = '{ + "bank": { + "iban": "FR14 2004 1010 0505 0001 3M02 606", + "ownerName": "John Smith", + "countryCode": "FR" + }, + "recurring": { + "contract": "PAYOUT" + }, + "shopperEmail": "john.smith@test.com", + "shopperReference": "johnsmithuniqueid", + "merchantAccount": "' . $this->_merchantAccount .'" + }'; + + $params = json_decode($json, true); + + try { + $result = $service->storeDetail($params); + } catch (\Exception $e) { + $this->validateApiPermission($e); + } + + // must exists + $this->assertTrue(isset($result['resultCode'])); + + // Assert + $this->assertEquals('Success', $result['resultCode']); + + // return the result so this can be used in other test cases + return $result; + + } public function testStoreDetailAndSubmitPayoutThirdPartySuccess() { From 79b922cc3fa41727a7ed65489cf4db539b9b5030 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 10 Mar 2017 15:00:56 +0100 Subject: [PATCH 02/18] add coveralls --- .travis.yml | 3 ++- composer.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a421e625..01a3fbd83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,5 @@ php: - hhvm - nightly before_script: - - composer install \ No newline at end of file + - composer install +after_script: ./vendor/bin/coveralls -v \ No newline at end of file diff --git a/composer.json b/composer.json index a310aeef8..43a03c320 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ }, "require-dev": { "phpunit/phpunit": "~4", + "satooshi/php-coveralls": "~1.0.1", "squizlabs/php_codesniffer": "~2.3" }, "autoload": { From 33fbd5daa7d011b70e0c39c5c06ad8b3a52a7ada Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 10 Mar 2017 15:04:22 +0100 Subject: [PATCH 03/18] add coveralls config file --- .coveralls.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 000000000..85e7d3964 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,4 @@ +service_name: travis-ci +src_dir: . +coverage_clover: clover.xml +json_path: coveralls-upload.json \ No newline at end of file From e9807a3b4ded7592a9fd5e9bd49e162a70932225 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 10 Mar 2017 15:07:32 +0100 Subject: [PATCH 04/18] removed deprecated src_dir --- .coveralls.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.coveralls.yml b/.coveralls.yml index 85e7d3964..b97b80d8f 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,4 +1,3 @@ service_name: travis-ci -src_dir: . coverage_clover: clover.xml json_path: coveralls-upload.json \ No newline at end of file From d3e100ee4126b8edd95b70b99cb85961473478f7 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 10 Mar 2017 15:13:31 +0100 Subject: [PATCH 05/18] use new coveralls implementation --- .coveralls.yml | 3 --- .travis.yml | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index b97b80d8f..000000000 --- a/.coveralls.yml +++ /dev/null @@ -1,3 +0,0 @@ -service_name: travis-ci -coverage_clover: clover.xml -json_path: coveralls-upload.json \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 01a3fbd83..536fd4a6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,5 @@ php: - nightly before_script: - composer install -after_script: ./vendor/bin/coveralls -v \ No newline at end of file +after_script: + - travis_retry php vendor/bin/coveralls \ No newline at end of file From 062d025026c83b9c12556a65cf6cdfb679f398f8 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 10 Mar 2017 16:03:44 +0100 Subject: [PATCH 06/18] coveralls fix --- .travis.yml | 9 +++++++-- phpunit.xml | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 536fd4a6f..d24506eb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,10 @@ php: - nightly before_script: - composer install -after_script: - - travis_retry php vendor/bin/coveralls \ No newline at end of file + +script: + - mkdir -p build/logs + - phpunit --coverage-clover build/logs/clover.xml -c app + +after_success: + - bin/coveralls -v \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml index a27aa3298..8d9a6962a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,4 +9,7 @@ ./src + + + \ No newline at end of file From 9168a5c6a9d4fce140c1acf8de15aabcf31081de Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 10 Mar 2017 16:08:20 +0100 Subject: [PATCH 07/18] revert --- .travis.yml | 9 +-------- phpunit.xml | 3 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index d24506eb7..3a421e625 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,4 @@ php: - hhvm - nightly before_script: - - composer install - -script: - - mkdir -p build/logs - - phpunit --coverage-clover build/logs/clover.xml -c app - -after_success: - - bin/coveralls -v \ No newline at end of file + - composer install \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml index 8d9a6962a..a27aa3298 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,7 +9,4 @@ ./src - - - \ No newline at end of file From d4b7a9c5a9c58e65eb6428e65bf173ef8ebc0ea3 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Fri, 14 Apr 2017 11:12:33 +0200 Subject: [PATCH 08/18] Update to v25 --- src/Adyen/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index 70ee65093..cd3c0b6e9 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -14,7 +14,7 @@ class Client const ENDPOINT_LIVE = "https://pal-live.adyen.com"; const ENPOINT_TEST_DIRECTORY_LOOKUP = "https://test.adyen.com/hpp/directory.shtml"; const ENPOINT_LIVE_DIRECTORY_LOOKUP = "https://live.adyen.com/hpp/directory.shtml"; - const API_VERSION = "v18"; + const API_VERSION = "v25"; /** * @var Adyen_Config $config From 79ab1ebfca125e0423b89f1e28864d0e0add65e2 Mon Sep 17 00:00:00 2001 From: ivodvb Date: Wed, 3 May 2017 11:33:26 +0200 Subject: [PATCH 09/18] Made error handlers protected instead of private --- src/Adyen/HttpClient/CurlClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index 027b36dad..c0bf5e79c 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -184,7 +184,7 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params) * @param $logger * @throws \Adyen\AdyenException */ - private function handleCurlError($url, $errno, $message, $logger) + protected function handleCurlError($url, $errno, $message, $logger) { switch ($errno) { case CURLE_OK: @@ -217,7 +217,7 @@ private function handleCurlError($url, $errno, $message, $logger) * @param $logger * @throws \Adyen\AdyenException */ - private function handleResultError($result, $logger) + protected function handleResultError($result, $logger) { $decodeResult = json_decode($result, true); From 4112c8d796d669ab2d3ae9567e17c35517828f5c Mon Sep 17 00:00:00 2001 From: ivodvb Date: Wed, 3 May 2017 11:41:27 +0200 Subject: [PATCH 10/18] Also testing php 7.0 and 7.1 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3a421e625..afe75aa90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 + - 7.1 - hhvm - nightly before_script: From 24d1500a0ff41e3b1152d92b98c0eede2842c9ed Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Mon, 26 Jun 2017 15:59:10 +0200 Subject: [PATCH 11/18] #27 use unique Exception for CURL errors. Changed AdyenException to ConnectionException for empty result from API result --- src/Adyen/ConnectionException.php | 10 ++++++++++ src/Adyen/HttpClient/CurlClient.php | 2 +- tests/ExceptionTest.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/Adyen/ConnectionException.php diff --git a/src/Adyen/ConnectionException.php b/src/Adyen/ConnectionException.php new file mode 100644 index 000000000..5d24bf5b7 --- /dev/null +++ b/src/Adyen/ConnectionException.php @@ -0,0 +1,10 @@ +error($msg); - throw new \Adyen\AdyenException($msg); + throw new \Adyen\ConnectionException($msg); } /** diff --git a/tests/ExceptionTest.php b/tests/ExceptionTest.php index ca40f5c20..bac76c6a3 100644 --- a/tests/ExceptionTest.php +++ b/tests/ExceptionTest.php @@ -116,7 +116,7 @@ public function testExceptionMissingUsernamePassword() } // check if exception is correct - $this->assertEquals('Adyen\AdyenException', get_class($e)); + $this->assertEquals('Adyen\ConnectionException', get_class($e)); $this->assertEquals("Probably your Web Service username and/or password is incorrect\n(Network error [errno 0]: )", $e->getMessage()); $this->assertEquals('0', $e->getCode()); } From 42a821dbe77a650542083281a8286e8dde2de98b Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Tue, 27 Jun 2017 08:44:05 +0200 Subject: [PATCH 12/18] change distribution to trusty to support HHVM tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index afe75aa90..5c35d3e3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: php +dist: trusty # to support hhvm tests php: - 5.3 - 5.4 From 2203a3faf212264c1241aafedc0ac5d62fb2b456 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Tue, 27 Jun 2017 08:47:44 +0200 Subject: [PATCH 13/18] change distribution to trusty to support HHVM tests --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5c35d3e3a..4f08ae453 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: php -dist: trusty # to support hhvm tests php: - 5.3 - 5.4 @@ -9,5 +8,9 @@ php: - 7.1 - hhvm - nightly +matrix: # to support hhvm tests + include: + - php: "hhvm" + dist: trusty before_script: - composer install \ No newline at end of file From 49f1c898a6cb4a479d4e46280ce994516e3ab224 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Tue, 27 Jun 2017 08:55:34 +0200 Subject: [PATCH 14/18] fix php version in matrix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f08ae453..276942e0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ php: - nightly matrix: # to support hhvm tests include: - - php: "hhvm" + - php: hhvm dist: trusty before_script: - composer install \ No newline at end of file From 2737a21644ead132c42cadf78be8e65abedc8899 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Tue, 27 Jun 2017 09:17:15 +0200 Subject: [PATCH 15/18] change distribution to trusty to support HHVM tests --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 276942e0d..f38088f0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,9 @@ php: - 7.1 - hhvm - nightly -matrix: # to support hhvm tests +matrix: include: - - php: hhvm - dist: trusty + - php: hhvm + dist: trusty before_script: - composer install \ No newline at end of file From b7017c64ae1c5884c5a476bb4b659e1d74a95847 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Mon, 3 Jul 2017 11:39:27 +0200 Subject: [PATCH 16/18] remove hhvm from automatic build because of limitation travis-ci platform --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f38088f0a..5efc2b8ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,6 @@ php: - 5.6 - 7.0 - 7.1 - - hhvm - nightly -matrix: - include: - - php: hhvm - dist: trusty before_script: - composer install \ No newline at end of file From e7b42bfef83a042e72230ee809c9366a2ecf7268 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Mon, 3 Jul 2017 12:08:47 +0200 Subject: [PATCH 17/18] #29 Add status and ErrorType into the AdyenException --- src/Adyen/AdyenException.php | 39 ++++++++++++++++++++++++++--- src/Adyen/HttpClient/CurlClient.php | 2 +- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/Adyen/AdyenException.php b/src/Adyen/AdyenException.php index 0b3ed6d8b..d476125fd 100644 --- a/src/Adyen/AdyenException.php +++ b/src/Adyen/AdyenException.php @@ -7,8 +7,39 @@ class AdyenException extends Exception { -//"status": 403, -//"errorCode": "901", -//"message": "Invalid Merchant Account", -//"errorType": "security" + protected $_status; + protected $_errorType; + + /** + * AdyenException constructor. + * @param string $message + * @param int $code + * @param Exception|null $previous + * @param null $status + * @param null $errorType + */ + public function __construct($message = "", $code = 0, Exception $previous = null, $status = null, $errorType = null) + { + $this->_status = $status; + $this->_errorType = $errorType; + parent::__construct($message, $code, $previous); + } + + /** + * Get status + * + * @return null + */ + public function getStatus() + { + return $this->_status; + } + + /** + * Get Adyen Error type + */ + public function getErrorType() + { + return $this->_errorType; + } } diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index 796d27070..e312ac62f 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -223,7 +223,7 @@ protected function handleResultError($result, $logger) if(isset($decodeResult['message']) && isset($decodeResult['errorCode'])) { $logger->error($decodeResult['errorCode'] . ': ' . $decodeResult['message']); - throw new \Adyen\AdyenException($decodeResult['message'], $decodeResult['errorCode']); + throw new \Adyen\AdyenException($decodeResult['message'], $decodeResult['errorCode'], null, $decodeResult['status'], $decodeResult['errorType']); } $logger->error($result); throw new \Adyen\AdyenException($result); From 95f6faf135f75d3e121cefd54ce919322d2e18a1 Mon Sep 17 00:00:00 2001 From: Rik ter Beek Date: Mon, 7 Aug 2017 08:43:28 +0200 Subject: [PATCH 18/18] update version to 1.3.0 --- src/Adyen/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index cd3c0b6e9..5a73f3a8b 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -8,7 +8,7 @@ class Client { - const LIB_VERSION = "1.2.0"; + const LIB_VERSION = "1.3.0"; const USER_AGENT_SUFFIX = "adyen-php-api-library/"; const ENDPOINT_TEST = "https://pal-test.adyen.com"; const ENDPOINT_LIVE = "https://pal-live.adyen.com";