Skip to content

Commit

Permalink
[ECP-9450] Update naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Nov 13, 2024
1 parent c42eaf5 commit 3aac56c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Gateway/Request/CheckoutDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\StateData;
use Adyen\Payment\Helper\OpenInvoice;
use Adyen\Payment\Model\Config\Source\ThreeDSMode;
use Adyen\Payment\Model\Config\Source\ThreeDSFlow;
use Adyen\Payment\Model\Ui\AdyenPayByLinkConfigProvider;
use Adyen\Payment\Observer\AdyenCcDataAssignObserver;
use Adyen\Payment\Observer\AdyenPaymentMethodDataAssignObserver;
Expand Down Expand Up @@ -211,7 +211,7 @@ public function build(array $buildSubject): array
}

$requestBody['additionalData']['allow3DS2'] =
$this->configHelper->getThreeDSMode($storeId) === ThreeDSMode::THREEDS_MODE_NATIVE;
$this->configHelper->getThreeDSFlow($storeId) === ThreeDSFlow::THREEDS_NATIVE;

return [
'body' => $requestBody
Expand Down
4 changes: 2 additions & 2 deletions Gateway/Request/RecurringVaultDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\StateData;
use Adyen\Payment\Helper\Vault;
use Adyen\Payment\Model\Config\Source\ThreeDSMode;
use Adyen\Payment\Model\Config\Source\ThreeDSFlow;
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Payment\Gateway\Helper\SubjectReader;
Expand Down Expand Up @@ -68,7 +68,7 @@ public function build(array $buildSubject): array
*/
if ($paymentMethod->getCode() === AdyenCcConfigProvider::CC_VAULT_CODE) {
$requestBody['additionalData']['allow3DS2'] =
$this->configHelper->getThreeDSMode($order->getStoreId()) === ThreeDSMode::THREEDS_MODE_NATIVE;
$this->configHelper->getThreeDSFlow($order->getStoreId()) === ThreeDSFlow::THREEDS_NATIVE;
$requestBody['paymentMethod']['holderName'] = $details['cardHolderName'] ?? null;
}

Expand Down
6 changes: 3 additions & 3 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Config
const AUTO_CAPTURE_OPENINVOICE = 'auto';
const XML_RECURRING_CONFIGURATION = 'recurring_configuration';
const XML_ALLOW_MULTISTORE_TOKENS = 'allow_multistore_tokens';
const XML_THREEDS_MODE = 'threeds_mode';
const XML_THREEDS_FLOW = 'threeds_flow';

protected ScopeConfigInterface $scopeConfig;
private EncryptorInterface $encryptor;
Expand Down Expand Up @@ -583,10 +583,10 @@ public function getAllowMultistoreTokens(int $storeId = null): ?bool
* @param int|null $storeId
* @return string
*/
public function getThreeDSMode(int $storeId = null): string
public function getThreeDSFlow(int $storeId = null): string
{
return $this->getConfigData(
self::XML_THREEDS_MODE,
self::XML_THREEDS_FLOW,
self::XML_ADYEN_CC,
$storeId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@

use Magento\Framework\Data\OptionSourceInterface;

class ThreeDSMode implements OptionSourceInterface
class ThreeDSFlow implements OptionSourceInterface
{
const THREEDS_MODE_NATIVE = 'native';
const THREEDS_MODE_REDIRECT = 'redirect';
const THREEDS_NATIVE = 'native';
const THREEDS_REDIRECT = 'redirect';

/**
* @return array
*/
public function toOptionArray(): array
{
return [
['value' => self::THREEDS_MODE_NATIVE, 'label' => __('Native 3D Secure 2')],
['value' => self::THREEDS_MODE_REDIRECT, 'label' => __('Redirect 3D Secure 2')],
['value' => self::THREEDS_NATIVE, 'label' => __('Native 3D Secure 2')],
['value' => self::THREEDS_REDIRECT, 'label' => __('Redirect 3D Secure 2')],
];
}
}
6 changes: 3 additions & 3 deletions Test/Unit/Gateway/Request/CheckoutDataBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\OpenInvoice;
use Adyen\Payment\Helper\StateData;
use Adyen\Payment\Model\Config\Source\ThreeDSMode;
use Adyen\Payment\Model\Config\Source\ThreeDSFlow;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Quote\Api\CartRepositoryInterface;
Expand Down Expand Up @@ -72,9 +72,9 @@ public function testAllowThreeDSFlag()
];

$this->configMock->expects($this->once())
->method('getThreeDSMode')
->method('getThreeDSFlow')
->with($storeId)
->willReturn(ThreeDSMode::THREEDS_MODE_NATIVE);
->willReturn(ThreeDSFlow::THREEDS_NATIVE);

$request = $this->checkoutDataBuilder->build($buildSubject);

Expand Down
4 changes: 2 additions & 2 deletions Test/Unit/Helper/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ public function testGetThreeDSModes()
"%s/%s/%s",
Config::XML_PAYMENT_PREFIX,
Config::XML_ADYEN_CC,
Config::XML_THREEDS_MODE
Config::XML_THREEDS_FLOW
);

$this->scopeConfigMock->expects($this->once())
->method('getValue')
->with($this->equalTo($path), $this->equalTo(ScopeInterface::SCOPE_STORE), $this->equalTo($storeId))
->willReturn($expectedResult);

$result = $this->configHelper->getThreeDSMode($storeId);
$result = $this->configHelper->getThreeDSFlow($storeId);
$this->assertEquals($expectedResult, $result);
}
}
8 changes: 4 additions & 4 deletions Test/Unit/Model/Config/Source/ThreeDSModeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace Adyen\Payment\Test\Unit\Model\Config\Source;

