diff --git a/README.md b/README.md index e87712fbb..38aa53189 100644 --- a/README.md +++ b/README.md @@ -42,15 +42,16 @@ $client = new \Adyen\Client(); $client->setApplicationName("Adyen PHP Api Library Example"); $client->setUsername("YOUR USERNAME"); $client->setPassword("YOUR PASSWORD"); +$client->setXApiKey("YOUR API KEY"); $client->setEnvironment(\Adyen\Environment::TEST); -$service = new Service\Payment($client); +$service = new \Adyen\Service\Payment($client); $json = '{ "card": { "number": "4111111111111111", - "expiryMonth": "6", - "expiryYear": "2016", + "expiryMonth": "10", + "expiryYear": "2020", "cvc": "737", "holderName": "John Smith" }, @@ -92,10 +93,11 @@ $client = new \Adyen\Client(); $client->setApplicationName("Adyen PHP Api Library Example"); $client->setUsername("YOUR USERNAME"); $client->setPassword("YOUR PASSWORD"); +$client->setXApiKey("YOUR API KEY"); $client->setEnvironment(\Adyen\Environment::TEST); // intialize modification service -$service = new Service\Modification($client); +$service = new \Adyen\Service\Modification($client); // set the amount you want to refund $modificationAmount = array('currency' => 'CURRENCY', 'value' => 'VALUE'); diff --git a/src/Adyen/AdyenException.php b/src/Adyen/AdyenException.php index b942e593f..3d793303e 100644 --- a/src/Adyen/AdyenException.php +++ b/src/Adyen/AdyenException.php @@ -6,40 +6,47 @@ class AdyenException extends Exception { + /** + * @var null + */ + protected $_status; - protected $_status; - protected $_errorType; + /** + * @var null + */ + 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, (int) $code, $previous); - } + /** + * 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, (int)$code, $previous); + } - /** - * Get status - * - * @return null - */ - public function getStatus() - { - return $this->_status; - } + /** + * Get status + * + * @return null + */ + public function getStatus() + { + return $this->_status; + } - /** - * Get Adyen Error type - */ - public function getErrorType() - { - return $this->_errorType; - } + /** + * Get Adyen Error type + */ + public function getErrorType() + { + return $this->_errorType; + } } diff --git a/src/Adyen/ApiKeyAuthenticatedService.php b/src/Adyen/ApiKeyAuthenticatedService.php index adc0bcaaf..5a45f7c60 100644 --- a/src/Adyen/ApiKeyAuthenticatedService.php +++ b/src/Adyen/ApiKeyAuthenticatedService.php @@ -2,8 +2,10 @@ namespace Adyen; - class ApiKeyAuthenticatedService extends Service { - protected $_requiresApiKey = true; -} \ No newline at end of file + /** + * @var bool + */ + protected $_requiresApiKey = true; +} diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index ed94c860c..d35422b67 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -8,7 +8,7 @@ class Client { - const LIB_VERSION = "1.5.2"; + const LIB_VERSION = "1.5.3"; const LIB_NAME = "adyen-php-api-library"; const USER_AGENT_SUFFIX = "adyen-php-api-library/"; const ENDPOINT_TEST = "https://pal-test.adyen.com"; @@ -16,7 +16,8 @@ class Client const ENDPOINT_LIVE_SUFFIX = "-pal-live.adyenpayments.com"; const ENDPOINT_TEST_DIRECTORY_LOOKUP = "https://test.adyen.com/hpp/directory/v2.shtml"; const ENDPOINT_LIVE_DIRECTORY_LOOKUP = "https://live.adyen.com/hpp/directory/v2.shtml"; - const API_VERSION = "v30"; + const API_PAYMENT_VERSION = "v40"; + const API_PAYOUT_VERSION = "v30"; const API_RECURRING_VERSION = "v25"; const API_CHECKOUT_VERSION = "v32"; const API_CHECKOUT_UTILITY_VERSION = "v1"; @@ -26,134 +27,149 @@ class Client const ENDPOINT_CHECKOUT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout"; const ENDPOINT_PROTOCOL = "https://"; - /** - * @var \Adyen\Config $config - */ - private $_config; - private $_httpClient; + /** + * @var \Adyen\Config $config + */ + private $_config; - /** - * @var Logger $logger - */ - private $logger; + /** + * @var + */ + private $_httpClient; - /** - * Client constructor. - * @param null $config - * @throws AdyenException - */ - public function __construct($config = null) - { - if (!$config) { - // create config - $this->_config = new \Adyen\Config(); - } 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"); - } - } + /** + * @var Logger $logger + */ + private $logger; - public function getConfig() - { - return $this->_config; - } + /** + * Client constructor. + * + * @param null $config + * @throws AdyenException + */ + public function __construct($config = null) + { + if (!$config) { + // create config + $this->_config = new \Adyen\Config(); + } 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"); + } + } - /** - * Set Username of Web Service User - * - * @param $username - */ - public function setUsername($username) - { - $this->_config->set('username', $username); - } + /** + * @return Config|ConfigInterface|null + */ + public function getConfig() + { + return $this->_config; + } + /** + * Set Username of Web Service User + * + * @param $username + */ + public function setUsername($username) + { + $this->_config->set('username', $username); + } - /** - * Set Password of Web Service User - * - * @param $password - */ - public function setPassword($password) - { - $this->_config->set('password', $password); - } + /** + * Set Password of Web Service User + * + * @param $password + */ + 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 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 - * For live please specify the unique identifier. - * - * @param string $environment - * @param null $liveEndpointUrlPrefix Provide the unique live url prefix from the "API URLs and Response" menu in the Adyen Customer Area - * @throws AdyenException - */ - public function setEnvironment($environment, $liveEndpointUrlPrefix = null) - { - if ($environment == \Adyen\Environment::TEST) { - $this->_config->set('environment', \Adyen\Environment::TEST); - $this->_config->set('endpoint', self::ENDPOINT_TEST); - $this->_config->set('endpointDirectorylookup', self::ENDPOINT_TEST_DIRECTORY_LOOKUP); - $this->_config->set('endpointTerminalCloud', self::ENDPOINT_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('endpointDirectorylookup', self::ENDPOINT_LIVE_DIRECTORY_LOOKUP); - $this->_config->set('endpointTerminalCloud', self::ENDPOINT_TERMINAL_CLOUD_LIVE); - - if ($liveEndpointUrlPrefix) { - $this->_config->set('endpoint', self::ENDPOINT_PROTOCOL . $liveEndpointUrlPrefix . self::ENDPOINT_LIVE_SUFFIX); - $this->_config->set('endpointCheckout', self::ENDPOINT_PROTOCOL . $liveEndpointUrlPrefix . self::ENDPOINT_CHECKOUT_LIVE_SUFFIX); - } else { - $this->_config->set('endpoint', self::ENDPOINT_LIVE); - $this->_config->set('endpointCheckout', null); // not supported please specify unique identifier - } - } else { - // environment does not exist - $msg = "This environment does not exist, use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; - throw new \Adyen\AdyenException($msg); - } - } + /** + * Set environment to connect to test or live platform of Adyen + * For live please specify the unique identifier. + * + * @param string $environment + * @param null $liveEndpointUrlPrefix Provide the unique live url prefix from the "API URLs and Response" menu in the Adyen Customer Area + * @throws AdyenException + */ + public function setEnvironment($environment, $liveEndpointUrlPrefix = null) + { + if ($environment == \Adyen\Environment::TEST) { + $this->_config->set('environment', \Adyen\Environment::TEST); + $this->_config->set('endpoint', self::ENDPOINT_TEST); + $this->_config->set('endpointDirectorylookup', self::ENDPOINT_TEST_DIRECTORY_LOOKUP); + $this->_config->set('endpointTerminalCloud', self::ENDPOINT_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('endpointDirectorylookup', self::ENDPOINT_LIVE_DIRECTORY_LOOKUP); + $this->_config->set('endpointTerminalCloud', self::ENDPOINT_TERMINAL_CLOUD_LIVE); + + if ($liveEndpointUrlPrefix) { + $this->_config->set('endpoint', + self::ENDPOINT_PROTOCOL . $liveEndpointUrlPrefix . self::ENDPOINT_LIVE_SUFFIX); + $this->_config->set('endpointCheckout', + self::ENDPOINT_PROTOCOL . $liveEndpointUrlPrefix . self::ENDPOINT_CHECKOUT_LIVE_SUFFIX); + } else { + $this->_config->set('endpoint', self::ENDPOINT_LIVE); + $this->_config->set('endpointCheckout', null); // not supported please specify unique identifier + } + } else { + // environment does not exist + $msg = "This environment does not exist, use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; + throw new \Adyen\AdyenException($msg); + } + } - /** - * Set Request URl - * - * @param $url - */ - public function setRequestUrl($url) - { - $this->_config->set('endpoint', $url); - } + /** + * Set Request URl + * + * @param $url + */ + public function setRequestUrl($url) + { + $this->_config->set('endpoint', $url); + } - /** - * Set directory lookup URL - * - * @param $url - */ - public function setDirectoryLookupUrl($url) - { - $this->_config->set('endpointDirectorylookup', $url); - } + /** + * Set directory lookup URL + * + * @param $url + */ + public function setDirectoryLookupUrl($url) + { + $this->_config->set('endpointDirectorylookup', $url); + } - public function setMerchantAccount($merchantAccount) - { - $this->_config->set('merchantAccount', $merchantAccount); - } + /** + * @param $merchantAccount + */ + public function setMerchantAccount($merchantAccount) + { + $this->_config->set('merchantAccount', $merchantAccount); + } - public function setApplicationName($applicationName) - { - $this->_config->set('applicationName', $applicationName); - } + /** + * @param $applicationName + */ + public function setApplicationName($applicationName) + { + $this->_config->set('applicationName', $applicationName); + } /** * Set external platform name, version and integrator @@ -164,7 +180,8 @@ public function setApplicationName($applicationName) */ public function setExternalPlatform($name, $version, $integrator = "") { - $this->_config->set('externalPlatform', array('name' => $name, 'version' => $version, 'integrator' => $integrator)); + $this->_config->set('externalPlatform', + array('name' => $name, 'version' => $version, 'integrator' => $integrator)); } /** @@ -178,30 +195,33 @@ public function setAdyenPaymentSource($name, $version) $this->_config->set('adyenPaymentSource', array('name' => $name, 'version' => $version)); } - /** - * Type can be json or array - * - * @param $value - */ - public function setInputType($value) - { - $this->_config->set('inputType', $value); - } + /** + * Type can be json or array + * + * @param $value + */ + public function setInputType($value) + { + $this->_config->set('inputType', $value); + } - /** - * Type can be json or array - * - * @param $value - */ - public function setOutputType($value) - { - $this->_config->set('outputType', $value); - } + /** + * Type can be json or array + * + * @param $value + */ + public function setOutputType($value) + { + $this->_config->set('outputType', $value); + } - public function setTimeout($value) - { - $this->_config->set('timeout', $value); - } + /** + * @param $value + */ + public function setTimeout($value) + { + $this->_config->set('timeout', $value); + } /** * Get the library name @@ -213,106 +233,124 @@ public function getLibraryName() return self::LIB_NAME; } - /** - * Get the library version - * - * @return string - */ - public function getLibraryVersion() - { - return self::LIB_VERSION; - } + /** + * Get the library version + * + * @return string + */ + public function getLibraryVersion() + { + return self::LIB_VERSION; + } /** - * Get the version of the API endpoint + * Get the version of the API Payment endpoint * * @return string */ - public function getApiVersion() + public function getApiPaymentVersion() { - return self::API_VERSION; + return self::API_PAYMENT_VERSION; } - /** - * Get the version of the Recurring API endpoint - * - * @return string - */ - public function getApiRecurringVersion() - { - return self::API_RECURRING_VERSION; - } + /** + * Get the version of the API Payout endpoint + * + * @return string + */ + public function getApiPayoutVersion() + { + return self::API_PAYOUT_VERSION; + } - /** - * Get the version of the Checkout API endpoint - * - * @return string - */ - public function getApiCheckoutVersion() - { - return self::API_CHECKOUT_VERSION; - } + /** + * Get the version of the Recurring API endpoint + * + * @return string + */ + public function getApiRecurringVersion() + { + return self::API_RECURRING_VERSION; + } - /** - * Get the version of the Checkout Utility API endpoint - * - * @return string - */ - public function getApiCheckoutUtilityVersion() - { - return self::API_CHECKOUT_UTILITY_VERSION; - } + /** + * Get the version of the Checkout API endpoint + * + * @return string + */ + public function getApiCheckoutVersion() + { + return self::API_CHECKOUT_VERSION; + } - /** - * @param HttpClient\ClientInterface $httpClient - */ - public function setHttpClient(\Adyen\HttpClient\ClientInterface $httpClient) - { - $this->_httpClient = $httpClient; - } + /** + * Get the version of the Checkout Utility API endpoint + * + * @return string + */ + public function getApiCheckoutUtilityVersion() + { + return self::API_CHECKOUT_UTILITY_VERSION; + } - /** - * @return mixed - */ - public function getHttpClient() - { - if (is_null($this->_httpClient)) { - $this->_httpClient = $this->_createDefaultHttpClient(); - } - return $this->_httpClient; - } + /** + * @param HttpClient\ClientInterface $httpClient + */ + public function setHttpClient(\Adyen\HttpClient\ClientInterface $httpClient) + { + $this->_httpClient = $httpClient; + } - protected function _createDefaultHttpClient() - { - return new \Adyen\HttpClient\CurlClient(); - } + /** + * @return mixed + */ + public function getHttpClient() + { + if (is_null($this->_httpClient)) { + $this->_httpClient = $this->_createDefaultHttpClient(); + } + return $this->_httpClient; + } - /** - * Set the Logger object - * @param \Psr\Log\LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger) - { - $this->logger = $logger; - } + /** + * @return HttpClient\CurlClient + */ + protected function _createDefaultHttpClient() + { + return new \Adyen\HttpClient\CurlClient(); + } - /** - * @return \Psr\Log\LoggerInterface implementation - */ - public function getLogger() - { - if (!isset($this->logger)) { - $this->logger = $this->createDefaultLogger(); - } + /** + * Set the Logger object + * + * @param \Psr\Log\LoggerInterface $logger + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } - return $this->logger; - } + /** + * @return \Psr\Log\LoggerInterface implementation + */ + public function getLogger() + { + if (!isset($this->logger)) { + $this->logger = $this->createDefaultLogger(); + } - protected function createDefaultLogger() - { - $logger = new Logger('adyen-php-api-library'); - $logger->pushHandler(new StreamHandler('php://stderr', Logger::NOTICE)); + return $this->logger; + } - return $logger; - } + /** + * @return Logger + * @throws \Exception + */ + protected function createDefaultLogger() + { + $logger = new Logger('adyen-php-api-library'); + $logger->pushHandler(new StreamHandler('php://stderr', Logger::NOTICE)); + + return $logger; + } } diff --git a/src/Adyen/Config.php b/src/Adyen/Config.php index 4d0d44021..50e30c1a1 100644 --- a/src/Adyen/Config.php +++ b/src/Adyen/Config.php @@ -4,99 +4,135 @@ class Config implements ConfigInterface { + /** + * @var array + */ + protected $data = array(); + + /** + * @var array + */ + protected $allowedInput = array('array', 'json'); + + /** + * @var string + */ + protected $defaultInput = 'array'; + + /** + * @var array + */ + protected $allowedOutput = array('array', 'json'); + + /** + * @var string + */ + protected $defaultOutput = 'array'; + + /** + * Config constructor. + * + * @param null $params + */ + public function __construct($params = null) + { + if ($params && is_array($params)) { + foreach ($params as $key => $param) { + $this->data[$key] = $param; + } + } + + return $this; + } + + /** + * Get a specific key value. + * + * @param string $key Key to retrieve. + * + * @return mixed|null Value of the key or NULL + */ + public function get($key) + { + return isset($this->data[$key]) ? $this->data[$key] : null; + } + + /** + * Set a key value pair + * + * @param string $key Key to set + * @param mixed $value Value to set + */ + public function set($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @return mixed|null + */ + public function getUsername() + { + return isset($this->data['username']) ? $this->data['username'] : null; + } - /** @var array */ - protected $data = array(); - - // allowed input - protected $allowedInput = array('array', 'json'); - protected $defaultInput = 'array'; - - // allowed output - protected $allowedOutput = array('array', 'json'); - protected $defaultOutput = 'array'; - - public function __construct($params = null) - { - if($params && is_array($params)) { - foreach($params as $key => $param) { - $this->data[$key] = $param; - } - } - return $this; - } - - /** - * Get a specific key value. - * - * @param string $key Key to retrieve. - * - * @return mixed|null Value of the key or NULL - */ - public function get($key) - { - return isset($this->data[$key]) ? $this->data[$key] : null; - } - - /** - * Set a key value pair - * - * @param string $key Key to set - * @param mixed $value Value to set - */ - public function set($key, $value) - { - $this->data[$key] = $value; - } - - public function getUsername() - { - return isset($this->data['username']) ? $this->data['username'] : null; - } - - 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)) { - return $this->data['inputType']; - } - - // return default type - return $this->defaultInput; - } - - public function getOutputType() - { - if(isset($this->data['outputType']) && in_array($this->data['outputType'], $this->allowedOutput)) { - return $this->data['outputType']; - } - // return the default type - 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; - } + /** + * @return mixed|null + */ + 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; + } + + /** + * @return mixed|string + */ + public function getInputType() + { + if (isset($this->data['inputType']) && in_array($this->data['inputType'], $this->allowedInput)) { + return $this->data['inputType']; + } + + return $this->defaultInput; + } + + /** + * @return mixed|string + */ + public function getOutputType() + { + if (isset($this->data['outputType']) && in_array($this->data['outputType'], $this->allowedOutput)) { + return $this->data['outputType']; + } + + return $this->defaultOutput; + } + + /** + * @return mixed|null + */ + public function getTimeout() + { + return !empty($this->data['timeout']) ? $this->data['timeout'] : null; + } + + /** + * @return mixed|null + */ + public function getMerchantAccount() + { + return isset($this->data['merchantAccount']) ? $this->data['merchantAccount'] : null; + } /** * @return mixed|null @@ -113,4 +149,4 @@ public function getExternalPlatform() { return isset($this->data['externalPlatform']) ? $this->data['externalPlatform'] : null; } -} \ No newline at end of file +} diff --git a/src/Adyen/ConfigInterface.php b/src/Adyen/ConfigInterface.php index 0f0ef66fc..0962ab279 100644 --- a/src/Adyen/ConfigInterface.php +++ b/src/Adyen/ConfigInterface.php @@ -2,14 +2,22 @@ namespace Adyen; -Interface ConfigInterface { - - 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 +Interface ConfigInterface +{ + + 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(); +} diff --git a/src/Adyen/Contract.php b/src/Adyen/Contract.php index dd3aad266..19674e687 100644 --- a/src/Adyen/Contract.php +++ b/src/Adyen/Contract.php @@ -4,8 +4,8 @@ class Contract { - const NONE = ""; - const ONECLICK = "ONECLICK"; - const RECURRING = "RECURRING"; - const ONECLICK_RECURRING = "ONECLICK,RECURRING"; -} \ No newline at end of file + const NONE = ""; + const ONECLICK = "ONECLICK"; + const RECURRING = "RECURRING"; + const ONECLICK_RECURRING = "ONECLICK,RECURRING"; +} diff --git a/src/Adyen/Environment.php b/src/Adyen/Environment.php index 11b8e53ce..afb46d58a 100644 --- a/src/Adyen/Environment.php +++ b/src/Adyen/Environment.php @@ -4,6 +4,6 @@ class Environment { - const TEST = "test"; - const LIVE = "live"; -} \ No newline at end of file + const TEST = "test"; + const LIVE = "live"; +} diff --git a/src/Adyen/HttpClient/ClientInterface.php b/src/Adyen/HttpClient/ClientInterface.php index ab529d5da..322e3c587 100644 --- a/src/Adyen/HttpClient/ClientInterface.php +++ b/src/Adyen/HttpClient/ClientInterface.php @@ -4,21 +4,19 @@ interface ClientInterface { - /** - * @param string $method The HTTP method being used - * @param string $absUrl The URL being requested, including domain and protocol - * @param array $headers Headers to be used in the request (full strings, not KV pairs) - * @param array $params KV pairs for parameters. Can be nested for arrays and hashes - * @return array($rawBody, $httpStatusCode, $httpHeader) - */ + /** + * @param \Adyen\Service $service + * @param $requestUrl + * @param $params + * @return mixed + */ + public function requestJson(\Adyen\Service $service, $requestUrl, $params); - - /** - * @param \Adyen\Service $service - * @param $requestUrl - * @param $params - * @return mixed - */ - public function requestJson(\Adyen\Service $service, $requestUrl, $params); - public function requestPost(\Adyen\Service $service, $requestUrl, $params); -} \ No newline at end of file + /** + * @param \Adyen\Service $service + * @param $requestUrl + * @param $params + * @return mixed + */ + public function requestPost(\Adyen\Service $service, $requestUrl, $params); +} diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index 71b1d7882..2cb226f2b 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -2,281 +2,286 @@ namespace Adyen\HttpClient; - class CurlClient implements ClientInterface { - /** - * Json API request to Adyen - * - * @param \Adyen\Service $service - * @param $requestUrl - * @param $params - * @return mixed - * @throws \Adyen\AdyenException - */ - public function requestJson(\Adyen\Service $service, $requestUrl, $params) - { - $client = $service->getClient(); - $config = $client->getConfig(); - $logger = $client->getLogger(); - $username = $config->getUsername(); - $password = $config->getPassword(); - $xApiKey = $config->getXApiKey(); - - $jsonRequest = json_encode($params); - - // log the request - $this->logRequest($logger, $requestUrl, $params); - - //Initiate cURL. - $ch = curl_init($requestUrl); - - //Tell cURL that we want to send a POST request. - curl_setopt($ch, CURLOPT_POST, 1); - - //Attach our encoded JSON string to the POST fields. - curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonRequest); - - //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 - $headers = array( - 'Content-Type: application/json', - 'User-Agent: ' . $userAgent - ); + /** + * Json API request to Adyen + * + * @param \Adyen\Service $service + * @param $requestUrl + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function requestJson(\Adyen\Service $service, $requestUrl, $params) + { + $client = $service->getClient(); + $config = $client->getConfig(); + $logger = $client->getLogger(); + $username = $config->getUsername(); + $password = $config->getPassword(); + $xApiKey = $config->getXApiKey(); + + $jsonRequest = json_encode($params); + + // log the request + $this->logRequest($logger, $requestUrl, $params); + + //Initiate cURL. + $ch = curl_init($requestUrl); + + //Tell cURL that we want to send a POST request. + curl_setopt($ch, CURLOPT_POST, 1); + + //Attach our encoded JSON string to the POST fields. + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonRequest); + + //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 + $headers = array( + 'Content-Type: application/json', + 'User-Agent: ' . $userAgent + ); // set authorisation credentials according to support & availability - if ($service->requiresApiKey() && !empty($xApiKey)) { + if (!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)) { + } elseif ($service->requiresApiKey()) { $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 - list($result, $httpStatus) = $this->curlRequest($ch); - - // log the raw response - $logger->info("JSON Response is: " . $result); - - // result not 200 throw error - if ($httpStatus != 200 && $result) { - $this->handleResultError($result, $logger); - } elseif (!$result) { - - list($errno, $message) = $this->curlError($ch); - - curl_close($ch); - $this->handleCurlError($requestUrl, $errno, $message, $logger); - } + //Set the basic auth credentials + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); + } - curl_close($ch); + //Set the timeout + if ($config->getTimeout() != null) { + curl_setopt($ch, CURLOPT_TIMEOUT, $config->getTimeout()); + } - // result in array or json - if ($config->getOutputType() == 'array') { + //Set the headers + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - // transform to PHP Array - $result = json_decode($result, true); + // return the result + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - // log the array result - $logger->info('Params in response from Adyen:' . print_r($result, 1)); - } + //Execute the request + list($result, $httpStatus) = $this->curlRequest($ch); + + // log the raw response + $logger->info("JSON Response is: " . $result); - return $result; - - } - - /** - * Request to Adyen with query string used for Directory Lookup - * - * @param \Adyen\Service $service - * @param $requestUrl - * @param $params - * @return mixed - * @throws \Adyen\AdyenException - */ - public function requestPost(\Adyen\Service $service, $requestUrl, $params) - { - $client = $service->getClient(); - $config = $client->getConfig(); - $logger = $client->getLogger(); - $username = $config->getUsername(); - $password = $config->getPassword(); - - // log the requestUr, params and json request - $logger->info("Request url to Adyen: " . $requestUrl); - $logger->info('Params in request to Adyen:' . print_r($params, 1)); - - //Initiate cURL. - $ch = curl_init($requestUrl); - - //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); - curl_setopt($ch, CURLOPT_POST, count($params)); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); - - // set 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 - $headers = array( - 'Content-Type: application/x-www-form-urlencoded', - 'User-Agent: ' . $userAgent - ); - - 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); - - // log the raw response - $logger->info("JSON Response is: " . $result); - - if ($httpStatus != 200 && $result) { - $this->handleResultError($result, $logger); - } elseif (!$result) { - $errno = curl_errno($ch); - $message = curl_error($ch); - - curl_close($ch); - $this->handleCurlError($requestUrl, $errno, $message, $logger); - } - - curl_close($ch); - - // result in array or json - if ($config->getOutputType() == 'array') { - // transform to PHP Array - $result = json_decode($result, true); - - if (!$result) { - $msg = "The result is empty, looks like your request is invalid"; - $logger->error($msg); - throw new \Adyen\AdyenException($msg); - } - - // log the array result - $logger->info('Params in response from Adyen:' . print_r($result, 1)); - } - - - return $result; - } - - - /** - * Handle Curl exceptions - * - * @param $url - * @param $errno - * @param $message - * @param $logger - * @throws \Adyen\ConnectionException - */ - protected function handleCurlError($url, $errno, $message, $logger) - { - switch ($errno) { - case CURLE_OK: - $msg = "Probably your Web Service username and/or password is incorrect"; - break; - case CURLE_COULDNT_RESOLVE_HOST: - case CURLE_OPERATION_TIMEOUTED: - $msg = "Could not connect to Adyen ($url). Please check your " - . "internet connection and try again."; - break; - case CURLE_SSL_CACERT: - case CURLE_SSL_PEER_CERTIFICATE: - $msg = "Could not verify Adyen's SSL certificate. Please make sure " - . "that your network is not intercepting certificates. " - . "(Try going to $url in your browser.) " - . "If this problem persists,"; - break; - default: - $msg = "Unexpected error communicating with Adyen."; - } - $msg .= "\n(Network error [errno $errno]: $message)"; - $logger->error($msg); - throw new \Adyen\ConnectionException($msg, $errno); - } - - /** - * Handle result errors from Adyen - * - * @param $result - * @param $logger - * @throws \Adyen\AdyenException - */ - 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, - $decodeResult['status'], $decodeResult['errorType']); - } - $logger->error($result); - throw new \Adyen\AdyenException($result); - } - - /** - * Logs the API request, removing sensitive data - * - * @param \Psr\Log\LoggerInterface $logger - * @param $requestUrl - * @param $params - */ - private function logRequest(\Psr\Log\LoggerInterface $logger, $requestUrl, $params) - { - // log the requestUr, params and json request - $logger->info("Request url to Adyen: " . $requestUrl); - if (isset($params["additionalData"]) && isset($params["additionalData"]["card.encrypted.json"])) { - $params["additionalData"]["card.encrypted.json"] = "*"; - } - if (isset($params["card"]) && isset($params["card"]["number"])) { - $params["card"]["number"] = "*"; - $params["card"]["cvc"] = "*"; - } - $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); - } + // Get errors + list($errno, $message) = $this->curlError($ch); + + curl_close($ch); + + // result not 200 throw error + if ($httpStatus != 200 && $result) { + $this->handleResultError($result, $logger); + } elseif (!$result) { + $this->handleCurlError($requestUrl, $errno, $message, $logger); + } + // result in array or json + if ($config->getOutputType() == 'array') { + + // transform to PHP Array + $result = json_decode($result, true); + + // log the array result + $logger->info('Params in response from Adyen:' . print_r($result, 1)); + } + + return $result; + } + + /** + * Request to Adyen with query string used for Directory Lookup + * + * @param \Adyen\Service $service + * @param $requestUrl + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function requestPost(\Adyen\Service $service, $requestUrl, $params) + { + $client = $service->getClient(); + $config = $client->getConfig(); + $logger = $client->getLogger(); + $username = $config->getUsername(); + $password = $config->getPassword(); + + // log the requestUr, params and json request + $logger->info("Request url to Adyen: " . $requestUrl); + $logger->info('Params in request to Adyen:' . print_r($params, 1)); + + //Initiate cURL. + $ch = curl_init($requestUrl); + + //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); + curl_setopt($ch, CURLOPT_POST, count($params)); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); + + // set 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 + $headers = array( + 'Content-Type: application/x-www-form-urlencoded', + 'User-Agent: ' . $userAgent + ); + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + // return the result + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + //Execute the request + list($result, $httpStatus) = $this->curlRequest($ch); + + // log the raw response + $logger->info("JSON Response is: " . $result); + + // Get errors + list($errno, $message) = $this->curlError($ch); + + curl_close($ch); + + if ($httpStatus != 200 && $result) { + $this->handleResultError($result, $logger); + } elseif (!$result) { + $this->handleCurlError($requestUrl, $errno, $message, $logger); + } + + // result in array or json + if ($config->getOutputType() == 'array') { + // transform to PHP Array + $result = json_decode($result, true); + + if (!$result) { + $msg = "The result is empty, looks like your request is invalid"; + $logger->error($msg); + throw new \Adyen\AdyenException($msg); + } + + // log the array result + $logger->info('Params in response from Adyen:' . print_r($result, 1)); + } + + return $result; + } + + + /** + * Handle Curl exceptions + * + * @param $url + * @param $errno + * @param $message + * @param $logger + * @throws \Adyen\ConnectionException + */ + protected function handleCurlError($url, $errno, $message, $logger) + { + switch ($errno) { + case CURLE_OK: + $msg = "Probably your Web Service username and/or password is incorrect"; + break; + case CURLE_COULDNT_RESOLVE_HOST: + case CURLE_OPERATION_TIMEOUTED: + $msg = "Could not connect to Adyen ($url). Please check your " + . "internet connection and try again."; + break; + case CURLE_SSL_CACERT: + case CURLE_SSL_PEER_CERTIFICATE: + $msg = "Could not verify Adyen's SSL certificate. Please make sure " + . "that your network is not intercepting certificates. " + . "(Try going to $url in your browser.) " + . "If this problem persists,"; + break; + default: + $msg = "Unexpected error communicating with Adyen."; + } + $msg .= "\n(Network error [errno $errno]: $message)"; + $logger->error($msg); + throw new \Adyen\ConnectionException($msg, $errno); + } + + /** + * Handle result errors from Adyen + * + * @param $result + * @param $logger + * @throws \Adyen\AdyenException + */ + 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, + $decodeResult['status'], $decodeResult['errorType']); + } + $logger->error($result); + throw new \Adyen\AdyenException($result); + } + + /** + * Logs the API request, removing sensitive data + * + * @param \Psr\Log\LoggerInterface $logger + * @param $requestUrl + * @param $params + */ + private function logRequest(\Psr\Log\LoggerInterface $logger, $requestUrl, $params) + { + // log the requestUr, params and json request + $logger->info("Request url to Adyen: " . $requestUrl); + if (isset($params["additionalData"]) && isset($params["additionalData"]["card.encrypted.json"])) { + $params["additionalData"]["card.encrypted.json"] = "*"; + } + if (isset($params["card"]) && isset($params["card"]["number"])) { + $params["card"]["number"] = "*"; + $params["card"]["cvc"] = "*"; + } + $logger->info('JSON Request to Adyen:' . json_encode($params)); + } + + /** + * Execute curl, return the result and the http response code + * + * @param $ch + * @return array + */ + protected function curlRequest($ch) + { + $result = curl_exec($ch); + $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); + return array($result, $httpStatus); + } + + /** + * Retrieve curl error number and message + * + * @param $ch + * @return array + */ + 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 ada85ecea..cfe030032 100644 --- a/src/Adyen/Service.php +++ b/src/Adyen/Service.php @@ -4,31 +4,49 @@ class Service { - private $client; - protected $_requiresApiKey = false; - - public function __construct(\Adyen\Client $client) - { - $msg = null; - - // validate if client has all the configuration we need - if(!$client->getConfig()->get('environment')) { - // throw exception - $msg = "The Client does not have a correct environment, use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; - throw new \Adyen\AdyenException($msg); - } - - $this->client = $client; - } - - public function getClient() - { - return $this->client; - } - - public function requiresApiKey() - { - return $this->_requiresApiKey; - } - -} \ No newline at end of file + /** + * @var Client + */ + private $client; + + /** + * @var bool + */ + protected $_requiresApiKey = false; + + /** + * Service constructor. + * + * @param Client $client + * @throws AdyenException + */ + public function __construct(\Adyen\Client $client) + { + $msg = null; + + // validate if client has all the configuration we need + if (!$client->getConfig()->get('environment')) { + // throw exception + $msg = "The Client does not have a correct environment, use " . \Adyen\Environment::TEST . ' or ' . \Adyen\Environment::LIVE; + throw new \Adyen\AdyenException($msg); + } + + $this->client = $client; + } + + /** + * @return Client + */ + public function getClient() + { + return $this->client; + } + + /** + * @return bool + */ + public function requiresApiKey() + { + return $this->_requiresApiKey; + } +} diff --git a/src/Adyen/Service/AbstractCheckoutResource.php b/src/Adyen/Service/AbstractCheckoutResource.php index a90efab17..d8efeead8 100644 --- a/src/Adyen/Service/AbstractCheckoutResource.php +++ b/src/Adyen/Service/AbstractCheckoutResource.php @@ -4,24 +4,23 @@ class AbstractCheckoutResource extends AbstractResource { + /** + * Return Checkout endpoint + * + * @param $service + * @return mixed + * @throws \Adyen\AdyenException + */ + public function getCheckoutEndpoint($service) + { + // check if endpoint is set + if ($service->getClient()->getConfig()->get('endpointCheckout') == null) { + $logger = $service->getClient()->getLogger(); + $msg = "Please provide your unique live url prefix on the setEnvironment() call on the Client or provide endpointCheckout in your config object."; + $logger->error($msg); + throw new \Adyen\AdyenException($msg); + } - /** - * Return Checkout endpoint - * - * @param $service - * @return mixed - * @throws \Adyen\AdyenException - */ - public function getCheckoutEndpoint($service) - { - // check if endpoint is set - if ($service->getClient()->getConfig()->get('endpointCheckout') == null) { - $logger = $service->getClient()->getLogger(); - $msg = "Please provide your unique live url prefix on the setEnvironment() call on the Client or provide endpointCheckout in your config object."; - $logger->error($msg); - throw new \Adyen\AdyenException($msg); - } - - return $service->getClient()->getConfig()->get('endpointCheckout'); - } -} \ No newline at end of file + return $service->getClient()->getConfig()->get('endpointCheckout'); + } +} diff --git a/src/Adyen/Service/AbstractResource.php b/src/Adyen/Service/AbstractResource.php index 32d9ec4c7..6bc9f1b06 100644 --- a/src/Adyen/Service/AbstractResource.php +++ b/src/Adyen/Service/AbstractResource.php @@ -2,22 +2,22 @@ namespace Adyen\Service; -class AbstractResource +abstract class AbstractResource { /** * @var \Adyen\Service */ - protected $_service; + protected $_service; /** * @var string */ - protected $_endpoint; + protected $_endpoint; /** * @var bool */ - protected $allowApplicationInfo; + protected $allowApplicationInfo; /** * AbstractResource constructor. @@ -26,12 +26,12 @@ class AbstractResource * @param $endpoint * @param bool $allowApplicationInfo */ - public function __construct(\Adyen\Service $service, $endpoint, $allowApplicationInfo = false) - { - $this->_service = $service; - $this->_endpoint = $endpoint; - $this->allowApplicationInfo = $allowApplicationInfo; - } + public function __construct(\Adyen\Service $service, $endpoint, $allowApplicationInfo = false) + { + $this->_service = $service; + $this->_endpoint = $endpoint; + $this->allowApplicationInfo = $allowApplicationInfo; + } /** * Do the request to the Http Client @@ -40,18 +40,17 @@ public function __construct(\Adyen\Service $service, $endpoint, $allowApplicatio * @return mixed * @throws \Adyen\AdyenException */ - public function request($params) - { - // convert to PHP Array if type is inputType is json - if($this->_service->getClient()->getConfig()->getInputType() == 'json') - { - $params = json_decode($params, true); - if ($params === null && json_last_error() !== JSON_ERROR_NONE) { + public function request($params) + { + // convert to PHP Array if type is inputType is json + if ($this->_service->getClient()->getConfig()->getInputType() == 'json') { + $params = json_decode($params, true); + if ($params === null && json_last_error() !== JSON_ERROR_NONE) { $msg = 'The parameters in the request expect valid JSON but JSON error code found: ' . json_last_error(); $this->_service->getClient()->getLogger()->error($msg); throw new \Adyen\AdyenException($msg); } - } + } if (!is_array($params)) { $msg = 'The parameter is not valid array'; @@ -59,31 +58,31 @@ public function request($params) throw new \Adyen\AdyenException($msg); } - $params = $this->addDefaultParametersToRequest($params); + $params = $this->addDefaultParametersToRequest($params); - $params = $this->handleApplicationInfoInRequest($params); + $params = $this->handleApplicationInfoInRequest($params); - $curlClient = $this->_service->getClient()->getHttpClient(); - return $curlClient->requestJson($this->_service, $this->_endpoint, $params); - } + $curlClient = $this->_service->getClient()->getHttpClient(); + return $curlClient->requestJson($this->_service, $this->_endpoint, $params); + } /** * @param $params * @return mixed * @throws \Adyen\AdyenException */ - public function requestPost($params) - { - // check if paramenters has a value - if(!$params) { - $msg = 'The parameters in the request are empty'; - $this->_service->getClient()->getLogger()->error($msg); - throw new \Adyen\AdyenException($msg); - } - - $curlClient = $this->_service->getClient()->getHttpClient(); - return $curlClient->requestPost($this->_service, $this->_endpoint, $params); - } + public function requestPost($params) + { + // check if paramenters has a value + if (!$params) { + $msg = 'The parameters in the request are empty'; + $this->_service->getClient()->getLogger()->error($msg); + throw new \Adyen\AdyenException($msg); + } + + $curlClient = $this->_service->getClient()->getHttpClient(); + return $curlClient->requestPost($this->_service, $this->_endpoint, $params); + } /** * Fill expected but missing parameters with default data @@ -91,10 +90,10 @@ public function requestPost($params) * @param $params * @return mixed */ - private function addDefaultParametersToRequest($params) + private function addDefaultParametersToRequest($params) { // check if merchantAccount is setup in client and request is missing merchantAccount then add it - if(!isset($params['merchantAccount']) && $this->_service->getClient()->getConfig()->getMerchantAccount()) { + if (!isset($params['merchantAccount']) && $this->_service->getClient()->getConfig()->getMerchantAccount()) { $params['merchantAccount'] = $this->_service->getClient()->getConfig()->getMerchantAccount(); } diff --git a/src/Adyen/Service/Checkout.php b/src/Adyen/Service/Checkout.php index 9677c94c2..884d0692c 100644 --- a/src/Adyen/Service/Checkout.php +++ b/src/Adyen/Service/Checkout.php @@ -2,59 +2,101 @@ namespace Adyen\Service; - class Checkout extends \Adyen\ApiKeyAuthenticatedService { - protected $_paymentSession; - protected $_paymentsResult; - protected $_paymentMethods; - protected $_payments; - protected $_paymentsDetails; - - /** - * Checkout constructor. - * @param \Adyen\Client $client - * @throws \Adyen\AdyenException - */ - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - $this->_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 + /** + * @var ResourceModel\Checkout\PaymentSession + */ + protected $_paymentSession; + + /** + * @var ResourceModel\Checkout\PaymentsResult + */ + protected $_paymentsResult; + + /** + * @var ResourceModel\Checkout\PaymentMethods + */ + protected $_paymentMethods; + + /** + * @var ResourceModel\Checkout\Payments + */ + protected $_payments; + + /** + * @var ResourceModel\Checkout\PaymentsDetails + */ + protected $_paymentsDetails; + + /** + * Checkout constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_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); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function paymentSession($params) + { + $result = $this->_paymentSession->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function paymentsResult($params) + { + $result = $this->_paymentsResult->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function paymentMethods($params) + { + $result = $this->_paymentMethods->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function payments($params) + { + $result = $this->_payments->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function paymentsDetails($params) + { + $result = $this->_paymentsDetails->request($params); + return $result; + } +} diff --git a/src/Adyen/Service/CheckoutUtility.php b/src/Adyen/Service/CheckoutUtility.php index e4b75b783..d30e7856c 100644 --- a/src/Adyen/Service/CheckoutUtility.php +++ b/src/Adyen/Service/CheckoutUtility.php @@ -2,23 +2,33 @@ namespace Adyen\Service; - class CheckoutUtility extends \Adyen\ApiKeyAuthenticatedService { - protected $_originKeys; - - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_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 + /** + * @var ResourceModel\CheckoutUtility\OriginKeys + */ + protected $_originKeys; + + /** + * CheckoutUtility constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_originKeys = new \Adyen\Service\ResourceModel\CheckoutUtility\OriginKeys($this); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function originKeys($params) + { + $result = $this->_originKeys->request($params); + return $result; + } +} diff --git a/src/Adyen/Service/DirectoryLookup.php b/src/Adyen/Service/DirectoryLookup.php index 4cd5ebd6f..8429f951b 100644 --- a/src/Adyen/Service/DirectoryLookup.php +++ b/src/Adyen/Service/DirectoryLookup.php @@ -4,20 +4,31 @@ class DirectoryLookup extends \Adyen\Service { + /** + * @var ResourceModel\DirectoryLookup\Directory + */ + protected $_directoryLookup; - protected $_directoryLookup; + /** + * DirectoryLookup constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_directoryLookup = new \Adyen\Service\ResourceModel\DirectoryLookup\Directory($this); + } - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_directoryLookup = new \Adyen\Service\ResourceModel\DirectoryLookup\Directory($this); - } - - public function directoryLookup($params) - { - $result = $this->_directoryLookup->requestPost($params); - return $result; - } - -} \ No newline at end of file + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function directoryLookup($params) + { + $result = $this->_directoryLookup->requestPost($params); + return $result; + } +} diff --git a/src/Adyen/Service/Modification.php b/src/Adyen/Service/Modification.php index edb0cb543..f79ced28c 100644 --- a/src/Adyen/Service/Modification.php +++ b/src/Adyen/Service/Modification.php @@ -4,51 +4,99 @@ class Modification extends \Adyen\Service { + /** + * @var ResourceModel\Modification\Cancel + */ + protected $_cancel; - protected $_cancel; - protected $_cancelOrRefund; - protected $_capture; - protected $_refund; - protected $_adjustAuthorisation; - - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_cancel = new \Adyen\Service\ResourceModel\Modification\Cancel($this); - $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) - { - $result = $this->_cancel->request($params); - return $result; - } - - public function cancelOrRefund($params) - { - $result = $this->_cancelOrRefund->request($params); - return $result; - } - - public function capture($params) - { - $result = $this->_capture->request($params); - return $result; - } - - public function refund($params) - { - $result = $this->_refund->request($params); - return $result; - } - - public function adjustAuthorisation($params) - { - $result = $this->_adjustAuthorisation->request($params); - return $result; - } -} \ No newline at end of file + /** + * @var ResourceModel\Modification\CancelOrRefund + */ + protected $_cancelOrRefund; + + /** + * @var ResourceModel\Modification\Capture + */ + protected $_capture; + + /** + * @var ResourceModel\Modification\Refund + */ + protected $_refund; + + /** + * @var ResourceModel\Modification\AdjustAuthorisation + */ + protected $_adjustAuthorisation; + + /** + * Modification constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_cancel = new \Adyen\Service\ResourceModel\Modification\Cancel($this); + $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); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function cancel($params) + { + $result = $this->_cancel->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function cancelOrRefund($params) + { + $result = $this->_cancelOrRefund->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function capture($params) + { + $result = $this->_capture->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function refund($params) + { + $result = $this->_refund->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function adjustAuthorisation($params) + { + $result = $this->_adjustAuthorisation->request($params); + return $result; + } +} diff --git a/src/Adyen/Service/Payment.php b/src/Adyen/Service/Payment.php index aa48b8dbb..42b9b512a 100644 --- a/src/Adyen/Service/Payment.php +++ b/src/Adyen/Service/Payment.php @@ -4,31 +4,48 @@ class Payment extends \Adyen\Service { - - protected $_authorise; - protected $_authorise3D; - - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_authorise = new \Adyen\Service\ResourceModel\Payment\Authorise($this); - $this->_authorise3D = new \Adyen\Service\ResourceModel\Payment\Authorise3D($this); - - } - - public function authorise($params) - { - $result = $this->_authorise->request($params); - return $result; - } - - public function authorise3D($params) - { - $result = $this->_authorise3D->request($params); - return $result; - } - - - + /** + * @var ResourceModel\Payment\Authorise + */ + protected $_authorise; + + /** + * @var ResourceModel\Payment\Authorise3D + */ + protected $_authorise3D; + + /** + * Payment constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_authorise = new \Adyen\Service\ResourceModel\Payment\Authorise($this); + $this->_authorise3D = new \Adyen\Service\ResourceModel\Payment\Authorise3D($this); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function authorise($params) + { + $result = $this->_authorise->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function authorise3D($params) + { + $result = $this->_authorise3D->request($params); + return $result; + } } diff --git a/src/Adyen/Service/Payout.php b/src/Adyen/Service/Payout.php index 244aef39d..2e7934a3a 100644 --- a/src/Adyen/Service/Payout.php +++ b/src/Adyen/Service/Payout.php @@ -4,68 +4,167 @@ class Payout extends \Adyen\Service { + /** + * @var ResourceModel\Payout\Confirm + */ + protected $_confirm; - protected $_confirm; - protected $_decline; - protected $_storeDetailsAndSubmit; - protected $_submit; - protected $_confirmThirdParty; - protected $_declineThirdParty; - protected $_storeDetailsAndSubmitThirdParty; - protected $_submitThirdParty; - protected $_storeDetail; - - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_confirm = new \Adyen\Service\ResourceModel\Payout\Confirm($this); - $this->_decline = new \Adyen\Service\ResourceModel\Payout\Decline($this); - $this->_storeDetailsAndSubmit = new \Adyen\Service\ResourceModel\Payout\StoreDetailsAndSubmit($this); - $this->_submit = new \Adyen\Service\ResourceModel\Payout\Submit($this); - $this->_confirmThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\ConfirmThirdParty($this); - $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) { + /** + * @var ResourceModel\Payout\Decline + */ + protected $_decline; + + /** + * @var ResourceModel\Payout\StoreDetailsAndSubmit + */ + protected $_storeDetailsAndSubmit; + + /** + * @var ResourceModel\Payout\Submit + */ + protected $_submit; + + /** + * @var ResourceModel\Payout\ThirdParty\ConfirmThirdParty + */ + protected $_confirmThirdParty; + + /** + * @var ResourceModel\Payout\ThirdParty\DeclineThirdParty + */ + protected $_declineThirdParty; + + /** + * @var ResourceModel\Payout\ThirdParty\StoreDetailsAndSubmitThirdParty + */ + protected $_storeDetailsAndSubmitThirdParty; + + /** + * @var ResourceModel\Payout\ThirdParty\SubmitThirdParty + */ + protected $_submitThirdParty; + + /** + * @var ResourceModel\Payout\ThirdParty\StoreDetail + */ + protected $_storeDetail; + + /** + * Payout constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_confirm = new \Adyen\Service\ResourceModel\Payout\Confirm($this); + $this->_decline = new \Adyen\Service\ResourceModel\Payout\Decline($this); + $this->_storeDetailsAndSubmit = new \Adyen\Service\ResourceModel\Payout\StoreDetailsAndSubmit($this); + $this->_submit = new \Adyen\Service\ResourceModel\Payout\Submit($this); + $this->_confirmThirdParty = new \Adyen\Service\ResourceModel\Payout\ThirdParty\ConfirmThirdParty($this); + $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); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function confirm($params) + { $result = $this->_confirm->request($params); return $result; } - public function decline($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function decline($params) + { $result = $this->_decline->request($params); return $result; } - public function storeDetailsAndSubmit($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function storeDetailsAndSubmit($params) + { $result = $this->_storeDetailsAndSubmit->request($params); return $result; } - public function submit($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function submit($params) + { $result = $this->_submit->request($params); return $result; } - public function confirmThirdParty($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function confirmThirdParty($params) + { $result = $this->_confirmThirdParty->request($params); return $result; } - public function declineThirdParty($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function declineThirdParty($params) + { $result = $this->_declineThirdParty->request($params); return $result; } - public function storeDetailsAndSubmitThirdParty($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function storeDetailsAndSubmitThirdParty($params) + { $result = $this->_storeDetailsAndSubmitThirdParty->request($params); return $result; } - public function submitThirdParty($params) { + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function submitThirdParty($params) + { $result = $this->_submitThirdParty->request($params); return $result; } - public function storeDetail($params) { - $result = $this->_storeDetail->request($params); - return $result; - } - + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function storeDetail($params) + { + $result = $this->_storeDetail->request($params); + return $result; + } } diff --git a/src/Adyen/Service/PosPayment.php b/src/Adyen/Service/PosPayment.php index 9d3fe9390..e78703f7c 100644 --- a/src/Adyen/Service/PosPayment.php +++ b/src/Adyen/Service/PosPayment.php @@ -4,37 +4,65 @@ class PosPayment extends \Adyen\ApiKeyAuthenticatedService { + /** + * @var ResourceModel\Payment\TerminalCloudAPI + */ + protected $_runTenderSync; - protected $_runTenderSync; - protected $_runTenderAsync; - protected $_txType; - - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_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; - } + /** + * @var ResourceModel\Payment\TerminalCloudAPI + */ + protected $_runTenderAsync; + /** + * @var + */ + protected $_txType; + + /** + * PosPayment constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_runTenderSync = new \Adyen\Service\ResourceModel\Payment\TerminalCloudAPI($this, false); + $this->_runTenderAsync = new \Adyen\Service\ResourceModel\Payment\TerminalCloudAPI($this, true); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function runTenderSync($params) + { + $result = $this->_runTenderSync->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function runTenderAsync($params) + { + $result = $this->_runTenderAsync->request($params); + return $result; + } + + /** + * @param $request + * @return null + */ + public function getServiceId($request) + { + if (isset($request['SaleToPOIRequest']['MessageHeader']['ServiceID'])) { + return $request['SaleToPOIRequest']['MessageHeader']['ServiceID']; + } + return null; + } } diff --git a/src/Adyen/Service/Recurring.php b/src/Adyen/Service/Recurring.php index 27dbb6d59..3300d7acb 100644 --- a/src/Adyen/Service/Recurring.php +++ b/src/Adyen/Service/Recurring.php @@ -4,33 +4,52 @@ class Recurring extends \Adyen\Service { - - protected $_listRecurringDetails; - protected $_disable; - - public function __construct(\Adyen\Client $client) - { - parent::__construct($client); - - $this->_listRecurringDetails = new \Adyen\Service\ResourceModel\Recurring\ListRecurringDetails( - $this); - - $this->_disable = new \Adyen\Service\ResourceModel\Recurring\Disable( - $this, - $this->getClient()->getConfig()->get('endpoint') . '/disable', - array('merchantAccount', 'shopperReference')); - } - - public function listRecurringDetails($params) - { - $result = $this->_listRecurringDetails->request($params); - return $result; - } - - public function disable($params) - { - $result = $this->_disable->request($params); - return $result; - } - -} \ No newline at end of file + /** + * @var ResourceModel\Recurring\ListRecurringDetails + */ + protected $_listRecurringDetails; + + /** + * @var ResourceModel\Recurring\Disable + */ + protected $_disable; + + /** + * Recurring constructor. + * + * @param \Adyen\Client $client + * @throws \Adyen\AdyenException + */ + public function __construct(\Adyen\Client $client) + { + parent::__construct($client); + $this->_listRecurringDetails = new \Adyen\Service\ResourceModel\Recurring\ListRecurringDetails($this); + + $this->_disable = new \Adyen\Service\ResourceModel\Recurring\Disable( + $this, + $this->getClient()->getConfig()->get('endpoint') . '/disable', + array('merchantAccount', 'shopperReference')); + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function listRecurringDetails($params) + { + $result = $this->_listRecurringDetails->request($params); + return $result; + } + + /** + * @param $params + * @return mixed + * @throws \Adyen\AdyenException + */ + public function disable($params) + { + $result = $this->_disable->request($params); + return $result; + } +} diff --git a/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php b/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php index 2470d73fb..7d9c5020d 100644 --- a/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentMethods.php @@ -15,9 +15,9 @@ class PaymentMethods extends \Adyen\Service\AbstractCheckoutResource * @param \Adyen\Service $service * @throws \Adyen\AdyenException */ - public function __construct($service) - { - $this->_endpoint = $this->getCheckoutEndpoint($service) .'/'. $service->getClient()->getApiCheckoutVersion() . '/paymentMethods'; - parent::__construct($service, $this->_endpoint); - } + public function __construct($service) + { + $this->_endpoint = $this->getCheckoutEndpoint($service) . '/' . $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 index d0f617c2a..5f7ac1f61 100644 --- a/src/Adyen/Service/ResourceModel/Checkout/PaymentSession.php +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentSession.php @@ -15,9 +15,9 @@ class PaymentSession extends \Adyen\Service\AbstractCheckoutResource * @param \Adyen\Service $service * @throws \Adyen\AdyenException */ - public function __construct($service) - { - $this->_endpoint = $this->getCheckoutEndpoint($service) .'/'. $service->getClient()->getApiCheckoutVersion() . '/paymentSession'; - parent::__construct($service, $this->_endpoint); - } + public function __construct($service) + { + $this->_endpoint = $this->getCheckoutEndpoint($service) . '/' . $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 index 68dde8fa0..6d284f513 100644 --- a/src/Adyen/Service/ResourceModel/Checkout/Payments.php +++ b/src/Adyen/Service/ResourceModel/Checkout/Payments.php @@ -22,9 +22,9 @@ class Payments extends \Adyen\Service\AbstractCheckoutResource * @param \Adyen\Service $service * @throws \Adyen\AdyenException */ - public function __construct($service) - { - $this->_endpoint = $this->getCheckoutEndpoint($service) .'/'. $service->getClient()->getApiCheckoutVersion() . '/payments'; - parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); - } + public function __construct($service) + { + $this->_endpoint = $this->getCheckoutEndpoint($service) . '/' . $service->getClient()->getApiCheckoutVersion() . '/payments'; + parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); + } } diff --git a/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php b/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php index 482c24dc5..b29d0ffdc 100644 --- a/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentsDetails.php @@ -15,9 +15,9 @@ class PaymentsDetails extends \Adyen\Service\AbstractCheckoutResource * @param \Adyen\Service $service * @throws \Adyen\AdyenException */ - public function __construct($service) - { - $this->_endpoint = $this->getCheckoutEndpoint($service) .'/'. $service->getClient()->getApiCheckoutVersion() . '/payments/details'; - parent::__construct($service, $this->_endpoint); - } + public function __construct($service) + { + $this->_endpoint = $this->getCheckoutEndpoint($service) . '/' . $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 index 51cc7c808..9e6c6cad5 100644 --- a/src/Adyen/Service/ResourceModel/Checkout/PaymentsResult.php +++ b/src/Adyen/Service/ResourceModel/Checkout/PaymentsResult.php @@ -15,9 +15,9 @@ class PaymentsResult extends \Adyen\Service\AbstractCheckoutResource * @param \Adyen\Service $service * @throws \Adyen\AdyenException */ - public function __construct($service) - { - $this->_endpoint = $this->getCheckoutEndpoint($service) .'/'. $service->getClient()->getApiCheckoutVersion() . '/payments/result'; - parent::__construct($service, $this->_endpoint); - } + public function __construct($service) + { + $this->_endpoint = $this->getCheckoutEndpoint($service) . '/' . $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 index 1fbac8cf5..8baacaf4d 100644 --- a/src/Adyen/Service/ResourceModel/CheckoutUtility/OriginKeys.php +++ b/src/Adyen/Service/ResourceModel/CheckoutUtility/OriginKeys.php @@ -7,7 +7,7 @@ class OriginKeys extends \Adyen\Service\AbstractCheckoutResource /** * @var string */ - protected $_endpoint; + protected $_endpoint; /** * OriginKeys constructor. @@ -15,9 +15,9 @@ class OriginKeys extends \Adyen\Service\AbstractCheckoutResource * @param \Adyen\Service $service * @throws \Adyen\AdyenException */ - public function __construct($service) - { - $this->_endpoint = $this->getCheckoutEndpoint($service) .'/'. $service->getClient()->getApiCheckoutUtilityVersion() . '/originKeys'; - parent::__construct($service, $this->_endpoint); - } + public function __construct($service) + { + $this->_endpoint = $this->getCheckoutEndpoint($service) . '/' . $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 52d35d32d..0cecf425c 100644 --- a/src/Adyen/Service/ResourceModel/DirectoryLookup/Directory.php +++ b/src/Adyen/Service/ResourceModel/DirectoryLookup/Directory.php @@ -1,24 +1,23 @@ _endpoint = $service->getClient()->getConfig()->get('endpointDirectorylookup'); - parent::__construct($service, $this->_endpoint); - } + public function __construct($service) + { + $this->_endpoint = $service->getClient()->getConfig()->get('endpointDirectorylookup'); + parent::__construct($service, $this->_endpoint); + } } diff --git a/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php b/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php index e9db79a1c..a3145c11a 100644 --- a/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php +++ b/src/Adyen/Service/ResourceModel/Modification/AdjustAuthorisation.php @@ -23,7 +23,7 @@ class AdjustAuthorisation extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint').'/pal/servlet/Payment/'.$service->getClient()->getApiVersion().'/adjustAuthorisation'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint').'/pal/servlet/Payment/'.$service->getClient()->getApiPaymentVersion().'/adjustAuthorisation'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Modification/Cancel.php b/src/Adyen/Service/ResourceModel/Modification/Cancel.php index f203bbecf..dc3c4c13f 100644 --- a/src/Adyen/Service/ResourceModel/Modification/Cancel.php +++ b/src/Adyen/Service/ResourceModel/Modification/Cancel.php @@ -23,7 +23,7 @@ class Cancel extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/cancel'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/cancel'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php b/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php index 0778d99bb..1b9077a9f 100644 --- a/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php +++ b/src/Adyen/Service/ResourceModel/Modification/CancelOrRefund.php @@ -23,7 +23,7 @@ class CancelOrRefund extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/'. $service->getClient()->getApiVersion() . '/cancelOrRefund'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/'. $service->getClient()->getApiPaymentVersion() . '/cancelOrRefund'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Modification/Capture.php b/src/Adyen/Service/ResourceModel/Modification/Capture.php index 15440a854..b4cb46566 100644 --- a/src/Adyen/Service/ResourceModel/Modification/Capture.php +++ b/src/Adyen/Service/ResourceModel/Modification/Capture.php @@ -23,7 +23,7 @@ class Capture extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/capture'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/capture'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Modification/Refund.php b/src/Adyen/Service/ResourceModel/Modification/Refund.php index b17e58639..cad285a08 100644 --- a/src/Adyen/Service/ResourceModel/Modification/Refund.php +++ b/src/Adyen/Service/ResourceModel/Modification/Refund.php @@ -23,7 +23,7 @@ class Refund extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/refund'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/refund'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Payment/Authorise.php b/src/Adyen/Service/ResourceModel/Payment/Authorise.php index ce2afd982..01ff66ff1 100644 --- a/src/Adyen/Service/ResourceModel/Payment/Authorise.php +++ b/src/Adyen/Service/ResourceModel/Payment/Authorise.php @@ -23,7 +23,7 @@ class Authorise extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/authorise'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/authorise'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php b/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php index c505376c0..2ea15dbf4 100644 --- a/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php +++ b/src/Adyen/Service/ResourceModel/Payment/Authorise3D.php @@ -23,7 +23,7 @@ class Authorise3D extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiVersion() . '/authorise3d'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/authorise3d'; parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo); } } diff --git a/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php b/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php index 870181e56..82dda716c 100644 --- a/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php +++ b/src/Adyen/Service/ResourceModel/Payment/TerminalCloudAPI.php @@ -15,13 +15,13 @@ class TerminalCloudAPI extends \Adyen\Service\AbstractResource * @param \Adyen\Service $service * @param bool $asynchronous */ - public function __construct($service, $asynchronous) - { - if ($asynchronous) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpointTerminalCloud') . '/async'; - } else { - $this->_endpoint = $service->getClient()->getConfig()->get('endpointTerminalCloud') . '/sync'; - } - parent::__construct($service, $this->_endpoint); - } + public function __construct($service, $asynchronous) + { + if ($asynchronous) { + $this->_endpoint = $service->getClient()->getConfig()->get('endpointTerminalCloud') . '/async'; + } else { + $this->_endpoint = $service->getClient()->getConfig()->get('endpointTerminalCloud') . '/sync'; + } + parent::__construct($service, $this->_endpoint); + } } diff --git a/src/Adyen/Service/ResourceModel/Payout/Confirm.php b/src/Adyen/Service/ResourceModel/Payout/Confirm.php index 1699d90a4..576395be3 100644 --- a/src/Adyen/Service/ResourceModel/Payout/Confirm.php +++ b/src/Adyen/Service/ResourceModel/Payout/Confirm.php @@ -16,7 +16,7 @@ class Confirm extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/confirm'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/confirm'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/Decline.php b/src/Adyen/Service/ResourceModel/Payout/Decline.php index f82b6ca4f..351531f60 100644 --- a/src/Adyen/Service/ResourceModel/Payout/Decline.php +++ b/src/Adyen/Service/ResourceModel/Payout/Decline.php @@ -16,7 +16,7 @@ class Decline extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/decline'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/decline'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php b/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php index 1491d0274..0faac78f7 100644 --- a/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php +++ b/src/Adyen/Service/ResourceModel/Payout/StoreDetailsAndSubmit.php @@ -16,7 +16,7 @@ class StoreDetailsAndSubmit extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetailAndSubmit'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/storeDetailAndSubmit'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/Submit.php b/src/Adyen/Service/ResourceModel/Payout/Submit.php index 81be2d7d3..8706801a7 100644 --- a/src/Adyen/Service/ResourceModel/Payout/Submit.php +++ b/src/Adyen/Service/ResourceModel/Payout/Submit.php @@ -16,7 +16,7 @@ class Submit extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/submit'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/submit'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php index 6c9cf850f..78d9c5bd9 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/ConfirmThirdParty.php @@ -16,7 +16,7 @@ class ConfirmThirdParty extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/confirmThirdParty'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/confirmThirdParty'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php index 162b3e14d..e9802b131 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/DeclineThirdParty.php @@ -16,7 +16,7 @@ class DeclineThirdParty extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/declineThirdParty'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/declineThirdParty'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php index 9f6ef242d..89467f91c 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetail.php @@ -16,7 +16,7 @@ class StoreDetail extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetail'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/storeDetail'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php index 6be93f413..bf3de71d5 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/StoreDetailsAndSubmitThirdParty.php @@ -16,7 +16,7 @@ class StoreDetailsAndSubmitThirdParty extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/storeDetailAndSubmitThirdParty'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/storeDetailAndSubmitThirdParty'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php index 393c38ad8..bca9898fd 100644 --- a/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php +++ b/src/Adyen/Service/ResourceModel/Payout/ThirdParty/SubmitThirdParty.php @@ -16,7 +16,7 @@ class SubmitThirdParty extends \Adyen\Service\AbstractResource */ public function __construct($service) { - $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiVersion() . '/submitThirdParty'; + $this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payout/' . $service->getClient()->getApiPayoutVersion() . '/submitThirdParty'; parent::__construct($service, $this->_endpoint); } } diff --git a/src/Adyen/Service/ResourceModel/Recurring/Disable.php b/src/Adyen/Service/ResourceModel/Recurring/Disable.php index 2f2978e32..92126be31 100644 --- a/src/Adyen/Service/ResourceModel/Recurring/Disable.php +++ b/src/Adyen/Service/ResourceModel/Recurring/Disable.php @@ -14,9 +14,9 @@ class Disable extends \Adyen\Service\AbstractResource * * @param \Adyen\Service $service */ - public function __construct($service) - { - $this->endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Recurring/' . $service->getClient()->getApiRecurringVersion() . '/disable'; - parent::__construct($service, $this->endpoint); - } + public function __construct($service) + { + $this->endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Recurring/' . $service->getClient()->getApiRecurringVersion() . '/disable'; + parent::__construct($service, $this->endpoint); + } } diff --git a/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php b/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php index 650554280..5947c78fa 100644 --- a/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php +++ b/src/Adyen/Service/ResourceModel/Recurring/ListRecurringDetails.php @@ -14,9 +14,9 @@ class ListRecurringDetails extends \Adyen\Service\AbstractResource * * @param \Adyen\Service $service */ - public function __construct($service) - { - $this->endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Recurring/' . $service->getClient()->getApiRecurringVersion() . '/listRecurringDetails'; - parent::__construct($service, $this->endpoint); - } + public function __construct($service) + { + $this->endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Recurring/' . $service->getClient()->getApiRecurringVersion() . '/listRecurringDetails'; + parent::__construct($service, $this->endpoint); + } } diff --git a/src/Adyen/TransactionType.php b/src/Adyen/TransactionType.php index abd8e1a74..d39bd3e32 100644 --- a/src/Adyen/TransactionType.php +++ b/src/Adyen/TransactionType.php @@ -1,12 +1,9 @@