1 | <?php |
||
2 | /** |
||
3 | * Copyright © Getnet. All rights reserved. |
||
4 | * |
||
5 | * @author Bruno Elisei <[email protected]> |
||
6 | * See LICENSE for license details. |
||
7 | */ |
||
8 | |||
9 | namespace Getnet\PaymentMagento\Gateway\Request; |
||
10 | |||
11 | use Getnet\PaymentMagento\Gateway\Config\Config; |
||
12 | use Getnet\PaymentMagento\Gateway\Data\Order\OrderAdapterFactory; |
||
0 ignored issues
–
show
|
|||
13 | use Getnet\PaymentMagento\Gateway\SubjectReader; |
||
14 | use InvalidArgumentException; |
||
15 | use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
||
16 | use Magento\Payment\Gateway\Request\BuilderInterface; |
||
17 | |||
18 | /** |
||
19 | * Class Subtotal Amount Data Request - Payment amount structure. |
||
20 | */ |
||
21 | class SubTotalAmountDataRequest implements BuilderInterface |
||
22 | { |
||
23 | /** |
||
24 | * Amount block name. |
||
25 | */ |
||
26 | public const AMOUNT = 'amount'; |
||
27 | |||
28 | /** |
||
29 | * @var SubjectReader |
||
30 | */ |
||
31 | protected $subjectReader; |
||
32 | |||
33 | /** |
||
34 | * @var OrderAdapterFactory |
||
35 | */ |
||
36 | protected $orderAdapterFactory; |
||
37 | |||
38 | /** |
||
39 | * @var Config |
||
40 | */ |
||
41 | protected $config; |
||
42 | |||
43 | /** |
||
44 | * @param SubjectReader $subjectReader |
||
45 | * @param OrderAdapterFactory $orderAdapterFactory |
||
46 | * @param Config $config |
||
47 | */ |
||
48 | public function __construct( |
||
49 | SubjectReader $subjectReader, |
||
50 | OrderAdapterFactory $orderAdapterFactory, |
||
51 | Config $config |
||
52 | ) { |
||
53 | $this->subjectReader = $subjectReader; |
||
54 | $this->orderAdapterFactory = $orderAdapterFactory; |
||
55 | $this->config = $config; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Build. |
||
60 | * |
||
61 | * @param array $buildSubject |
||
62 | */ |
||
63 | public function build(array $buildSubject) |
||
64 | { |
||
65 | if (!isset($buildSubject['payment']) |
||
66 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
||
67 | ) { |
||
68 | throw new InvalidArgumentException('Payment data object should be provided'); |
||
69 | } |
||
70 | |||
71 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||
72 | |||
73 | $result = []; |
||
74 | |||
75 | $order = $paymentDO->getOrder(); |
||
76 | |||
77 | $payment = $paymentDO->getPayment(); |
||
78 | |||
79 | /** @var OrderAdapterFactory $orderAdapter * */ |
||
80 | $orderAdapter = $this->orderAdapterFactory->create( |
||
81 | ['order' => $payment->getOrder()] |
||
82 | ); |
||
83 | |||
84 | $grandTotal = $order->getGrandTotalAmount(); |
||
85 | $tax = $orderAdapter->getTaxAmount(); |
||
86 | |||
87 | $total = $grandTotal - $tax; |
||
88 | |||
89 | $result[self::AMOUNT] = $this->config->formatPrice($total); |
||
90 | |||
91 | return $result; |
||
92 | } |
||
93 | } |
||
94 |
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