diff --git a/Block/Onepage/Review.php b/Block/Onepage/Review.php index 1db408f1..77dc17f4 100644 --- a/Block/Onepage/Review.php +++ b/Block/Onepage/Review.php @@ -337,19 +337,6 @@ public function getFingerprintJsUrl() return $asset->getUrl(); } - /** - * Check if paydirekt email message has to be shown - * - * @return bool - */ - public function showPaydirektEmailMessage() - { - if ($this->_quote->getPayment()->getMethod() == PayoneConfig::METHOD_PAYDIREKT && $this->databaseHelper->getPaydirektOneklickOrderCount($this->_quote->getCustomerId()) == 0) { - return true; - } - return false; - } - /** * Retrieve payment method and assign additional template values * diff --git a/Block/Paydirekt/OneklickButton.php b/Block/Paydirekt/OneklickButton.php deleted file mode 100644 index 60a44c1e..00000000 --- a/Block/Paydirekt/OneklickButton.php +++ /dev/null @@ -1,91 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Block\Paydirekt; - -use Magento\Framework\View\Element\Template; - -/** - * Block class for the Paydirekt Oneklick button - */ -class OneklickButton extends Template implements \Magento\Catalog\Block\ShortcutInterface -{ - /** - * Shortcut alias - * - * @var string - */ - protected $alias = 'payone.block.paydirekt.oneklick'; - - /** - * Constructor - * - * @param \Magento\Framework\View\Element\Template\Context $context - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - array $data = [] - ) { - parent::__construct($context, $data); - $this->setTemplate('paydirekt/oneklick_button.phtml'); - } - - /** - * Get shortcut alias - * - * @return string - */ - public function getAlias() - { - return $this->alias; - } - - /** - * URL to paypal start controller - * - * @return string - */ - public function getReviewLink() - { - return $this->getUrl('payone/paydirekt/agreement'); - } - - /** - * Return URL to Paydirekt oneKlick image - * - * @return string - */ - public function getLogoUrl() - { - $params = [ - 'theme' => 'Magento/luma', - 'area' => 'frontend', - ]; - $asset = $this->_assetRepo->createAsset('Payone_Core::images/paydirekt.png', $params); - return $asset->getUrl(); - } -} diff --git a/Controller/Paydirekt/Agreement.php b/Controller/Paydirekt/Agreement.php deleted file mode 100644 index ec43ed63..00000000 --- a/Controller/Paydirekt/Agreement.php +++ /dev/null @@ -1,158 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Controller\Paydirekt; - -use Payone\Core\Model\PayoneConfig; - -/** - * Controller for paydirekt oneKlick registration - */ -class Agreement extends \Magento\Framework\App\Action\Action -{ - /** - * PAYONE authorization request model - * - * @var \Payone\Core\Model\Api\Request\PaydirektAgreement - */ - protected $paydirektAgreement; - - /** - * Customer session object - * - * @var \Magento\Customer\Model\Session - */ - protected $customerSession; - - /** - * Checkout session object - * - * @var \Magento\Checkout\Model\Session - */ - protected $checkoutSession; - - /** - * PAYONE database helper - * - * @var \Payone\Core\Helper\Database - */ - protected $databaseHelper; - - /** - * Payone checkout helper - * - * @var \Payone\Core\Helper\Checkout - */ - protected $checkoutHelper; - - /** - * Constructor - * - * @param \Magento\Framework\App\Action\Context $context - * @param \Payone\Core\Model\Api\Request\PaydirektAgreement $paydirektAgreement - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Payone\Core\Helper\Database $databaseHelper - * @param \Payone\Core\Helper\Checkout $checkoutHelper - */ - public function __construct( - \Magento\Framework\App\Action\Context $context, - \Payone\Core\Model\Api\Request\PaydirektAgreement $paydirektAgreement, - \Magento\Customer\Model\Session $customerSession, - \Magento\Checkout\Model\Session $checkoutSession, - \Payone\Core\Helper\Database $databaseHelper, - \Payone\Core\Helper\Checkout $checkoutHelper - ) { - parent::__construct($context); - $this->paydirektAgreement = $paydirektAgreement; - $this->customerSession = $customerSession; - $this->checkoutSession = $checkoutSession; - $this->databaseHelper = $databaseHelper; - $this->checkoutHelper = $checkoutHelper; - } - - /** - * Set payment method to paydirekt and add some session params - * - * @return void - */ - protected function prepareQuote() - { - $oQuote = $this->checkoutSession->getQuote(); - - $oPayment = $oQuote->getPayment(); - $oPayment->setMethod(PayoneConfig::METHOD_PAYDIREKT); - $oQuote->setPayment($oPayment); - - $oCustomer = $this->customerSession->getCustomer(); - - if ($oCustomer->getDefaultBillingAddress()) { - $oDefaultBilling = $oCustomer->getDefaultBillingAddress()->getDataModel(); - - $oQuote->getBillingAddress()->importCustomerAddressData($oDefaultBilling); - $oQuote->getBillingAddress()->setShouldIgnoreValidation(true); - } - - if ($oCustomer->getDefaultShippingAddress()) { - $oDefaultShipping = $oCustomer->getDefaultShippingAddress()->getDataModel(); - - $oQuote->getShippingAddress()->importCustomerAddressData($oDefaultShipping); - $oQuote->getShippingAddress()->setCollectShippingRates(true)->setShouldIgnoreValidation(true); - } - - $oQuote->collectTotals()->save(); - - $this->checkoutSession->setPayoneQuoteComparisonString($this->checkoutHelper->getQuoteComparisonString($oQuote)); - } - - /** - * Redirect to payment-provider or to success page - * - * @return void - */ - public function execute() - { - $oCustomer = $this->customerSession->getCustomer(); - if ($this->getRequest()->getParam('return') && (bool)$oCustomer->getPayonePaydirektRegistered() === false) { - $oCustomer->setPayonePaydirektRegistered(1); - $this->databaseHelper->markUserAsRegisteredWithPaydirekt($oCustomer->getId()); - } - if ((bool)$oCustomer->getPayonePaydirektRegistered() === true) { - $this->prepareQuote(); - $this->_redirect($this->_url->getUrl('payone/onepage/review')); - return; - } - - $oQuote = $this->checkoutSession->getQuote(); - $aResponse = $this->paydirektAgreement->sendAgreementRequest($oCustomer, $oQuote); - if (isset($aResponse['status']) && $aResponse['status'] == 'REDIRECT' && !empty($aResponse['redirecturl'])) { - $this->prepareQuote(); - $this->_redirect($aResponse['redirecturl']); - return; - } - $this->_redirect($this->_url->getUrl('checkout')); - } -} diff --git a/Helper/Database.php b/Helper/Database.php index b84022e6..7d97c550 100644 --- a/Helper/Database.php +++ b/Helper/Database.php @@ -389,24 +389,4 @@ public function markUserAsRegisteredWithPaydirekt($iCustomerId) $where = ['entity_id = ?' => $iCustomerId]; return $this->getDb()->update($table, $data, $where); } - - /** - * Selects count of paydirekt oneclick orders from database - * - * @param int $iCustomerId - * @return int - */ - public function getPaydirektOneklickOrderCount($iCustomerId) - { - $oSelect = $this->getDb() - ->select() - ->from($this->databaseResource->getTableName('sales_order'), ['COUNT(entity_id)']) - ->where("customer_id = :customerId") - ->where("payone_express_type = :expressType"); - $iCount = $this->getDb()->fetchOne($oSelect, ['customerId' => $iCustomerId, 'expressType' => PayoneConfig::METHOD_PAYDIREKT]); - if ($iCount === null) { - return 0; - } - return $iCount; - } } diff --git a/Model/Api/Request/PaydirektAgreement.php b/Model/Api/Request/PaydirektAgreement.php deleted file mode 100644 index 31ce4cb0..00000000 --- a/Model/Api/Request/PaydirektAgreement.php +++ /dev/null @@ -1,114 +0,0 @@ -url = $url; - $this->paydirekt = $paydirekt; - } - - /** - * Send paydirekt oneKlick agreement request - * - * @param Customer $oCustomer - * @param Quote $oQuote - * @return array - * @throws \Exception - */ - public function sendAgreementRequest(Customer $oCustomer, Quote $oQuote) - { - $this->initRequest(); // reinitialize - - $this->addParameter('request', 'preauthorization'); // add request type - $this->addParameter('mode', $this->paydirekt->getOperationMode()); - $this->addParameter('clearingtype', $this->paydirekt->getClearingtype()); - $this->addParameter('wallettype', 'PDT'); - $this->addParameter('currency', $oQuote->getQuoteCurrencyCode()); - $this->addParameter('amount', '1'); - $this->addParameter('aid', $this->shopHelper->getConfigParam('aid')); // add sub account id - if ($this->shopHelper->getConfigParam('transmit_customerid') == '1') { - $this->addParameter('customerid', $oCustomer->getId()); - } - $this->addParameter('customer_is_present', 'yes'); - $this->addParameter('reference', 'custnr_'.$oCustomer->getId()); - $this->addParameter('add_paydata[device_id]', '1'); - $this->addParameter('add_paydata[device_name]', 'Test'); - $this->addParameter('api_version', '3.10'); - $this->addParameter('recurrence', 'oneclick'); - $sIp = $this->environmentHelper->getRemoteIp(); - if ($sIp != '') { - $this->addParameter('ip', $sIp); - } - - $oBillingAddress = $oCustomer->getDefaultBillingAddress(); - if (!$oBillingAddress) { - $oBillingAddress = $oQuote->getBillingAddress(); - } - - $this->addAddress($oBillingAddress); - $this->addUserDataParameters($oBillingAddress, $this->paydirekt, $oCustomer->getGender(), $oCustomer->getEmail(), $oCustomer->getDob()); - $this->addAgreementRedirectUrls(); - - $aResponse = $this->send(); - - return $aResponse; - } - - /** - * Add the redirect urls to the request - * - * @return void - */ - protected function addAgreementRedirectUrls() - { - $this->addParameter('successurl', $this->url->getUrl('payone/paydirekt/agreement?return=1')); - $this->addParameter('errorurl', $this->url->getUrl('payone/onepage/cancel?error=1')); - $this->addParameter('backurl', $this->url->getUrl('payone/onepage/cancel')); - } -} diff --git a/Model/ConfigProvider.php b/Model/ConfigProvider.php index 6d92ef73..76c3f0e1 100644 --- a/Model/ConfigProvider.php +++ b/Model/ConfigProvider.php @@ -284,7 +284,6 @@ protected function getPayoneConfig() 'orderDeferredExists' => (bool)version_compare($this->shopHelper->getMagentoVersion(), '2.1.0', '>='), 'saveCCDataEnabled' => (bool)$this->requestHelper->getConfigParam('save_data_enabled', PayoneConfig::METHOD_CREDITCARD, 'payone_payment'), 'savedPaymentData' => $this->savedPaymentData->getSavedPaymentData($this->checkoutSession->getQuote()->getCustomerId(), PayoneConfig::METHOD_CREDITCARD), - 'isPaydirektOneKlickDisplayable' => $this->isPaydirektOneKlickDisplayable(), 'currency' => $this->requestHelper->getConfigParam('currency'), 'klarnaTitles' => $this->paymentHelper->getKlarnaMethodTitles(), 'storeName' => $this->shopHelper->getStoreName(), @@ -328,19 +327,6 @@ protected function getCanceledPaymentMethod() return false; } - /** - * Check if paydirekt oneklick is enabled, user is logged in and not yet marked as registered with paydirekt - * - * @return bool - */ - protected function isPaydirektOneKlickDisplayable() - { - if ($this->customerSession->isLoggedIn() && (bool)$this->customerSession->getCustomer()->getPayonePaydirektRegistered() === false) { - return (bool)$this->requestHelper->getConfigParam('oneklick_active', PayoneConfig::METHOD_PAYDIREKT, 'payone_payment'); - } - return false; - } - /** * Return ratepay config for all ratepay payment methods * diff --git a/Model/Methods/Paydirekt.php b/Model/Methods/Paydirekt.php index 3f2df516..506688a8 100644 --- a/Model/Methods/Paydirekt.php +++ b/Model/Methods/Paydirekt.php @@ -72,21 +72,6 @@ class Paydirekt extends PayoneMethod public function getPaymentSpecificParameters(Order $oOrder) { $aParams = ['wallettype' => 'PDT']; - if ($this->checkoutSession->getPayoneExpressType() == $this->_code) { - $aParams['add_paydata[device_fingerprint]'] = $this->checkoutSession->getPayoneDeviceFingerprint(); - $aParams['add_paydata[device_name]'] = $this->checkoutSession->getPayoneUserAgent(); - $aParams['customer_is_present'] = 'no'; - $aParams['recurrence'] = 'oneclick'; - - $aParams['add_paydata[terminal_address_city]'] = $this->shopHelper->getConfigParam('city', 'store_information', 'general'); - $aParams['add_paydata[terminal_address_company]'] = $this->shopHelper->getConfigParam('name', 'store_information', 'general'); - $aParams['add_paydata[terminal_address_country]'] = $this->shopHelper->getConfigParam('country_id', 'store_information', 'general'); // CHECKEN! - $aParams['add_paydata[terminal_address_name]'] = $this->shopHelper->getConfigParam('name', 'store_information', 'general'); - $aParams['add_paydata[terminal_address_streetname]'] = $this->shopHelper->getConfigParam('street_line1', 'store_information', 'general'); - $aParams['add_paydata[terminal_address_streetnumber]'] = '';// IS THIS NECESSARY? - $aParams['add_paydata[terminal_address_zip]'] = $this->shopHelper->getConfigParam('postcode', 'store_information', 'general'); - $aParams['add_paydata[terminal_id]'] = $this->shopHelper->getConfigParam('name', 'store_information', 'general'); - } $blSecuredOrder = (bool)$this->getCustomConfigParam('order_secured'); if ($blSecuredOrder === true && $this->getAuthorizationMode() == PayoneConfig::REQUEST_TYPE_PREAUTHORIZATION) { // params only available with preauth diff --git a/Observer/AddPaydirektOneklickButton.php b/Observer/AddPaydirektOneklickButton.php deleted file mode 100644 index 57e154b2..00000000 --- a/Observer/AddPaydirektOneklickButton.php +++ /dev/null @@ -1,109 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2017 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Observer; - -use Magento\Customer\Model\Session as CustomerSession; -use Magento\Framework\Event\ObserverInterface; -use Payone\Core\Helper\Payment; -use Magento\Framework\Event\Observer; -use Magento\Paypal\Block\Express\Shortcut; -use Magento\Store\Model\StoreManagerInterface; -use Payone\Core\Model\PayoneConfig; - -/** - * Event class to add the Paydirekt Oneklick buttons to the frontend - */ -class AddPaydirektOneklickButton implements ObserverInterface -{ - /** - * PAYONE payment helper - * - * @var Payment - */ - protected $paymentHelper; - - /** - * Store manager object - * - * @var StoreManagerInterface\ - */ - protected $storeManager; - - /** - * Customer session object - * - * @var CustomerSession - */ - protected $customerSession; - - /** - * Constructor. - * - * @param Payment $paymentHelper - * @param StoreManagerInterface $storeManager - * @param CustomerSession $customerSession - */ - public function __construct(Payment $paymentHelper, StoreManagerInterface $storeManager, CustomerSession $customerSession) - { - $this->paymentHelper = $paymentHelper; - $this->storeManager = $storeManager; - $this->customerSession = $customerSession; - } - - /** - * Add PayPal shortcut buttons - * - * @param Observer $observer - * @return void - */ - public function execute(Observer $observer) - { - if ($this->paymentHelper->isPaymentMethodActive(PayoneConfig::METHOD_PAYDIREKT) === false) { - return; - } - - /** @var \Magento\Catalog\Block\ShortcutButtons $shortcutButtons */ - $shortcutButtons = $observer->getEvent()->getContainer(); - - if (in_array($shortcutButtons->getNameInLayout(), ['addtocart.shortcut.buttons', 'addtocart.shortcut.buttons.additional', 'map.shortcut.buttons'])) { - return; - } - - if ($this->customerSession->isLoggedIn() === false || (bool)$this->customerSession->getCustomer()->getPayonePaydirektRegistered() === false) { - return; - } - - /** @var Shortcut $shortcut */ - $shortcut = $shortcutButtons->getLayout()->createBlock( - 'Payone\Core\Block\Paydirekt\OneklickButton', - '', - [] - ); - - $shortcutButtons->addShortcut($shortcut); - } -} diff --git a/Test/Unit/Block/Onepage/ReviewTest.php b/Test/Unit/Block/Onepage/ReviewTest.php index 763dab28..d70f2da0 100644 --- a/Test/Unit/Block/Onepage/ReviewTest.php +++ b/Test/Unit/Block/Onepage/ReviewTest.php @@ -186,9 +186,6 @@ protected function setUp(): void $this->shopHelper = $this->getMockBuilder(Shop::class)->disableOriginalConstructor()->getMock(); - $databaseHelper = $this->getMockBuilder(Database::class)->disableOriginalConstructor()->getMock(); - $databaseHelper->method('getPaydirektOneklickOrderCount')->willReturn(0); - $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ 'context' => $context, 'checkoutSession' => $checkoutSession, @@ -354,20 +351,6 @@ public function testGetFingerprintJsUrl() $this->assertEquals($expected, $result); } - public function testShowPaydirektEmailMessageTrue() - { - $this->payment->method('getMethod')->willReturn(PayoneConfig::METHOD_PAYDIREKT); - $result = $this->classToTest->showPaydirektEmailMessage(); - $this->assertTrue($result); - } - - public function testShowPaydirektEmailMessageFalse() - { - $this->payment->method('getMethod')->willReturn(PayoneConfig::METHOD_PAYPAL); - $result = $this->classToTest->showPaydirektEmailMessage(); - $this->assertFalse($result); - } - public function testToHtml() { $infoInstance = $this->getMockBuilder(MethodInterface::class)->disableOriginalConstructor()->getMock(); diff --git a/Test/Unit/Block/Paydirekt/OneklickButtonTest.php b/Test/Unit/Block/Paydirekt/OneklickButtonTest.php deleted file mode 100644 index 4a934683..00000000 --- a/Test/Unit/Block/Paydirekt/OneklickButtonTest.php +++ /dev/null @@ -1,98 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Test\Unit\Block\Paydirekt; - -use Payone\Core\Block\Paydirekt\OneklickButton as ClassToTest; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Framework\View\Element\Template\Context; -use Magento\Framework\UrlInterface; -use Payone\Core\Test\Unit\BaseTestCase; -use Payone\Core\Test\Unit\PayoneObjectManager; -use Magento\Framework\View\Asset\Repository; -use Magento\Framework\View\Asset\File; - -class OneklickButtonTest extends BaseTestCase -{ - /** - * @var ClassToTest - */ - private $classToTest; - - /** - * @var ObjectManager|PayoneObjectManager - */ - private $objectManager; - - /** - * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $urlBuilder; - - protected function setUp(): void - { - $this->objectManager = $this->getObjectManager(); - - $this->urlBuilder = $this->getMockBuilder(UrlInterface::class)->disableOriginalConstructor()->getMock(); - - $asset = $this->getMockBuilder(File::class)->disableOriginalConstructor()->getMock(); - $asset->method('getUrl')->willReturn('expected'); - - $assetRepo = $this->getMockBuilder(Repository::class)->disableOriginalConstructor()->getMock(); - $assetRepo->method('createAsset')->willReturn($asset); - - $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); - $context->method('getUrlBuilder')->willReturn($this->urlBuilder); - $context->method('getAssetRepository')->willReturn($assetRepo); - - $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ - 'context' => $context, - ]); - } - - public function testGetAlias() - { - $result = $this->classToTest->getAlias(); - $expected = 'payone.block.paydirekt.oneklick'; - $this->assertEquals($expected, $result); - } - - public function testGetReviewLink() - { - $expected = 'http://testdomain.com'; - $this->urlBuilder->method('getUrl')->willReturn($expected); - - $result = $this->classToTest->getReviewLink(); - $this->assertEquals($expected, $result); - } - - public function testGetLogoUrl() - { - $result = $this->classToTest->getLogoUrl(); - $expected = 'expected'; - $this->assertEquals($expected, $result); - } -} diff --git a/Test/Unit/Controller/Paydirekt/AgreementTest.php b/Test/Unit/Controller/Paydirekt/AgreementTest.php deleted file mode 100644 index ce03e91e..00000000 --- a/Test/Unit/Controller/Paydirekt/AgreementTest.php +++ /dev/null @@ -1,167 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Test\Unit\Controller\Paydirekt; - -use Payone\Core\Controller\Paydirekt\Agreement as ClassToTest; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Checkout\Model\Session as CheckoutSession; -use Magento\Customer\Model\Session as CustomerSession; -use Magento\Framework\App\Action\Context; -use Payone\Core\Test\Unit\BaseTestCase; -use Payone\Core\Test\Unit\PayoneObjectManager; -use Magento\Framework\App\Response\RedirectInterface; -use Magento\Framework\App\RequestInterface; -use Magento\Framework\App\ResponseInterface; -use Magento\Framework\UrlInterface; -use Payone\Core\Model\Api\Request\PaydirektAgreement; -use Magento\Customer\Model\Customer; -use Magento\Quote\Model\Quote; -use Magento\Quote\Model\Quote\Payment; -use Magento\Customer\Model\Address; -use Magento\Quote\Model\Quote\Address as QuoteAddress; -use Magento\Customer\Api\Data\AddressInterface; - -class AgreementTest extends BaseTestCase -{ - /** - * @var ClassToTest - */ - private $classToTest; - - /** - * @var ObjectManager|PayoneObjectManager - */ - private $objectManager; - - /** - * @var PaydirektAgreement|PayoneObjectManager - */ - private $paydirektAgreement; - - /** - * @var Customer|PayoneObjectManager - */ - private $customer; - - protected function setUp(): void - { - $this->objectManager = $this->getObjectManager(); - - $request = $this->getMockBuilder(RequestInterface::class)->disableOriginalConstructor()->getMock(); - $request->method('getParam')->willReturn('123'); - - $response = $this->getMockBuilder(ResponseInterface::class)->disableOriginalConstructor()->getMock(); - $redirect = $this->getMockBuilder(RedirectInterface::class)->disableOriginalConstructor()->getMock(); - $urlBuilder = $this->getMockBuilder(UrlInterface::class)->disableOriginalConstructor()->getMock(); - $urlBuilder->method('getUrl')->willReturn('http://www.test.com'); - - $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); - $context->method('getRequest')->willReturn($request); - $context->method('getUrl')->willReturn($urlBuilder); - $context->method('getResponse')->willReturn($response); - $context->method('getRedirect')->willReturn($redirect); - - $payment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock(); - - $quoteAddress = $this->getMockBuilder(QuoteAddress::class) - ->disableOriginalConstructor() - ->setMethods(['setCollectShippingRates', 'importCustomerAddressData']) - ->getMock(); - $quoteAddress->method('setCollectShippingRates')->willReturn($quoteAddress); - - $quote = $this->getMockBuilder(Quote::class)->disableOriginalConstructor()->getMock(); - $quote->method('getPayment')->willReturn($payment); - $quote->method('getBillingAddress')->willReturn($quoteAddress); - $quote->method('getShippingAddress')->willReturn($quoteAddress); - $quote->method('collectTotals')->willReturn($quote); - - $checkoutSession = $this->getMockBuilder(CheckoutSession::class)->disableOriginalConstructor()->getMock(); - $checkoutSession->method('getQuote')->willReturn($quote); - - $addressData = $this->getMockBuilder(AddressInterface::class)->disableOriginalConstructor()->getMock(); - $address = $this->getMockBuilder(Address::class)->disableOriginalConstructor()->getMock(); - $address->method('getDataModel')->willReturn($addressData); - - $this->customer = $this->getMockBuilder(Customer::class) - ->disableOriginalConstructor() - ->setMethods([ - 'getPayonePaydirektRegistered', - 'setPayonePaydirektRegistered', - 'getDefaultBillingAddress', - 'getDefaultShippingAddress', - 'setPayoneGenericpaymentSubtotal' - ]) - ->getMock(); - $this->customer->method('getDefaultBillingAddress')->willReturn($address); - $this->customer->method('getDefaultShippingAddress')->willReturn($address); - - $customerSession = $this->getMockBuilder(CustomerSession::class)->disableOriginalConstructor()->getMock(); - $customerSession->method('getCustomer')->willReturn($this->customer); - - $this->paydirektAgreement = $this->getMockBuilder(PaydirektAgreement::class)->disableOriginalConstructor()->getMock(); - - $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ - 'context' => $context, - 'checkoutSession' => $checkoutSession, - 'customerSession' => $customerSession, - 'paydirektAgreement' => $this->paydirektAgreement, - ]); - } - - public function testExecuteReview() - { - $this->customer->method('getPayonePaydirektRegistered')->willReturn(true); - - $result = $this->classToTest->execute(); - $this->assertNull($result); - } - - public function testExecuteRedirect() - { - $this->customer->method('getPayonePaydirektRegistered')->willReturn(false); - - $response = [ - 'status' => 'REDIRECT', - 'redirecturl' => 'test', - ]; - $this->paydirektAgreement->method('sendAgreementRequest')->willReturn($response); - - $result = $this->classToTest->execute(); - $this->assertNull($result); - } - - public function testExecuteError() - { - $this->customer->method('getPayonePaydirektRegistered')->willReturn(false); - - $response = ['status' => 'ERROR']; - $this->paydirektAgreement->method('sendAgreementRequest')->willReturn($response); - - $result = $this->classToTest->execute(); - $this->assertNull($result); - } -} diff --git a/Test/Unit/Helper/DatabaseTest.php b/Test/Unit/Helper/DatabaseTest.php index 328d6164..114ae209 100644 --- a/Test/Unit/Helper/DatabaseTest.php +++ b/Test/Unit/Helper/DatabaseTest.php @@ -321,24 +321,4 @@ public function testMarkUserAsRegisteredWithPaydirekt() $result = $this->database->markUserAsRegisteredWithPaydirekt(12345); $this->assertEquals($expected, $result); } - - public function testGetPaydirektOneklickOrderCount() - { - $expected = 1; - - $this->connection->method('fetchOne')->willReturn($expected); - - $result = $this->database->getPaydirektOneklickOrderCount(12345); - $this->assertEquals($expected, $result); - } - - public function testGetPaydirektOneklickOrderCountNull() - { - $expected = 0; - - $this->connection->method('fetchOne')->willReturn(null); - - $result = $this->database->getPaydirektOneklickOrderCount(12345); - $this->assertEquals($expected, $result); - } } diff --git a/Test/Unit/Model/Api/Request/PaydirektAgreementTest.php b/Test/Unit/Model/Api/Request/PaydirektAgreementTest.php deleted file mode 100644 index 9f4eca72..00000000 --- a/Test/Unit/Model/Api/Request/PaydirektAgreementTest.php +++ /dev/null @@ -1,122 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Test\Unit\Model\Api\Request; - -use Payone\Core\Helper\Shop; -use Payone\Core\Model\Api\Request\PaydirektAgreement as ClassToTest; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Payone\Core\Helper\Api; -use Payone\Core\Helper\Customer; -use Payone\Core\Test\Unit\BaseTestCase; -use Payone\Core\Test\Unit\PayoneObjectManager; -use Magento\Customer\Model\Customer as CustomerModel; -use Magento\Quote\Model\Quote; -use Magento\Customer\Model\Address; -use Magento\Framework\Url; -use Payone\Core\Helper\Environment; - -class PaydirektAgreementTest extends BaseTestCase -{ - /** - * @var ClassToTest - */ - private $classToTest; - - /** - * @var Api|\PHPUnit_Framework_MockObject_MockObject - */ - private $apiHelper; - - protected function setUp(): void - { - $objectManager = $this->getObjectManager(); - - $this->apiHelper = $this->getMockBuilder(Api::class)->disableOriginalConstructor()->getMock(); - - $customerHelper = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock(); - $customerHelper->method('getSalutationParameter')->willReturn('mr'); - $customerHelper->method('getGenderParameter')->willReturn('m'); - - $url = $this->getMockBuilder(Url::class)->disableOriginalConstructor()->getMock(); - $url->method('getUrl')->willReturn('test'); - - $environmentHelper = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); - $environmentHelper->method('getRemoteIp')->willReturn('1.1.1.1'); - - $shopHelper = $this->getMockBuilder(Shop::class)->disableOriginalConstructor()->getMock(); - $shopHelper->method('getConfigParam')->willReturn('1'); - - $this->classToTest = $objectManager->getObject(ClassToTest::class, [ - 'apiHelper' => $this->apiHelper, - 'shopHelper' => $shopHelper, - 'customerHelper' => $customerHelper, - 'url' => $url, - 'environmentHelper' => $environmentHelper, - ]); - } - - public function testSendAgreementRequest() - { - $address = $this->getMockBuilder(Address::class)->disableOriginalConstructor()->getMock(); - - $customer = $this->getMockBuilder(CustomerModel::class)->disableOriginalConstructor()->getMock(); - $customer->method('getDefaultBillingAddress')->willReturn($address); - - $quote = $this->getMockBuilder(Quote::class) - ->disableOriginalConstructor() - ->setMethods(['getQuoteCurrencyCode', 'getBillingAddress']) - ->getMock(); - $quote->method('getQuoteCurrencyCode')->willReturn('EUR'); - - $response = ['status' => 'APPROVED']; - $this->apiHelper->method('sendApiRequest')->willReturn($response); - - $result = $this->classToTest->sendAgreementRequest($customer, $quote); - $this->assertArrayHasKey('status', $result); - } - - public function testSendAgreementRequestNoCustomerAddress() - { - $address = $this->getMockBuilder(Address::class)->disableOriginalConstructor()->getMock(); - - $customer = $this->getMockBuilder(CustomerModel::class)->disableOriginalConstructor()->getMock(); - $customer->method('getDefaultBillingAddress')->willReturn(false); - - $quote = $this->getMockBuilder(Quote::class) - ->disableOriginalConstructor() - ->setMethods(['getQuoteCurrencyCode', 'getBillingAddress']) - ->getMock(); - $quote->method('getQuoteCurrencyCode')->willReturn('EUR'); - $quote->method('getBillingAddress')->willReturn($address); - - $response = ['status' => 'APPROVED']; - $this->apiHelper->method('sendApiRequest')->willReturn($response); - - $result = $this->classToTest->sendAgreementRequest($customer, $quote); - $this->assertArrayHasKey('status', $result); - } -} diff --git a/Test/Unit/Observer/AddPaydirektOneklickButtonTest.php b/Test/Unit/Observer/AddPaydirektOneklickButtonTest.php deleted file mode 100644 index 6cad086e..00000000 --- a/Test/Unit/Observer/AddPaydirektOneklickButtonTest.php +++ /dev/null @@ -1,164 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ - -namespace Payone\Core\Test\Unit\Observer; - -use Magento\Catalog\Block\ShortcutButtons; -use Magento\Framework\Event; -use Magento\Framework\Event\Observer; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Framework\View\LayoutInterface; -use Magento\Paypal\Block\Express\Shortcut; -use Payone\Core\Helper\Payment; -use Payone\Core\Observer\AddPaydirektOneklickButton as ClassToTest; -use Payone\Core\Test\Unit\BaseTestCase; -use Payone\Core\Test\Unit\PayoneObjectManager; -use Magento\Customer\Model\Session; -use Magento\Customer\Model\Customer; - -class AddPaydirektOneklickButtonTest extends BaseTestCase -{ - /** - * @var ClassToTest - */ - private $classToTest; - - /** - * @var ObjectManager|PayoneObjectManager - */ - private $objectManager; - - /** - * @var Payment|\PHPUnit_Framework_MockObject_MockObject - */ - private $paymentHelper; - - /** - * @var Session|\PHPUnit_Framework_MockObject_MockObject - */ - private $customerSession; - - protected function setUp(): void - { - $this->objectManager = $this->getObjectManager(); - - $this->paymentHelper = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock(); - - $customer = $this->getMockBuilder(Customer::class) - ->disableOriginalConstructor() - ->setMethods(['getPayonePaydirektRegistered']) - ->getMock(); - $customer->method('getPayonePaydirektRegistered')->willReturn(true); - - $this->customerSession = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); - $this->customerSession->method('getCustomer')->willReturn($customer); - - $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ - 'paymentHelper' => $this->paymentHelper, - 'customerSession' => $this->customerSession, - ]); - } - - public function testExecutePaydirektInactive() - { - $this->paymentHelper->method('isPaymentMethodActive')->willReturn(false); - $observer = $this->getMockBuilder(Observer::class)->disableOriginalConstructor()->getMock(); - - $result = $this->classToTest->execute($observer); - $this->assertNull($result); - } - - public function testExecuteWrongContainer() - { - $this->paymentHelper->method('isPaymentMethodActive')->willReturn(true); - - $shortcutButtons = $this->getMockBuilder(ShortcutButtons::class)->disableOriginalConstructor()->getMock(); - $shortcutButtons->method('getNameInLayout')->willReturn('addtocart.shortcut.buttons'); - - $event = $this->getMockBuilder(Event::class) - ->disableOriginalConstructor() - ->setMethods(['getContainer']) - ->getMock(); - $event->method('getContainer')->willReturn($shortcutButtons); - - $observer = $this->getMockBuilder(Observer::class)->disableOriginalConstructor()->getMock(); - $observer->method('getEvent')->willReturn($event); - - $result = $this->classToTest->execute($observer); - $this->assertNull($result); - } - - public function testExecuteNotLoggedInContainer() - { - $this->paymentHelper->method('isPaymentMethodActive')->willReturn(true); - - $shortcutButtons = $this->getMockBuilder(ShortcutButtons::class)->disableOriginalConstructor()->getMock(); - $shortcutButtons->method('getNameInLayout')->willReturn('test'); - - $event = $this->getMockBuilder(Event::class) - ->disableOriginalConstructor() - ->setMethods(['getContainer']) - ->getMock(); - $event->method('getContainer')->willReturn($shortcutButtons); - - $observer = $this->getMockBuilder(Observer::class)->disableOriginalConstructor()->getMock(); - $observer->method('getEvent')->willReturn($event); - - $this->customerSession->method('isLoggedIn')->willReturn(false); - - $result = $this->classToTest->execute($observer); - $this->assertNull($result); - } - - public function testExecutePaydirektActive() - { - $this->paymentHelper->method('isPaymentMethodActive')->willReturn(true); - - $shortcut = $this->getMockBuilder(Shortcut::class)->disableOriginalConstructor()->getMock(); - - $layout = $this->getMockBuilder(LayoutInterface::class)->disableOriginalConstructor()->getMock(); - $layout->method('createBlock')->willReturn($shortcut); - - $shortcutButtons = $this->getMockBuilder(ShortcutButtons::class)->disableOriginalConstructor()->getMock(); - $shortcutButtons->method('getNameInLayout')->willReturn('test'); - $shortcutButtons->method('getLayout')->willReturn($layout); - - $event = $this->getMockBuilder(Event::class) - ->disableOriginalConstructor() - ->setMethods(['getContainer']) - ->getMock(); - $event->method('getContainer')->willReturn($shortcutButtons); - - $observer = $this->getMockBuilder(Observer::class)->disableOriginalConstructor()->getMock(); - $observer->method('getEvent')->willReturn($event); - - $this->customerSession->method('isLoggedIn')->willReturn(true); - - $result = $this->classToTest->execute($observer); - $executed = true; - $this->assertTrue($executed); - } -} diff --git a/etc/adminhtml/system/payone_paydirekt.xml b/etc/adminhtml/system/payone_paydirekt.xml index bb4b2c6a..da61751f 100644 --- a/etc/adminhtml/system/payone_paydirekt.xml +++ b/etc/adminhtml/system/payone_paydirekt.xml @@ -32,10 +32,6 @@ Magento\Config\Model\Config\Source\Yesno payment/payone_paydirekt/active - - - Magento\Config\Model\Config\Source\Yesno - payment/payone_paydirekt/title diff --git a/etc/di.xml b/etc/di.xml index 0f2c60b3..23a22313 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -135,11 +135,6 @@ Payone\Core\Model\Handler\SubstituteOrder\Proxy - - - Magento\Customer\Model\Session\Proxy - - Magento\Checkout\Model\Session\Proxy diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index b573b39d..fe9e9c92 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -28,6 +28,5 @@ - diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index 8f41bcc4..3bd12fbb 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -1151,7 +1151,6 @@ "Payment method is not available anymore","Zahlart steht nicht mehr zur Verfügung" -"Register for paydirekt oneKlick","Für paydirekt oneKlick registrieren" "Please check your email account for the paydirekt registration email before continuing.","Bitte prüfen Sie Ihr Email-Konto bzgl. der Registrierungs-Email von paydirekt bevor Sie fortfahren." "ratepay_legal_text_snippet_1","Mit Klicken auf" diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 3e546985..afc52be7 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -176,7 +176,6 @@ - diff --git a/view/frontend/templates/onepage/review.phtml b/view/frontend/templates/onepage/review.phtml index 7a1b2ab0..d9746dc7 100644 --- a/view/frontend/templates/onepage/review.phtml +++ b/view/frontend/templates/onepage/review.phtml @@ -27,13 +27,6 @@ * @var \Payone\Core\Block\Onepage\Review $block */ ?> -showPaydirektEmailMessage() === true): ?> -
-
-
-

-
-
diff --git a/view/frontend/templates/paydirekt/oneklick_button.phtml b/view/frontend/templates/paydirekt/oneklick_button.phtml deleted file mode 100644 index 1583c083..00000000 --- a/view/frontend/templates/paydirekt/oneklick_button.phtml +++ /dev/null @@ -1,30 +0,0 @@ -. - * - * PHP version 5 - * - * @category Payone - * @package Payone_Magento2_Plugin - * @author FATCHIP GmbH - * @copyright 2003 - 2019 Payone GmbH - * @license GNU Lesser General Public License - * @link http://www.payone.de - */ -?> - diff --git a/view/frontend/web/js/view/payment/method-renderer/paydirekt-method.js b/view/frontend/web/js/view/payment/method-renderer/paydirekt-method.js index 181dadfe..54dae68e 100644 --- a/view/frontend/web/js/view/payment/method-renderer/paydirekt-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/paydirekt-method.js @@ -38,12 +38,6 @@ define( getInstructions: function () { return window.checkoutConfig.payment.instructions[this.item.method]; }, - isPaydirektOneKlickDisplayable: function () { - return customer.isLoggedIn() && window.checkoutConfig.payment.payone.isPaydirektOneKlickDisplayable; - }, - redirectToOneKlickController: function () { - window.location.replace(url.build('payone/paydirekt/agreement/')); - } }); } ); diff --git a/view/frontend/web/template/payment/paydirekt.html b/view/frontend/web/template/payment/paydirekt.html index 66db31d1..5f2c1aba 100644 --- a/view/frontend/web/template/payment/paydirekt.html +++ b/view/frontend/web/template/payment/paydirekt.html @@ -70,9 +70,6 @@
- - -