SofortResponseSaver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 6
eloc 23
c 4
b 1
f 0
dl 0
loc 60
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A savePaymentComputopOrderItemsEntities() 0 5 2
A save() 0 15 2
A savePaymentComputopDetailEntity() 0 8 1
A savePaymentComputopEntity() 0 6 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\Computop\Business\Payment\Handler\Saver\Init;
9
10
use Generated\Shared\Transfer\ComputopSofortInitResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ortInitResponseTransfer 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\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...
12
13
class SofortResponseSaver extends AbstractResponseSaver
14
{
15
    /**
16
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
17
     *
18
     * @return \Generated\Shared\Transfer\QuoteTransfer
19
     */
20
    public function save(QuoteTransfer $quoteTransfer)
21
    {
22
        $responseTransfer = $quoteTransfer->getPayment()->getComputopSofort()->getSofortInitResponse();
23
        $this->setPaymentEntity($responseTransfer->getHeader()->getTransId());
24
        if ($responseTransfer->getHeader()->getIsSuccess()) {
25
            $this->getTransactionHandler()->handleTransaction(
26
                function () use ($responseTransfer) {
27
                    $this->savePaymentComputopEntity($responseTransfer);
28
                    $this->savePaymentComputopDetailEntity($responseTransfer);
29
                    $this->savePaymentComputopOrderItemsEntities();
30
                }
31
            );
32
        }
33
34
        return $quoteTransfer;
35
    }
36
37
    /**
38
     * @param \Generated\Shared\Transfer\ComputopSofortInitResponseTransfer $responseTransfer
39
     *
40
     * @return void
41
     */
42
    protected function savePaymentComputopEntity(ComputopSofortInitResponseTransfer $responseTransfer)
43
    {
44
        $paymentEntity = $this->getPaymentEntity();
45
        $paymentEntity->setPayId($responseTransfer->getHeader()->getPayId());
46
        $paymentEntity->setXId($responseTransfer->getHeader()->getXId());
47
        $paymentEntity->save();
48
    }
49
50
    /**
51
     * @param \Generated\Shared\Transfer\ComputopSofortInitResponseTransfer $responseTransfer
52
     *
53
     * @return void
54
     */
55
    protected function savePaymentComputopDetailEntity(ComputopSofortInitResponseTransfer $responseTransfer)
56
    {
57
        $paymentEntityDetails = $this->getPaymentEntity()->getSpyPaymentComputopDetail();
58
        $paymentEntityDetails->setAccountOwner($responseTransfer->getAccountOwner());
59
        $paymentEntityDetails->setAccountBank($responseTransfer->getAccountBank());
60
        $paymentEntityDetails->setBankAccountBic($responseTransfer->getBankAccountBic());
61
        $paymentEntityDetails->setBankAccountIban($responseTransfer->getBankAccountIban());
62
        $paymentEntityDetails->save();
63
    }
64
65
    /**
66
     * @return void
67
     */
68
    protected function savePaymentComputopOrderItemsEntities()
69
    {
70
        foreach ($this->getPaymentEntity()->getSpyPaymentComputopOrderItems() as $item) {
71
            $item->setStatus($this->config->getOmsStatusCaptured());
72
            $item->save();
73
        }
74
    }
75
}
76