1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controller\Hyperwallet; |
4
|
|
|
|
5
|
|
|
use Hyperwallet\Exception\HyperwalletApiException; |
6
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
8
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class PaymentsController |
13
|
|
|
* @package App\Controller\Hyperwallet |
14
|
|
|
* |
15
|
|
|
* @Route("/hyperwallet/payments", name="hyperwallet-payments-") |
16
|
|
|
*/ |
17
|
|
|
class PaymentsController extends AbstractController |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @Route("/", name="index", methods={"GET"}) |
21
|
|
|
* |
22
|
|
|
* @return Response |
23
|
|
|
*/ |
24
|
|
|
public function index(): Response |
25
|
|
|
{ |
26
|
|
|
return $this->render('hyperwallet/payments/index.html.twig'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @Route("/create", name="create-get", methods={"GET"}) |
31
|
|
|
* |
32
|
|
|
* @return Response |
33
|
|
|
*/ |
34
|
|
|
public function createPaymentGet(): Response |
35
|
|
|
{ |
36
|
|
|
return $this->render('hyperwallet/payments/create.html.twig'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @Route("/create", name="create-post", methods={"POST"}) |
41
|
|
|
* |
42
|
|
|
* @return Response |
43
|
|
|
*/ |
44
|
|
|
public function createPaymentPost(): Response |
45
|
|
|
{ |
46
|
|
|
$request = Request::createFromGlobals(); |
47
|
|
|
$paymentDetails = $request->request->all(); |
48
|
|
|
$payment = $this->hyperwalletService->getPaymentservice()->create($paymentDetails); |
49
|
|
|
return $this->render('default/dump.html.twig', [ |
50
|
|
|
'raw_result' => false, |
51
|
|
|
'result' => $payment, |
52
|
|
|
]); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @Route("/search", name="search", methods={"GET"}) |
57
|
|
|
* |
58
|
|
|
* @return Response |
59
|
|
|
* @throws HyperwalletApiException |
60
|
|
|
*/ |
61
|
|
|
public function searchPayment(): Response |
62
|
|
|
{ |
63
|
|
|
$payments = $this->hyperwalletService->getPaymentService()->list(); |
64
|
|
|
return $this->render('hyperwallet/payments/search.html.twig', [ |
65
|
|
|
'payments' => $payments, |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Route("/{paymentToken}", name="get", methods={"GET"}) |
71
|
|
|
* |
72
|
|
|
* @param string $paymentToken |
73
|
|
|
* |
74
|
|
|
* @return Response |
75
|
|
|
*/ |
76
|
|
|
public function getPayment(string $paymentToken): Response |
77
|
|
|
{ |
78
|
|
|
$payment = $this->hyperwalletService->getPaymentService()->get($paymentToken); |
79
|
|
|
return $this->render('default/dump.html.twig', [ |
80
|
|
|
'raw_result' => false, |
81
|
|
|
'result' => $payment, |
82
|
|
|
]); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|