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

[PW-6858] Add multiselect config for selecting which PMs to tokenize #1605

Merged
merged 3 commits into from
Jul 11, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 0 additions & 42 deletions Api/Data/AdyenPaymentMethodInterface.php

This file was deleted.

25 changes: 0 additions & 25 deletions Api/Data/AdyenPaymentMethodRepositoryInterface.php

This file was deleted.

5 changes: 5 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ public function getCardRecurringType($storeId): ?string
return $this->getConfigData('card_type', self::XML_ADYEN_ONECLICK, $storeId);
}

public function getTokenizedPaymentMethods($storeId)
{
return $this->getConfigData('tokenized_payment_methods', self::XML_ADYEN_HPP, $storeId);
}

/**
* Retrieve information from payment configuration
*
Expand Down
2 changes: 1 addition & 1 deletion Helper/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class PaymentMethodFactory
{
private static AdyenLogger $adyenLogger;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static $adyenLogger;

public function __construct(AdyenLogger $adyenLogger)
{
Expand Down
14 changes: 6 additions & 8 deletions Helper/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

namespace Adyen\Payment\Helper;

use Adyen\Payment\Api\Data\AdyenPaymentMethodRepositoryInterface;
use Adyen\Payment\Exception\InvalidAdditionalDataException;
use Adyen\Payment\Exception\PaymentMethodException;
use Adyen\Payment\Helper\PaymentMethods\PaymentMethodFactory;
Expand Down Expand Up @@ -82,9 +81,6 @@ class Vault
/** @var PaymentMethods */
private $paymentMethodsHelper;

/** @var AdyenPaymentMethodRepositoryInterface */
private $adyenPaymentMethodRepo;

/** @var PaymentMethodFactory */
private $paymentMethodFactory;

Expand All @@ -96,7 +92,6 @@ public function __construct(
PaymentTokenRepositoryInterface $paymentTokenRepository,
Config $config,
PaymentMethods $paymentMethodsHelper,
AdyenPaymentMethodRepositoryInterface $adyenPaymentMethodRepo,
PaymentMethodFactory $paymentMethodFactory
) {
$this->adyenHelper = $adyenHelper;
Expand All @@ -106,7 +101,6 @@ public function __construct(
$this->paymentTokenRepository = $paymentTokenRepository;
$this->config = $config;
$this->paymentMethodsHelper = $paymentMethodsHelper;
$this->adyenPaymentMethodRepo = $adyenPaymentMethodRepo;
$this->paymentMethodFactory = $paymentMethodFactory;
}

Expand Down Expand Up @@ -255,9 +249,13 @@ public function allowRecurringOnPaymentMethod(PaymentMethodInterface $adyenPayme
$methodSupportsRecurring = $adyenPaymentMethod->supportsSubscription();
}

$paymentMethodModel = $this->adyenPaymentMethodRepo->getByPaymentMethodName($adyenPaymentMethod->getTxVariant());
$tokenizedPaymentMethods = array_map(
'trim',
explode(',', $this->config->getTokenizedPaymentMethods($storeId))
);
$shouldTokenize = in_array($adyenPaymentMethod->getTxVariant(), $tokenizedPaymentMethods);

return $methodSupportsRecurring && $paymentMethodModel->getEnableRecurring();
return $methodSupportsRecurring && $shouldTokenize;
}

/**
Expand Down
34 changes: 34 additions & 0 deletions Model/Config/Source/TokenizedPaymentMethods.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Adyen\Payment\Model\Config\Source;

use Adyen\Payment\Helper\PaymentMethods;
use Magento\Framework\Data\OptionSourceInterface;

class TokenizedPaymentMethods implements OptionSourceInterface
{
/**
* @inheritDoc
*/
public function toOptionArray()
{
return [
[
'value' => PaymentMethods\ApplePayPaymentMethod::TX_VARIANT,
'label' => PaymentMethods\ApplePayPaymentMethod::NAME
],
[
'value' => PaymentMethods\GooglePayPaymentMethod::TX_VARIANT,
'label' => PaymentMethods\GooglePayPaymentMethod::NAME
],
[
'value' => PaymentMethods\PayPalPaymentMethod::TX_VARIANT,
'label' => PaymentMethods\PayPalPaymentMethod::NAME
],
[
'value' => PaymentMethods\SepaPaymentMethod::TX_VARIANT,
'label' => PaymentMethods\SepaPaymentMethod::NAME
],
];
}
}
2 changes: 1 addition & 1 deletion Model/InstantPurchase/PaymentMethods/TokenFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class TokenFormatter extends AbstractAdyenTokenFormatter implements PaymentTokenFormatterInterface
{
/** @var PaymentMethodFactory */
private PaymentMethodFactory $paymentMethodFactory;
private $paymentMethodFactory;

public function __construct(PaymentMethodFactory $paymentMethodFactory)
{
Expand Down
51 changes: 0 additions & 51 deletions Model/PaymentMethod/AdyenPaymentMethod.php

This file was deleted.

74 changes: 0 additions & 74 deletions Model/PaymentMethod/AdyenPaymentMethodRepository.php

This file was deleted.

24 changes: 0 additions & 24 deletions Model/ResourceModel/AdyenPaymentMethod.php

This file was deleted.

29 changes: 0 additions & 29 deletions Model/ResourceModel/AdyenPaymentMethod/Collection.php

This file was deleted.

4 changes: 2 additions & 2 deletions Model/Ui/AdyenUiComponentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
class AdyenUiComponentProvider
{

protected TokenUiComponentInterfaceFactory $componentFactory;
protected Data $dataHelper;
protected $componentFactory;
protected $dataHelper;

/**
* @param TokenUiComponentInterfaceFactory $componentFactory
Expand Down
4 changes: 2 additions & 2 deletions Model/Ui/PaymentMethodUiComponentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
class PaymentMethodUiComponentProvider extends AdyenUiComponentProvider implements TokenUiComponentProviderInterface
{

private Vault $vaultHelper;
private PaymentMethodFactory $paymentMethodFactory;
private $vaultHelper;
private $paymentMethodFactory;

/**
* @param TokenUiComponentInterfaceFactory $componentFactory
Expand Down