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

OrderAuthFailedNotifyTransaction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 2
A __construct() 0 6 1
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\Transaction\Notification;
9
10
use Generated\Shared\Transfer\AmazonpayCallTransfer;
11
use SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction\AmazonpayTransactionInterface;
12
13
class OrderAuthFailedNotifyTransaction implements AmazonpayTransactionInterface
14
{
15
16
    /**
17
     * @var \SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction\Notification\OrderNotificationSenderInterface
18
     */
19
    protected $orderFailedAuthNotificationSender;
20
21
    /**
22
     * @var \SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction\Notification\OrderMessageFactoryInterface
23
     */
24
    protected $orderMessageFactory;
25
26
    /**
27
     * @param \SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction\Notification\OrderNotificationSenderInterface $orderFailedAuthNotificationSender
28
     * @param \SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction\Notification\OrderMessageFactoryInterface $orderMessageFactory
29
     */
30
    public function __construct(
31
        OrderNotificationSenderInterface $orderFailedAuthNotificationSender,
32
        OrderMessageFactoryInterface $orderMessageFactory
33
    ) {
34
        $this->orderFailedAuthNotificationSender = $orderFailedAuthNotificationSender;
35
        $this->orderMessageFactory = $orderMessageFactory;
36
    }
37
38
    /**
39
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
40
     *
41
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
42
     */
43
    public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)
44
    {
45
        $message = $this->orderMessageFactory->createFailedAuthMessage($amazonpayCallTransfer);
46
47
        if ($amazonpayCallTransfer->getAmazonpayPayment()
48
                ->getAuthorizationDetails()
49
                ->getAuthorizationStatus()
50
                ->getIsDeclined()
51
        ) {
52
            $this->orderFailedAuthNotificationSender->notify($message);
53
        }
54
55
        return $amazonpayCallTransfer;
56
    }
57
58
}
59