Skip to content

Commit 9f864b3

Browse files
committed
Added new fields for screen/order API.
1 parent f63038f commit 9f864b3

File tree

5 files changed

+64
-117
lines changed

5 files changed

+64
-117
lines changed

Block/Adminhtml/Order/View/Tab/Flpsummary.php

+1-49
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,12 @@
22

33
namespace Hexasoft\FraudLabsPro\Block\Adminhtml\Order\View\Tab;
44

5-
65
class Flpsummary extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface
76
{
8-
/**
9-
* Template
10-
*
11-
* @var string
12-
*/
13-
protected $_template = 'order/view/tab/flpsummary.phtml';
147

15-
/**
16-
* Core registry
17-
*
18-
* @var \Magento\Framework\Registry
19-
*/
8+
protected $_template = 'order/view/tab/flpsummary.phtml';
209
protected $coreRegistry = null;
2110

22-
/**
23-
* @param \Magento\Backend\Block\Template\Context $context
24-
* @param \Magento\Framework\Registry $registry
25-
* @param array $data
26-
*/
2711
public function __construct(
2812
\Magento\Backend\Block\Template\Context $context,
2913
\Magento\Framework\Registry $registry,
@@ -33,73 +17,41 @@ public function __construct(
3317
parent::__construct($context, $data);
3418
}
3519

36-
/**
37-
* Retrieve order model instance
38-
*
39-
* @return \Magento\Sales\Model\Order
40-
*/
4120
public function getOrder()
4221
{
4322
return $this->coreRegistry->registry('current_order');
4423
}
4524

46-
/**
47-
* {@inheritdoc}
48-
*/
4925
public function getTabLabel()
5026
{
5127
return __('FraudLabs Pro');
5228
}
5329

54-
/**
55-
* {@inheritdoc}
56-
*/
5730
public function getTabTitle()
5831
{
5932
return __('FraudLabs Pro');
6033
}
6134

62-
/**
63-
* {@inheritdoc}
64-
*/
6535
public function canShowTab()
6636
{
6737
return true;
6838
}
6939

70-
/**
71-
* {@inheritdoc}
72-
*/
7340
public function isHidden()
7441
{
7542
return false;
7643
}
7744

78-
/**
79-
* Get Tab Class
80-
*
81-
* @return string
82-
*/
8345
public function getTabClass()
8446
{
8547
return 'ajax only';
8648
}
8749

88-
/**
89-
* Get Class
90-
*
91-
* @return string
92-
*/
9350
public function getClass()
9451
{
9552
return $this->getTabClass();
9653
}
9754

98-
/**
99-
* Get Tab Url
100-
*
101-
* @return string
102-
*/
10355
public function getTabUrl()
10456
{
10557
return $this->getUrl('flpsummarytab/*/flpsummaryTab', ['_current' => true]);

CHANGELOG

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ Revision History for FraudLabs Pro Magento2
99
Added "Blacklist" button.
1010

1111
2.0.6 2017-08-24
12-
Fixed IP detection when Magento is running behind a reverse proxy server.
12+
Fixed IP detection when Magento is running behind a reverse proxy server.
13+
14+
2.0.7 2017-09-15
15+
Added new fields for screen/order API.

Controller/Adminhtml/Order/FlpsummaryTab.php

+50-60
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,70 @@
22

33
namespace Hexasoft\FraudLabsPro\Controller\Adminhtml\Order;
44

5+
use Psr\Log\LoggerInterface;
56
use Magento\Backend\App\Action;
6-
use Magento\Sales\Api\OrderManagementInterface;
77
use Magento\Sales\Api\OrderRepositoryInterface;
8-
use Psr\Log\LoggerInterface;
8+
use Magento\Sales\Api\OrderManagementInterface;
99

10+
// Flpsummarytab class
1011
class FlpsummaryTab extends \Magento\Sales\Controller\Adminhtml\Order
1112
{
12-
/**
13-
* @var \Magento\Framework\View\LayoutFactory
14-
*/
15-
protected $layoutFactory;
1613

17-
/**
18-
* @param Action\Context $context
19-
* @param \Magento\Framework\Registry $coreRegistry
20-
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
21-
* @param \Magento\Framework\Translate\InlineInterface $translateInline
22-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
23-
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
24-
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
25-
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
26-
* @param OrderManagementInterface $orderManagement
27-
* @param OrderRepositoryInterface $orderRepository
28-
* @param LoggerInterface $logger
29-
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
30-
*
31-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
32-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
33-
*/
14+
// used for LayoutFactory
15+
protected $layout_factorys;
16+
17+
// construct function
3418
public function __construct(
35-
Action\Context $context,
36-
\Magento\Framework\Registry $coreRegistry,
37-
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
38-
\Magento\Framework\Translate\InlineInterface $translateInline,
39-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
40-
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
41-
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
42-
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
43-
OrderManagementInterface $orderManagement,
44-
OrderRepositoryInterface $orderRepository,
45-
LoggerInterface $logger,
46-
\Magento\Framework\View\LayoutFactory $layoutFactory
19+
Action\Context $contexts,
20+
\Magento\Framework\Registry $core_registrys,
21+
\Magento\Framework\App\Response\Http\FileFactory $file_factorys,
22+
\Magento\Framework\Translate\InlineInterface $translate_inlines,
23+
\Magento\Framework\View\Result\PageFactory $result_page_factorys,
24+
\Magento\Framework\Controller\Result\JsonFactory $result_json_factorys,
25+
\Magento\Framework\View\Result\LayoutFactory $result_layout_factorys,
26+
\Magento\Framework\Controller\Result\RawFactory $result_raw_factorys,
27+
OrderManagementInterface $order_managements,
28+
OrderRepositoryInterface $order_repositorys,
29+
LoggerInterface $loggers,
30+
\Magento\Framework\View\LayoutFactory $layout_factorys
4731
) {
48-
$this->layoutFactory = $layoutFactory;
32+
$this->layoutFactorys = $layout_factorys;
4933
parent::__construct(
50-
$context,
51-
$coreRegistry,
52-
$fileFactory,
53-
$translateInline,
54-
$resultPageFactory,
55-
$resultJsonFactory,
56-
$resultLayoutFactory,
57-
$resultRawFactory,
58-
$orderManagement,
59-
$orderRepository,
60-
$logger
34+
$contexts,
35+
$core_registrys,
36+
$file_factorys,
37+
$translate_inlines,
38+
$result_page_factorys,
39+
$result_json_factorys,
40+
$result_layout_factorys,
41+
$result_raw_factorys,
42+
$order_managements,
43+
$order_repositorys,
44+
$loggers
6145
);
6246
}
6347

64-
/**
65-
* Generate order history for ajax request
66-
*
67-
* @return \Magento\Framework\Controller\Result\Raw
68-
*/
48+
// execute function
6949
public function execute()
7050
{
51+
// initiliase order
7152
$this->_initOrder();
72-
$layout = $this->layoutFactory->create();
73-
$html = $layout->createBlock('Hexasoft\FraudLabsPro\Block\Adminhtml\Order\View\Tab\Flpsummary')
74-
->toHtml();
75-
$this->_translateInline->processResponseBody($html);
76-
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
77-
$resultRaw = $this->resultRawFactory->create();
78-
$resultRaw->setContents($html);
79-
return $resultRaw;
53+
54+
//create layout
55+
$layouts = $this->layoutFactorys->create();
56+
57+
//create block
58+
$htmls = $layouts->createBlock('Hexasoft\FraudLabsPro\Block\Adminhtml\Order\View\Tab\Flpsummary')->toHtml();
59+
60+
// process response body of block
61+
$this->_translateInline->processResponseBody($htmls);
62+
63+
// create result to be display
64+
$results = $this->resultRawFactory->create();
65+
66+
// set content of body
67+
$results->setContents($htmls);
68+
69+
return $results;
8070
}
8171
}

Controller/Observer.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ public function processSendRequestToFraudLabsPro($order) {
8787
}
8888

8989
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
90-
$xip = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])));
90+
$xip = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])));
9191

