From 6d4ddd01d0b36dd552e5e487ebe08286d2e504f6 Mon Sep 17 00:00:00 2001 From: cyattilakiss <42297201+cyattilakiss@users.noreply.github.com> Date: Thu, 26 Mar 2020 14:12:47 +0100 Subject: [PATCH 1/3] Add accepted http status codes 201, 202 and 204 in requestJson() (#177) Adyen API can respond with 200, 201, 202 and 204 http codes when OK --- src/Adyen/HttpClient/CurlClient.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index 62896f31a..2a617f7c8 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -127,8 +127,9 @@ public function requestJson(\Adyen\Service $service, $requestUrl, $params, $requ curl_close($ch); - // result not 200 throw error - if ($httpStatus != 200 && $result) { + $resultOKHttpStatusCodes = array(200, 201, 202, 204); + + if (!in_array($httpStatus, $resultOKHttpStatusCodes) && $result) { $this->handleResultError($result, $logger); } elseif (!$result) { $this->handleCurlError($requestUrl, $errno, $message, $logger); From de5c38359553f1e89b6e40e67cf7fa3bacf8c757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20Geli=C5=9F?= Date: Thu, 26 Mar 2020 17:58:45 +0300 Subject: [PATCH 2/3] integration for /DisputeService service resources (#151) --- src/Adyen/Client.php | 16 ++- src/Adyen/Service/DisputeService.php | 107 ++++++++++++++++++ .../DisputeService/DefendDispute.php | 17 +++ .../DeleteDisputeDefenseDocument.php | 17 +++ .../RetrieveApplicableDefenseReasons.php | 17 +++ .../DisputeService/SupplyDefenseDocument.php | 17 +++ 6 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 src/Adyen/Service/DisputeService.php create mode 100644 src/Adyen/Service/ResourceModel/DisputeService/DefendDispute.php create mode 100644 src/Adyen/Service/ResourceModel/DisputeService/DeleteDisputeDefenseDocument.php create mode 100644 src/Adyen/Service/ResourceModel/DisputeService/RetrieveApplicableDefenseReasons.php create mode 100644 src/Adyen/Service/ResourceModel/DisputeService/SupplyDefenseDocument.php diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index ecb2ad398..ff48be21d 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -25,6 +25,7 @@ class Client const API_NOTIFICATION_VERSION = "v5"; const API_ACCOUNT_VERSION = "v5"; const API_FUND_VERSION = "v5"; + const API_DISPUTE_SERVICE_VERSION = "v30"; const ENDPOINT_TERMINAL_CLOUD_TEST = "https://terminal-api-test.adyen.com"; const ENDPOINT_TERMINAL_CLOUD_LIVE = "https://terminal-api-live.adyen.com"; const ENDPOINT_CHECKOUT_TEST = "https://checkout-test.adyen.com/checkout"; @@ -36,7 +37,8 @@ class Client const ENDPOINT_ACCOUNT_LIVE = "https://cal-live.adyen.com/cal/services/Account"; const ENDPOINT_FUND_TEST = "https://cal-test.adyen.com/cal/services/Fund"; const ENDPOINT_FUND_LIVE = "https://cal-live.adyen.com/cal/services/Fund"; - + const ENDPOINT_DISPUTE_SERVICE_TEST = "https://ca-test.adyen.com/ca/services/DisputeService"; + const ENDPOINT_DISPUTE_SERVICE_LIVE = "https://ca-live.adyen.com/ca/services/DisputeService"; /** * @var \Adyen\Config $config @@ -142,6 +144,7 @@ public function setEnvironment($environment, $liveEndpointUrlPrefix = null) $this->config->set('endpointNotification', self::ENDPOINT_NOTIFICATION_TEST); $this->config->set('endpointAccount', self::ENDPOINT_ACCOUNT_TEST); $this->config->set('endpointFund', self::ENDPOINT_FUND_TEST); + $this->config->set('endpointDisputeService', self::ENDPOINT_DISPUTE_SERVICE_TEST); } elseif ($environment == \Adyen\Environment::LIVE) { $this->config->set('environment', \Adyen\Environment::LIVE); $this->config->set('endpointDirectorylookup', self::ENDPOINT_LIVE_DIRECTORY_LOOKUP); @@ -149,6 +152,7 @@ public function setEnvironment($environment, $liveEndpointUrlPrefix = null) $this->config->set('endpointNotification', self::ENDPOINT_NOTIFICATION_LIVE); $this->config->set('endpointAccount', self::ENDPOINT_ACCOUNT_LIVE); $this->config->set('endpointFund', self::ENDPOINT_FUND_LIVE); + $this->config->set('endpointDisputeService', self::ENDPOINT_DISPUTE_SERVICE_LIVE); if ($liveEndpointUrlPrefix) { $this->config->set( @@ -382,6 +386,16 @@ public function getApiFundVersion() return self::API_FUND_VERSION; } + /** + * Get the disputes service API version + * + * @return string + */ + public function getDisputeServiceVersion() + { + return self::API_DISPUTE_SERVICE_VERSION; + } + /** * @param HttpClient\ClientInterface $httpClient */ diff --git a/src/Adyen/Service/DisputeService.php b/src/Adyen/Service/DisputeService.php new file mode 100644 index 000000000..4c309c6e4 --- /dev/null +++ b/src/Adyen/Service/DisputeService.php @@ -0,0 +1,107 @@ +retrieveApplicableDefenseReasons = new RetrieveApplicableDefenseReasons($this); + $this->deleteDisputeDefenseDocument = new DeleteDisputeDefenseDocument($this); + $this->defendDispute = new DefendDispute($this); + $this->supplyDefenseDocument = new SupplyDefenseDocument($this); + } + + /** + * Handler for /retrieveApplicableDefenseReasons endpoint + * + * @param array $params + * + * @return mixed + * @throws \Adyen\AdyenException + */ + public function retrieveApplicableDefenseReasons($params) + { + return $this->retrieveApplicableDefenseReasons->request($params); + } + + /** + * Handler for /supplyDefenseDocument endpoint + * + * @param array $params + * + * @return mixed + * @throws \Adyen\AdyenException + */ + public function supplyDefenseDocument($params) + { + return $this->supplyDefenseDocument->request($params); + } + + /** + * Handler for /deleteDisputeDefenseDocument endpoint + * + * @param array $params + * + * @return mixed + * @throws \Adyen\AdyenException + */ + public function deleteDisputeDefenseDocument($params) + { + return $this->deleteDisputeDefenseDocument->request($params); + } + + /** + * Handler for /defendDispute endpoint + * + * @param array $params + * + * @return mixed + * @throws \Adyen\AdyenException + */ + public function defendDispute($params) + { + return $this->defendDispute->request($params); + } + + /** + * Get the service resource endpoint URL + * + * @param string $endpoint + * + * @return string + */ + public function getResourceURL($endpoint) + { + return $this->getClient()->getConfig()->get('endpointDisputeService') . '/' . $this->getClient()->getDisputeServiceVersion() . '/' . $endpoint; + } +} diff --git a/src/Adyen/Service/ResourceModel/DisputeService/DefendDispute.php b/src/Adyen/Service/ResourceModel/DisputeService/DefendDispute.php new file mode 100644 index 000000000..9c538254b --- /dev/null +++ b/src/Adyen/Service/ResourceModel/DisputeService/DefendDispute.php @@ -0,0 +1,17 @@ +getResourceURL('defendDispute')); + } +} diff --git a/src/Adyen/Service/ResourceModel/DisputeService/DeleteDisputeDefenseDocument.php b/src/Adyen/Service/ResourceModel/DisputeService/DeleteDisputeDefenseDocument.php new file mode 100644 index 000000000..db8008239 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/DisputeService/DeleteDisputeDefenseDocument.php @@ -0,0 +1,17 @@ +getResourceURL('deleteDisputeDefenseDocument')); + } +} diff --git a/src/Adyen/Service/ResourceModel/DisputeService/RetrieveApplicableDefenseReasons.php b/src/Adyen/Service/ResourceModel/DisputeService/RetrieveApplicableDefenseReasons.php new file mode 100644 index 000000000..800194203 --- /dev/null +++ b/src/Adyen/Service/ResourceModel/DisputeService/RetrieveApplicableDefenseReasons.php @@ -0,0 +1,17 @@ +getResourceURL('retrieveApplicableDefenseReasons')); + } +} diff --git a/src/Adyen/Service/ResourceModel/DisputeService/SupplyDefenseDocument.php b/src/Adyen/Service/ResourceModel/DisputeService/SupplyDefenseDocument.php new file mode 100644 index 000000000..97b6f028a --- /dev/null +++ b/src/Adyen/Service/ResourceModel/DisputeService/SupplyDefenseDocument.php @@ -0,0 +1,17 @@ +getResourceURL('supplyDefenseDocument')); + } +} From 48be394e10cd5665b1bfdc5807712085883d092e Mon Sep 17 00:00:00 2001 From: attilak Date: Thu, 26 Mar 2020 16:04:01 +0100 Subject: [PATCH 3/3] Version bump 6.1.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 ff48be21d..49aa9d2b4 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -8,7 +8,7 @@ class Client { - const LIB_VERSION = "6.0.1"; + const LIB_VERSION = "6.1.0"; const LIB_NAME = "adyen-php-api-library"; const USER_AGENT_SUFFIX = "adyen-php-api-library/"; const ENDPOINT_TEST = "https://pal-test.adyen.com";