use Adyen\Payment\Model\Config\Source\ThreeDSMode;
use Adyen\Payment\Model\Config\Source\ThreeDSFlow;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;

class ThreeDSModeTest extends AbstractAdyenTestCase
{
public function testToOptionArray()
{
$threeDSModeSource = new ThreeDSMode();
$threeDSModeSource = new ThreeDSFlow();

$expected = [
['value' => ThreeDSMode::THREEDS_MODE_NATIVE, 'label' => __('Native 3D Secure 2')],
['value' => ThreeDSMode::THREEDS_MODE_REDIRECT, 'label' => __('Redirect 3D Secure 2')],
['value' => ThreeDSFlow::THREEDS_NATIVE, 'label' => __('Native 3D Secure 2')],
['value' => ThreeDSFlow::THREEDS_REDIRECT, 'label' => __('Redirect 3D Secure 2')],
];

$this->assertEquals($expected, $threeDSModeSource->toOptionArray());
Expand Down
8 changes: 4 additions & 4 deletions etc/adminhtml/system/adyen_card_payments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/enable_click_to_pay</config_path>
</field>
<field id="threeds_mode" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1">
<label>Preferred 3D Secure 2 authentication</label>
<source_model>Adyen\Payment\Model\Config\Source\ThreeDSMode</source_model>
<config_path>payment/adyen_cc/threeds_mode</config_path>
<field id="threeds_flow" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1">
<label>3D Secure 2 authentication flow</label>
<source_model>Adyen\Payment\Model\Config\Source\ThreeDSFlow</source_model>
<config_path>payment/adyen_cc/threeds_flow</config_path>
</field>
</group>
</include>
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<can_authorize_vault>1</can_authorize_vault>
<can_capture_vault>1</can_capture_vault>
<supports_recurring>1</supports_recurring>
<threeds_mode>native</threeds_mode>
<threeds_flow>native</threeds_flow>
<group>adyen</group>
</adyen_cc>
<adyen_cc_vault>
Expand Down

0 comments on commit 3aac56c

Please sign in to comment.