92-
if (filter_var($xip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
93-
$ip = $xip;
94-
}
95-
}
92+
if (filter_var($xip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
93+
$ip = $xip;
94+
}
95+
}
9696

9797
$payment_mode = $order->getPayment()->getMethod();
9898
if($payment_mode === 'ccsave'){
@@ -128,12 +128,14 @@ public function processSendRequestToFraudLabsPro($order) {
128128
'payment_mode' => $paymentMode,
129129
'flp_checksum' => '',
130130
'source' => 'magento',
131-
'source_version' => '2.0.5',
131+
'source_version' => '2.0.7',
132132
);
133133

134134
$shippingAddress = $order->getShippingAddress();
135135

136136
if($shippingAddress){
137+
$queries['ship_first_name'] = $shippingAddress->getFirstname();
138+
$queries['ship_last_name'] = $shippingAddress->getLastname();
137139
$queries['ship_addr'] = implode(" ", $shippingAddress->getStreet());
138140
$queries['ship_city'] = $shippingAddress->getCity();
139141
$queries['ship_state'] = $shippingAddress->getRegion();

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "hexasoft/module-fraudlabspro",
33
"description": "FraudLabs Pro Fraud Prevention plugin that screen the order transaction for online frauds. Fraud Prevention extension for Magento 2.",
4-
"version": "2.0.6",
4+
"version": "2.0.7",
55
"type": "magento2-module",
66
"require": {
77
"php": "~5.5.0|~5.6.0|~7.0.0"

0 commit comments

Comments
 (0)