Skip to content

Commit

Permalink
Merge pull request #93 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 1.5.4
  • Loading branch information
rikterbeek authored Nov 29, 2018
2 parents 5d8cad3 + 0d8f10f commit 8272f52
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Adyen/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Client
{
const LIB_VERSION = "1.5.3";
const LIB_VERSION = "1.5.4";
const LIB_NAME = "adyen-php-api-library";
const USER_AGENT_SUFFIX = "adyen-php-api-library/";
const ENDPOINT_TEST = "https://pal-test.adyen.com";
Expand All @@ -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
17 changes: 17 additions & 0 deletions src/Adyen/Service/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class Payment extends \Adyen\Service
*/
protected $_authorise3D;

/**
* @var ResourceModel\Payment\Authorise3DS2
*/
protected $_authorise3DS2;

/**
* Payment constructor.
*
Expand All @@ -25,6 +30,7 @@ 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);
$this->_authorise3DS2 = new \Adyen\Service\ResourceModel\Payment\Authorise3DS2($this);
}

/**
Expand All @@ -48,4 +54,15 @@ public function authorise3D($params)
$result = $this->_authorise3D->request($params);
return $result;
}

/**
* @param $params
* @return mixed
* @throws \Adyen\AdyenException
*/
public function authorise3DS2($params)
{
$result = $this->_authorise3DS2->request($params);
return $result;
}
}
29 changes: 29 additions & 0 deletions src/Adyen/Service/ResourceModel/Payment/Authorise3DS2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Adyen\Service\ResourceModel\Payment;

class Authorise3DS2 extends \Adyen\Service\AbstractResource
{
/**
* @var string
*/
protected $_endpoint;

/**
* Include applicationInfo key in the request parameters
*
* @var bool
*/
protected $allowApplicationInfo = true;

/**
* Authorise3DS2 constructor.
*
* @param \Adyen\Service $service
*/
public function __construct($service)
{
$this->_endpoint = $service->getClient()->getConfig()->get('endpoint') . '/pal/servlet/Payment/' . $service->getClient()->getApiPaymentVersion() . '/authorise3ds2';
parent::__construct($service, $this->_endpoint, $this->allowApplicationInfo);
}
}
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);
}
}
6 changes: 3 additions & 3 deletions tests/PayoutThirdPartyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testStoreDetailAndSubmitPayoutThirdPartyMissingReference()

// check if exception is correct
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals('Missing the following fields: reference', $e->getMessage());
$this->assertEquals('Required field \'reference\' is null', $e->getMessage());

}

Expand Down Expand Up @@ -314,7 +314,7 @@ public function testConfirmPayoutThirdPartyInvalidReference()

// check if exception is correct
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals('Missing the following values: originalReference', $e->getMessage());
$this->assertEquals('Invalid Request: Original pspReference is invalid for this environment!', $e->getMessage());
}

public function testDeclinePayoutThirdPartySuccess()
Expand Down Expand Up @@ -373,7 +373,7 @@ public function testDeclinePayoutThirdPartyInvalidReference()

// check if exception is correct
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals('Missing the following values: originalReference', $e->getMessage());
$this->assertEquals('Invalid Request: Original pspReference is invalid for this environment!', $e->getMessage());
}

}
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 8272f52

Please sign in to comment.