|
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
|
|
|
$extra = $request->request->get('extra', null); |
|
28
|
|
|
if (($clientId && $clientSecret) || $extra) { |
|
29
|
|
|
$this->paypalService->getSessionService()->updateCredentials($clientId, $clientSecret, $extra); |
|
30
|
|
|
} |
|
31
|
|
|
return $this->redirectToRoute('paypal-index'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @Route("/sandbox-credentials/delete", name="sandbox-credentials-delete", methods={"GET"}) |
|
36
|
|
|
* |
|
37
|
|
|
* @return RedirectResponse |
|
38
|
|
|
*/ |
|
39
|
|
|
public function sandboxCredentialsDelete() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->paypalService->getSessionService()->removeCredentials(); |
|
42
|
|
|
|
|
43
|
|
|
return $this->redirectToRoute('paypal-index'); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|