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 | declare(strict_types=1); |
||||
10 | |||||
11 | namespace Moip\Magento2\Gateway\Http\Client; |
||||
12 | |||||
13 | use InvalidArgumentException; |
||||
14 | use Magento\Framework\HTTP\ZendClient; |
||||
0 ignored issues
–
show
|
|||||
15 | use Magento\Framework\HTTP\ZendClientFactory; |
||||
0 ignored issues
–
show
The type
Magento\Framework\HTTP\ZendClientFactory was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
16 | use Magento\Framework\Serialize\Serializer\Json; |
||||
0 ignored issues
–
show
The type
Magento\Framework\Serialize\Serializer\Json was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
17 | use Magento\Payment\Gateway\Http\ClientInterface; |
||||
0 ignored issues
–
show
The type
Magento\Payment\Gateway\Http\ClientInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
18 | use Magento\Payment\Gateway\Http\TransferInterface; |
||||
0 ignored issues
–
show
The type
Magento\Payment\Gateway\Http\TransferInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
19 | use Magento\Payment\Model\Method\Logger; |
||||
0 ignored issues
–
show
The type
Magento\Payment\Model\Method\Logger was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
20 | use Moip\Magento2\Gateway\Config\Config; |
||||
21 | |||||
22 | /** |
||||
23 | * Class FetchTransactionInfoClient - Returns order query. |
||||
24 | */ |
||||
25 | class FetchTransactionInfoClient implements ClientInterface |
||||
26 | { |
||||
27 | const MOIP_ORDER_ID = 'moip_order_id'; |
||||
28 | |||||
29 | /** |
||||
30 | * @var LoggerInterface |
||||
0 ignored issues
–
show
The type
Moip\Magento2\Gateway\Http\Client\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
31 | */ |
||||
32 | private $logger; |
||||
33 | |||||
34 | /** |
||||
35 | * @var ZendClientFactory |
||||
36 | */ |
||||
37 | private $httpClientFactory; |
||||
38 | |||||
39 | /** |
||||
40 | * @var Config |
||||
41 | */ |
||||
42 | private $config; |
||||
43 | |||||
44 | /** |
||||
45 | * @var Json |
||||
46 | */ |
||||
47 | private $json; |
||||
48 | |||||
49 | /** |
||||
50 | * @param Logger $logger |
||||
51 | * @param ZendClientFactory $httpClientFactory |
||||
52 | * @param Config $config |
||||
53 | * @param Json $json |
||||
54 | */ |
||||
55 | public function __construct( |
||||
56 | Logger $logger, |
||||
57 | ZendClientFactory $httpClientFactory, |
||||
58 | Config $config, |
||||
59 | Json $json |
||||
60 | ) { |
||||
61 | $this->config = $config; |
||||
62 | $this->httpClientFactory = $httpClientFactory; |
||||
63 | $this->logger = $logger; |
||||
64 | $this->json = $json; |
||||
65 | } |
||||
66 | |||||
67 | /** |
||||
68 | * Places request to gateway. |
||||
69 | * |
||||
70 | * @param TransferInterface $transferObject |
||||
71 | * |
||||
72 | * @return array |
||||
73 | */ |
||||
74 | public function placeRequest(TransferInterface $transferObject) |
||||
75 | { |
||||
76 | $client = $this->httpClientFactory->create(); |
||||
77 | $request = $transferObject->getBody(); |
||||
78 | $url = $this->config->getApiUrl(); |
||||
79 | $apiBearer = $this->config->getMerchantGatewayOauth(); |
||||
80 | $orderMoip = $request[self::MOIP_ORDER_ID]; |
||||
81 | |||||
82 | try { |
||||
83 | $client->setUri($url.'orders/'.$orderMoip); |
||||
84 | $client->setConfig(['maxredirects' => 0, 'timeout' => 120]); |
||||
85 | $client->setHeaders('Authorization', 'Bearer '.$apiBearer); |
||||
86 | $client->setMethod(ZendClient::GET); |
||||
87 | |||||
88 | $responseBody = $client->request()->getBody(); |
||||
89 | $data = $this->json->unserialize($responseBody); |
||||
90 | if (isset($data['status'])) { |
||||
91 | $cancelDetailsAdmin = __('We did not record the payment.'); |
||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
92 | $cancelDetailsCus = __('The payment deadline has been exceeded.'); |
||||
93 | if (isset($data['payments'])) { |
||||
94 | foreach ($data['payments'] as $payment) { |
||||
95 | if (isset($payment['cancellationDetails'])) { |
||||
96 | $cancelCode = $payment['cancellationDetails']['code']; |
||||
97 | $cancelDescription = $payment['cancellationDetails']['description']; |
||||
98 | $cancelBy = $payment['cancellationDetails']['cancelledBy']; |
||||
99 | $cancelDetailsAdmin = __('%1, code %2, by %3', $cancelDescription, $cancelCode, $cancelBy); |
||||
100 | $cancelDetailsCus = __('%1', $cancelDescription); |
||||
101 | } |
||||
102 | } |
||||
103 | } |
||||
104 | $response = array_merge( |
||||
105 | [ |
||||
106 | 'RESULT_CODE' => 1, |
||||
107 | 'STATUS' => $data['status'], |
||||
108 | 'CANCELLATION_DETAILS_CUSTOMER' => $cancelDetailsCus, |
||||
109 | 'CANCELLATION_DETAILS_ADMIN' => $cancelDetailsAdmin, |
||||
110 | ], |
||||
111 | $data |
||||
112 | ); |
||||
113 | } else { |
||||
114 | $response = array_merge( |
||||
115 | [ |
||||
116 | 'RESULT_CODE' => 0, |
||||
117 | ], |
||||
118 | $data |
||||
119 | ); |
||||
120 | } |
||||
121 | $this->logger->debug( |
||||
122 | [ |
||||
123 | 'url' => $url.'orders/'.$orderMoip, |
||||
124 | 'response' => $responseBody, |
||||
125 | ] |
||||
126 | ); |
||||
127 | } catch (InvalidArgumentException $e) { |
||||
128 | // phpcs:ignore Magento2.Exceptions.DirectThrow |
||||
129 | throw new \Exception('Invalid JSON was returned by the gateway'); |
||||
130 | } |
||||
131 | |||||
132 | return $response; |
||||
133 | } |
||||
134 | } |
||||
135 |
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