From bcb908953cfa26e7fa6831f02b82f92a0a11df2b Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Tue, 30 Oct 2018 16:56:48 +0100 Subject: [PATCH] Update checkout API version to v40 v40 has some useful features that we need. A separate test case was added to verify the behaviour. --- src/Adyen/Client.php | 2 +- tests/CheckoutTest.php | 63 ++++++++++++++++++++++++++++++++++++++++++ tests/TestCase.php | 17 +++++++++++- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 tests/CheckoutTest.php diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index ed94c860c..6792ebf41 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -18,7 +18,7 @@ class Client const ENDPOINT_LIVE_DIRECTORY_LOOKUP = "https://live.adyen.com/hpp/directory/v2.shtml"; const API_VERSION = "v30"; const API_RECURRING_VERSION = "v25"; - const API_CHECKOUT_VERSION = "v32"; + const API_CHECKOUT_VERSION = "v40"; const API_CHECKOUT_UTILITY_VERSION = "v1"; const ENDPOINT_TERMINAL_CLOUD_TEST = "https://terminal-api-test.adyen.com"; const ENDPOINT_TERMINAL_CLOUD_LIVE = "https://terminal-api-live.adyen.com"; diff --git a/tests/CheckoutTest.php b/tests/CheckoutTest.php new file mode 100644 index 000000000..c7f246561 --- /dev/null +++ b/tests/CheckoutTest.php @@ -0,0 +1,63 @@ +createCheckoutAPIClient(); + + $service = new Service\Checkout($client); + + $params = array( + 'amount' => 1000, + 'countryCode' => 'NL', + 'shopperLocale' => 'nl_NL', + 'merchantAccount' => $this->_merchantAccount, + ); + + $result = $service->paymentMethods($params); + + $this->assertInternalType('array',$result); + + // needs to have Ideal in result because country is netherlands + $hasIdeal = false; + foreach($result['paymentMethods'] as $paymentMethod) { + if($paymentMethod['type'] == 'ideal') { + $hasIdeal = true; + } + } + + $this->assertEquals(true, $hasIdeal); + } + + public function testBlockedPaymentMethods() + { + $client = $this->createCheckoutAPIClient(); + + $service = new Service\Checkout($client); + + $params = array( + 'amount' => 1000, + 'countryCode' => 'NL', + 'shopperLocale' => 'nl_NL', + 'merchantAccount' => $this->_merchantAccount, + 'blockedPaymentMethods' => array('ideal'), + ); + + $result = $service->paymentMethods($params); + + $this->assertInternalType('array',$result); + + $hasIdeal = false; + foreach($result['paymentMethods'] as $paymentMethod) { + if($paymentMethod['type'] == 'ideal') { + $hasIdeal = true; + } + } + + $this->assertFalse($hasIdeal); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 5d40080bb..6d6764390 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -18,10 +18,10 @@ class TestCase extends \PHPUnit_Framework_TestCase public function __construct() { + $this->settings = $this->_loadConfigIni(); $this->_merchantAccount = $this->getMerchantAccount(); $this->_skinCode = $this->getSkinCode(); $this->_hmacSignature = $this->getHmacSignature(); - $this->settings = $this->_loadConfigIni(); $this->setDefaultsDuringDevelopment(); } @@ -201,6 +201,21 @@ protected function createClientWithMerchantAccount() return $client; } + protected function createCheckoutAPIClient() + { + $client = $this->createClientWithMerchantAccount(); + + // load settings from .ini file + $settings = $this->settings; + + if(!isset($settings['x-api-key']) || $settings['x-api-key'] == 'YOUR X-API KEY'){ + $this->_skipTest("Skipped the test. Configure your x-api-key"); + }else{ + $client->setXApiKey($settings['x-api-key']); + return $client; + } + } + protected function getMerchantAccount() { $settings = $this->settings;