Skip to content

Commit

Permalink
Merge pull request #83 from frankbv/checkout-v40
Browse files Browse the repository at this point in the history
Update checkout API version to v40
  • Loading branch information
rikterbeek authored Nov 27, 2018
2 parents 065033b + bcb9089 commit ec54efd
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Adyen/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
63 changes: 63 additions & 0 deletions tests/CheckoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
namespace Adyen;

use Adyen\Util\Util;

class CheckoutTest extends TestCase
{
public function testPaymentMethods()
{
$client = $this->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);
}
}
17 changes: 16 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ec54efd

Please sign in to comment.