We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 530139f4 authored by Marcos Garcia's avatar Marcos Garcia Committed by GitHub

PW-1616 Implement an API endpoint for Origin Keys (#512)

To help merchants implements a Progressive Web App shop, this change will expose the origin key so that it's easier to configure the payment module.
parent 42c9dca8
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Api;
interface AdyenOriginKeyInterface
{
/**
* @return string
*/
public function getOriginKey();
}
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
use Adyen\AdyenException;
use Adyen\Payment\Helper\Data as AdyenHelper;
use Magento\Framework\Exception\NoSuchEntityException as MagentoNoSuchEntityException;
class AdyenOriginKey implements \Adyen\Payment\Api\AdyenOriginKeyInterface
{
/**
* @var AdyenHelper
*/
private $helper;
public function __construct(AdyenHelper $helper)
{
$this->helper = $helper;
}
/**
* {@inheritDoc}
* @throws MagentoNoSuchEntityException
* @throws AdyenException
*/
public function getOriginKey()
{
return $this->helper->getOriginKeyForBaseUrl();
}
}
\ No newline at end of file
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
use Adyen\Payment\Helper\Data as AdyenHelper;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
class AdyenOriginKeyTest extends TestCase
{
/** @var AdyenHelper|MockObject */
private $helper;
protected function setUp()
{
$this->helper = $this->getMockBuilder(AdyenHelper::class)
->disableOriginalConstructor()
->getMock();
}
/** @throws \Exception */
public function testGetOriginKey()
{
$this->helper->method('getOriginKeyForBaseUrl')
->willReturn('something');
$module = new AdyenOriginKey($this->helper);
$this->assertEquals('something', $module->getOriginKey());
}
/** @throws \Exception */
public function testGetOriginKeyDoesNotHandleExceptions()
{
$this->helper->method('getOriginKeyForBaseUrl')
->willThrowException(new \Exception('Some error message', 400));
$module = new AdyenOriginKey($this->helper);
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Some error message');
$this->expectExceptionCode(400);
$module->getOriginKey();
}
}
......@@ -972,6 +972,8 @@
type="Adyen\Payment\Model\AdyenPaymentProcess"/>
<preference for="Adyen\Payment\Api\AdyenThreeDS2ProcessInterface"
type="Adyen\Payment\Model\AdyenThreeDS2Process"/>
<preference for="Adyen\Payment\Api\AdyenOriginKeyInterface"
type="Adyen\Payment\Model\AdyenOriginKey"/>
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</type>
......
......@@ -71,4 +71,11 @@
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/adyen/originKey" method="GET">
<service class="Adyen\Payment\Api\AdyenOriginKeyInterface" method="getOriginKey"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment