Completed
Pull Request — master (#15)
by Cesar
01:41
created

SessionController::sandboxCredentialsDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Controller\Paypal;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\Routing\Annotation\Route;
8
9
/**
10
 * Class SessionController
11
 * @package App\Controller\Paypal
12
 *
13
 * @Route("/paypal/session", name="paypal-session-")
14
 */
15
class SessionController extends AbstractController
16
{
17
    /**
18
     * @Route("/sandbox-credentials", name="sandbox-credentials-create", methods={"POST"})
19
     *
20
     * @return RedirectResponse
21
     */
22
    public function sandboxCredentialsCreate()
23
    {
24
        $request = Request::createFromGlobals();
25
        $clientId = $request->request->get('client_id', null);
26
        $clientSecret = $request->request->get('client_secret', null);
27
        if ($clientId && $clientSecret) {
28
            $this->paypalService->getSessionService()->updateCredentials($clientId, $clientSecret);
29
        }
30
        return $this->redirectToRoute('paypal-index');
31
    }
32
33
    /**
34
     * @Route("/sandbox-credentials/delete", name="sandbox-credentials-delete", methods={"GET"})
35
     *
36
     * @return RedirectResponse
37
     */
38
    public function sandboxCredentialsDelete()
39
    {
40
        $this->paypalService->getSessionService()->removeCredentials();
41
42
        return $this->redirectToRoute('paypal-index');
43
    }
44
}
45