Issues (570)

Gateway/Request/VoidRequest.php (4 issues)

Labels
Severity
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\ConfigInterface;
0 ignored issues
show
The type Magento\Payment\Gateway\ConfigInterface 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
0 ignored issues
show
The type Magento\Payment\Gateway\...mentDataObjectInterface 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Magento\Payment\Gateway\Request\BuilderInterface;
0 ignored issues
show
The type Magento\Payment\Gateway\Request\BuilderInterface 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Magento\Sales\Api\Data\OrderPaymentInterface;
0 ignored issues
show
The type Magento\Sales\Api\Data\OrderPaymentInterface 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * Class VoidRequest - Void data structure.
18
 */
19
class VoidRequest implements BuilderInterface
20
{
21
    /**
22
     * @var ConfigInterface
23
     */
24
    private $config;
25
26
    /**
27
     * @param ConfigInterface $config
28
     */
29
    public function __construct(
30
        ConfigInterface $config
31
    ) {
32
        $this->config = $config;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function build(array $buildSubject)
39
    {
40
        if (!isset($buildSubject['payment'])
41
            || !$buildSubject['payment'] instanceof PaymentDataObjectInterface
42
        ) {
43
            throw new \InvalidArgumentException('Payment data object should be provided');
44
        }
45
46
        $paymentDO = $buildSubject['payment'];
47
48
        $payment = $paymentDO->getPayment();
49
50
        if (!$payment instanceof OrderPaymentInterface) {
51
            throw new \LogicException('Order payment should be provided.');
52
        }
53
54
        return [
55
            'TXN_TYPE' => 'V',
56
            'TXN_ID'   => $payment->getLastTransId(),
57
        ];
58
    }
59
}
60