/** * If card can be saved for further use * * @return boolean */ public function canSaveCard() { if ($this->config->useVault() && ($this->customerSession->isLoggedIn() || $this->onepage->getCheckoutMethod() == \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER)) { return true; } return false; }
/** * {@inheritdoc} */ public function getCheckoutMethod() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getCheckoutMethod'); if (!$pluginInfo) { return parent::getCheckoutMethod(); } else { return $this->___callPlugins('getCheckoutMethod', func_get_args(), $pluginInfo); } }
/** * @dataProvider getCheckoutMethodDataProvider */ public function testGetCheckoutMethod($isLoggedIn, $quoteCheckoutMethod, $isAllowedGuestCheckout, $expected) { $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue($isLoggedIn)); /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */ $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false); $quoteMock->expects($this->any())->method('setCheckoutMethod')->with($expected); $quoteMock->expects($this->any())->method('getCheckoutMethod')->will($this->returnValue($quoteCheckoutMethod)); $this->checkoutHelperMock->expects($this->any())->method('isAllowedGuestCheckout')->will($this->returnValue($isAllowedGuestCheckout)); $this->onepage->setQuote($quoteMock); $this->assertEquals($expected, $this->onepage->getCheckoutMethod()); }
/** * Send request to authorize.net * * @return string */ public function execute() { $paymentParam = $this->getRequest()->getParam('payment'); $controller = $this->getRequest()->getParam('controller'); $response = $this->getResponse(); if (isset($paymentParam['method'])) { $this->_getDirectPostSession()->setQuoteId($this->_getCheckout()->getQuote()->getId()); /** * Current workaround depends on Onepage checkout model defect * Method Onepage::getCheckoutMethod performs setCheckoutMethod */ $this->onepageCheckout->getCheckoutMethod(); if ($controller == IframeConfigProvider::CHECKOUT_IDENTIFIER) { return $this->placeCheckoutOrder(); } $params = $this->dataFactory->create(DataFactory::AREA_FRONTEND)->getSaveOrderUrlParams($controller); $this->_forward($params['action'], $params['controller'], $params['module'], $this->getRequest()->getParams()); } else { $result = ['error_messages' => __('Please choose a payment method.'), 'goto_section' => 'payment']; if ($response instanceof Http) { $response->representJson($this->jsonHelper->jsonEncode($result)); } } }