Passed
Push — feature/eco-2635-amazon-psd2-a... ( e3557f...8790e7 )
by Volodymyr
04:26
created

AmazonpayPaymentWriter::getConfirmedOrderStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
4
namespace SprykerEco\Zed\AmazonPay\Business\Payment\Writer;
5
6
7
use Generated\Shared\Transfer\AmazonpayPaymentTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\AmazonpayPaymentTransfer 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...
8
use Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay;
1 ignored issue
show
Bug introduced by
The type Orm\Zed\AmazonPay\Persistence\SpyPaymentAmazonpay 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...
9
10
class AmazonpayPaymentWriter implements AmazonpayPaymentWriterInterface
11
{
12
    /**
13
     * @param AmazonpayPaymentTransfer $amazonpayPaymentTransfer
14
     *
15
     * @return bool
16
     */
17
    public function writerConfirmedAmazonPayPayment(AmazonpayPaymentTransfer $amazonpayPaymentTransfer): bool
18
    {
19
        $paymentEntity = new SpyPaymentAmazonpay();
20
        $paymentEntity->setOrderReferenceId($amazonpayPaymentTransfer->getOrderReferenceId());
21
        $status = $this->getConfirmedOrderStatus($amazonpayPaymentTransfer);
22
        $paymentEntity->setStatus($status);
23
        $paymentEntity->setSellerOrderId($amazonpayPaymentTransfer->getSellerOrderId());
24
25
        $paymentEntity->setAuthorizationReferenceId(
26
            $amazonpayPaymentTransfer->getAuthorizationDetails()->getAuthorizationReferenceId()
27
        );
28
29
        $paymentEntity->setAmazonAuthorizationId(
30
            $amazonpayPaymentTransfer->getAuthorizationDetails()->getAmazonAuthorizationId()
31
        );
32
33
        $paymentEntity->setRequestId(
34
            $amazonpayPaymentTransfer->getResponseHeader()->getRequestId()
35
        );
36
37
        $paymentEntity->setIsSandbox($amazonpayPaymentTransfer->getIsSandbox());
38
39
        return $paymentEntity->save();
40
    }
41
42
    /**
43
     * @param \Generated\Shared\Transfer\AmazonpayPaymentTransfer $paymentTransfer
44
     *
45
     * @return string
46
     */
47
    protected function getConfirmedOrderStatus(AmazonpayPaymentTransfer $paymentTransfer)
48
    {
49
        return $paymentTransfer->getOrderReferenceStatus()->getState();
50
    }
51
}
52