diff --git a/app/code/Magento/Braintree/Block/Form.php b/app/code/Magento/Braintree/Block/Form.php index dc0071f175fb1..cefc0a8418243 100644 --- a/app/code/Magento/Braintree/Block/Form.php +++ b/app/code/Magento/Braintree/Block/Form.php @@ -9,8 +9,10 @@ use Magento\Braintree\Gateway\Config\Config as GatewayConfig; use Magento\Braintree\Model\Adminhtml\Source\CcType; use Magento\Braintree\Model\Ui\ConfigProvider; +use Magento\Framework\App\ObjectManager; use Magento\Framework\View\Element\Template\Context; use Magento\Payment\Block\Form\Cc; +use Magento\Payment\Helper\Data; use Magento\Payment\Model\Config; use Magento\Vault\Model\VaultPaymentInterface; @@ -36,9 +38,9 @@ class Form extends Cc protected $ccType; /** - * @var VaultPaymentInterface + * @var Data */ - protected $vaultService; + private $paymentDataHelper; /** * @param Context $context @@ -46,7 +48,6 @@ class Form extends Cc * @param Quote $sessionQuote * @param GatewayConfig $gatewayConfig * @param CcType $ccType - * @param VaultPaymentInterface $vaultService * @param array $data */ public function __construct( @@ -55,14 +56,12 @@ public function __construct( Quote $sessionQuote, GatewayConfig $gatewayConfig, CcType $ccType, - VaultPaymentInterface $vaultService, array $data = [] ) { parent::__construct($context, $paymentConfig, $data); $this->sessionQuote = $sessionQuote; $this->gatewayConfig = $gatewayConfig; $this->ccType = $ccType; - $this->vaultService = $vaultService; } /** @@ -91,7 +90,9 @@ public function useCvv() */ public function isVaultEnabled() { - return $this->vaultService->isActiveForPayment(ConfigProvider::CODE); + $storeId = $this->_storeManager->getStore()->getId(); + $vaultPayment = $this->getVaultPayment(); + return $vaultPayment->isActive($storeId); } /** @@ -123,4 +124,26 @@ private function filterCardTypesForCountry(array $configCardTypes, $countryId) } return $filtered; } + + /** + * Get configured vault payment for Braintree + * @return VaultPaymentInterface + */ + private function getVaultPayment() + { + return $this->getPaymentDataHelper()->getMethodInstance(ConfigProvider::CC_VAULT_CODE); + } + + /** + * Get payment data helper instance + * @return Data + * @deprecated + */ + private function getPaymentDataHelper() + { + if ($this->paymentDataHelper === null) { + $this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class); + } + return $this->paymentDataHelper; + } } diff --git a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php index bba77b0fe9682..d720b748ba819 100644 --- a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php +++ b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php @@ -20,6 +20,8 @@ final class ConfigProvider implements ConfigProviderInterface const PAYPAL_CODE = 'braintree_paypal'; + const CC_VAULT_CODE = 'braintree_cc_vault'; + /** * @var ResolverInterface */ @@ -88,6 +90,7 @@ public function getConfig() 'kountMerchantId' => $this->config->getKountMerchantId(), 'hasFraudProtection' => $this->config->hasFraudProtection(), 'merchantId' => $this->config->getMerchantId(), + 'ccVaultCode' => static::CC_VAULT_CODE ], Config::CODE_3DSECURE => [ 'enabled' => $this->config->isVerify3DSecure(), diff --git a/app/code/Magento/Braintree/Model/Ui/TokenUiComponentProvider.php b/app/code/Magento/Braintree/Model/Ui/TokenUiComponentProvider.php index 5f511ebbf4e3d..1fe3fb24db8d8 100644 --- a/app/code/Magento/Braintree/Model/Ui/TokenUiComponentProvider.php +++ b/app/code/Magento/Braintree/Model/Ui/TokenUiComponentProvider.php @@ -49,6 +49,7 @@ public function getComponentForToken(PaymentTokenInterface $paymentToken) $component = $this->componentFactory->create( [ 'config' => [ + 'code' => ConfigProvider::CC_VAULT_CODE, 'nonceUrl' => $this->getNonceRetrieveUrl(), TokenUiComponentProviderInterface::COMPONENT_DETAILS => $jsonDetails, TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash() diff --git a/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php b/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php index 6c07d2401d56c..f056ba0cefd36 100644 --- a/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php @@ -11,9 +11,13 @@ use Magento\Braintree\Model\Adminhtml\Source\CcType; use Magento\Braintree\Model\Ui\ConfigProvider; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Payment\Helper\Data; use Magento\Payment\Model\Config; -use Magento\Vault\Model\Ui\VaultConfigProvider; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Store\Model\StoreManagerInterface; use Magento\Vault\Model\VaultPaymentInterface; +use OAuthTest\Mocks\Common\Service\Mock; +use PHPUnit_Framework_MockObject_MockObject as MockObject; /** * Class FormTest @@ -40,32 +44,41 @@ class FormTest extends \PHPUnit_Framework_TestCase private $block; /** - * @var Quote|\PHPUnit_Framework_MockObject_MockObject + * @var Quote|MockObject */ private $sessionQuote; /** - * @var Config|\PHPUnit_Framework_MockObject_MockObject + * @var Config|MockObject */ private $gatewayConfig; /** - * @var CcType|\PHPUnit_Framework_MockObject_MockObject + * @var CcType|MockObject */ private $ccType; /** - * @var VaultPaymentInterface|\PHPUnit_Framework_MockObject_MockObject + * @var StoreManagerInterface|MockObject */ - private $vaultService; + private $storeManager; + + /** + * @var Data|MockObject + */ + private $paymentDataHelper; protected function setUp() { $this->initCcTypeMock(); $this->initSessionQuoteMock(); $this->initGatewayConfigMock(); - - $this->vaultService = $this->getMock(VaultPaymentInterface::class); + + $this->storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class); + $this->paymentDataHelper = $this->getMockBuilder(Data::class) + ->disableOriginalConstructor() + ->setMethods(['getMethodInstance']) + ->getMock(); $managerHelper = new ObjectManager($this); $this->block = $managerHelper->getObject(Form::class, [ @@ -73,8 +86,10 @@ protected function setUp() 'sessionQuote' => $this->sessionQuote, 'gatewayConfig' => $this->gatewayConfig, 'ccType' => $this->ccType, - 'vaultService' => $this->vaultService + 'storeManager' => $this->storeManager ]); + + $managerHelper->setBackwardCompatibleProperty($this->block, 'paymentDataHelper', $this->paymentDataHelper); } /** @@ -117,11 +132,30 @@ public function countryCardTypesDataProvider() ]; } + /** + * @covers \Magento\Braintree\Block\Form::isVaultEnabled + */ public function testIsVaultEnabled() { - $this->vaultService->expects(static::once()) - ->method('isActiveForPayment') - ->with(ConfigProvider::CODE) + $storeId = 1; + $store = $this->getMockForAbstractClass(StoreInterface::class); + $this->storeManager->expects(static::once()) + ->method('getStore') + ->willReturn($store); + + $store->expects(static::once()) + ->method('getId') + ->willReturn($storeId); + + $vaultPayment = $this->getMockForAbstractClass(VaultPaymentInterface::class); + $this->paymentDataHelper->expects(static::once()) + ->method('getMethodInstance') + ->with(ConfigProvider::CC_VAULT_CODE) + ->willReturn($vaultPayment); + + $vaultPayment->expects(static::once()) + ->method('isActive') + ->with($storeId) ->willReturn(true); static::assertTrue($this->block->isVaultEnabled()); diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php index 71f87f1ec398d..a787111fa93aa 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php @@ -148,7 +148,7 @@ public function getConfigDataProvider() 'getEnvironment' => 'test-environment', 'getKountMerchantId' => 'test-kount-merchant-id', 'getMerchantId' => 'test-merchant-id', - 'hasFraudProtection' => true + 'hasFraudProtection' => true, ], 'expected' => [ 'payment' => [ @@ -167,7 +167,8 @@ public function getConfigDataProvider() 'environment' => 'test-environment', 'kountMerchantId' => 'test-kount-merchant-id', 'merchantId' => 'test-merchant-id', - 'hasFraudProtection' => true + 'hasFraudProtection' => true, + 'ccVaultCode' => ConfigProvider::CC_VAULT_CODE ], Config::CODE_3DSECURE => [ 'enabled' => true, diff --git a/app/code/Magento/Braintree/etc/adminhtml/di.xml b/app/code/Magento/Braintree/etc/adminhtml/di.xml index 5a2c4da5dcd8f..9cffa57abd6dc 100644 --- a/app/code/Magento/Braintree/etc/adminhtml/di.xml +++ b/app/code/Magento/Braintree/etc/adminhtml/di.xml @@ -19,13 +19,6 @@ - - - - BraintreeFacade - - - diff --git a/app/code/Magento/Braintree/etc/adminhtml/system.xml b/app/code/Magento/Braintree/etc/adminhtml/system.xml index a3752db022111..3668cd7779fda 100644 --- a/app/code/Magento/Braintree/etc/adminhtml/system.xml +++ b/app/code/Magento/Braintree/etc/adminhtml/system.xml @@ -34,6 +34,14 @@ + + + Magento\Config\Model\Config\Source\Yesno + payment/braintree_cc_vault/active + + + + Click here to login to your existing Braintree account. Or to setup a new account and accept payments on your website, click here to signup for a Braintree account.]]> @@ -71,6 +79,10 @@ Magento\Config\Block\System\Config\Form\Fieldset + + + payment/braintree_cc_vault/title + If you don't specify the merchant account to use to process a transaction, Braintree will process it using your default merchant account. diff --git a/app/code/Magento/Braintree/etc/config.xml b/app/code/Magento/Braintree/etc/config.xml index 5a1076eabf071..7511ec2ca1563 100644 --- a/app/code/Magento/Braintree/etc/config.xml +++ b/app/code/Magento/Braintree/etc/config.xml @@ -60,6 +60,10 @@ processorResponseCode,processorResponseText,paymentId processorResponseCode,processorResponseText,paymentId,payerEmail + + BraintreeCreditCardVaultFacade + Stored Cards (Braintree) + diff --git a/app/code/Magento/Braintree/etc/di.xml b/app/code/Magento/Braintree/etc/di.xml index 359cb93b2d82a..def12ff4c8a7e 100644 --- a/app/code/Magento/Braintree/etc/di.xml +++ b/app/code/Magento/Braintree/etc/di.xml @@ -25,6 +25,32 @@ BraintreePayPalCommandPool + + + + Magento\Braintree\Model\Ui\ConfigProvider::CC_VAULT_CODE + + + + + BraintreeVaultPaymentConfig + + + + + + BraintreeVaultPaymentValueHandler + + + + + + BraintreeVaultPaymentConfig + BraintreeVaultPaymentValueHandlerPool + BraintreeFacade + Magento\Braintree\Model\Ui\ConfigProvider::CC_VAULT_CODE + + diff --git a/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml index c881e008dc24f..76f6b5a4d616c 100644 --- a/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml +++ b/app/code/Magento/Braintree/view/adminhtml/layout/sales_order_create_index.xml @@ -13,6 +13,12 @@ Magento_Braintree::form/cc.phtml + + + braintree_cc_vault + Magento_Vault::form/vault.phtml + + Magento_Braintree::form/cc.phtml + + + braintree_cc_vault + Magento_Vault::form/vault.phtml + + \ No newline at end of file diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js index bb7697b22da12..ef57428acaa3c 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js @@ -11,7 +11,7 @@ define([ 'Magento_Braintree/js/validator', 'Magento_Vault/js/view/payment/vault-enabler', 'mage/translate' -], function ($, Component, validator, vaultEnabler, $t) { +], function ($, Component, validator, VaultEnabler, $t) { 'use strict'; return Component.extend({ @@ -33,8 +33,8 @@ define([ */ initialize: function () { this._super(); - this.vaultEnabler = vaultEnabler(); - this.vaultEnabler.setPaymentCode(this.getCode()); + this.vaultEnabler = new VaultEnabler(); + this.vaultEnabler.setPaymentCode(this.getVaultCode()); return this; }, @@ -150,6 +150,13 @@ define([ if (this.validateCardType()) { $(this.getSelector('submit')).trigger('click'); } + }, + + /** + * @returns {String} + */ + getVaultCode: function () { + return window.checkoutConfig.payment[this.getCode()].ccVaultCode; } }); }); diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js index 3a96c938603dd..b1b13e9c13ac0 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js @@ -21,14 +21,6 @@ define([ } }, - /** - * Get current Braintree vault id - * @returns {String} - */ - getId: function () { - return 'braintree_' + this.index; - }, - /** * Get last 4 digits of card * @returns {String} @@ -75,7 +67,7 @@ define([ self.hostedFields(function (formComponent) { formComponent.setPaymentMethodNonce(response.paymentMethodNonce); formComponent.additionalData['public_hash'] = self.publicHash; - formComponent.code = 'vault'; + formComponent.code = self.code; formComponent.placeOrder(); }); }) diff --git a/app/code/Magento/Paypal/Block/Adminhtml/Payflowpro/CcForm.php b/app/code/Magento/Paypal/Block/Adminhtml/Payflowpro/CcForm.php index 0fb21769a686d..1fb0489de0f9e 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/Payflowpro/CcForm.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/Payflowpro/CcForm.php @@ -6,8 +6,12 @@ namespace Magento\Paypal\Block\Adminhtml\Payflowpro; use Magento\Checkout\Model\Session; +use Magento\Framework\App\ObjectManager; use Magento\Framework\View\Element\Template\Context; +use Magento\Payment\Helper\Data; use Magento\Payment\Model\Config; +use Magento\Paypal\Model\Payflow\Transparent; +use Magento\Store\Model\StoreManagerInterface; use Magento\Vault\Model\VaultPaymentInterface; class CcForm extends \Magento\Payment\Block\Transparent\Form @@ -18,26 +22,23 @@ class CcForm extends \Magento\Payment\Block\Transparent\Form protected $_template = 'Magento_Paypal::transparent/form.phtml'; /** - * @var VaultPaymentInterface + * @var Data */ - private $vaultService; + private $paymentDataHelper; /** * @param Context $context * @param Config $paymentConfig * @param Session $checkoutSession - * @param VaultPaymentInterface $vaultService * @param array $data */ public function __construct( Context $context, Config $paymentConfig, Session $checkoutSession, - VaultPaymentInterface $vaultService, array $data = [] ) { parent::__construct($context, $paymentConfig, $checkoutSession, $data); - $this->vaultService = $vaultService; } /** @@ -46,9 +47,9 @@ public function __construct( */ public function isVaultEnabled() { - return $this->vaultService->isActiveForPayment( - \Magento\Paypal\Model\Config::METHOD_PAYFLOWPRO - ); + $storeId = $this->_storeManager->getStore()->getId(); + $vaultPayment = $this->getVaultPayment(); + return $vaultPayment->isActive($storeId); } /** @@ -68,4 +69,26 @@ protected function initializeMethod() { return; } + + /** + * Get configured vault payment for PayflowPro + * @return VaultPaymentInterface + */ + private function getVaultPayment() + { + return $this->getPaymentDataHelper()->getMethodInstance(Transparent::CC_VAULT_CODE); + } + + /** + * Get payment data helper instance + * @return Data + * @deprecated + */ + private function getPaymentDataHelper() + { + if ($this->paymentDataHelper === null) { + $this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class); + } + return $this->paymentDataHelper; + } } diff --git a/app/code/Magento/Paypal/Model/Payflow/Transparent.php b/app/code/Magento/Paypal/Model/Payflow/Transparent.php index 2c8d43d30b26b..05609ee5ee88f 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Transparent.php +++ b/app/code/Magento/Paypal/Model/Payflow/Transparent.php @@ -32,6 +32,8 @@ class Transparent extends Payflowpro implements TransparentInterface const CC_DETAILS = 'cc_details'; + const CC_VAULT_CODE = 'payflowpro_cc_vault'; + /** * @var string */ diff --git a/app/code/Magento/Paypal/Model/Payflow/Ui/TokenUiComponentProvider.php b/app/code/Magento/Paypal/Model/Payflow/Ui/TokenUiComponentProvider.php index 7957033e546fb..4048d712ea57b 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Ui/TokenUiComponentProvider.php +++ b/app/code/Magento/Paypal/Model/Payflow/Ui/TokenUiComponentProvider.php @@ -5,6 +5,7 @@ */ namespace Magento\Paypal\Model\Payflow\Ui; +use Magento\Paypal\Model\Payflow\Transparent; use Magento\Vault\Api\Data\PaymentTokenInterface; use Magento\Vault\Model\Ui\TokenUiComponentInterface; use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface; @@ -40,6 +41,7 @@ public function getComponentForToken(PaymentTokenInterface $paymentToken) $component = $this->componentFactory->create( [ 'config' => [ + 'code' => Transparent::CC_VAULT_CODE, TokenUiComponentProviderInterface::COMPONENT_DETAILS => $jsonDetails, TokenUiComponentProviderInterface::COMPONENT_PUBLIC_HASH => $paymentToken->getPublicHash() ], diff --git a/app/code/Magento/Paypal/etc/adminhtml/di.xml b/app/code/Magento/Paypal/etc/adminhtml/di.xml index 3ba0c2b6164e7..0ae9d9569969d 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/di.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/di.xml @@ -61,14 +61,6 @@ - - - - Magento\Paypal\Model\Payflow\Transparent - - - - diff --git a/app/code/Magento/Paypal/etc/adminhtml/system/paypal_payflowpro.xml b/app/code/Magento/Paypal/etc/adminhtml/system/paypal_payflowpro.xml index b4a610d31c2aa..2150d5dcb392b 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/system/paypal_payflowpro.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/system/paypal_payflowpro.xml @@ -80,6 +80,15 @@ + + + Magento\Config\Model\Config\Source\Yesno + payment/payflowpro_cc_vault/active + 1 + + + + @@ -90,6 +99,10 @@ payment/payflowpro/title 1 + + + payment/payflowpro_cc_vault/title + payment/payflowpro/sort_order diff --git a/app/code/Magento/Paypal/etc/config.xml b/app/code/Magento/Paypal/etc/config.xml index dbfcc67536229..2fe6ecefc17bd 100644 --- a/app/code/Magento/Paypal/etc/config.xml +++ b/app/code/Magento/Paypal/etc/config.xml @@ -92,6 +92,10 @@ 1 1 + + PayflowProCreditCardVaultFacade + Stored Cards (Payflow Pro) + 1 1 diff --git a/app/code/Magento/Paypal/etc/di.xml b/app/code/Magento/Paypal/etc/di.xml index 38a3ee049c139..8b287d08e77a4 100644 --- a/app/code/Magento/Paypal/etc/di.xml +++ b/app/code/Magento/Paypal/etc/di.xml @@ -90,6 +90,32 @@ payflowproConfigFactory + + + + Magento\Paypal\Model\Payflow\Transparent::CC_VAULT_CODE + + + + + PayflowProVaultPaymentConfig + + + + + + PayflowProVaultPaymentValueHandler + + + + + + PayflowProVaultPaymentConfig + PayflowProVaultPaymentValueHandlerPool + Magento\Paypal\Model\Payflow\Transparent + Magento\Paypal\Model\Payflow\Transparent::CC_VAULT_CODE + + payflowlinkConfigFactory diff --git a/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_index.xml index 37eded79dc02b..c858a29e9a1de 100644 --- a/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_index.xml +++ b/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_index.xml @@ -13,5 +13,11 @@ Magento_Paypal::transparent/form.phtml + + + payflowpro_cc_vault + Magento_Vault::form/vault.phtml + + \ No newline at end of file diff --git a/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml b/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml index f6d8643aa35e8..ffd0d656ba550 100644 --- a/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml +++ b/app/code/Magento/Paypal/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml @@ -13,5 +13,11 @@ Magento_Paypal::transparent/form.phtml + + + payflowpro_cc_vault + Magento_Vault::form/vault.phtml + + \ No newline at end of file diff --git a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js index cbb0a8085dad2..f8f19818c3fc2 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js @@ -12,7 +12,7 @@ define( 'Magento_Checkout/js/model/full-screen-loader', 'Magento_Vault/js/view/payment/vault-enabler' ], - function ($, Component, additionalValidators, setPaymentInformationAction, fullScreenLoader, vaultEnabler) { + function ($, Component, additionalValidators, setPaymentInformationAction, fullScreenLoader, VaultEnabler) { 'use strict'; return Component.extend({ @@ -27,8 +27,8 @@ define( */ initialize: function () { this._super(); - this.vaultEnabler = vaultEnabler(); - this.vaultEnabler.setPaymentCode(this.getCode()); + this.vaultEnabler = new VaultEnabler(); + this.vaultEnabler.setPaymentCode(this.getVaultCode()); return this; }, @@ -127,6 +127,13 @@ define( */ isVaultEnabled: function () { return this.vaultEnabler.isVaultEnabled(); + }, + + /** + * @returns {String} + */ + getVaultCode: function () { + return 'payflowpro_cc_vault'; } }); } diff --git a/app/code/Magento/Paypal/view/frontend/web/template/payment/payflowpro-form.html b/app/code/Magento/Paypal/view/frontend/web/template/payment/payflowpro-form.html index 28f1ba5c55fd7..da1da321fe621 100644 --- a/app/code/Magento/Paypal/view/frontend/web/template/payment/payflowpro-form.html +++ b/app/code/Magento/Paypal/view/frontend/web/template/payment/payflowpro-form.html @@ -53,7 +53,7 @@ class="checkbox-inline" data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/> diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 03dd565072799..b47be0f5bd8fb 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -515,11 +515,6 @@ public function initFromOrder(\Magento\Sales\Model\Order $order) $this->setShippingMethod($order->getShippingMethod()); $quote->getShippingAddress()->setShippingDescription($order->getShippingDescription()); - $paymentData = $order->getPayment()->getData(); - unset($paymentData['cc_type'], $paymentData['cc_last_4']); - unset($paymentData['cc_exp_month'], $paymentData['cc_exp_year']); - $quote->getPayment()->addData($paymentData); - $orderCouponCode = $order->getCouponCode(); if ($orderCouponCode) { $quote->setCouponCode($orderCouponCode); diff --git a/app/code/Magento/Vault/Block/Form.php b/app/code/Magento/Vault/Block/Form.php index 7dcb4bf76d13d..fbf62a7d8f7a6 100644 --- a/app/code/Magento/Vault/Block/Form.php +++ b/app/code/Magento/Vault/Block/Form.php @@ -59,13 +59,13 @@ protected function _prepareLayout() protected function createVaultBlocks() { $icons = $this->cardConfigProvider->getIcons(); - $payments = $this->tokensProvider->getTokensComponents(); + $payments = $this->tokensProvider->getTokensComponents($this->_nameInLayout); foreach ($payments as $key => $payment) { $this->addChild( $key, $payment->getName(), array_merge( - ['id' => $key, 'icons' => $icons], + ['id' => $this->_nameInLayout . $key, 'icons' => $icons], $payment->getConfig() ) ); diff --git a/app/code/Magento/Vault/Block/System/Config/EmptyFieldsetDecorator.php b/app/code/Magento/Vault/Block/System/Config/EmptyFieldsetDecorator.php deleted file mode 100644 index a1a9590d2dfec..0000000000000 --- a/app/code/Magento/Vault/Block/System/Config/EmptyFieldsetDecorator.php +++ /dev/null @@ -1,26 +0,0 @@ -_getChildrenElementsHtml($element); - if (empty($childrenHtml)) { - return ''; - } - - return parent::render($element); - } -} diff --git a/app/code/Magento/Vault/Block/System/Config/EmptySelectDecorator.php b/app/code/Magento/Vault/Block/System/Config/EmptySelectDecorator.php deleted file mode 100644 index 302e1fc849ade..0000000000000 --- a/app/code/Magento/Vault/Block/System/Config/EmptySelectDecorator.php +++ /dev/null @@ -1,29 +0,0 @@ -getData('values'))) { - return ''; - } - - return parent::render($element); - } -} diff --git a/app/code/Magento/Vault/Controller/Cards/DeleteAction.php b/app/code/Magento/Vault/Controller/Cards/DeleteAction.php index 56832d0054396..d1d12e541a09d 100644 --- a/app/code/Magento/Vault/Controller/Cards/DeleteAction.php +++ b/app/code/Magento/Vault/Controller/Cards/DeleteAction.php @@ -14,9 +14,9 @@ use Magento\Framework\Data\Form\FormKey\Validator; use Magento\Framework\Exception\NotFoundException; use Magento\Vault\Api\Data\PaymentTokenInterface; +use Magento\Vault\Api\PaymentTokenRepositoryInterface; use Magento\Vault\Controller\CardsManagement; use Magento\Vault\Model\PaymentTokenManagement; -use Magento\Vault\Model\PaymentTokenRepositoryProxy; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -45,7 +45,7 @@ class DeleteAction extends CardsManagement private $fkValidator; /** - * @var PaymentTokenRepositoryProxy + * @var PaymentTokenRepositoryInterface */ private $tokenRepository; @@ -59,7 +59,7 @@ class DeleteAction extends CardsManagement * @param Session $customerSession * @param JsonFactory $jsonFactory * @param Validator $fkValidator - * @param PaymentTokenRepositoryProxy $tokenRepository + * @param PaymentTokenRepositoryInterface $tokenRepository * @param PaymentTokenManagement $paymentTokenManagement */ public function __construct( @@ -67,7 +67,7 @@ public function __construct( Session $customerSession, JsonFactory $jsonFactory, Validator $fkValidator, - PaymentTokenRepositoryProxy $tokenRepository, + PaymentTokenRepositoryInterface $tokenRepository, PaymentTokenManagement $paymentTokenManagement ) { parent::__construct($context, $customerSession); diff --git a/app/code/Magento/Vault/Gateway/Config/ActiveHandler.php b/app/code/Magento/Vault/Gateway/Config/ActiveHandler.php deleted file mode 100644 index e063aa9fd24e5..0000000000000 --- a/app/code/Magento/Vault/Gateway/Config/ActiveHandler.php +++ /dev/null @@ -1,41 +0,0 @@ -config = $config; - } - - /** - * @inheritdoc - */ - public function handle(array $subject, $storeId = null) - { - $vaultPaymentCode = $this->config->getValue(VaultProvidersMap::VALUE_CODE, $storeId); - - return (int) ((int)$this->config->getValue('active', $storeId) === 1 - && $vaultPaymentCode - && $vaultPaymentCode !== VaultProvidersMap::EMPTY_VALUE); - } -} diff --git a/app/code/Magento/Vault/Model/Adminhtml/Source/VaultProvidersMap.php b/app/code/Magento/Vault/Model/Adminhtml/Source/VaultProvidersMap.php deleted file mode 100644 index 2d2ab8eafd2e7..0000000000000 --- a/app/code/Magento/Vault/Model/Adminhtml/Source/VaultProvidersMap.php +++ /dev/null @@ -1,64 +0,0 @@ - $paymentMethod->getCode(), - 'label' => __($paymentMethod->getCode()) - ]; - }, - $options - ); - - if (!empty($configuredMethods)) { - $this->options = array_merge( - [ - [ - 'value' => self::EMPTY_VALUE, - 'label' => __('Select vault provider') - ] - ], - $configuredMethods - ); - } - } - - /** - * Return array of options as value-label pairs - * - * @return array Format: array(array('value' => '', 'label' => ' - - - - Magento\Vault\Model\VaultPaymentInterface::CODE - - - - VaultPaymentConfig + Magento\Payment\Gateway\Config\Config VaultPaymentValueHandlerPool Magento\Vault\Model\Method\NullPaymentProvider - - - - - - Magento\Vault\Model\PaymentTokenRepository - VaultPaymentConfig - + vault - VaultPaymentConfig + Magento\Payment\Gateway\Config\Config - - - VaultPaymentConfig - - VaultPaymentDefaultValueHandler - Magento\Vault\Gateway\Config\ActiveHandler diff --git a/app/code/Magento/Vault/etc/module.xml b/app/code/Magento/Vault/etc/module.xml index 00290b817274e..cc654548a1bba 100644 --- a/app/code/Magento/Vault/etc/module.xml +++ b/app/code/Magento/Vault/etc/module.xml @@ -12,7 +12,6 @@ - diff --git a/app/code/Magento/Vault/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Vault/view/adminhtml/layout/sales_order_create_index.xml deleted file mode 100644 index 472be65695503..0000000000000 --- a/app/code/Magento/Vault/view/adminhtml/layout/sales_order_create_index.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - vault - Magento_Vault::form/vault.phtml - - - - diff --git a/app/code/Magento/Vault/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml b/app/code/Magento/Vault/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml deleted file mode 100644 index 8b1e15107e16b..0000000000000 --- a/app/code/Magento/Vault/view/adminhtml/layout/sales_order_create_load_block_billing_method.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - vault - Magento_Vault::form/vault.phtml - - - - \ No newline at end of file diff --git a/app/code/Magento/Vault/view/frontend/web/js/view/payment/method-renderer/vault.js b/app/code/Magento/Vault/view/frontend/web/js/view/payment/method-renderer/vault.js index 35b48d9cf011d..a225997a74f98 100644 --- a/app/code/Magento/Vault/view/frontend/web/js/view/payment/method-renderer/vault.js +++ b/app/code/Magento/Vault/view/frontend/web/js/view/payment/method-renderer/vault.js @@ -67,7 +67,7 @@ define( * @returns {String} */ getCode: function () { - return 'vault'; + return this.code; }, /** diff --git a/app/code/Magento/Vault/view/frontend/web/js/view/payment/vault-enabler.js b/app/code/Magento/Vault/view/frontend/web/js/view/payment/vault-enabler.js index f928e14fdb539..9ffdb519292a4 100644 --- a/app/code/Magento/Vault/view/frontend/web/js/view/payment/vault-enabler.js +++ b/app/code/Magento/Vault/view/frontend/web/js/view/payment/vault-enabler.js @@ -56,8 +56,8 @@ define( * @returns {Boolean} */ isVaultEnabled: function () { - return window.checkoutConfig.vault['is_enabled'] === true && - window.checkoutConfig.vault['vault_provider_code'] === this.paymentCode; + return typeof window.checkoutConfig.vault[this.paymentCode] !== 'undefined' && + window.checkoutConfig.vault[this.paymentCode]['is_enabled'] === true; } }); } diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml index 479bf2f7e3580..916943e03af97 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml @@ -191,19 +191,19 @@ - + payment 1 - Braintree - braintree + Yes + 1 - + payment 1 - Select vault provider - null + No + 0 diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml index 84b0a58433ca0..0ae7da744c2f4 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateVaultOrderBackendTest.xml @@ -7,7 +7,7 @@ --> - + test_type:3rd_party_test catalogProductSimple::product_10_dollar default diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/DeleteSavedCreditCardTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/DeleteSavedCreditCardTest.xml deleted file mode 100644 index 0a3a7206175e2..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/DeleteSavedCreditCardTest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - catalogProductSimple::product_10_dollar - default - US_address_1_without_email - login - Flat Rate - Fixed - braintree - credit_card_braintree - visa_braintree - Yes - braintree, braintree_use_vault - test_type:3rd_party_test - - - - diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml index c9fc94be5ebae..cfe2e5f51b18e 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/UseVaultOnCheckoutTest.xml @@ -7,7 +7,7 @@ --> - + Use saved for Braintree credit card on checkout catalogProductSimple::product_10_dollar default @@ -22,7 +22,6 @@ braintree, braintree_use_vault Processing test_type:3rd_party_test - Processing Back, Cancel, Send Email, Hold, Invoice, Ship diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml index b5d754d8e2174..f6c93407a0ccd 100644 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml +++ b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml @@ -14,6 +14,13 @@ 123 + + 378282246310005 + 02 - February + 2021 + 1234 + + 4617747819866651 01 - January diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml index 790ab9cad5ae1..0706f45beeb4b 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml @@ -278,19 +278,19 @@ - + payment 1 - PayflowPro - payflowpro + Yes + 1 - + payment 1 - Select vault provider - null + No + 0 diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/DeleteSavedCreditCardTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/DeleteSavedCreditCardTest.xml deleted file mode 100644 index 42afe4fbb58f0..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/DeleteSavedCreditCardTest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - catalogProductSimple::product_10_dollar - default - US_address_1_without_email - login - Flat Rate - Fixed - payflowpro - credit_card - visa_default - Yes - payflowpro, payflowpro_use_vault - test_type:3rd_party_test - - - - diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml index ef66a1b419f27..ff5f151580b11 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/UseVaultOnCheckoutTest.xml @@ -7,7 +7,7 @@ --> - + catalogProductSimple::product_10_dollar default US_address_1_without_email diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/CreateVaultOrderBackendTest.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/CreateVaultOrderBackendTest.php index 57fb2a998909e..37d0fdc81c5aa 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/CreateVaultOrderBackendTest.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/CreateVaultOrderBackendTest.php @@ -31,6 +31,7 @@ * 16. Place order. * * @group Order_Management_(CS) + * @ZephyrId MAGETWO-48127, MAGETWO-48091 */ class CreateVaultOrderBackendTest extends Scenario { diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php index 6964feb2533ed..43497e821f6a9 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php @@ -5,7 +5,10 @@ */ namespace Magento\Vault\Test\TestCase; -use Magento\Mtf\TestCase\Scenario; +use Magento\Checkout\Test\Page\CheckoutOnepage; +use Magento\Mtf\ObjectManager; +use Magento\Mtf\TestCase\Injectable; +use Magento\Vault\Test\Constraint\AssertCreditCardNotPresentOnCheckout; /** * Preconditions: @@ -21,9 +24,9 @@ * 7. Perform assertions. * * @group Vault_(CS) - * @ZephyrId MAGETWO-48086 + * @ZephyrId MAGETWO-54059, MAGETWO-54072, MAGETWO-54068, MAGETWO-54015, MAGETWO-54011 */ -class DeleteSavedCreditCardTest extends Scenario +class DeleteSavedCreditCardTest extends Injectable { /* tags */ const MVP = 'yes'; @@ -34,10 +37,264 @@ class DeleteSavedCreditCardTest extends Scenario /** * Runs delete saved credit card test. * + * @param AssertCreditCardNotPresentOnCheckout $assertCreditCardNotPresentOnCheckout + * @param CheckoutOnepage $checkoutOnepage + * @param $products + * @param $configData + * @param $customer + * @param $checkoutMethod + * @param $shippingAddress + * @param $shipping + * @param array $payments + * @param $creditCardSave + */ + public function test( + AssertCreditCardNotPresentOnCheckout $assertCreditCardNotPresentOnCheckout, + CheckoutOnepage $checkoutOnepage, + $products, + $configData, + $customer, + $checkoutMethod, + $shippingAddress, + $shipping, + array $payments, + $creditCardSave + ) { + // Preconditions + $products = $this->prepareProducts($products); + $this->setupConfiguration($configData); + $customer = $this->createCustomer($customer); + + // Steps + foreach ($payments as $key => $payment) { + $this->addToCart($products); + $this->proceedToCheckout(); + if($key < 1) { // if this is the first order to be placed + $this->selectCheckoutMethod($checkoutMethod, $customer); + $this->fillShippingAddress($shippingAddress); + } + $this->fillShippingMethod($shipping); + if ($key >= 2) { // if this order will be placed via stored credit card + $this->useSavedCreditCard($payment); + } else { + $this->selectPaymentMethod($payment, $payment['creditCardClass'], $payment['creditCard']); + $this->saveCreditCard($payment, $creditCardSave); + } + $this->placeOrder(); + } + // Delete credit cards from My Account and verify they are not available on checkout + $paymentsCount = count($payments); + for($i = 2; $i < $paymentsCount; $i++) { + $deletedCard = $this->deleteCreditCardFromMyAccount( + $customer, + $payments[$i]['creditCard'], + $payments[$i]['creditCardClass'] + ); + $this->addToCart($products); + $this->proceedToCheckout(); + $this->fillShippingMethod($shipping); + $assertCreditCardNotPresentOnCheckout->processAssert( + $checkoutOnepage, + $deletedCard['deletedCreditCard'] + ); + } + } + + /** + * @param $configData + */ + protected function setupConfiguration($configData) + { + $setupConfigurationStep = ObjectManager::getInstance()->create( + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, + ['configData' => $configData] + ); + + $setupConfigurationStep->run(); + } + + /** + * Create products + * + * @param string $productList + * @return array + */ + protected function prepareProducts($productList) + { + $addToCartStep = ObjectManager::getInstance()->create( + \Magento\Catalog\Test\TestStep\CreateProductsStep::class, + ['products' => $productList] + ); + + $result = $addToCartStep->run(); + return $result['products']; + } + + /** + * @param array $products + * @return void + */ + protected function addToCart(array $products) + { + $addToCartStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class, + ['products' => $products] + ); + $addToCartStep->run(); + } + + /** + * @return void + */ + protected function proceedToCheckout() + { + $clickProceedToCheckoutStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\ProceedToCheckoutStep::class + ); + $clickProceedToCheckoutStep->run(); + } + + /** + * @param array $customer + */ + protected function createCustomer(array $customer) + { + $createCustomerStep = ObjectManager::getInstance()->create( + \Magento\Customer\Test\TestStep\CreateCustomerStep::class, + ['customer' => $customer] + ); + $result = $createCustomerStep->run(); + return $result['customer']; + } + + /** + * @param $checkoutMethod + * @param $customer + */ + protected function selectCheckoutMethod($checkoutMethod, $customer) + { + $selectCheckoutMethodStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\SelectCheckoutMethodStep::class, + [ + 'checkoutMethod' => $checkoutMethod, + 'customer' => $customer, + ] + ); + $selectCheckoutMethodStep->run(); + } + + /** + * @param array $shippingAddress + */ + protected function fillShippingAddress(array $shippingAddress) + { + $fillShippingAddressStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\FillShippingAddressStep::class, + ['shippingAddress' => $shippingAddress] + ); + $fillShippingAddressStep->run(); + } + + /** + * Add products to cart + * + * @param array $shipping + */ + protected function fillShippingMethod(array $shipping) + { + $fillShippingMethodStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\FillShippingMethodStep::class, + ['shipping' => $shipping] + ); + $fillShippingMethodStep->run(); + } + + /** + * @param array $payment + * @param $creditCardClass + * @param array $creditCard + */ + protected function selectPaymentMethod(array $payment, $creditCardClass, array $creditCard) + { + $selectPaymentMethodStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\SelectPaymentMethodStep::class, + [ + 'payment' => $payment, + 'creditCardClass' => $creditCardClass, + 'creditCard' => $creditCard, + ] + ); + $selectPaymentMethodStep->run(); + } + + /** + * Add products to cart + * + * @param $payment + * @param $creditCardSave + */ + protected function saveCreditCard($payment, $creditCardSave) + { + $saveCreditCardStep = ObjectManager::getInstance()->create( + \Magento\Vault\Test\TestStep\SaveCreditCardStep::class, + [ + 'creditCardSave' => $creditCardSave, + 'payment' => $payment + ] + ); + $saveCreditCardStep->run(); + } + + /** + * @return void + */ + protected function fillBillingInformation() + { + $fillBillingInformationStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\FillBillingInformationStep::class + ); + $fillBillingInformationStep->run(); + } + + /** * @return void */ - public function test() + protected function placeOrder() + { + $placeOrderStep = ObjectManager::getInstance()->create( + \Magento\Checkout\Test\TestStep\PlaceOrderStep::class + ); + $placeOrderStep->run(); + } + + /** + * @param $payment + */ + protected function useSavedCreditCard($payment) + { + $useSavedCreditCardStep = ObjectManager::getInstance()->create( + \Magento\Vault\Test\TestStep\UseSavedCreditCardStep::class, + ['payment' => $payment] + ); + $useSavedCreditCardStep->run(); + } + + /** + * @param $customer + * @param $creditCard + * @param $creditCardClass + */ + protected function deleteCreditCardFromMyAccount($customer, $creditCard, $creditCardClass) { - $this->executeScenario(); + $deleteCreditCardFromMyAccountStep = ObjectManager::getInstance()->create( + \Magento\Vault\Test\TestStep\DeleteCreditCardFromMyAccountStep::class, + [ + 'customer' => $customer, + 'creditCard' => $creditCard, + 'creditCardClass' => $creditCardClass + ] + ); + $deletedCard = $deleteCreditCardFromMyAccountStep->run(); + return $deletedCard; } } diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml new file mode 100644 index 0000000000000..ecbed706005b4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.xml @@ -0,0 +1,52 @@ + + + + + + catalogProductSimple::product_10_dollar + default + US_address_1_without_email + login + Flat Rate + Fixed + + + braintree + credit_card_braintree + + visa_braintree + + + + payflowpro + credit_card + + amex_default + + + + braintree + credit_card_braintree + + visa_braintree + + + + payflowpro + credit_card + + amex_default + + + + Yes + braintree, payflowpro, braintree_use_vault, payflowpro_use_vault + test_type:3rd_party_test + + + diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php index 85150d6c4798e..beb644a6ba224 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php @@ -90,7 +90,7 @@ public function __construct( public function run() { $this->objectManager->create( - 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer] )->run(); $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Credit Cards'); diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseSavedCreditCardStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseSavedCreditCardStep.php index 1139913f3ef26..c3b4ac238610b 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseSavedCreditCardStep.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseSavedCreditCardStep.php @@ -46,7 +46,7 @@ public function __construct (CheckoutOnepage $checkoutOnepage, array $payment) */ public function run() { - $this->payment['method'] = 'vault_item_'; + $this->payment['method'] .= '_item_'; $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment); } } diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseVaultPaymentTokenStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseVaultPaymentTokenStep.php index 56f94252c8f23..ad693923955d4 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseVaultPaymentTokenStep.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/UseVaultPaymentTokenStep.php @@ -17,13 +17,20 @@ class UseVaultPaymentTokenStep implements TestStepInterface * @var OrderCreateIndex */ private $orderCreatePage; + + /** + * @var array + */ + private $payment; /** * @param OrderCreateIndex $orderCreateIndex + * @param array $payment */ - public function __construct(OrderCreateIndex $orderCreateIndex) + public function __construct(OrderCreateIndex $orderCreateIndex, array $payment) { $this->orderCreatePage = $orderCreateIndex; + $this->payment = $payment; } /** @@ -32,7 +39,8 @@ public function __construct(OrderCreateIndex $orderCreateIndex) public function run() { $block = $this->orderCreatePage->getCreateBlock(); - $block->selectPaymentMethod(['method' => 'vault']); - $block->selectVaultToken('token_switcher_'); + $this->payment['method'] .= '_cc_vault'; + $block->selectPaymentMethod($this->payment); + $block->selectVaultToken('token_switcher_' . $this->payment['method']); } } diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml index 3ffbabdec638b..a804e4ac34555 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml @@ -6,25 +6,6 @@ */ --> - - - - - - - - - - - - - - - - - - - diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml b/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml index 66b46a65bea81..61d9f6f2a475c 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml @@ -100,6 +100,15 @@ + + + Magento\Config\Model\Config\Source\Yesno + payment/payflowpro_cc_vault/active + 1 + + + + @@ -110,6 +119,10 @@ payment/payflowpro/title 1 + + + payment/payflowpro_cc_vault/title + payment/payflowpro/sort_order diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php index e56e87b12176b..540d1de77a177 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php @@ -6,6 +6,8 @@ namespace Magento\Sales\Model\AdminOrder; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Sales\Model\Order; +use Magento\Framework\Registry; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -120,6 +122,32 @@ public function testInitFromOrderCcInformationDeleted() $this->assertNull($payment->getCcLast4()); } + /** + * @magentoDataFixture Magento/Sales/_files/order.php + */ + public function testInitFromOrderWithEmptyPaymentDetails() + { + /** @var $objectManager \Magento\TestFramework\ObjectManager */ + $objectManager = Bootstrap::getObjectManager(); + /** @var $order \Magento\Sales\Model\Order */ + $order = $objectManager->create(Order::class); + $order->loadByIncrementId('100000001'); + + $objectManager->get(Registry::class) + ->unregister('rule_data'); + + $initOrder = $this->_model->initFromOrder($order); + $payment = $initOrder->getQuote()->getPayment(); + + static::assertEquals($initOrder->getQuote()->getId(), $payment->getData('quote_id')); + $payment->unsetData('quote_id'); + + static::assertEmpty($payment->getMethod()); + static::assertEmpty($payment->getAdditionalInformation()); + static::assertEmpty($payment->getAdditionalData()); + static::assertEmpty($payment->getData()); + } + /** * @magentoAppIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php index 8d941daeba82b..ecbe322040bd8 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php @@ -23,7 +23,7 @@ class MethodsTest extends \PHPUnit_Framework_TestCase */ public function testPaymentMethod($code, $methodClass) { - if ($code == \Magento\Vault\Model\VaultPaymentInterface::CODE) { + if ($code == 'vault') { return; } Bootstrap::getObjectManager()->configure($this->getTestConfiguration());