Issues (139)

Plugin/PaymentToken.php (2 issues)

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
declare(strict_types=1);
10
11
namespace Getnet\PaymentMagento\Plugin;
12
13
use Magento\Sales\Api\Data\OrderPaymentInterface;
14
use Magento\Vault\Api\Data\PaymentTokenInterface;
15
use Magento\Vault\Api\PaymentTokenManagementInterface;
16
17
/**
18
 * Class Payment Token Management Interface - Corrected duplicity.
19
 */
20
class PaymentToken
21
{
22
    /**
23
     * Around Save Token With Payment Link.
24
     *
25
     * @param PaymentTokenManagementInterface $paymentTokenManagement
26
     * @param callable                        $proceed
27
     * @param PaymentTokenInterface           $token
28
     * @param OrderPaymentInterface           $payment
29
     *
30
     * @return $proceed
0 ignored issues
show
Documentation Bug introduced by
The doc comment $proceed at position 0 could not be parsed: Unknown type name '$proceed' at position 0 in $proceed.
Loading history...
31
     */
32
    public function aroundSaveTokenWithPaymentLink(
33
        PaymentTokenManagementInterface $paymentTokenManagement,
34
        callable $proceed,
35
        PaymentTokenInterface $token,
36
        OrderPaymentInterface $payment
37
    ): bool {
38
        $order = $payment->getOrder();
39
40
        if ($order->getCustomerIsGuest()) {
41
            return $proceed($token, $payment);
42
        }
43
44
        $existingToken = $paymentTokenManagement->getByGatewayToken(
45
            $token->getGatewayToken(),
46
            $payment->getMethodInstance()->getCode(),
0 ignored issues
show
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

46
            $payment->/** @scrutinizer ignore-call */ 
47
                      getMethodInstance()->getCode(),

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...
47
            $order->getCustomerId()
48
        );
49
50
        if ($existingToken === null) {
51
            return $proceed($token, $payment);
52
        }
53
54
        $existingToken->addData($token->getData());
55
56
        return $proceed($existingToken, $payment);
57
    }
58
}
59