Completed
Push — master ( 9db63e...40913a )
by Oleksandr
24s queued 13s
created

PayoneCreditCardChecker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 5
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\Checker;
9
10
use Generated\Shared\Transfer\CreditCardCheckResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rdCheckResponseTransfer 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\PayoneCreditCardTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PayoneCreditCardTransfer 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 Generated\Shared\Transfer\PayoneStandardParameterTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...andardParameterTransfer 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 SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface;
14
use SprykerEco\Zed\Payone\Business\Api\Response\Container\CreditCardCheckResponseContainer;
15
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CreditCardCheckResponseMapperInterface;
16
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface;
17
use SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface;
18
19
class PayoneCreditCardChecker implements PayoneCreditCardCheckerInterface
20
{
21
    /**
22
     * @var \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface
23
     */
24
    protected $executionAdapter;
25
26
    /**
27
     * @var \Generated\Shared\Transfer\PayoneStandardParameterTransfer
28
     */
29
    protected $standardParameter;
30
31
    /**
32
     * @var \SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface
33
     */
34
    protected $standartParameterMapper;
35
36
    /**
37
     * @var \SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface
38
     */
39
    protected $paymentMapperReader;
40
41
    /**
42
     * @var \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CreditCardCheckResponseMapperInterface
43
     */
44
    protected $creditCardCheckResponseMapper;
45
46
    /**
47
     * @param \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface $executionAdapter
48
     * @param \Generated\Shared\Transfer\PayoneStandardParameterTransfer $standardParameter
49
     * @param \SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface $standartParameterMapper
50
     * @param \SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface $paymentMapperReader
51
     * @param \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CreditCardCheckResponseMapperInterface $creditCardCheckResponseMapper
52
     */
53
    public function __construct(
54
        AdapterInterface $executionAdapter,
55
        PayoneStandardParameterTransfer $standardParameter,
56
        StandartParameterMapperInterface $standartParameterMapper,
57
        PaymentMapperReaderInterface $paymentMapperReader,
58
        CreditCardCheckResponseMapperInterface $creditCardCheckResponseMapper
59
    ) {
60
        $this->executionAdapter = $executionAdapter;
61
        $this->standardParameter = $standardParameter;
62
        $this->standartParameterMapper = $standartParameterMapper;
63
        $this->paymentMapperReader = $paymentMapperReader;
64
        $this->creditCardCheckResponseMapper = $creditCardCheckResponseMapper;
65
    }
66
67
    /**
68
     * @param \Generated\Shared\Transfer\PayoneCreditCardTransfer $creditCardData
69
     *
70
     * @return \Generated\Shared\Transfer\CreditCardCheckResponseTransfer
71
     */
72
    public function creditCardCheck(PayoneCreditCardTransfer $creditCardData): CreditCardCheckResponseTransfer
73
    {
74
        /** @var \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\CreditCardPseudo $paymentMethodMapper */
75
        $paymentMethodMapper = $this->paymentMapperReader->getRegisteredPaymentMethodMapper($creditCardData->getPayment()->getPaymentMethod());
76
        $requestContainer = $paymentMethodMapper->mapCreditCardCheck($creditCardData);
77
78
        $this->standartParameterMapper->setStandardParameter($requestContainer, $this->standardParameter);
79
80
        $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
81
        $responseContainer = new CreditCardCheckResponseContainer($rawResponse);
82
83
        return $this->creditCardCheckResponseMapper->getCreditCardCheckResponseTransfer($responseContainer);
84
    }
85
}
86