Passed
Push — master ( a2100c...af4f13 )
by Andrey
06:37
created

UpdateOrderRefundStatusTransaction::execute()   B

Complexity

Conditions 6
Paths 7

Size

Total Lines 25
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 12
nc 7
nop 1
dl 0
loc 25
rs 8.439
c 0
b 0
f 0
1
<?php
2
3
4
/**
5
 * Apache OSL-2
6
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
7
 */
8
9
namespace SprykerEco\Zed\Amazonpay\Business\Payment\Handler\Transaction;
10
11
use Generated\Shared\Transfer\OrderTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer 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
use SprykerEco\Shared\Amazonpay\AmazonpayConstants;
13
14
class UpdateOrderRefundStatusTransaction extends AbstractOrderTransaction
15
{
16
17
    /**
18
     * @var \Generated\Shared\Transfer\AmazonpayRefundOrderResponseTransfer
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...ndOrderResponseTransfer 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...
19
     */
20
    protected $apiResponse;
21
22
    /**
23
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
24
     *
25
     * @return \Generated\Shared\Transfer\OrderTransfer
26
     */
27
    public function execute(OrderTransfer $orderTransfer)
28
    {
29
        if (!$orderTransfer->getAmazonpayPayment()->getRefundDetails()->getRefundStatus()->getIsPending()) {
30
            return $orderTransfer;
31
        }
32
33
        $orderTransfer = parent::execute($orderTransfer);
34
35
        if ($this->apiResponse->getHeader()->getIsSuccess()) {
36
            if ($this->apiResponse->getRefundDetails()->getRefundStatus()->getIsPending()) {
37
                return $orderTransfer;
38
            }
39
40
            if ($this->apiResponse->getRefundDetails()->getRefundStatus()->getIsDeclined()) {
41
                $this->paymentEntity->setStatus(AmazonpayConstants::OMS_STATUS_REFUND_DECLINED);
42
            }
43
44
            if ($this->apiResponse->getRefundDetails()->getRefundStatus()->getIsCompleted()) {
45
                $this->paymentEntity->setStatus(AmazonpayConstants::OMS_STATUS_REFUND_COMPLETED);
46
            }
47
48
            $this->paymentEntity->save();
49
        }
50
51
        return $orderTransfer;
52
    }
53
54
}
55