Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PAYONE-GmbH/magento-2 int…
Browse files Browse the repository at this point in the history
…o MAG2-77-Back-button-problem

# Conflicts:
#	Model/PayoneConfig.php
#	Setup/UpgradeSchema.php
#	Test/Unit/Controller/Onepage/CancelTest.php
#	Test/Unit/Controller/Onepage/PlaceOrderTest.php
#	etc/module.xml
  • Loading branch information
FatchipRobert committed Nov 14, 2018
2 parents 6c39e67 + c4a950c commit 3944eb9
Show file tree
Hide file tree
Showing 66 changed files with 2,025 additions and 469 deletions.
73 changes: 73 additions & 0 deletions Block/Customer/Link.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/**
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2018 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Block\Customer;

use Payone\Core\Model\PayoneConfig;

/**
* Block class for deactivating display of the creditcard management
*/
class Link extends \Magento\Framework\View\Element\Html\Link\Current
{
/**
* PAYONE base helper
*
* @var \Payone\Core\Helper\Base
*/
protected $baseHelper;

/**
* Constructor
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\App\DefaultPathInterface $defaultPath
* @param \Payone\Core\Helper\Base $baseHelper
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\App\DefaultPathInterface $defaultPath,
\Payone\Core\Helper\Base $baseHelper,
array $data = []
) {
parent::__construct($context, $defaultPath, $data);
$this->baseHelper = $baseHelper;
}

/**
* Render block HTML
*
* @return string
*/
public function toHtml()
{
if ((bool)$this->baseHelper->getConfigParam('save_data_enabled', PayoneConfig::METHOD_CREDITCARD, 'payone_payment') === true) {
return parent::toHtml();
}
return '';
}
}
99 changes: 99 additions & 0 deletions Block/Payments/Management.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

/**
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2018 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Block\Payments;

use Magento\Framework\View\Element\Template;
use Payone\Core\Model\PayoneConfig;
use Payone\Core\Model\ResourceModel\SavedPaymentData;
use Magento\Customer\Model\Session;

/**
* Block class for saved payment data
*/
class Management extends \Magento\Framework\View\Element\Template
{
/**
* SavedPaymentData resource class
*
* @var SavedPaymentData
*/
protected $savedPaymentData;

/**
* Customer session object
*
* @var Session
*/
protected $customerSession;

/**
* Constructor
*
* @param Template\Context $context
* @param SavedPaymentData $savedPaymentData
* @param Session $customerSession
* @param array $data
*/
public function __construct(
Template\Context $context,
SavedPaymentData $savedPaymentData,
Session $customerSession,
array $data = []
) {
parent::__construct($context, $data);
$this->savedPaymentData = $savedPaymentData;
$this->customerSession = $customerSession;
}

public function getCardtypeUrl($aData)
{
return 'https://cdn.pay1.de/cc/'.strtolower($aData['payment_data']['cardtype']).'/s/default.png';
}

/**
* Load all saved payment data of the current customer
*
* @return array
*/
public function getSavedPaymentData()
{
$iCustomerId = $this->customerSession->getCustomerId();
return $this->savedPaymentData->getSavedPaymentData($iCustomerId, PayoneConfig::METHOD_CREDITCARD);
}

/**
* Generate action url
*
* @param int $iId
* @param string $sAction
* @return string
*/
public function getActionUrl($iId, $sAction)
{
return $this->getUrl('payone/payments/'.$sAction, ['id' => $iId]);
}
}
61 changes: 0 additions & 61 deletions Controller/Adminhtml/Information/Index.php

This file was deleted.

1 change: 1 addition & 0 deletions Controller/Onepage/Cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function execute()
try {
$this->checkoutSession->setIsPayoneRedirectCancellation(true);
$this->checkoutSession->unsPayoneWorkorderId();
$this->checkoutSession->unsIsPayonePayPalExpress();

$sPaymentMethod = $this->checkoutSession->getPayoneRedirectedPaymentMethod();
if ($sPaymentMethod) {
Expand Down
2 changes: 1 addition & 1 deletion Controller/Onepage/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function placeOrder()

// "last successful quote"
$sQuoteId = $oQuote->getId();
$this->checkoutSession->setLastQuoteId($sQuoteId)->setLastSuccessQuoteId($sQuoteId)->unsPayoneWorkorderId();
$this->checkoutSession->setLastQuoteId($sQuoteId)->setLastSuccessQuoteId($sQuoteId)->unsPayoneWorkorderId()->unsIsPayonePayPalExpress();

$oQuote->setIsActive(false)->save();
}
Expand Down
83 changes: 83 additions & 0 deletions Controller/Payments/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <[email protected]>
* @copyright 2003 - 2018 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/

namespace Payone\Core\Controller\Payments;

use Magento\Framework\App\Action\Context;
use Payone\Core\Model\ResourceModel\SavedPaymentData;
use Magento\Customer\Model\Session;

/**
* Delete saved payment data controller
*/
class Delete extends \Magento\Framework\App\Action\Action
{
/**
* SavedPaymentData resource class
*
* @var SavedPaymentData
*/
protected $savedPaymentData;

/**
* Customer session object
*
* @var Session
*/
protected $customerSession;

/**
* Constructor
*
* @param Context $context
* @param SavedPaymentData $savedPaymentData
* @param Session $customerSession
*/
public function __construct(
Context $context,
SavedPaymentData $savedPaymentData,
Session $customerSession
) {
parent::__construct($context);
$this->savedPaymentData = $savedPaymentData;
$this->customerSession = $customerSession;
}

/**
* Dispatch request
*
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
$iDeleteId = $this->getRequest()->getParam('id');
$iCustomerId = $this->customerSession->getCustomerId();
if ($iCustomerId) {
$this->savedPaymentData->deletePaymentData($iDeleteId, $iCustomerId);
}
return $this->resultRedirectFactory->create()->setPath('payone/payments/management');
}
}
Loading

0 comments on commit 3944eb9

Please sign in to comment.