AdyenController::paymentCapture()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace App\Controller\Paypal;
4
5
use Adyen\AdyenException;
6
use App\Service\AdyenService;
7
use App\Service\PaypalService;
8
use App\Service\SettingsService;
9
use Symfony\Component\HttpFoundation\JsonResponse;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\Routing\Annotation\Route;
12
use Symfony\Component\HttpFoundation\Response;
13
use Symfony\Component\HttpFoundation\RedirectResponse;
14
15
/**
16
 * Class AdyenController
17
 * @package App\Controller\Paypal
18
 *
19
 * @Route("/paypal/adyen", name="paypal-adyen-")
20
 */
21
class AdyenController extends AbstractController
22
{
23
    /**
24
     * @var AdyenService
25
     */
26
    protected $adyenService;
27
28
    /**
29
     * @param AdyenService $adyenService
30
     * @param PaypalService $paypalService
31
     * @param SettingsService $settingsService
32
     */
33
    public function __construct(
34
        PaypalService $paypalService,
35
        SettingsService $settingsService,
36
        AdyenService $adyenService
37
    ) {
38
        $this->adyenService = $adyenService;
39
        return parent::__construct($paypalService, $settingsService);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::__construct($pay...vice, $settingsService) targeting App\Controller\Paypal\Ab...ntroller::__construct() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
40
    }
41
42
43
    /**
44
     * @Route("/", name="index", methods={"GET"})
45
     * @return Response | RedirectResponse
46
     * @throws AdyenException
47
     */
48
    public function index()
49
    {
50
        $paymentMethods = $this->adyenService->getPaymentMethods();
51
        $clientKey = $this->adyenService->getClientKey();
52
        $paypalId = $this->adyenService->getPayPalId();
53
        return $this->render('paypal/adyen/index.html.twig', [
54
            'paymentMethods' => $paymentMethods,
55
            'clientKey' => $clientKey,
56
            'paypalId' => $paypalId,
57
        ]);
58
    }
59
60
    /**
61
     * @Route("/make-payment", name="make-payment", methods={"POST"})
62
     * @return JsonResponse
63
     * @throws AdyenException
64
     */
65
    public function paymentMake()
66
    {
67
        $request = Request::createFromGlobals();
68
        $paymentData = $request->request->all();
69
        $action = $this->adyenService->makePayment($paymentData);
70
71
        return new JsonResponse($action);
72
    }
73
74
    /**
75
     * @Route("/payment-details", name="payment-details", methods={"POST"})
76
     * @return Response
77
     * @throws AdyenException
78
     */
79
    public function paymentDetails()
80
    {
81
        $request = Request::createFromGlobals();
82
        $paymentData = $request->request->all();
83
        $paymentDetails = $this->adyenService->paymentDetails($paymentData);
84
85
        return $this->render('default/dump-input-id.html.twig', [
86
            'result' => $paymentDetails,
87
            'raw_result' => false,
88
            'result_id' => $paymentDetails['pspReference'],
89
        ]);
90
    }
91
92
    /**
93
     * @Route("/payment-capture", name="payment-capture", methods={"POST"})
94
     * @return Response
95
     * @throws AdyenException
96
     */
97
    public function paymentCapture()
98
    {
99
        $request = Request::createFromGlobals();
100
        $paymentData = $request->request->all();
101
        $captureDetails = $this->adyenService->paymentCapture($paymentData);
102
103
        return $this->render('default/dump.html.twig', [
104
            'result' => $captureDetails,
105
            'raw_result' => false,
106
        ]);
107
    }
108
}
109