Passed
Pull Request — master (#4)
by Andrey
06:53 queued 03:48
created

GetOrderReferenceDetailsTransaction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B execute() 0 31 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\Transaction;
9
10
use Generated\Shared\Transfer\AmazonpayCallTransfer;
11
use Generated\Shared\Transfer\AmazonpayStatusTransfer;
12
use SprykerEco\Shared\Amazonpay\AmazonpayConstants;
13
14
class GetOrderReferenceDetailsTransaction extends AbstractAmazonpayTransaction
15
{
16
17
    /**
18
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
19
     *
20
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
21
     */
22
    public function execute(AmazonpayCallTransfer $amazonpayCallTransfer)
23
    {
24
        $amazonpayCallTransfer = parent::execute($amazonpayCallTransfer);
25
26
        if ($amazonpayCallTransfer->getAmazonpayPayment()->getResponseHeader()->getIsSuccess()) {
27
            $amazonpayCallTransfer->setShippingAddress($this->apiResponse->getShippingAddress());
28
29
            if ($this->apiResponse->getBillingAddress()) {
30
                $amazonpayCallTransfer->setBillingAddress($this->apiResponse->getBillingAddress());
31
            } else {
32
                $amazonpayCallTransfer->setBillingAddress($this->apiResponse->getShippingAddress());
33
                $amazonpayCallTransfer->setBillingSameAsShipping(true);
34
            }
35
36
            $amazonpayCallTransfer->getAmazonpayPayment()->setIsSandbox(
37
                $this->apiResponse->getIsSandbox()
38
            );
39
            $amazonpayCallTransfer->setOrderReference(
40
                $amazonpayCallTransfer->getAmazonpayPayment()->getOrderReferenceId()
41
            );
42
43
            $orderReferenceStatus = new AmazonpayStatusTransfer();
44
            $orderReferenceStatus->setState($this->apiResponse->getOrderReferenceStatus());
0 ignored issues
show
Bug introduced by
$this->apiResponse->getOrderReferenceStatus() of type Generated\Shared\Transfer\AmazonpayStatusTransfer is incompatible with the type string expected by parameter $state of Generated\Shared\Transfe...tusTransfer::setState(). ( Ignorable by Annotation )

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

44
            $orderReferenceStatus->setState(/** @scrutinizer ignore-type */ $this->apiResponse->getOrderReferenceStatus());
Loading history...
45
            $orderReferenceStatus->setIsOpen(
46
                $this->apiResponse->getOrderReferenceStatus() === AmazonpayConstants::ORDER_REFERENCE_STATUS_OPEN
47
            );
48
49
            $amazonpayCallTransfer->getAmazonpayPayment()->setOrderReferenceStatus($orderReferenceStatus);
50
        }
51
52
        return $amazonpayCallTransfer;
53
    }
54
55
}
56