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

initPaypalExpressCheckout()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 16
rs 9.9666
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\PayoneInitPaypalExpressCheckoutRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...CheckoutRequestTransfer 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\PayonePaypalExpressCheckoutGenericPaymentResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...PaymentResponseTransfer 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\Shared\Payone\PayoneApiConstants;
13
use SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface;
14
15
class PayoneInitPaypalExpressCheckoutMethodSender implements PayoneInitPaypalExpressCheckoutMethodSenderInterface
16
{
17
    /**
18
     * @var \SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface
19
     */
20
    protected $paymentMapperReader;
21
22
    /**
23
     * @var \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneGenericRequestMethodSenderInterface
24
     */
25
    protected $genericRequestMethodSender;
26
27
    /**
28
     * @param \SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface $paymentMapperReader
29
     * @param \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneGenericRequestMethodSenderInterface $genericRequestMethodSender
30
     */
31
    public function __construct(
32
        PaymentMapperReaderInterface $paymentMapperReader,
33
        PayoneGenericRequestMethodSenderInterface $genericRequestMethodSender
34
    ) {
35
        $this->paymentMapperReader = $paymentMapperReader;
36
        $this->genericRequestMethodSender = $genericRequestMethodSender;
37
    }
38
39
    /**
40
     * @param \Generated\Shared\Transfer\PayoneInitPaypalExpressCheckoutRequestTransfer $requestTransfer
41
     *
42
     * @return \Generated\Shared\Transfer\PayonePaypalExpressCheckoutGenericPaymentResponseTransfer
43
     */
44
    public function initPaypalExpressCheckout(
45
        PayoneInitPaypalExpressCheckoutRequestTransfer $requestTransfer
46
    ): PayonePaypalExpressCheckoutGenericPaymentResponseTransfer {
47
        /** @var \SprykerEco\Zed\Payone\Business\Payment\GenericPaymentMethodMapperInterface $paymentMethodMapper */
48
        $paymentMethodMapper = $this->paymentMapperReader->getRegisteredPaymentMethodMapper(
49
            PayoneApiConstants::PAYMENT_METHOD_PAYPAL_EXPRESS_CHECKOUT
50
        );
51
        $baseGenericPaymentContainer = $paymentMethodMapper->createBaseGenericPaymentContainer();
52
        $baseGenericPaymentContainer->getPaydata()->setAction(PayoneApiConstants::PAYONE_EXPRESS_CHECKOUT_SET_ACTION);
53
        $requestContainer = $paymentMethodMapper->mapRequestTransferToGenericPayment(
54
            $baseGenericPaymentContainer,
55
            $requestTransfer
56
        );
57
        $responseTransfer = $this->genericRequestMethodSender->performGenericRequest($requestContainer);
58
59
        return $responseTransfer;
60
    }
61
}
62