PaypalController::webhookAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
/**
4
 * @author    Markus Tacker <[email protected]>
5
 * @copyright 2013-2016 Verein zur Förderung der Netzkultur im Rhein-Main-Gebiet e.V. | http://netzkultur-rheinmain.de/
6
 */
7
8
namespace BCRM\WebBundle\Controller;
9
10
use BCRM\BackendBundle\Service\Event\CreatePaymentCommand;
11
use LiteCQRS\Bus\CommandBus;
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\Response;
14
15
/**
16
 * Manages Paypal webhooks notifications
17
 */
18
class PaypalController
19
{
20
    /**
21
     * @var \LiteCQRS\Bus\CommandBus
22
     */
23
    private $commandBus;
24
25
    public function __construct(CommandBus $commandBus)
26
    {
27
        $this->commandBus = $commandBus;
28
    }
29
30
    /**
31
     * @param Request $request
32
     *
33
     * @return Response
34
     */
35
    public function webhookAction(Request $request)
36
    {
37
        $command          = new CreatePaymentCommand();
38
        $command->payload = $request->request->all();
39
        $command->txId    = $command->payload['txn_id'];
40
        $command->method  = 'paypal';
41
        $this->commandBus->handle($command);
42
        return new Response();
43
    }
44
}
45