-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
188 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
|
||
namespace Adyen\Payment\Model\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
|
||
class ThreeDSFlow implements OptionSourceInterface | ||
{ | ||
const THREEDS_NATIVE = 'native'; | ||
const THREEDS_REDIRECT = 'redirect'; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toOptionArray(): array | ||
{ | ||
return [ | ||
['value' => self::THREEDS_NATIVE, 'label' => __('Native 3D Secure 2')], | ||
['value' => self::THREEDS_REDIRECT, 'label' => __('Redirect 3D Secure 2')], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
namespace Adyen\Payment\Test\Gateway\Request; | ||
|
||
use Adyen\Payment\Gateway\Request\CheckoutDataBuilder; | ||
use Adyen\Payment\Helper\ChargedCurrency; | ||
use Adyen\Payment\Helper\Config; | ||
use Adyen\Payment\Helper\Data; | ||
use Adyen\Payment\Helper\OpenInvoice; | ||
use Adyen\Payment\Helper\StateData; | ||
use Adyen\Payment\Model\Config\Source\ThreeDSFlow; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Magento\Payment\Gateway\Data\PaymentDataObject; | ||
use Magento\Quote\Api\CartRepositoryInterface; | ||
use Magento\Sales\Model\Order; | ||
use Magento\Sales\Model\Order\Payment; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class CheckoutDataBuilderTest extends AbstractAdyenTestCase | ||
{ | ||
protected ?CheckoutDataBuilder $checkoutDataBuilder; | ||
|
||
protected Data|MockObject $adyenHelperMock; | ||
protected StateData|MockObject $stateDataMock; | ||
protected CartRepositoryInterface|MockObject $cartRepositoryMock; | ||
protected ChargedCurrency|MockObject $chargedCurrencyMock; | ||
protected Config|MockObject $configMock; | ||
protected OpenInvoice|MockObject $openInvoiceMock; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->adyenHelperMock = $this->createMock(Data::class); | ||
$this->stateDataMock = $this->createMock(StateData::class); | ||
$this->cartRepositoryMock = $this->createMock(CartRepositoryInterface::class); | ||
$this->chargedCurrencyMock = $this->createMock(ChargedCurrency::class); | ||
$this->configMock = $this->createMock(Config::class); | ||
$this->openInvoiceMock = $this->createMock(OpenInvoice::class); | ||
|
||
$this->checkoutDataBuilder = new CheckoutDataBuilder( | ||
$this->adyenHelperMock, | ||
$this->stateDataMock, | ||
$this->cartRepositoryMock, | ||
$this->chargedCurrencyMock, | ||
$this->configMock, | ||
$this->openInvoiceMock | ||
); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
$this->checkoutDataBuilder = null; | ||
} | ||
|
||
|
||
public function testAllowThreeDSFlag() | ||
{ | ||
$storeId = 1; | ||
|
||
$orderMock = $this->createMock(Order::class); | ||
$orderMock->method('getQuoteId')->willReturn(1); | ||
$orderMock->method('getStoreId')->willReturn($storeId); | ||
|
||
$paymentMock = $this->createMock(Payment::class); | ||
$paymentMock->method('getOrder')->willReturn($orderMock); | ||
|
||
$buildSubject = [ | ||
'payment' => $this->createConfiguredMock(PaymentDataObject::class, [ | ||
'getPayment' => $paymentMock | ||
]) | ||
]; | ||
|
||
$this->configMock->expects($this->once()) | ||
->method('getThreeDSFlow') | ||
->with($storeId) | ||
->willReturn(ThreeDSFlow::THREEDS_NATIVE); | ||
|
||
$request = $this->checkoutDataBuilder->build($buildSubject); | ||
|
||
$this->assertTrue($request['body']['additionalData']['allow3DS2']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Adyen\Payment\Test\Unit\Model\Config\Source; | ||
|
||
use Adyen\Payment\Model\Config\Source\ThreeDSFlow; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
|
||
class ThreeDSModeTest extends AbstractAdyenTestCase | ||
{ | ||
public function testToOptionArray() | ||
{ | ||
$threeDSModeSource = new ThreeDSFlow(); | ||
|
||
$expected = [ | ||
['value' => ThreeDSFlow::THREEDS_NATIVE, 'label' => __('Native 3D Secure 2')], | ||
['value' => ThreeDSFlow::THREEDS_REDIRECT, 'label' => __('Redirect 3D Secure 2')], | ||
]; | ||
|
||
$this->assertEquals($expected, $threeDSModeSource->toOptionArray()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters