Completed
Push — master ( 9d8165...e9b726 )
by Cesar
28s queued 13s
created

BillingAgreementsController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 65
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A tokenCreate() 0 7 1
A index() 0 3 1
A referenceTransaction() 0 8 1
A billingAgreementDelete() 0 5 1
A billingAgreementCreate() 0 7 1
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