Passed
Branch feature/ECO-808-scrutinizer (bde35b)
by Andrey
07:45
created

IpnPaymentCaptureCompletedHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOmsStatusName() 0 3 1
A handle() 0 18 3
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Ipn;
9
10
use Spryker\Shared\Kernel\Transfer\AbstractTransfer;
11
use SprykerEco\Shared\Amazonpay\AmazonpayConstants;
12
13
class IpnPaymentCaptureCompletedHandler extends IpnAbstractPaymentCaptureHandler
14
{
15
16
    /**
17
     * @return string
18
     */
19
    protected function getOmsStatusName()
20
    {
21
        return AmazonpayConstants::OMS_STATUS_CAPTURE_COMPLETED;
22
    }
23
24
    /**
25
     * @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer|\Generated\Shared\Transfer\AmazonpayIpnPaymentCaptureRequestTransfer $amazonpayIpnRequestTransfer
26
     *
27
     * @return void
28
     */
29
    public function handle(AbstractTransfer $amazonpayIpnRequestTransfer)
30
    {
31
        $paymentEntity = $this->retrievePaymentEntity($amazonpayIpnRequestTransfer);
32
33
        if (!$paymentEntity) {
34
            $paymentEntity = $this->amazonpayQueryContainer->queryPaymentByAuthorizationReferenceId(
35
                $amazonpayIpnRequestTransfer->getCaptureDetails()->getCaptureReferenceId()
0 ignored issues
show
Bug introduced by
The method getCaptureDetails() does not exist on Spryker\Shared\Kernel\Transfer\AbstractTransfer. It seems like you code against a sub-type of Spryker\Shared\Kernel\Transfer\AbstractTransfer such as Generated\Shared\Transfe...azonpayResponseTransfer or Generated\Shared\Transfer\AmazonpayPaymentTransfer or Generated\Shared\Transfe...tCaptureRequestTransfer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
                $amazonpayIpnRequestTransfer->/** @scrutinizer ignore-call */ getCaptureDetails()->getCaptureReferenceId()
Loading history...
36
            )
37
                ->findOne();
38
39
            if ($paymentEntity) {
40
                $paymentEntity->setAmazonCaptureId($amazonpayIpnRequestTransfer->getCaptureDetails()->getAmazonCaptureId())
41
                    ->setCaptureReferenceId($amazonpayIpnRequestTransfer->getCaptureDetails()->getCaptureReferenceId())
42
                    ->save();
43
            }
44
        }
45
46
        parent::handle($amazonpayIpnRequestTransfer);
47
    }
48
49
}
50