Skip to content

Commit 6f005da

Browse files
committed
MAG2-171 - Added Ratepay invoice payment method
1 parent 1b84e5b commit 6f005da

34 files changed

+2139
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/**
4+
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* PHP version 5
18+
*
19+
* @category Payone
20+
* @package Payone_Magento2_Plugin
21+
* @author FATCHIP GmbH <[email protected]>
22+
* @copyright 2003 - 2020 Payone GmbH
23+
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
24+
* @link http://www.payone.de
25+
*/
26+
27+
namespace Payone\Core\Block\Adminhtml\Config\Form\Field;
28+
29+
/**
30+
* Block class for Ratepay shop config grid-element
31+
*/
32+
class RatepayShopConfig extends \Payone\Core\Block\Adminhtml\Config\Form\Field\FieldArray\Multiselect
33+
{
34+
/**
35+
* Element factory
36+
*
37+
* @var \Magento\Framework\Data\Form\Element\Factory
38+
*/
39+
protected $elementFactory;
40+
41+
/**
42+
* Constructor
43+
*
44+
* @param \Magento\Backend\Block\Template\Context $context
45+
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
46+
* @param array $data
47+
*/
48+
public function __construct(
49+
\Magento\Backend\Block\Template\Context $context,
50+
\Magento\Framework\Data\Form\Element\Factory $elementFactory,
51+
array $data = []
52+
) {
53+
parent::__construct($context, $data);
54+
$this->elementFactory = $elementFactory;
55+
}
56+
57+
/**
58+
* Initialise form fields
59+
*
60+
* @return void
61+
*/
62+
protected function _construct()
63+
{
64+
$this->addColumn('shop_id', ['label' => __('Shop-ID')]);
65+
$this->addColumn('currency', ['label' => __('Currency')]);
66+
$this->_addAfter = false;
67+
$this->_addButtonLabel = __('Add Shop-ID');
68+
parent::_construct();
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
/**
4+
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* PHP version 5
18+
*
19+
* @category Payone
20+
* @package Payone_Magento2_Plugin
21+
* @author FATCHIP GmbH <[email protected]>
22+
* @copyright 2003 - 2020 Payone GmbH
23+
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
24+
* @link http://www.payone.de
25+
*/
26+
27+
namespace Payone\Core\Block\Adminhtml\Config\Form\Field;
28+
29+
/**
30+
* Admin-block for displaying Ratepay shop config
31+
*/
32+
class RatepayShowShopConfig extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
33+
{
34+
/**
35+
* Template
36+
*
37+
* @var string
38+
*/
39+
protected $_template = 'Payone_Core::system/config/form/field/ratepay_show_shop_config.phtml';
40+
41+
/**
42+
* @var \Payone\Core\Helper\Ratepay
43+
*/
44+
protected $ratepayHelper;
45+
46+
/**
47+
* Ratepay profile resource model
48+
*
49+
* @var \Payone\Core\Model\ResourceModel\RatepayProfileConfig
50+
*/
51+
protected $ratepayProfileResource;
52+
53+
/**
54+
* Constructor
55+
*
56+
* @param \Magento\Backend\Block\Template\Context $context
57+
* @param \Payone\Core\Helper\Ratepay $ratepayHelper
58+
* @param \Payone\Core\Model\ResourceModel\RatepayProfileConfig $ratepayProfileResource
59+
* @param array $data
60+
*/
61+
public function __construct(
62+
\Magento\Backend\Block\Template\Context $context,
63+
\Payone\Core\Helper\Ratepay $ratepayHelper,
64+
\Payone\Core\Model\ResourceModel\RatepayProfileConfig $ratepayProfileResource,
65+
array $data = []
66+
) {
67+
parent::__construct($context, $data);
68+
$this->ratepayHelper = $ratepayHelper;
69+
$this->ratepayProfileResource = $ratepayProfileResource;
70+
}
71+
72+
/**
73+
* Initialise form fields
74+
*
75+
* @return void
76+
*/
77+
protected function _construct()
78+
{
79+
$this->addColumn('txaction', ['label' => __('Transactionstatus-message')]);
80+
$this->_addAfter = false;
81+
$this->_addButtonLabel = __('Add Minimum Qty');
82+
parent::_construct();
83+
}
84+
85+
/**
86+
* Returns current payment method
87+
*
88+
* @return string|false
89+
*/
90+
protected function getCurrentPaymentMethod()
91+
{
92+
$oElement = $this->getDataByKey('element');
93+
if ($oElement) {
94+
$aOrigData = $oElement->getOriginalData();
95+
if (isset($aOrigData['path'])) {
96+
return str_replace('payone_payment/', '', $aOrigData['path']);
97+
}
98+
}
99+
return false;
100+
}
101+
102+
/**
103+
* Returns Ratepay shop configurations for current payment method
104+
*
105+
* @return array
106+
*/
107+
public function getRatepayShopConfig()
108+
{
109+
$sCurrentPaymentMethod = $this->getCurrentPaymentMethod();
110+
111+
$aShopIds = $this->ratepayHelper->getRatepayShopConfigIdsByPaymentMethod($sCurrentPaymentMethod);
112+
if (empty($aShopIds)) {
113+
return [];
114+
}
115+
return $this->ratepayProfileResource->getProfileConfigsByIds($aShopIds);
116+
}
117+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
/**
4+
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* PHP version 5
18+
*
19+
* @category Payone
20+
* @package Payone_Magento2_Plugin
21+
* @author FATCHIP GmbH <[email protected]>
22+
* @copyright 2003 - 2020 Payone GmbH
23+
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
24+
* @link http://www.payone.de
25+
*/
26+
27+
namespace Payone\Core\Block\Adminhtml\Config\Form\Field;
28+
29+
/**
30+
* Admin-block for the Ratepay refresh profile button
31+
*/
32+
class RefreshRatepayProfiles extends \Magento\Config\Block\System\Config\Form\Field
33+
{
34+
/**
35+
* Set template to itself
36+
*
37+
* @return \Payone\Core\Block\Adminhtml\Config\Form\Field\AmazonConfiguration
38+
*/
39+
protected function _prepareLayout()
40+
{
41+
parent::_prepareLayout();
42+
if (!$this->getTemplate()) {
43+
$this->setTemplate('system/config/form/field/refresh_ratepay_profiles.phtml');
44+
}
45+
return $this;
46+
}
47+
48+
/**
49+
* Unset some non-related element parameters
50+
*
51+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
52+
* @return string
53+
*/
54+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
55+
{
56+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
57+
return parent::render($element);
58+
}
59+
60+
/**
61+
* Get the button and scripts contents
62+
*
63+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
64+
* @return string
65+
*/
66+
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
67+
{
68+
$originalData = $element->getOriginalData();
69+
$sPaymentMethod = str_replace('payone_payment/', '', $originalData['path']);
70+
71+
$this->addData([
72+
'ajax_url' => $this->_urlBuilder->getUrl('payone/config_ratepay/refresh', ['method' => $sPaymentMethod])
73+
]);
74+
75+
return $this->_toHtml();
76+
}
77+
}

Block/RatepayDeviceFingerprint.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/**
4+
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* PHP version 5
18+
*
19+
* @category Payone
20+
* @package Payone_Magento2_Plugin
21+
* @author FATCHIP GmbH <[email protected]>
22+
* @copyright 2003 - 2020 Payone GmbH
23+
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
24+
* @link http://www.payone.de
25+
*/
26+
27+
namespace Payone\Core\Block;
28+
29+
use Magento\Framework\View\Element\Template;
30+
31+
class RatepayDeviceFingerprint extends Template
32+
{
33+
/**
34+
* @var \Payone\Core\Helper\Ratepay
35+
*/
36+
protected $ratepayHelper;
37+
38+
/**
39+
* Constructor
40+
*
41+
* @param Template\Context $context
42+
* @param \Payone\Core\Helper\Ratepay $ratepayHelper
43+
* @param array $data
44+
*/
45+
public function __construct(Template\Context $context, \Payone\Core\Helper\Ratepay $ratepayHelper, array $data = [])
46+
{
47+
parent::__construct($context, $data);
48+
$this->ratepayHelper = $ratepayHelper;
49+
}
50+
51+
/**
52+
* Returns snippet id from config
53+
*
54+
* @return string
55+
*/
56+
public function getDevicefingerprintSnippetId()
57+
{
58+
return $this->ratepayHelper->getConfigParam('devicefingerprint_snippet_id', 'ratepay', 'payone_misc');
59+
}
60+
61+
/**
62+
* Returns token generated by Ratepay helper
63+
*
64+
* @return string
65+
*/
66+
public function getDevicefingerprintToken()
67+
{
68+
return $this->ratepayHelper->getRatepayDeviceFingerprintToken();
69+
}
70+
}

0 commit comments

Comments
 (0)