Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions Block/Customer/Bankdata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/**
* Copyright (c) Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace RatePAY\Payment\Block\Customer;

class Bankdata extends \Magento\Framework\View\Element\Template
{
/**
* BAMS GetStoredBankAccounts request model
*
* @var \RatePAY\Payment\Model\BamsApi\GetStoredBankAccounts
*/
protected $getStoredBankAccounts;

/**
* Magento customer session object
*
* @var \Magento\Customer\Model\Session
*/
protected $customerSession;

/**
* Constructor
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \RatePAY\Payment\Model\BamsApi\GetStoredBankAccounts $getStoredBankAccounts
* @param \Magento\Customer\Model\Session $customerSession
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\RatePAY\Payment\Model\BamsApi\GetStoredBankAccounts $getStoredBankAccounts,
\Magento\Customer\Model\Session $customerSession,
array $data = []
) {
parent::__construct($context, $data);
$this->getStoredBankAccounts = $getStoredBankAccounts;
$this->customerSession = $customerSession;
}

/**
* Generate action url
*
* @param string $sHash
* @param string $sAction
* @return string
*/
public function getActionUrl($sHash, $sAction)
{
return $this->getUrl('ratepay/customer/'.$sAction, ['hash' => $sHash]);
}

/**
* Retrieve bank data from Ratepay
*
* @return array|bool
*/
public function getSavedBankData()
{
$iCustomerId = $this->customerSession->getCustomerId();
$aBankAccounts = $this->getStoredBankAccounts->getBankDataForAllIbanProfiles($iCustomerId);
if (empty($aBankAccounts)) {
return false;
}
return $aBankAccounts;
}
}
50 changes: 50 additions & 0 deletions Block/Customer/DataLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* Copyright (c) Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace RatePAY\Payment\Block\Customer;

class DataLink extends \Magento\Framework\View\Element\Html\Link\Current
{
/**
* @var \RatePAY\Payment\Helper\Data
*/
protected $rpDataHelper;

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

/**
* Render block HTML
*
* @return string
*/
public function toHtml()
{
if ((bool)$this->rpDataHelper->getRpConfigDataByPath('ratepay/general/bams_enabled') === true) {
return parent::toHtml();
}
return '';
}
}
86 changes: 86 additions & 0 deletions Block/System/Config/BamsOauthCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

/**
* Copyright (c) Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace RatePAY\Payment\Block\System\Config;

class BamsOauthCheck extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
/**
* Template
*
* @var string
*/
protected $_template = 'RatePAY_Payment::system/config/bamsoauthcheck.phtml';

/**
* @var \Magento\Backend\Model\Session
*/
protected $backendSession;

/**
* @var bool
*/
protected $blStatus;

/**
* Constructor
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Model\Session $backendSession
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Model\Session $backendSession,
array $data = []
) {
parent::__construct($context, $data);
$this->backendSession = $backendSession;
}

/**
* Unset some non-related element parameters
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$this->blStatus = $this->backendSession->getRatepayBamsOauthChanged();
if ($this->blStatus === null) {
return '';
}

$this->backendSession->unsRatepayBamsOauthChanged();

$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}

/**
* Initialise form fields
*
* @return void
*/
protected function _construct()
{
$this->addColumn('txaction', ['label' => __('Transactionstatus-message')]);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add Minimum Qty');
parent::_construct();
}

/**
* @return bool
*/
public function getStatus()
{
return $this->blStatus;
}
}
59 changes: 59 additions & 0 deletions Controller/Customer/Bankdata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* Copyright (c) Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace RatePAY\Payment\Controller\Customer;

use \Magento\Framework\View\Result\PageFactory;

class Bankdata extends \Magento\Framework\App\Action\Action
{
/**
* @var \RatePAY\Payment\Helper\Data
*/
protected $rpDataHelper;

/**
* PAYONE base helper
*
* @var Base
*/
protected $baseHelper;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $pageFactory
* @param \RatePAY\Payment\Helper\Data $rpDataHelper
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $pageFactory,
\RatePAY\Payment\Helper\Data $rpDataHelper
) {
parent::__construct($context);
$this->pageFactory = $pageFactory;
$this->rpDataHelper = $rpDataHelper;
}

/**
* Dispatch request
*
* @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
* @throws \Magento\Framework\Exception\NotFoundException
*/
public function execute()
{
if ((bool)$this->rpDataHelper->getRpConfigDataByPath('ratepay/general/bams_enabled') === true) {
$resultPage = $this->pageFactory->create();
$resultPage->getConfig()->getTitle()->set(__('Bank data management'));

return $resultPage;
}
return $this->resultRedirectFactory->create()->setPath('customer/account');
}
}
74 changes: 74 additions & 0 deletions Controller/Customer/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

/**
* Copyright (c) Ratepay GmbH
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace RatePAY\Payment\Controller\Customer;

class Delete extends \Magento\Framework\App\Action\Action
{
/**
* Customer session object
*
* @var \Magento\Customer\Model\Session
*/
protected $customerSession;

/**
* BAMS GetStoredBankAccounts request model
*
* @var \RatePAY\Payment\Model\BamsApi\GetStoredBankAccounts
*/
protected $getStoredBankAccounts;

/**
* BAMS DeleteBankAccount request model
*
* @var \RatePAY\Payment\Model\BamsApi\DeleteBankAccount
*/
protected $deleteBankAccount;

/**
* Constructor
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param \RatePAY\Payment\Model\BamsApi\GetStoredBankAccounts $getStoredBankAccounts
* @param \RatePAY\Payment\Model\BamsApi\DeleteBankAccount $deleteBankAccount
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Customer\Model\Session $customerSession,
\RatePAY\Payment\Model\BamsApi\GetStoredBankAccounts $getStoredBankAccounts,
\RatePAY\Payment\Model\BamsApi\DeleteBankAccount $deleteBankAccount
) {
parent::__construct($context);
$this->customerSession = $customerSession;
$this->getStoredBankAccounts = $getStoredBankAccounts;
$this->deleteBankAccount = $deleteBankAccount;
}

/**
* Dispatch request
*
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
$sDeleteHash = $this->getRequest()->getParam('hash');

$iCustomerId = $this->customerSession->getCustomerId();
$aBankAccounts = $this->getStoredBankAccounts->getBankDataForAllIbanProfiles($iCustomerId);
foreach ($aBankAccounts as $aBankData) {
if ($aBankData['hash'] == $sDeleteHash) {
$this->deleteBankAccount->sendRequest($iCustomerId, $aBankData['profile'], $aBankData['bank_account_reference']);
break;
}
}
return $this->resultRedirectFactory->create()->setPath('ratepay/customer/bankdata');
}
}
9 changes: 8 additions & 1 deletion Helper/Content/Customer/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ public function getBankAccount($quoteOrOrder)
{
$return = false;

$ibanReference = $quoteOrOrder->getPayment()->getAdditionalInformation('rp_iban_reference');
if (!empty($ibanReference)) {
return [
'Reference' => $ibanReference,
];
}

$iban = $quoteOrOrder->getPayment()->getAdditionalInformation('rp_iban');
$accountHolder = $quoteOrOrder->getPayment()->getAdditionalInformation('rp_accountholder');
if (!empty($iban)) {
$return =[
$return = [
'Owner' => $quoteOrOrder->getBillingAddress()->getFirstname() . ' ' . $quoteOrOrder->getBillingAddress()->getLastname(),
//'BankName' =>
//'BankAccountNumber' => '1234567891',
Expand Down
Loading