Success::getPayment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\PaymentMagento\Block\Order;
10
11
use Magento\Checkout\Model\Session;
12
use Magento\Framework\App\Http\Context as HttpContext;
13
use Magento\Framework\View\Element\Template;
14
use Magento\Framework\View\Element\Template\Context;
15
use Magento\Sales\Model\Order\Config;
16
17
/**
18
 * Class Success - Success page information.
19
 */
20
class Success extends Template
21
{
22
    /**
23
     * @var Session
24
     */
25
    protected $checkoutSession;
26
27
    /**
28
     * @var Config
29
     */
30
    protected $orderConfig;
31
32
    /**
33
     * @var HttpContext
34
     */
35
    protected $httpContext;
36
37
    /**
38
     * @param Context     $context
39
     * @param Session     $checkoutSession
40
     * @param Config      $orderConfig
41
     * @param HttpContext $httpContext
42
     * @param array       $data
43
     */
44
    public function __construct(
45
        Context $context,
46
        Session $checkoutSession,
47
        Config $orderConfig,
48
        HttpContext $httpContext,
49
        array $data = []
50
    ) {
51
        parent::__construct($context, $data);
52
        $this->checkoutSession = $checkoutSession;
53
        $this->orderConfig = $orderConfig;
54
        $this->httpContext = $httpContext;
55
    }
56
57
    /**
58
     * Get Payment.
59
     *
60
     * @return \Magento\Payment\Model\MethodInterface
61
     */
62
    public function getPayment()
63
    {
64
        $order = $this->checkoutSession->getLastRealOrder();
65
66
        return $order->getPayment()->getMethodInstance();
0 ignored issues
show
Bug introduced by
The method getMethodInstance() does not exist on Magento\Sales\Api\Data\OrderPaymentInterface. Did you maybe mean getMethod()? ( Ignorable by Annotation )

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

66
        return $order->getPayment()->/** @scrutinizer ignore-call */ getMethodInstance();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
    }
68
69
    /**
70
     * Method Code.
71
     *
72
     * @return string
73
     */
74
    public function getMethodCode()
75
    {
76
        return $this->getPayment()->getCode();
77
    }
78
79
    /**
80
     * Info payment.
81
     *
82
     * @param string $info
83
     *
84
     * @return string
85
     */
86
    public function getInfo(string $info)
87
    {
88
        return  $this->getPayment()->getInfoInstance()->getAdditionalInformation($info);
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Payment\Model\Me...face::getInfoInstance() has been deprecated: 100.0.2 ( Ignorable by Annotation )

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

88
        return  /** @scrutinizer ignore-deprecated */ $this->getPayment()->getInfoInstance()->getAdditionalInformation($info);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
89
    }
90
91
    /**
92
     * Get Url to Image Qr Code.
93
     *
94
     * @param string $qrCode
95
     *
96
     * @return string
97
     */
98
    public function getImageQrCode($qrCode)
99
    {
100
        return $this->_urlBuilder->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]).$qrCode;
101
    }
102
}
103