PayoneAuthorizeRequestSender::authorizePayment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Business\Payment\RequestSender;
9
10
use Generated\Shared\Transfer\AuthorizationResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...izationResponseTransfer 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...
11
use Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer 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 SprykerEco\Zed\Payone\Business\Api\Response\Mapper\AuthorizationResponseMapperInterface;
13
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\PayoneRequestProductDataMapperInterface;
14
use SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface;
15
use SprykerEco\Zed\Payone\Persistence\PayoneQueryContainerInterface;
16
17
class PayoneAuthorizeRequestSender extends AbstractPayoneRequestSender implements PayoneAuthorizeRequestSenderInterface
18
{
19
    /**
20
     * @var \SprykerEco\Zed\Payone\Business\Payment\DataMapper\PayoneRequestProductDataMapperInterface
21
     */
22
    protected $payoneRequestProductDataMapper;
23
24
    /**
25
     * @var \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneBaseAuthorizeSenderInterface
26
     */
27
    protected $baseAuthorizeSender;
28
29
    /**
30
     * @var \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\AuthorizationResponseMapperInterface
31
     */
32
    protected $authorizationResponseMapper;
33
34
    /**
35
     * @param \SprykerEco\Zed\Payone\Persistence\PayoneQueryContainerInterface $queryContainer
36
     * @param \SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface $paymentMapperReader
37
     * @param \SprykerEco\Zed\Payone\Business\Payment\DataMapper\PayoneRequestProductDataMapperInterface $payoneRequestProductDataMapper
38
     * @param \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneBaseAuthorizeSenderInterface $baseAuthorizeSender
39
     * @param \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\AuthorizationResponseMapperInterface $authorizationResponseMapper
40
     */
41
    public function __construct(
42
        PayoneQueryContainerInterface $queryContainer,
43
        PaymentMapperReaderInterface $paymentMapperReader,
44
        PayoneRequestProductDataMapperInterface $payoneRequestProductDataMapper,
45
        PayoneBaseAuthorizeSenderInterface $baseAuthorizeSender,
46
        AuthorizationResponseMapperInterface $authorizationResponseMapper
47
    ) {
48
        parent::__construct($queryContainer, $paymentMapperReader);
49
        $this->payoneRequestProductDataMapper = $payoneRequestProductDataMapper;
50
        $this->baseAuthorizeSender = $baseAuthorizeSender;
51
        $this->authorizationResponseMapper = $authorizationResponseMapper;
52
    }
53
54
    /**
55
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
56
     *
57
     * @return \Generated\Shared\Transfer\AuthorizationResponseTransfer
58
     */
59
    public function authorizePayment(OrderTransfer $orderTransfer): AuthorizationResponseTransfer
60
    {
61
        $paymentEntity = $this->getPaymentEntity($orderTransfer->getIdSalesOrder());
62
        $paymentMethodMapper = $this->getPaymentMethodMapper($paymentEntity);
63
        $requestContainer = $paymentMethodMapper->mapPaymentToAuthorization($paymentEntity, $orderTransfer);
64
        $requestContainer = $this->payoneRequestProductDataMapper->mapProductData($orderTransfer, $requestContainer);
65
        $responseContainer = $this->baseAuthorizeSender->performAuthorizationRequest($paymentEntity, $requestContainer);
0 ignored issues
show
Bug introduced by
$requestContainer of type SprykerEco\Zed\Payone\Bu...bstractRequestContainer is incompatible with the type SprykerEco\Zed\Payone\Bu...ationContainerInterface expected by parameter $requestContainer of SprykerEco\Zed\Payone\Bu...mAuthorizationRequest(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

65
        $responseContainer = $this->baseAuthorizeSender->performAuthorizationRequest($paymentEntity, /** @scrutinizer ignore-type */ $requestContainer);
Loading history...
66
67
        return $this->authorizationResponseMapper->getAuthorizationResponseTransfer($responseContainer);
68
    }
69
}
70