Skip to content

Commit abb9ac2

Browse files
committed
ACP2E-1215: Customer has no any vault token save, but vault payment method appears in admin checkout
- fix
1 parent 24a2c46 commit abb9ac2

File tree

5 files changed

+11
-172
lines changed

5 files changed

+11
-172
lines changed

app/code/Magento/Payment/Test/Unit/Plugin/PaymentMethodProcessTest.php

Lines changed: 0 additions & 142 deletions
This file was deleted.

app/code/Magento/Payment/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"magento/module-quote": "*",
1414
"magento/module-sales": "*",
1515
"magento/module-store": "*",
16-
"magento/module-ui": "*",
17-
"magento/module-vault": "*"
16+
"magento/module-ui": "*"
1817
},
1918
"type": "magento2-module",
2019
"license": [

app/code/Magento/Payment/etc/di.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,4 @@
8181
<argument name="logger" xsi:type="object">Magento\Payment\Model\Method\VirtualLogger</argument>
8282
</arguments>
8383
</type>
84-
<type name="Magento\Payment\Block\Form\Container">
85-
<plugin name="PaymentMethodProcess" type="Magento\Payment\Plugin\PaymentMethodProcess"/>
86-
</type>
87-
<type name="Magento\Payment\Plugin\PaymentMethodProcess">
88-
<arguments>
89-
<argument name="braintreeCCVault" xsi:type="string">braintree_cc_vault</argument>
90-
</arguments>
91-
</type>
9284
</config>

app/code/Magento/Payment/Plugin/PaymentMethodProcess.php renamed to app/code/Magento/Vault/Plugin/PaymentMethodProcess.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,26 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\Payment\Plugin;
8+
namespace Magento\Vault\Plugin;
99

10-
use Magento\Framework\App\ObjectManager;
1110
use Magento\Payment\Block\Form\Container;
1211
use Magento\Vault\Model\Ui\Adminhtml\TokensConfigProvider;
12+
use Magento\Vault\Model\VaultPaymentInterface;
1313

14-
/**
15-
* @SuppressWarnings(PHPMD)
16-
*/
1714
class PaymentMethodProcess
1815
{
19-
/**
20-
* @var string
21-
*/
22-
private string $braintreeCCVault;
23-
2416
/**
2517
* @var TokensConfigProvider
2618
*/
2719
private TokensConfigProvider $tokensConfigProvider;
2820

2921
/**
30-
* @param string $braintreeCCVault
31-
* @param TokensConfigProvider|null $tokensConfigProvider
22+
* @param TokensConfigProvider $tokensConfigProvider
3223
*/
3324
public function __construct(
34-
string $braintreeCCVault = '',
35-
TokensConfigProvider $tokensConfigProvider = null
25+
TokensConfigProvider $tokensConfigProvider
3626
) {
37-
$this->braintreeCCVault = $braintreeCCVault;
38-
$this->tokensConfigProvider = $tokensConfigProvider ??
39-
ObjectManager::getInstance()->get(TokensConfigProvider::class);
27+
$this->tokensConfigProvider = $tokensConfigProvider;
4028
}
4129

4230
/**
@@ -51,9 +39,8 @@ public function afterGetMethods(Container $container, array $results): array
5139
{
5240
$methods = [];
5341
foreach ($results as $result) {
54-
if ($result->getCode() === $this->braintreeCCVault
55-
&& empty($this->tokensConfigProvider->getTokensComponents($result->getCode()))) {
56-
42+
if ($result instanceOf VaultPaymentInterface &&
43+
empty($this->tokensConfigProvider->getTokensComponents($result->getCode()))) {
5744
continue;
5845
}
5946
$methods[] = $result;

app/code/Magento/Vault/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@
5757
<plugin name="ProcessPaymentVaultInformationManagement"
5858
type="Magento\Vault\Plugin\PaymentVaultInformationManagement"/>
5959
</type>
60+
<type name="Magento\Payment\Block\Form\Container">
61+
<plugin name="PaymentMethodProcess" type="Magento\Vault\Plugin\PaymentMethodProcess"/>
62+
</type>
6063
</config>

0 commit comments

Comments
 (0)