1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controller\Paypal; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
6
|
|
|
use Symfony\Component\HttpFoundation\Request; |
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
8
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class BillingAgreementsController |
12
|
|
|
* @package App\Controller\Paypal |
13
|
|
|
* @Route("/paypal/billing-agreements", name="paypal-billing-agreements-") |
14
|
|
|
*/ |
15
|
|
|
class BillingAgreementsController extends AbstractController |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @Route("/", name="index", methods={"GET"}) |
19
|
|
|
* @return Response |
20
|
|
|
*/ |
21
|
|
|
public function index() |
22
|
|
|
{ |
23
|
|
|
return $this->render('paypal/billingAgreements/base.html.twig'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @Route("/token", name="token-create", methods={"POST"}) |
28
|
|
|
* @return JsonResponse |
29
|
|
|
*/ |
30
|
|
|
public function tokenCreate() |
31
|
|
|
{ |
32
|
|
|
$request = Request::createFromGlobals(); |
33
|
|
|
$requestBody = $request->getContent(); |
34
|
|
|
$response = $this->paypalService->getBillingAgreementService()->createBillingAgreementToken($requestBody); |
35
|
|
|
return new JsonResponse( |
36
|
|
|
$response['result'] |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @Route("/", name="create", methods={"POST"}) |
42
|
|
|
* @return JsonResponse |
43
|
|
|
*/ |
44
|
|
|
public function billingAgreementCreate() |
45
|
|
|
{ |
46
|
|
|
$request = Request::createFromGlobals(); |
47
|
|
|
$requestBody = $request->getContent(); |
48
|
|
|
$response = $this->paypalService->getBillingAgreementService()->createBillingAgreement($requestBody); |
49
|
|
|
return new JsonResponse( |
50
|
|
|
$response['result'] |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @Route("/{billingAgreementId}", name="delete", methods={"DELETE"}) |
56
|
|
|
* @param string $billingAgreementId |
57
|
|
|
* @return JsonResponse |
58
|
|
|
*/ |
59
|
|
|
public function billingAgreementDelete(string $billingAgreementId) |
60
|
|
|
{ |
61
|
|
|
$response = $this->paypalService->getBillingAgreementService()->deleteBillingAgreement($billingAgreementId); |
62
|
|
|
return new JsonResponse( |
63
|
|
|
$response['result'] |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @Route("/reference-trasaction/{fraudnetSession}", name="reference-transaction", methods={"POST"}) |
69
|
|
|
* @param string $fraudnetSession |
70
|
|
|
* @return JsonResponse |
71
|
|
|
*/ |
72
|
|
|
public function referenceTransaction(string $fraudnetSession) |
73
|
|
|
{ |
74
|
|
|
$request = Request::createFromGlobals(); |
75
|
|
|
$requestBody = $request->getContent(); |
76
|
|
|
$response = $this->paypalService->getBillingAgreementService() |
77
|
|
|
->createReferenceTransaction($requestBody, $fraudnetSession); |
78
|
|
|
return new JsonResponse( |
79
|
|
|
$response['result'] |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|