Skip to content

Commit f7143bb

Browse files
FATCHIP-GmbHT-Kuchel
authored andcommitted
Milestone 3 - Risk Management (PAYONE-GmbH#21)
* Milestone 3 - Risk Management - Changed status of INVALID addresscheck to red - Added option to individually control the addresscheck mode on consumerscore checks - Refactored some methods - Added address parameter - Fixed is consumerscore needed method
1 parent cec542f commit f7143bb

File tree

106 files changed

+4219
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+4219
-584
lines changed

Block/Adminhtml/Config/Form/Field/KlarnaStoreId.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ class KlarnaStoreId extends \Payone\Core\Block\Adminhtml\Config\Form\Field\Field
4848
/**
4949
* Constructor
5050
*
51-
* @param \Magento\Backend\Block\Template\Context $context
52-
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
53-
* @param \Payone\Core\Model\Source\TransactionStatus $klarnaCountries
54-
* @param array $data
55-
* @return void
51+
* @param \Magento\Backend\Block\Template\Context $context
52+
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
53+
* @param \Payone\Core\Model\Source\TransactionStatus $klarnaCountries
54+
* @param array $data
5655
*/
5756
public function __construct(
5857
\Magento\Backend\Block\Template\Context $context,
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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 - 2016 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 person-status-mapping grid-element
31+
*/
32+
class PersonStatusMapping extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
33+
{
34+
/**
35+
* Element factory
36+
*
37+
* @var \Magento\Framework\Data\Form\Element\Factory
38+
*/
39+
protected $elementFactory;
40+
41+
/**
42+
* Person status source class
43+
*
44+
* @var \Payone\Core\Model\Source\PersonStatus
45+
*/
46+
protected $personStatus;
47+
48+
/**
49+
* Credit score source class
50+
*
51+
* @var \Payone\Core\Model\Source\CreditScore
52+
*/
53+
protected $creditScore;
54+
55+
/**
56+
* Constructor
57+
*
58+
* @param \Magento\Backend\Block\Template\Context $context
59+
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
60+
* @param \Payone\Core\Model\Source\PersonStatus $personStatus
61+
* @param \Payone\Core\Model\Source\CreditScore $creditScore
62+
* @param array $data
63+
*/
64+
public function __construct(
65+
\Magento\Backend\Block\Template\Context $context,
66+
\Magento\Framework\Data\Form\Element\Factory $elementFactory,
67+
\Payone\Core\Model\Source\PersonStatus $personStatus,
68+
\Payone\Core\Model\Source\CreditScore $creditScore,
69+
array $data = []
70+
) {
71+
parent::__construct($context, $data);
72+
$this->elementFactory = $elementFactory;
73+
$this->personStatus = $personStatus;
74+
$this->creditScore = $creditScore;
75+
}
76+
77+
/**
78+
* Initialise form fields
79+
*
80+
* @return void
81+
*/
82+
protected function _construct()
83+
{
84+
$this->addColumn('personstatus', ['label' => __('Personstatus')]);
85+
$this->addColumn('score', ['label' => __('Score')]);
86+
$this->addAfter = false;
87+
$this->addButtonLabel = __('Add Personstatus Mapping');
88+
parent::_construct();
89+
}
90+
91+
/**
92+
* Render array cell for prototypeJS template
93+
*
94+
* @param string $columnName
95+
* @return string
96+
*/
97+
public function renderCellTemplate($columnName)
98+
{
99+
if ($columnName == 'personstatus' && isset($this->_columns[$columnName])) {
100+
$aOptions = $this->personStatus->toOptionArray();
101+
} elseif ($columnName == 'score' && isset($this->_columns[$columnName])) {
102+
$aOptions = $this->creditScore->toOptionArray();
103+
} else {
104+
return parent::renderCellTemplate($columnName);
105+
}
106+
107+
$oElement = $this->elementFactory->create('select');
108+
$oElement->setForm($this->getForm());
109+
$oElement->setName($this->_getCellInputElementName($columnName));
110+
$oElement->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName));
111+
$oElement->setValues($aOptions);
112+
return str_replace("\n", '', $oElement->getElementHtml());
113+
}
114+
}

