Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 6.1.0 #178

Merged
merged 3 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Adyen/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -142,13 +144,15 @@ 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);
$this->config->set('endpointTerminalCloud', self::ENDPOINT_TERMINAL_CLOUD_LIVE);
$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(
Expand Down Expand Up @@ -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
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Adyen/HttpClient/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
107 changes: 107 additions & 0 deletions src/Adyen/Service/DisputeService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

namespace Adyen\Service;

use Adyen\Service\ResourceModel\DisputeService\DefendDispute;
use Adyen\Service\ResourceModel\DisputeService\DeleteDisputeDefenseDocument;
use Adyen\Service\ResourceModel\DisputeService\RetrieveApplicableDefenseReasons;
use Adyen\Service\ResourceModel\DisputeService\SupplyDefenseDocument;

class DisputeService extends \Adyen\Service
{
/**
* @var \Adyen\Service\ResourceModel\DisputeService\RetrieveApplicableDefenseReasons
*/
protected $retrieveApplicableDefenseReasons;

/**
* @var \Adyen\Service\ResourceModel\DisputeService\DeleteDisputeDefenseDocument
*/
protected $deleteDisputeDefenseDocument;

/**
* @var \Adyen\Service\ResourceModel\DisputeService\DefendDispute
*/
protected $defendDispute;

/**
* @var \Adyen\Service\ResourceModel\DisputeService\SupplyDefenseDocument
*/
protected $supplyDefenseDocument;

/**
* @inheritDoc
*/
public function __construct(\Adyen\Client $client)
{
parent::__construct($client);
$this->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;
}
}
17 changes: 17 additions & 0 deletions src/Adyen/Service/ResourceModel/DisputeService/DefendDispute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Adyen\Service\ResourceModel\DisputeService;

use Adyen\Service\AbstractResource;

class DefendDispute extends AbstractResource
{
/**
* DefendDispute constructor.
*
* @param \Adyen\Service\DisputeService $service
*/
public function __construct($service) {
parent::__construct($service, $service->getResourceURL('defendDispute'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Adyen\Service\ResourceModel\DisputeService;

use Adyen\Service\AbstractResource;

class DeleteDisputeDefenseDocument extends AbstractResource
{
/**
* DeleteDisputeDefenseDocument constructor.
*
* @param \Adyen\Service\DisputeService $service
*/
public function __construct($service) {
parent::__construct($service, $service->getResourceURL('deleteDisputeDefenseDocument'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Adyen\Service\ResourceModel\DisputeService;

use Adyen\Service\AbstractResource;

class RetrieveApplicableDefenseReasons extends AbstractResource
{
/**
* RetrieveApplicableDefenseReasons constructor.
*
* @param \Adyen\Service\DisputeService $service
*/
public function __construct($service) {
parent::__construct($service, $service->getResourceURL('retrieveApplicableDefenseReasons'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Adyen\Service\ResourceModel\DisputeService;

use Adyen\Service\AbstractResource;

class SupplyDefenseDocument extends AbstractResource
{
/**
* SupplyDefenseDocument constructor.
*
* @param \Adyen\Service\DisputeService $service
*/
public function __construct($service) {
parent::__construct($service, $service->getResourceURL('supplyDefenseDocument'));
}
}