InitIdealMapper::getMethodName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Computop\Business\Hook\Mapper\Init;
9
10
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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 Spryker\Shared\Kernel\Transfer\TransferInterface;
12
use SprykerEco\Shared\Computop\ComputopConfig;
13
use SprykerEco\Shared\Computop\Config\ComputopApiConfig;
14
15
class InitIdealMapper extends AbstractMapper
16
{
17
    /**
18
     * @return string
19
     */
20
    public function getMethodName()
21
    {
22
        return ComputopConfig::PAYMENT_METHOD_IDEAL;
23
    }
24
25
    /**
26
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
27
     * @param \Spryker\Shared\Kernel\Transfer\TransferInterface $computopPaymentTransfer
28
     *
29
     * @return \Spryker\Shared\Kernel\Transfer\TransferInterface
30
     */
31
    public function updateComputopPaymentTransfer(QuoteTransfer $quoteTransfer, TransferInterface $computopPaymentTransfer)
32
    {
33
        /** @var \Generated\Shared\Transfer\ComputopIdealPaymentTransfer $computopPaymentTransfer */
34
        $computopPaymentTransfer = parent::updateComputopPaymentTransfer($quoteTransfer, $computopPaymentTransfer);
35
        $computopPaymentTransfer->setMerchantId($this->config->getMerchantId());
36
        $computopPaymentTransfer->setAmount($quoteTransfer->getTotals()->getGrandTotal());
37
        $computopPaymentTransfer->setMac(
38
            $this->computopApiService->generateEncryptedMac(
39
                $this->createRequestTransfer($computopPaymentTransfer)
40
            )
41
        );
42
43
        $decryptedValues = $this->computopApiService->getEncryptedArray(
44
            $this->getDataSubArray($computopPaymentTransfer),
45
            $this->config->getBlowfishPass()
46
        );
47
48
        $length = $decryptedValues[ComputopApiConfig::LENGTH];
49
        $data = $decryptedValues[ComputopApiConfig::DATA];
50
51
        $computopPaymentTransfer->setData($data);
52
        $computopPaymentTransfer->setLen($length);
53
        $computopPaymentTransfer->setUrl($this->getUrlToComputop($computopPaymentTransfer->getMerchantId(), $data, $length));
54
55
        return $computopPaymentTransfer;
56
    }
57
58
    /**
59
     * @param \Generated\Shared\Transfer\ComputopIdealPaymentTransfer $computopIdealPaymentTransfer
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...topIdealPaymentTransfer 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...
60
     *
61
     * @return array
62
     */
63
    protected function getDataSubArray(TransferInterface $computopIdealPaymentTransfer)
64
    {
65
        /** @var \Generated\Shared\Transfer\ComputopIdealPaymentTransfer $computopIdealPaymentTransfer */
66
        $dataSubArray[ComputopApiConfig::TRANS_ID] = $computopIdealPaymentTransfer->getTransId();
0 ignored issues
show
Comprehensibility Best Practice introduced by
$dataSubArray was never initialized. Although not strictly required by PHP, it is generally a good practice to add $dataSubArray = array(); before regardless.
Loading history...
67
        $dataSubArray[ComputopApiConfig::AMOUNT] = $computopIdealPaymentTransfer->getAmount();
68
        $dataSubArray[ComputopApiConfig::CURRENCY] = $computopIdealPaymentTransfer->getCurrency();
69
        $dataSubArray[ComputopApiConfig::URL_SUCCESS] = $computopIdealPaymentTransfer->getUrlSuccess();
70
        $dataSubArray[ComputopApiConfig::URL_NOTIFY] = $computopIdealPaymentTransfer->getUrlNotify();
71
        $dataSubArray[ComputopApiConfig::URL_FAILURE] = $computopIdealPaymentTransfer->getUrlFailure();
72
        $dataSubArray[ComputopApiConfig::RESPONSE] = $computopIdealPaymentTransfer->getResponse();
73
        $dataSubArray[ComputopApiConfig::MAC] = $computopIdealPaymentTransfer->getMac();
74
        $dataSubArray[ComputopApiConfig::ORDER_DESC] = $computopIdealPaymentTransfer->getOrderDesc();
75
        $dataSubArray[ComputopApiConfig::ETI_ID] = $this->config->getEtiId();
76
        $dataSubArray[ComputopApiConfig::IP_ADDRESS] = $computopIdealPaymentTransfer->getClientIp();
77
        $dataSubArray[ComputopApiConfig::SHIPPING_ZIP] = $computopIdealPaymentTransfer->getShippingZip();
78
        $dataSubArray[ComputopApiConfig::ISSUER_ID] = $this->config->getIdealIssuerId();
79
80
        return $dataSubArray;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    protected function getActionUrl()
87
    {
88
        return $this->config->getIdealInitAction();
89
    }
90
}
91