diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index b46274dd2..f0feaee2f 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -19,7 +19,7 @@ class Client const API_PAYMENT_VERSION = "v40"; const API_PAYOUT_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;