|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Wirecard Brasil. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See COPYING.txt for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Moip\Magento2\Gateway\Request; |
|
10
|
|
|
|
|
11
|
|
|
use Magento\Payment\Gateway\Request\BuilderInterface; |
|
|
|
|
|
|
12
|
|
|
use Moip\Magento2\Gateway\Config\Config; |
|
13
|
|
|
use Moip\Magento2\Gateway\SubjectReader; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class PurchasedItemsDataRequest - Data structure of purchased items. |
|
17
|
|
|
*/ |
|
18
|
|
|
class PurchasedItemsDataRequest implements BuilderInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* BillingAddress block name. |
|
22
|
|
|
*/ |
|
23
|
|
|
const PURCHASED_ITEMS = 'items'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The street address. Maximum 255 characters |
|
27
|
|
|
* Required. |
|
28
|
|
|
*/ |
|
29
|
|
|
const PURCHASED_ITEM_PRODUCT = 'product'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The street number. 1 or 10 alphanumeric digits |
|
33
|
|
|
* Required. |
|
34
|
|
|
*/ |
|
35
|
|
|
const PURCHASED_ITEM_QUANTITY = 'quantity'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The district address. Maximum 255 characters |
|
39
|
|
|
* Required. |
|
40
|
|
|
*/ |
|
41
|
|
|
const PURCHASED_ITEM_DETAIL = 'detail'; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* The complement address. Maximum 255 characters |
|
45
|
|
|
* Required. |
|
46
|
|
|
*/ |
|
47
|
|
|
const PURCHASED_ITEM_PRICE = 'price'; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var SubjectReader |
|
51
|
|
|
*/ |
|
52
|
|
|
private $subjectReader; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var Config |
|
56
|
|
|
*/ |
|
57
|
|
|
private $config; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param SubjectReader $subjectReader |
|
61
|
|
|
* @param Config $config |
|
62
|
|
|
*/ |
|
63
|
|
|
public function __construct( |
|
64
|
|
|
SubjectReader $subjectReader, |
|
65
|
|
|
Config $config |
|
66
|
|
|
) { |
|
67
|
|
|
$this->subjectReader = $subjectReader; |
|
68
|
|
|
$this->config = $config; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritdoc} |
|
73
|
|
|
*/ |
|
74
|
|
|
public function build(array $buildSubject) |
|
75
|
|
|
{ |
|
76
|
|
|
$paymentDO = $this->subjectReader->readPayment($buildSubject); |
|
77
|
|
|
|
|
78
|
|
|
$result = []; |
|
79
|
|
|
$order = $paymentDO->getOrder(); |
|
80
|
|
|
$items = $order->getItems(); |
|
81
|
|
|
$itemcount = count($items); |
|
82
|
|
|
if ($itemcount) { |
|
83
|
|
|
foreach ($items as $item) { |
|
84
|
|
|
if ($item->getParentItem()) { |
|
85
|
|
|
continue; |
|
86
|
|
|
} |
|
87
|
|
|
if ($item->getPrice() == 0) { |
|
88
|
|
|
continue; |
|
89
|
|
|
} |
|
90
|
|
|
if ($item->getPrice() > 0) { |
|
91
|
|
|
$result[self::PURCHASED_ITEMS][] = [ |
|
92
|
|
|
self::PURCHASED_ITEM_PRODUCT => $item->getName(), |
|
93
|
|
|
self::PURCHASED_ITEM_QUANTITY => $item->getQtyOrdered(), |
|
94
|
|
|
self::PURCHASED_ITEM_DETAIL => $item->getSku(), |
|
95
|
|
|
self::PURCHASED_ITEM_PRICE => $this->config->formatPrice($item->getPrice()), |
|
96
|
|
|
]; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
return $result; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths