Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update checkout API version to v40 #83

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Adyen/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
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