Block/Adminhtml/Config/Form/Field/StatusForwarding.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ class StatusForwarding extends \Payone\Core\Block\Adminhtml\Config\Form\Field\Fi
4848
/**
4949
* Constructor
5050
*
51-
* @param \Magento\Backend\Block\Template\Context $context
52-
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
53-
* @param \Payone\Core\Model\Source\TransactionStatus $transactionStatus
54-
* @param array $data
55-
* @return void
51+
* @param \Magento\Backend\Block\Template\Context $context
52+
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
53+
* @param \Payone\Core\Model\Source\TransactionStatus $transactionStatus
54+
* @param array $data
5655
*/
5756
public function __construct(
5857
\Magento\Backend\Block\Template\Context $context,

Block/Adminhtml/Config/Form/Field/StatusMapping.php

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ class StatusMapping extends \Magento\Config\Block\System\Config\Form\Field\Field
6262
/**
6363
* Constructor
6464
*
65-
* @param \Magento\Backend\Block\Template\Context $context
66-
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
67-
* @param \Magento\Sales\Model\Config\Source\Order\Status $orderStatus
68-
* @param \Payone\Core\Model\Source\TransactionStatus $transactionStatus
69-
* @param array $data
70-
* @return void
65+
* @param \Magento\Backend\Block\Template\Context $context
66+
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory
67+
* @param \Magento\Sales\Model\Config\Source\Order\Status $orderStatus
68+
* @param \Payone\Core\Model\Source\TransactionStatus $transactionStatus
69+
* @param array $data
7170
*/
7271
public function __construct(
7372
\Magento\Backend\Block\Template\Context $context,
@@ -89,10 +88,10 @@ public function __construct(
8988
*/
9089
protected function _construct()
9190
{
92-
$this->addColumn('txaction', ['label' => __('Transactionstatus-message')]);
93-
$this->addColumn('state_status', ['label' => __('Magento-status')]);
94-
$this->addAfter = false;
95-
$this->addButtonLabel = __('Add Statusmapping');
91+
$this->addColumn('txaction', ['label' => __('Transactionstatus-message')]); // set column name for txaction
92+
$this->addColumn('state_status', ['label' => __('Magento-status')]); // set column name for state_status
93+
$this->addAfter = false; // dont add "add after" button
94+
$this->addButtonLabel = __('Add Statusmapping'); // set the label text of the button
9695
parent::_construct();
9796
}
9897

@@ -105,23 +104,18 @@ protected function _construct()
105104
public function renderCellTemplate($columnName)
106105
{
107106
if ($columnName == 'txaction' && isset($this->_columns[$columnName])) {
108-
$aOptions = $this->transactionStatus->toOptionArray();
107+
$aOptions = $this->transactionStatus->toOptionArray(); // add transction status action options to dropdown
109108
} elseif ($columnName == 'state_status' && isset($this->_columns[$columnName])) {
110-
$aOptions = $this->orderStatus->toOptionArray();
109+
$aOptions = $this->orderStatus->toOptionArray(); // add state_status options to dropdown
111110
} else {
112111
return parent::renderCellTemplate($columnName);
113112
}
114113

115114
$oElement = $this->elementFactory->create('select');
116-
$oElement->setForm(
117-
$this->getForm()
118-
)->setName(
119-
$this->_getCellInputElementName($columnName)
120-
)->setHtmlId(
121-
$this->_getCellInputElementId('<%- _id %>', $columnName)
122-
)->setValues(
123-
$aOptions
124-
);
115+
$oElement->setForm($this->getForm());
116+
$oElement->setName($this->_getCellInputElementName($columnName));
117+
$oElement->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName));
118+
$oElement->setValues($aOptions);
125119
return str_replace("\n", '', $oElement->getElementHtml());
126120
}
127121

@@ -135,22 +129,21 @@ public function renderCellTemplate($columnName)
135129
public function getArrayRows()
136130
{
137131
if (null !== $this->_arrayRowsCache) {
138-
return $this->_arrayRowsCache;
132+
return $this->_arrayRowsCache; // return cached values if set
139133
}
140134
$result = [];
141135
/** @var \Magento\Framework\Data\Form\Element\AbstractElement */
142136
$element = $this->getElement();
143-
$aValue = $element->getValue();
144-
if (!is_array($aValue)) {
145-
$aValue = unserialize($aValue);
137+
$aValue = $element->getValue(); // get values
138+
if (!is_array($aValue)) { // values given as array?
139+
$aValue = unserialize($aValue); // convert string to array
146140
}
147-
148141
if ($aValue && is_array($aValue)) {
149142
foreach ($aValue as $rowId => $row) {
150143
$rowColumnValues = [];
151144
foreach ($row as $key => $value) {
152145
$row[$key] = $value;
153-
$rowColumnValues[$this->_getCellInputElementId($rowId, $key)] = $row[$key];
146+
$rowColumnValues[$this->_getCellInputElementId($rowId, $key)] = $row[$key]; // add value the row
154147
}
155148
$row['_id'] = $rowId;
156149
$row['column_values'] = $rowColumnValues;
@@ -170,9 +163,9 @@ public function getArrayRows()
170163
*/
171164
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
172165
{
173-
$this->setElement($element);
174-
$html = $this->_toHtml();
175-
$this->_arrayRowsCache = null;
166+
$this->setElement($element); // set element
167+
$html = $this->_toHtml(); // get render html for the object
168+
$this->_arrayRowsCache = null; // reset cache
176169
// doh, the object is used as singleton!
177170
return $html;
178171
}

Block/Adminhtml/Protocol/Api/View.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ class View extends \Magento\Backend\Block\Widget\Container
5050
/**
5151
* Constructor
5252
*
53-
* @param \Magento\Backend\Block\Widget\Context $context
54-
* @param \Payone\Core\Model\Entities\ApiLogFactory $apiLogFactory
55-
* @param array $data
56-
* @return void
53+
* @param \Magento\Backend\Block\Widget\Context $context
54+
* @param \Payone\Core\Model\Entities\ApiLogFactory $apiLogFactory
55+
* @param array $data
5756
*/
5857
public function __construct(
5958
\Magento\Backend\Block\Widget\Context $context,

Block/Adminhtml/Protocol/Transactionstatus/View.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ class View extends \Magento\Backend\Block\Widget\Container
4949

5050
/**
5151
*
52-
* @param \Magento\Backend\Block\Widget\Context $context
53-
* @param \Payone\Core\Model\Entities\TransactionStatusFactory $statusFactory
54-
* @param array $data
55-
* @return void
52+
* @param \Magento\Backend\Block\Widget\Context $context
53+
* @param \Payone\Core\Model\Entities\TransactionStatusFactory $statusFactory
54+
* @param array $data
5655
*/
5756
public function __construct(
5857
\Magento\Backend\Block\Widget\Context $context,

Block/Onepage/Debit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class Debit extends Template
5050
/**
5151
* Constructor
5252
*
53+
* @param \Magento\Checkout\Model\Session $checkoutSession
5354
* @param \Magento\Framework\View\Element\Template\Context $context
54-
* @param array $data
55-
* @return void
55+
* @param array $data
5656
*/
5757
public function __construct(
5858
\Magento\Checkout\Model\Session $checkoutSession,

Block/Onepage/Success.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ class Success extends Template
6464
/**
6565
* Constructor
6666
*
67-
* @param \Magento\Checkout\Model\Session $checkoutSession
68-
* @param \Magento\Framework\View\Element\Template\Context $context
69-
* @param \Payone\Core\Helper\Payment $paymentHelper
70-
* @param array $data
71-
* @return void
67+
* @param \Magento\Checkout\Model\Session $checkoutSession
68+
* @param \Magento\Framework\View\Element\Template\Context $context
69+
* @param \Payone\Core\Helper\Payment $paymentHelper
70+
* @param array $data
7271
*/
7372
public function __construct(
7473
\Magento\Checkout\Model\Session $checkoutSession,

Block/Paypal/ExpressButton.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ class ExpressButton extends Template implements \Magento\Catalog\Block\ShortcutI
8484
/**
8585
* Constructor
8686
*
87-
* @param \Magento\Framework\View\Element\Template\Context $context
88-
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
89-
* @param array $data
90-
* @return void
87+
* @param \Magento\Framework\View\Element\Template\Context $context
88+
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
89+
* @param array $data
9190
*/
9291
public function __construct(
9392
\Magento\Framework\View\Element\Template\Context $context,

Controller/Adminhtml/Config/Export/Index.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ class Index extends Action
5050
/**
5151
* Constructor
5252
*
53-
* @param \Magento\Backend\App\Action\Context $context
54-
* @param \Payone\Core\Model\Config\Export $configExport
55-
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
56-
* @return void
53+
* @param \Magento\Backend\App\Action\Context $context
54+
* @param \Payone\Core\Model\Config\Export $configExport
55+
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
5756
*/
5857
public function __construct(
5958
\Magento\Backend\App\Action\Context $context,

0 commit comments

Comments
 (0)