Completed
Pull Request — master (#64)
by
unknown
06:13 queued 10s
created

performGenericRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 26
rs 9.568
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\MethodSender;
9
10
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...
11
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...
12
use SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface;
13
use SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer;
14
use SprykerEco\Zed\Payone\Business\Api\Response\Container\GenericPaymentResponseContainer;
15
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface;
16
17
class PayoneGenericRequestMethodSender implements PayoneGenericRequestMethodSenderInterface
18
{
19
    /**
20
     * @var \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface
21
     */
22
    protected $executionAdapter;
23
24
    /**
25
     * @var \Generated\Shared\Transfer\PayoneStandardParameterTransfer
26
     */
27
    protected $standardParameter;
28
29
    /**
30
     * @var \SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface
31
     */
32
    protected $standartParameterMapper;
33
34
    /**
35
     * @param \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface $executionAdapter
36
     * @param \Generated\Shared\Transfer\PayoneStandardParameterTransfer $standardParameter
37
     * @param \SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface $standartParameterMapper
38
     */
39
    public function __construct(
40
        AdapterInterface $executionAdapter,
41
        PayoneStandardParameterTransfer $standardParameter,
42
        StandartParameterMapperInterface $standartParameterMapper
43
    ) {
44
        $this->executionAdapter = $executionAdapter;
45
        $this->standardParameter = $standardParameter;
46
        $this->standartParameterMapper = $standartParameterMapper;
47
    }
48
49
    /**
50
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\GenericPaymentContainer $requestContainer
51
     *
52
     * @return \Generated\Shared\Transfer\PayonePaypalExpressCheckoutGenericPaymentResponseTransfer
53
     */
54
    public function performGenericRequest(GenericPaymentContainer $requestContainer): PayonePaypalExpressCheckoutGenericPaymentResponseTransfer
55
    {
56
        $this->standartParameterMapper->setStandardParameter($requestContainer, $this->standardParameter);
57
58
        $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
59
        $responseContainer = new GenericPaymentResponseContainer($rawResponse);
60
        $responseTransfer = new PayonePaypalExpressCheckoutGenericPaymentResponseTransfer();
61
        $responseTransfer->setRedirectUrl($responseContainer->getRedirectUrl());
62
        $responseTransfer->setWorkOrderId($responseContainer->getWorkOrderId());
63
        $responseTransfer->setRawResponse(json_encode($rawResponse));
64
        $responseTransfer->setStatus($responseContainer->getStatus());
65
        $responseTransfer->setCustomerMessage($responseContainer->getCustomermessage());
66
        $responseTransfer->setErrorMessage($responseContainer->getErrormessage());
67
        $responseTransfer->setErrorCode($responseContainer->getErrorcode());
68
        $responseTransfer->setEmail($responseContainer->getEmail());
69
        $responseTransfer->setShippingFirstName($responseContainer->getShippingFirstname());
70
        $responseTransfer->setShippingLastName($responseContainer->getShippingLastname());
71
        $responseTransfer->setShippingCompany($responseContainer->getShippingCompany());
72
        $responseTransfer->setShippingCountry($responseContainer->getShippingCountry());
73
        $responseTransfer->setShippingState($responseContainer->getShippingState());
74
        $responseTransfer->setShippingStreet($responseContainer->getShippingStreet());
75
        $responseTransfer->setShippingAddressAdition($responseContainer->getShippingAddressaddition());
76
        $responseTransfer->setShippingCity($responseContainer->getShippingCity());
77
        $responseTransfer->setShippingZip($responseContainer->getShippingZip());
78
79
        return $responseTransfer;
80
    }
81
}
82