Skip to content

Commit bfd251d

Browse files
Card storage link
Added an option to show/hide card storage link in customer account.
1 parent 0ddf8bf commit bfd251d

File tree

6 files changed

+71
-8
lines changed

6 files changed

+71
-8
lines changed

Block/Customer/CardRenderer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
namespace CheckoutCom\Magento2\Block\Customer;
1212

1313
use Magento\Payment\Model\CcConfigProvider;
14-
use CheckoutCom\Magento2\Model\Ui\ConfigProvider;
1514
use Magento\Framework\View\Element\Template;
1615
use Magento\Vault\Api\Data\PaymentTokenInterface;
1716
use Magento\Vault\Block\AbstractCardRenderer;
17+
use CheckoutCom\Magento2\Model\Ui\ConfigProvider;
1818
use CheckoutCom\Magento2\Gateway\Config\Config as GatewayConfig;
1919

2020
class CardRenderer extends AbstractCardRenderer {
@@ -31,7 +31,12 @@ class CardRenderer extends AbstractCardRenderer {
3131
* @param GatewayConfig $gatewayConfig
3232
* @param array $data
3333
*/
34-
public function __construct(Template\Context $context, CcConfigProvider $iconsProvider, GatewayConfig $gatewayConfig, array $data) {
34+
public function __construct(
35+
Template\Context $context,
36+
CcConfigProvider $iconsProvider,
37+
GatewayConfig $gatewayConfig,
38+
array $data
39+
) {
3540
parent::__construct($context, $iconsProvider, $data);
3641

3742
$this->gatewayConfig = $gatewayConfig;

Model/Service/CallbackService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CallbackService {
8787
/**
8888
* @var OrderSender
8989
*/
90-
private $orderSender;
90+
protected $orderSender;
9191

9292
/**
9393
* CallbackService constructor.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace CheckoutCom\Magento2\Plugin;
4+
5+
use Closure;
6+
use Magento\Framework\View\Element\Html\Links;
7+
use Magento\Framework\View\Element\AbstractBlock;
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
10+
/**
11+
* Class CustomerDashboardLinksManagement
12+
*/
13+
class CustomerDashboardLinksManagement
14+
{
15+
/**
16+
* @var ScopeConfigInterface
17+
*/
18+
protected $scopeConfig;
19+
20+
21+
public function __construct (ScopeConfigInterface $scopeConfig) {
22+
$this->scopeConfig = $scopeConfig;
23+
}
24+
25+
public function aroundRenderLink(Links $subject, Closure $proceed, AbstractBlock $link)
26+
{
27+
// Get the output
28+
$output = $proceed($link);
29+
30+
// If it's the dashboard menu
31+
if ($subject->getNameInLayout() == 'customer_account_navigation') {
32+
// If it's the stored payment cards lenu link
33+
if ($link->getNameInLayout() == 'customer-account-navigation-my-credit-cards-link') {
34+
if ((bool) $this->scopeConfig->getValue('payment/checkout_com_cc_vault/hide_card_storage')) {
35+
return '';
36+
}
37+
}
38+
}
39+
40+
return $output;
41+
}
42+
}

etc/adminhtml/system.xml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,28 @@
140140
</comment>
141141
</field>
142142

143-
<field id="useccv" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
143+
<field id="checkout_com_cc_vault_hide_storage" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
144+
<label>Hide card storage</label>
145+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
146+
<config_path>payment/checkout_com_cc_vault/hide_card_storage</config_path>
147+
<comment>
148+
If set to "Yes", customers will not be able to access the stored payment methods links from the account.
149+
</comment>
150+
</field>
151+
152+
<field id="useccv" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
144153
<label>CVV Verification</label>
145154
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
146155
<config_path>payment/checkout_com/useccv</config_path>
147156
</field>
148157

149-
<field id="verify_3dsecure" translate="label" sortOrder="50" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
158+
<field id="verify_3dsecure" translate="label" sortOrder="60" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
150159
<label>3D Secure Verification</label>
151160
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
152161
<config_path>payment/checkout_com/verify_3dsecure</config_path>
153162
</field>
154163

155-
<field id="attemptN3D" translate="label comment" sortOrder="60" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
164+
<field id="attemptN3D" translate="label comment" sortOrder="70" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
156165
<label>Attempt Non 3D Secure</label>
157166
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
158167
<config_path>payment/checkout_com/attemptN3D</config_path>
@@ -164,13 +173,13 @@
164173
</comment>
165174
</field>
166175

167-
<field id="auto_capture" translate="label" sortOrder="70" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
176+
<field id="auto_capture" translate="label" sortOrder="80" type="select" showInDefault="1" showInWebsite="1" showInStore="0">
168177
<label>Auto Capture</label>
169178
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
170179
<config_path>payment/checkout_com/auto_capture</config_path>
171180
</field>
172181

173-
<field id="auto_capture_time" translate="label comment" sortOrder="80" type="text" showInDefault="1" showInWebsite="1" showInStore="0">
182+
<field id="auto_capture_time" translate="label comment" sortOrder="90" type="text" showInDefault="1" showInWebsite="1" showInStore="0">
174183
<label>Auto Capture Time</label>
175184
<config_path>payment/checkout_com/auto_capture_time</config_path>
176185
<validate>validate-required validate-digits validate-zero-or-greater</validate>

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<model>CheckoutComCreditCardVaultFacade</model>
6666
<title>Stored Cards (Checkout.com)</title>
6767
<autosave>1</autosave>
68+
<hide_card_storage>0</hide_card_storage>
6869
</checkout_com_cc_vault>
6970
</payment>
7071
</default>

etc/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@
433433
</type>
434434
<!-- END Around Payments Plugin -->
435435

436+
<!-- Accound dashboard plugin -->
437+
<type name="Magento\Framework\View\Element\Html\Links">
438+
<plugin sortOrder="1" name="CkoCustomerDashboardLinksManagement" type="CheckoutCom\Magento2\Plugin\CustomerDashboardLinksManagement"/>
439+
</type>
440+
<!-- END account dashboard plugin -->
441+
436442
<!-- Plans grid listing -->
437443
<virtualType name="CheckoutCom\Magento2\Model\ResourceModel\Plan\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
438444
<arguments>

0 commit comments

Comments
 (0)