GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (5)

src/PaymentProcessing/RefundPaymentProcessor.php (1 issue)

1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusBraintreePlugin\PaymentProcessing;
14
15
use BitBag\SyliusBraintreePlugin\ApiClient\BraintreeApiClientInterface;
16
use BitBag\SyliusBraintreePlugin\BraintreeGatewayFactory;
17
use Sylius\Component\Core\Model\PaymentInterface;
18
use Sylius\Component\Core\Model\PaymentMethodInterface;
19
use Sylius\Component\Resource\Exception\UpdateHandlingException;
20
use Symfony\Component\HttpFoundation\Session\Session;
21
22
final class RefundPaymentProcessor implements PaymentProcessorInterface
23
{
24
    /** @var Session */
25
    private $session;
26
27
    /** @var BraintreeApiClientInterface */
28
    private $braintreeApiClient;
29
30
    public function __construct(Session $session, BraintreeApiClientInterface $braintreeApiClient)
31
    {
32
        $this->session = $session;
33
        $this->braintreeApiClient = $braintreeApiClient;
34
    }
35
36
    public function process(PaymentInterface $payment): void
37
    {
38
        /** @var PaymentMethodInterface $paymentMethod */
39
        $paymentMethod = $payment->getMethod();
40
41
        if (BraintreeGatewayFactory::FACTORY_NAME !== $paymentMethod->getGatewayConfig()->getFactoryName()) {
0 ignored issues
show
Deprecated Code introduced by
The function Payum\Core\Model\Gateway...rface::getFactoryName() has been deprecated: since 1.3.3 will be removed in 2.0. set factory option inside the config ( Ignorable by Annotation )

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

41
        if (BraintreeGatewayFactory::FACTORY_NAME !== /** @scrutinizer ignore-deprecated */ $paymentMethod->getGatewayConfig()->getFactoryName()) {

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...
42
            return;
43
        }
44
45
        $details = $payment->getDetails();
46
47
        if (false === isset($details['sale']['transaction']['id'])) {
48
            $this->session->getFlashBag()->add('info', 'The payment refund was made only locally.');
49
50
            return;
51
        }
52
53
        $gatewayConfig = $paymentMethod->getGatewayConfig()->getConfig();
54
55
        $this->braintreeApiClient->initialise($gatewayConfig);
56
57
        try {
58
            $result = $this->braintreeApiClient->refund($details['sale']['transaction']['id']);
59
60
            if (true === $result->success) {
61
                return;
62
            }
63
64
            throw new \RuntimeException($result->message);
65
        } catch (\Exception $exception) {
66
            $message = $exception->getMessage();
67
68
            $this->session->getFlashBag()->add('error', $message);
69
70
            throw new UpdateHandlingException();
71
        }
72
    }
73
}
74